Skip to content

Commit 42820da

Browse files
committed
Directly encode Defaultness in metadata.
1 parent ec7f800 commit 42820da

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14501450
}))
14511451
}
14521452
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
1453-
record!(self.tables.impl_defaultness[def_id] <- defaultness);
1453+
self.tables.impl_defaultness.set(def_id.index, defaultness);
14541454
self.tables.impl_constness.set(def_id.index, constness);
14551455

14561456
let trait_ref = self.tcx.impl_trait_ref(def_id);

compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ define_tables! {
312312
impl_parent: Table<DefIndex, Lazy!(DefId)>,
313313
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
314314
impl_constness: Table<DefIndex, hir::Constness>,
315-
impl_defaultness: Table<DefIndex, Lazy!(hir::Defaultness)>,
315+
impl_defaultness: Table<DefIndex, hir::Defaultness>,
316316
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
317317
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
318318
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,

compiler/rustc_metadata/src/rmeta/table.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ fixed_size_enum! {
120120
}
121121
}
122122

123+
fixed_size_enum! {
124+
hir::Defaultness {
125+
( Final )
126+
( Default { has_value: false } )
127+
( Default { has_value: true } )
128+
}
129+
}
130+
123131
// NOTE(eddyb) there could be an impl for `usize`, which would enable a more
124132
// generic `Lazy<T>` impl, but in the general case we might not need / want to
125133
// fit every `usize` in `u32`.

0 commit comments

Comments
 (0)