diff options
| -rw-r--r-- | src/librustc/hir/lowering.rs | 65 | ||||
| -rw-r--r-- | src/librustc/hir/lowering/expr.rs | 67 |
2 files changed, 66 insertions, 66 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 9a4cf4c36cc..78941a6545f 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -971,64 +971,6 @@ impl<'a> LoweringContext<'a> { (lowered_generics, res) } - fn with_catch_scope<T, F>(&mut self, catch_id: NodeId, f: F) -> T - where - F: FnOnce(&mut LoweringContext<'_>) -> T, - { - let len = self.catch_scopes.len(); - self.catch_scopes.push(catch_id); - - let result = f(self); - assert_eq!( - len + 1, - self.catch_scopes.len(), - "catch scopes should be added and removed in stack order" - ); - - self.catch_scopes.pop().unwrap(); - - result - } - - fn with_loop_scope<T, F>(&mut self, loop_id: NodeId, f: F) -> T - where - F: FnOnce(&mut LoweringContext<'_>) -> T, - { - // We're no longer in the base loop's condition; we're in another loop. - let was_in_loop_condition = self.is_in_loop_condition; - self.is_in_loop_condition = false; - - let len = self.loop_scopes.len(); - self.loop_scopes.push(loop_id); - - let result = f(self); - assert_eq!( - len + 1, - self.loop_scopes.len(), - "loop scopes should be added and removed in stack order" - ); - - self.loop_scopes.pop().unwrap(); - - self.is_in_loop_condition = was_in_loop_condition; - - result - } - - fn with_loop_condition_scope<T, F>(&mut self, f: F) -> T - where - F: FnOnce(&mut LoweringContext<'_>) -> T, - { - let was_in_loop_condition = self.is_in_loop_condition; - self.is_in_loop_condition = true; - - let result = f(self); - - self.is_in_loop_condition = was_in_loop_condition; - - result - } - fn with_dyn_type_scope<T, F>(&mut self, in_scope: bool, f: F) -> T where F: FnOnce(&mut LoweringContext<'_>) -> T, @@ -3005,13 +2947,6 @@ impl<'a> LoweringContext<'a> { }] } - fn lower_capture_clause(&mut self, c: CaptureBy) -> hir::CaptureClause { - match c { - CaptureBy::Value => hir::CaptureByValue, - CaptureBy::Ref => hir::CaptureByRef, - } - } - fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode { match *b { BlockCheckMode::Default => hir::DefaultBlock, diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs index 96887ed85ae..d273006fbe0 100644 --- a/src/librustc/hir/lowering/expr.rs +++ b/src/librustc/hir/lowering/expr.rs @@ -700,9 +700,16 @@ impl LoweringContext<'_> { }) } + fn lower_capture_clause(&mut self, c: CaptureBy) -> hir::CaptureClause { + match c { + CaptureBy::Value => hir::CaptureByValue, + CaptureBy::Ref => hir::CaptureByRef, + } + } + fn generator_movability_for_fn( &mut self, - decl: &ast::FnDecl, + decl: &FnDecl, fn_decl_span: Span, generator_kind: Option<hir::GeneratorKind>, movability: Movability, @@ -898,6 +905,64 @@ impl LoweringContext<'_> { } } + fn with_catch_scope<T, F>(&mut self, catch_id: NodeId, f: F) -> T + where + F: FnOnce(&mut LoweringContext<'_>) -> T, + { + let len = self.catch_scopes.len(); + self.catch_scopes.push(catch_id); + + let result = f(self); + assert_eq!( + len + 1, + self.catch_scopes.len(), + "catch scopes should be added and removed in stack order" + ); + + self.catch_scopes.pop().unwrap(); + + result + } + + fn with_loop_scope<T, F>(&mut self, loop_id: NodeId, f: F) -> T + where + F: FnOnce(&mut LoweringContext<'_>) -> T, + { + // We're no longer in the base loop's condition; we're in another loop. + let was_in_loop_condition = self.is_in_loop_condition; + self.is_in_loop_condition = false; + + let len = self.loop_scopes.len(); + self.loop_scopes.push(loop_id); + + let result = f(self); + assert_eq!( + len + 1, + self.loop_scopes.len(), + "loop scopes should be added and removed in stack order" + ); + + self.loop_scopes.pop().unwrap(); + + self.is_in_loop_condition = was_in_loop_condition; + + result + } + + fn with_loop_condition_scope<T, F>(&mut self, f: F) -> T + where + F: FnOnce(&mut LoweringContext<'_>) -> T, + { + let was_in_loop_condition = self.is_in_loop_condition; + self.is_in_loop_condition = true; + + let result = f(self); + + self.is_in_loop_condition = was_in_loop_condition; + + result + } + fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind { let hir_asm = hir::InlineAsm { inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(), |
