Skip to content

Commit

Permalink
Remove had_parse_errors from hir::Mod
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Dec 7, 2024
1 parent aa9899b commit d5c0728
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
8 changes: 3 additions & 5 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
fn lower_crate(&mut self, c: &Crate) {
debug_assert_eq!(self.resolver.node_id_to_def_id[&CRATE_NODE_ID], CRATE_DEF_ID);
self.with_lctx(CRATE_NODE_ID, |lctx| {
let module = lctx.lower_mod(&c.items, &c.spans, Ok(()));
let module = lctx.lower_mod(&c.items, &c.spans);
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs);
hir::OwnerNode::Crate(module)
})
Expand Down Expand Up @@ -118,15 +118,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
&mut self,
items: &[P<Item>],
spans: &ModSpans,
had_parse_errors: Result<(), ErrorGuaranteed>,
) -> &'hir hir::Mod<'hir> {
self.arena.alloc(hir::Mod {
spans: hir::ModSpans {
inner_span: self.lower_span(spans.inner_span),
inject_use_span: self.lower_span(spans.inject_use_span),
},
item_ids: self.arena.alloc_from_iter(items.iter().flat_map(|x| self.lower_item_ref(x))),
had_parse_errors,
})
}

Expand Down Expand Up @@ -237,8 +235,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
})
}
ItemKind::Mod(_, mod_kind) => match mod_kind {
ModKind::Loaded(items, _, spans, had_parse_errors) => {
hir::ItemKind::Mod(self.lower_mod(items, spans, *had_parse_errors))
ModKind::Loaded(items, _, spans, _) => {
hir::ItemKind::Mod(self.lower_mod(items, spans))
}
ModKind::Unloaded => panic!("`mod` items should have been loaded by now"),
},
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3075,7 +3075,6 @@ pub enum ClosureBinder {
pub struct Mod<'hir> {
pub spans: ModSpans,
pub item_ids: &'hir [ItemId],
pub had_parse_errors: Result<(), ErrorGuaranteed>,
}

#[derive(Copy, Clone, Debug, HashStable_Generic)]
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/stats/input-stats.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ hir-stats Name Accumulated Size Count Item Size
hir-stats ----------------------------------------------------------------
hir-stats ForeignItemRef 24 ( 0.3%) 1 24
hir-stats Lifetime 24 ( 0.3%) 1 24
hir-stats Mod 32 ( 0.4%) 1 32
hir-stats ExprField 40 ( 0.4%) 1 40
hir-stats Mod 40 ( 0.4%) 1 40
hir-stats TraitItemRef 56 ( 0.6%) 2 28
hir-stats GenericArg 64 ( 0.7%) 4 16
hir-stats - Type 16 ( 0.2%) 1
Expand Down Expand Up @@ -163,7 +163,7 @@ hir-stats - Struct 64 ( 0.7%) 1
hir-stats - InlineAsm 64 ( 0.7%) 1
hir-stats - Lit 128 ( 1.4%) 2
hir-stats - Block 384 ( 4.3%) 6
hir-stats Item 968 (10.8%) 11 88
hir-stats Item 968 (10.9%) 11 88
hir-stats - Enum 88 ( 1.0%) 1
hir-stats - Trait 88 ( 1.0%) 1
hir-stats - Impl 88 ( 1.0%) 1
Expand All @@ -174,5 +174,5 @@ hir-stats - Use 352 ( 3.9%) 4
hir-stats Path 1_240 (13.9%) 31 40
hir-stats PathSegment 1_920 (21.5%) 40 48
hir-stats ----------------------------------------------------------------
hir-stats Total 8_928 180
hir-stats Total 8_920 180
hir-stats

0 comments on commit d5c0728

Please sign in to comment.