Skip to content

Commit 1a71103

Browse files
committed
Take and restore fields in with_hir_id_owner calls
1 parent 3d6eae8 commit 1a71103

File tree

1 file changed

+6
-0
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+6
-0
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
482482
let current_owner = std::mem::replace(&mut self.current_hir_id_owner, def_id);
483483
let current_local_counter =
484484
std::mem::replace(&mut self.item_local_id_counter, hir::ItemLocalId::new(1));
485+
let current_impl_trait_defs = std::mem::take(&mut self.impl_trait_defs);
486+
let current_impl_trait_bounds = std::mem::take(&mut self.impl_trait_bounds);
485487

486488
// Always allocate the first `HirId` for the owner itself.
487489
let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::new(0));
488490
debug_assert_eq!(_old, None);
489491

490492
let item = f(self);
491493
debug_assert_eq!(def_id, item.def_id());
494+
debug_assert!(self.impl_trait_defs.is_empty());
495+
debug_assert!(self.impl_trait_bounds.is_empty());
492496
let info = self.make_owner_info(item);
493497

494498
self.attrs = current_attrs;
@@ -498,6 +502,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
498502
self.trait_map = current_trait_map;
499503
self.current_hir_id_owner = current_owner;
500504
self.item_local_id_counter = current_local_counter;
505+
self.impl_trait_defs = current_impl_trait_defs;
506+
self.impl_trait_bounds = current_impl_trait_bounds;
501507

502508
let _old = self.children.insert(def_id, hir::MaybeOwner::Owner(info));
503509
debug_assert!(_old.is_none())

0 commit comments

Comments
 (0)