Skip to content

Commit

Permalink
Resolve some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa committed Mar 17, 2020
1 parent 410cdd7 commit fb10e5c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/librustc/middle/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_data_structures::sync::Once;
// `ensure_sufficient_stack`.
const RED_ZONE: usize = 100 * 1024; // 100k

// Ony the first stack that is pushed, grows exponentially (2^n * STACK_PER_RECURSION) from then
// Only the first stack that is pushed, grows exponentially (2^n * STACK_PER_RECURSION) from then
// on. This flag has performance relevant characteristics. Don't set it too high.
const STACK_PER_RECURSION: usize = 1 * 1024 * 1024; // 1MB

Expand All @@ -27,7 +27,7 @@ const STACK_PER_RECURSION: usize = 1 * 1024 * 1024; // 1MB
/// from this.
///
/// Should not be sprinkled around carelessly, as it causes a little bit of overhead.
pub fn ensure_sufficient_stack<R, F: FnOnce() -> R>(f: F) -> R {
pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f)
}

Expand Down
5 changes: 2 additions & 3 deletions src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};

use rustc::bug;
use rustc::middle::limits::ensure_sufficient_stack;
use rustc::{bug, span_bug};
use rustc_ast::ast::*;
use rustc_ast::attr;
use rustc_ast::ptr::P as AstP;
Expand Down Expand Up @@ -210,9 +210,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
ExprKind::Yield(ref opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()),
ExprKind::Err => hir::ExprKind::Err,
ExprKind::Try(ref sub_expr) => self.lower_expr_try(e.span, sub_expr),

ExprKind::ForLoop(..) | ExprKind::Paren(_) => {
span_bug!(e.span, "Should be handled by `lower_expr`")
span_bug!(e.span, "Should have been handled by `lower_expr`")
}
ExprKind::MacCall(_) => span_bug!(e.span, "Shouldn't exist here"),
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// If we reach here the `..` pattern is not semantically allowed.
self.ban_illegal_rest_pat(p.span)
}
PatKind::Paren(_) => span_bug!(p.span, "Should be handled by `lower_pat`"),
PatKind::Paren(_) => span_bug!(p.span, "Should have been handled by `lower_pat`"),
PatKind::MacCall(_) => span_bug!(p.span, "Shouldn't exist here"),
}
}
Expand Down

0 comments on commit fb10e5c

Please sign in to comment.