Skip to content

Commit 22379bd

Browse files
committed
Use &'hir Mod everywhere.
For consistency, and because it makes HIR measurement simpler and more accurate.
1 parent a847d5e commit 22379bd

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

compiler/rustc_ast_lowering/src/item.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
120120
self.with_lctx(CRATE_NODE_ID, |lctx| {
121121
let module = lctx.lower_mod(&c.items, &c.spans);
122122
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs);
123-
hir::OwnerNode::Crate(lctx.arena.alloc(module))
123+
hir::OwnerNode::Crate(module)
124124
})
125125
}
126126

@@ -158,14 +158,18 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
158158
}
159159

160160
impl<'hir> LoweringContext<'_, 'hir> {
161-
pub(super) fn lower_mod(&mut self, items: &[P<Item>], spans: &ModSpans) -> hir::Mod<'hir> {
162-
hir::Mod {
161+
pub(super) fn lower_mod(
162+
&mut self,
163+
items: &[P<Item>],
164+
spans: &ModSpans,
165+
) -> &'hir hir::Mod<'hir> {
166+
self.arena.alloc(hir::Mod {
163167
spans: hir::ModSpans {
164168
inner_span: self.lower_span(spans.inner_span),
165169
inject_use_span: self.lower_span(spans.inject_use_span),
166170
},
167171
item_ids: self.arena.alloc_from_iter(items.iter().flat_map(|x| self.lower_item_ref(x))),
168-
}
172+
})
169173
}
170174

171175
pub(super) fn lower_item_ref(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {

compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2991,7 +2991,7 @@ pub enum ItemKind<'hir> {
29912991
/// A MBE macro definition (`macro_rules!` or `macro`).
29922992
Macro(ast::MacroDef, MacroKind),
29932993
/// A module.
2994-
Mod(Mod<'hir>),
2994+
Mod(&'hir Mod<'hir>),
29952995
/// An external module, e.g. `extern { .. }`.
29962996
ForeignMod { abi: Abi, items: &'hir [ForeignItemRef] },
29972997
/// Module-level inline assembly (from `global_asm!`).

0 commit comments

Comments
 (0)