From fb10e5cca3b4d01f850d82198ad51f3406b3a1c3 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sat, 14 Mar 2020 20:13:55 +0200 Subject: [PATCH] Resolve some review comments --- src/librustc/middle/limits.rs | 4 ++-- src/librustc_ast_lowering/expr.rs | 5 ++--- src/librustc_ast_lowering/pat.rs | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/librustc/middle/limits.rs b/src/librustc/middle/limits.rs index 053f02ee8dbb8..6f6fc8b881a32 100644 --- a/src/librustc/middle/limits.rs +++ b/src/librustc/middle/limits.rs @@ -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 @@ -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: F) -> R { +pub fn ensure_sufficient_stack(f: impl FnOnce() -> R) -> R { stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f) } diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs index a78dd158b0036..842dc10ea7bdc 100644 --- a/src/librustc_ast_lowering/expr.rs +++ b/src/librustc_ast_lowering/expr.rs @@ -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; @@ -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"), } diff --git a/src/librustc_ast_lowering/pat.rs b/src/librustc_ast_lowering/pat.rs index c7d55c757f360..316a600e3c599 100644 --- a/src/librustc_ast_lowering/pat.rs +++ b/src/librustc_ast_lowering/pat.rs @@ -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"), } }