@@ -103,7 +103,6 @@ pub struct LoweringContext<'a> {
103103 loop_scopes : Vec < NodeId > ,
104104 is_in_loop_condition : bool ,
105105 is_in_trait_impl : bool ,
106- is_in_anon_const : bool ,
107106
108107 /// What to do when we encounter either an "anonymous lifetime
109108 /// reference". The term "anonymous" is meant to encompass both
@@ -231,7 +230,6 @@ pub fn lower_crate(
231230 node_id_to_hir_id : IndexVec :: new ( ) ,
232231 is_generator : false ,
233232 is_in_trait_impl : false ,
234- is_in_anon_const : false ,
235233 lifetimes_to_define : Vec :: new ( ) ,
236234 is_collecting_in_band_lifetimes : false ,
237235 in_scope_lifetimes : Vec :: new ( ) ,
@@ -970,26 +968,22 @@ impl<'a> LoweringContext<'a> {
970968 }
971969
972970 fn lower_loop_destination ( & mut self , destination : Option < ( NodeId , Label ) > ) -> hir:: Destination {
973- let target_id = if self . is_in_anon_const {
974- Err ( hir:: LoopIdError :: OutsideLoopScope )
975- } else {
976- match destination {
977- Some ( ( id, _) ) => {
978- if let Def :: Label ( loop_id) = self . expect_full_def ( id) {
979- Ok ( self . lower_node_id ( loop_id) . node_id )
980- } else {
981- Err ( hir:: LoopIdError :: UnresolvedLabel )
982- }
983- }
984- None => {
985- self . loop_scopes
986- . last ( )
987- . map ( |innermost_loop_id| * innermost_loop_id)
988- . map ( |id| Ok ( self . lower_node_id ( id) . node_id ) )
989- . unwrap_or ( Err ( hir:: LoopIdError :: OutsideLoopScope ) )
990- . into ( )
971+ let target_id = match destination {
972+ Some ( ( id, _) ) => {
973+ if let Def :: Label ( loop_id) = self . expect_full_def ( id) {
974+ Ok ( self . lower_node_id ( loop_id) . node_id )
975+ } else {
976+ Err ( hir:: LoopIdError :: UnresolvedLabel )
991977 }
992978 }
979+ None => {
980+ self . loop_scopes
981+ . last ( )
982+ . map ( |innermost_loop_id| * innermost_loop_id)
983+ . map ( |id| Ok ( self . lower_node_id ( id) . node_id ) )
984+ . unwrap_or ( Err ( hir:: LoopIdError :: OutsideLoopScope ) )
985+ . into ( )
986+ }
993987 } ;
994988 hir:: Destination {
995989 label : self . lower_label ( destination. map ( |( _, label) | label) ) ,
@@ -3448,22 +3442,14 @@ impl<'a> LoweringContext<'a> {
34483442 }
34493443
34503444 fn lower_anon_const ( & mut self , c : & AnonConst ) -> hir:: AnonConst {
3451- let was_in_loop_condition = self . is_in_loop_condition ;
3452- self . is_in_loop_condition = false ;
3453- let was_in_anon_const = self . is_in_anon_const ;
3454- self . is_in_anon_const = true ;
3455-
3456- let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( c. id ) ;
3457- let anon_const = hir:: AnonConst {
3458- id : node_id,
3459- hir_id,
3460- body : self . lower_body ( None , |this| this. lower_expr ( & c. value ) ) ,
3461- } ;
3462-
3463- self . is_in_anon_const = was_in_anon_const;
3464- self . is_in_loop_condition = was_in_loop_condition;
3465-
3466- anon_const
3445+ self . with_new_scopes ( |this| {
3446+ let LoweredNodeId { node_id, hir_id } = this. lower_node_id ( c. id ) ;
3447+ hir:: AnonConst {
3448+ id : node_id,
3449+ hir_id,
3450+ body : this. lower_body ( None , |this| this. lower_expr ( & c. value ) ) ,
3451+ }
3452+ } )
34673453 }
34683454
34693455 fn lower_expr ( & mut self , e : & Expr ) -> hir:: Expr {
0 commit comments