@@ -76,37 +76,27 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
7676 let node = self.ast_index[def_id];
7777 match node {
7878 AstOwner::NonOwner => {}
79- AstOwner::Crate(c) => self.lower_crate(c),
80- AstOwner::Item(item) => self.lower_item(item),
81- AstOwner::AssocItem(item, ctxt) => self.lower_assoc_item(item, ctxt),
82- AstOwner::ForeignItem(item) => self.lower_foreign_item(item),
79+ AstOwner::Crate(c) => {
80+ debug_assert_eq!(self.resolver.node_id_to_def_id[&CRATE_NODE_ID], CRATE_DEF_ID);
81+ self.with_lctx(CRATE_NODE_ID, |lctx| {
82+ let module = lctx.lower_mod(&c.items, &c.spans);
83+ // FIXME(jdonszelman): is dummy span ever a problem here?
84+ lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, DUMMY_SP);
85+ hir::OwnerNode::Crate(module)
86+ })
87+ }
88+ AstOwner::Item(item) => {
89+ self.with_lctx(item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
90+ }
91+ AstOwner::AssocItem(item, ctxt) => {
92+ self.with_lctx(item.id, |lctx| lctx.lower_assoc_item(item, ctxt))
93+ }
94+ AstOwner::ForeignItem(item) => self.with_lctx(item.id, |lctx| {
95+ hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item))
96+ }),
8397 }
8498 }
8599 }
86-
87- #[instrument(level = "debug", skip(self, c))]
88- fn lower_crate(&mut self, c: &Crate) {
89- debug_assert_eq!(self.resolver.node_id_to_def_id[&CRATE_NODE_ID], CRATE_DEF_ID);
90- self.with_lctx(CRATE_NODE_ID, |lctx| {
91- let module = lctx.lower_mod(&c.items, &c.spans);
92- // FIXME(jdonszelman): is dummy span ever a problem here?
93- lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, DUMMY_SP);
94- hir::OwnerNode::Crate(module)
95- })
96- }
97-
98- #[instrument(level = "debug", skip(self))]
99- fn lower_item(&mut self, item: &Item) {
100- self.with_lctx(item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
101- }
102-
103- fn lower_assoc_item(&mut self, item: &AssocItem, ctxt: AssocCtxt) {
104- self.with_lctx(item.id, |lctx| lctx.lower_assoc_item(item, ctxt))
105- }
106-
107- fn lower_foreign_item(&mut self, item: &ForeignItem) {
108- self.with_lctx(item.id, |lctx| hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item)))
109- }
110100}
111101
112102impl<'hir> LoweringContext<'_, 'hir> {
0 commit comments