Directly encode Defaultness in metadata.

This commit is contained in:
Camille GILLOT 2022-04-09 19:05:43 +02:00
parent ec7f80036d
commit 42820daf91
3 changed files with 10 additions and 2 deletions

View File

@ -1450,7 +1450,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
}))
}
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
record!(self.tables.impl_defaultness[def_id] <- defaultness);
self.tables.impl_defaultness.set(def_id.index, defaultness);
self.tables.impl_constness.set(def_id.index, constness);
let trait_ref = self.tcx.impl_trait_ref(def_id);

View File

@ -312,7 +312,7 @@ define_tables! {
impl_parent: Table<DefIndex, Lazy!(DefId)>,
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
impl_constness: Table<DefIndex, hir::Constness>,
impl_defaultness: Table<DefIndex, Lazy!(hir::Defaultness)>,
impl_defaultness: Table<DefIndex, hir::Defaultness>,
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,

View File

@ -120,6 +120,14 @@ fixed_size_enum! {
}
}
fixed_size_enum! {
hir::Defaultness {
( Final )
( Default { has_value: false } )
( Default { has_value: true } )
}
}
// NOTE(eddyb) there could be an impl for `usize`, which would enable a more
// generic `Lazy<T>` impl, but in the general case we might not need / want to
// fit every `usize` in `u32`.