@@ -141,6 +141,7 @@ struct LoweringContext<'a, 'hir> {
141
141
/// NodeIds of pattern identifiers and labelled nodes that are lowered inside the current HIR owner.
142
142
ident_and_label_to_local_id : NodeMap < hir:: ItemLocalId > ,
143
143
/// NodeIds that are lowered inside the current HIR owner. Only used for duplicate lowering check.
144
+ #[ cfg( debug_assertions) ]
144
145
node_id_to_local_id : NodeMap < hir:: ItemLocalId > ,
145
146
146
147
allow_try_trait : Lrc < [ Symbol ] > ,
@@ -172,6 +173,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
172
173
current_def_id_parent : CRATE_DEF_ID ,
173
174
item_local_id_counter : hir:: ItemLocalId :: ZERO ,
174
175
ident_and_label_to_local_id : Default :: default ( ) ,
176
+ #[ cfg( debug_assertions) ]
175
177
node_id_to_local_id : Default :: default ( ) ,
176
178
trait_map : Default :: default ( ) ,
177
179
@@ -591,6 +593,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
591
593
let current_bodies = std:: mem:: take ( & mut self . bodies ) ;
592
594
let current_ident_and_label_to_local_id =
593
595
std:: mem:: take ( & mut self . ident_and_label_to_local_id ) ;
596
+
597
+ #[ cfg( debug_assertions) ]
594
598
let current_node_id_to_local_id = std:: mem:: take ( & mut self . node_id_to_local_id ) ;
595
599
let current_trait_map = std:: mem:: take ( & mut self . trait_map ) ;
596
600
let current_owner =
@@ -605,8 +609,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
605
609
// and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
606
610
607
611
// 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
+ }
610
617
611
618
let item = self . with_def_id_parent ( def_id, f) ;
612
619
debug_assert_eq ! ( def_id, item. def_id( ) . def_id) ;
@@ -618,7 +625,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
618
625
self . attrs = current_attrs;
619
626
self . bodies = current_bodies;
620
627
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
+ }
622
633
self . trait_map = current_trait_map;
623
634
self . current_hir_id_owner = current_owner;
624
635
self . item_local_id_counter = current_local_counter;
0 commit comments