@@ -141,6 +141,7 @@ struct LoweringContext<'a, 'hir> {
141141 /// NodeIds of pattern identifiers and labelled nodes that are lowered inside the current HIR owner.
142142 ident_and_label_to_local_id : NodeMap < hir:: ItemLocalId > ,
143143 /// NodeIds that are lowered inside the current HIR owner. Only used for duplicate lowering check.
144+ #[ cfg( debug_assertions) ]
144145 node_id_to_local_id : NodeMap < hir:: ItemLocalId > ,
145146
146147 allow_try_trait : Lrc < [ Symbol ] > ,
@@ -179,6 +180,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
179180 current_def_id_parent : CRATE_DEF_ID ,
180181 item_local_id_counter : hir:: ItemLocalId :: ZERO ,
181182 ident_and_label_to_local_id : Default :: default ( ) ,
183+ #[ cfg( debug_assertions) ]
182184 node_id_to_local_id : Default :: default ( ) ,
183185 trait_map : Default :: default ( ) ,
184186
@@ -591,6 +593,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
591593 let current_bodies = std:: mem:: take ( & mut self . bodies ) ;
592594 let current_ident_and_label_to_local_id =
593595 std:: mem:: take ( & mut self . ident_and_label_to_local_id ) ;
596+
597+ #[ cfg( debug_assertions) ]
594598 let current_node_id_to_local_id = std:: mem:: take ( & mut self . node_id_to_local_id ) ;
595599 let current_trait_map = std:: mem:: take ( & mut self . trait_map ) ;
596600 let current_owner =
@@ -605,8 +609,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
605609 // and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
606610
607611 // Always allocate the first `HirId` for the owner itself.
608- let _old = self . node_id_to_local_id . insert ( owner, hir:: ItemLocalId :: ZERO ) ;
609- debug_assert_eq ! ( _old, None ) ;
612+ #[ cfg( debug_assertions) ]
613+ {
614+ let _old = self . node_id_to_local_id . insert ( owner, hir:: ItemLocalId :: ZERO ) ;
615+ debug_assert_eq ! ( _old, None ) ;
616+ }
610617
611618 let item = self . with_def_id_parent ( def_id, f) ;
612619 debug_assert_eq ! ( def_id, item. def_id( ) . def_id) ;
@@ -618,7 +625,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
618625 self . attrs = current_attrs;
619626 self . bodies = current_bodies;
620627 self . ident_and_label_to_local_id = current_ident_and_label_to_local_id;
621- self . node_id_to_local_id = current_node_id_to_local_id;
628+
629+ #[ cfg( debug_assertions) ]
630+ {
631+ self . node_id_to_local_id = current_node_id_to_local_id;
632+ }
622633 self . trait_map = current_trait_map;
623634 self . current_hir_id_owner = current_owner;
624635 self . item_local_id_counter = current_local_counter;
0 commit comments