Directly encode Constness in metadata.
This commit is contained in:
parent
81bac88e93
commit
ec7f80036d
@ -1048,7 +1048,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
};
|
||||
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
||||
record!(self.tables.impl_constness[def_id] <- hir::Constness::Const);
|
||||
self.tables.impl_constness.set(def_id.index, hir::Constness::Const);
|
||||
record!(self.tables.children[def_id] <- variant.fields.iter().map(|f| {
|
||||
assert!(f.did.is_local());
|
||||
f.did.index
|
||||
@ -1078,7 +1078,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
};
|
||||
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
||||
record!(self.tables.impl_constness[def_id] <- hir::Constness::Const);
|
||||
self.tables.impl_constness.set(def_id.index, hir::Constness::Const);
|
||||
self.encode_item_type(def_id);
|
||||
if variant.ctor_kind == CtorKind::Fn {
|
||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
@ -1157,7 +1157,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
};
|
||||
|
||||
record!(self.tables.repr_options[def_id] <- adt_def.repr());
|
||||
record!(self.tables.impl_constness[def_id] <- hir::Constness::Const);
|
||||
self.tables.impl_constness.set(def_id.index, hir::Constness::Const);
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Struct(self.lazy(data)));
|
||||
self.encode_item_type(def_id);
|
||||
if variant.ctor_kind == CtorKind::Fn {
|
||||
@ -1208,7 +1208,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
};
|
||||
record!(self.tables.asyncness[def_id] <- m_sig.header.asyncness);
|
||||
record!(self.tables.impl_constness[def_id] <- hir::Constness::NotConst);
|
||||
self.tables.impl_constness.set(def_id.index, hir::Constness::NotConst);
|
||||
record!(self.tables.kind[def_id] <- EntryKind::AssocFn(self.lazy(AssocFnData {
|
||||
container,
|
||||
has_self: trait_item.fn_has_self_parameter,
|
||||
@ -1273,7 +1273,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
} else {
|
||||
hir::Constness::NotConst
|
||||
};
|
||||
record!(self.tables.impl_constness[def_id] <- constness);
|
||||
self.tables.impl_constness.set(def_id.index, constness);
|
||||
record!(self.tables.kind[def_id] <- EntryKind::AssocFn(self.lazy(AssocFnData {
|
||||
container,
|
||||
has_self: impl_item.fn_has_self_parameter,
|
||||
@ -1396,7 +1396,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
hir::ItemKind::Fn(ref sig, .., body) => {
|
||||
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
||||
record!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body));
|
||||
record!(self.tables.impl_constness[def_id] <- sig.header.constness);
|
||||
self.tables.impl_constness.set(def_id.index, sig.header.constness);
|
||||
EntryKind::Fn
|
||||
}
|
||||
hir::ItemKind::Macro(ref macro_def, _) => {
|
||||
@ -1420,7 +1420,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
hir::ItemKind::Struct(ref struct_def, _) => {
|
||||
let adt_def = self.tcx.adt_def(def_id);
|
||||
record!(self.tables.repr_options[def_id] <- adt_def.repr());
|
||||
record!(self.tables.impl_constness[def_id] <- hir::Constness::Const);
|
||||
self.tables.impl_constness.set(def_id.index, hir::Constness::Const);
|
||||
|
||||
// Encode def_ids for each field and method
|
||||
// for methods, write all the stuff get_trait_method
|
||||
@ -1451,7 +1451,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
|
||||
record!(self.tables.impl_defaultness[def_id] <- defaultness);
|
||||
record!(self.tables.impl_constness[def_id] <- constness);
|
||||
self.tables.impl_constness.set(def_id.index, constness);
|
||||
|
||||
let trait_ref = self.tcx.impl_trait_ref(def_id);
|
||||
if let Some(trait_ref) = trait_ref {
|
||||
@ -1893,7 +1893,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
} else {
|
||||
hir::Constness::NotConst
|
||||
};
|
||||
record!(self.tables.impl_constness[def_id] <- constness);
|
||||
self.tables.impl_constness.set(def_id.index, constness);
|
||||
record!(self.tables.kind[def_id] <- EntryKind::ForeignFn);
|
||||
}
|
||||
hir::ForeignItemKind::Static(..) => {
|
||||
|
@ -311,7 +311,7 @@ define_tables! {
|
||||
thir_abstract_const: Table<DefIndex, Lazy!(&'tcx [thir::abstract_const::Node<'tcx>])>,
|
||||
impl_parent: Table<DefIndex, Lazy!(DefId)>,
|
||||
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
|
||||
impl_constness: Table<DefIndex, Lazy!(hir::Constness)>,
|
||||
impl_constness: Table<DefIndex, hir::Constness>,
|
||||
impl_defaultness: Table<DefIndex, Lazy!(hir::Defaultness)>,
|
||||
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
|
||||
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
|
||||
|
@ -113,6 +113,13 @@ fixed_size_enum! {
|
||||
}
|
||||
}
|
||||
|
||||
fixed_size_enum! {
|
||||
hir::Constness {
|
||||
( NotConst )
|
||||
( Const )
|
||||
}
|
||||
}
|
||||
|
||||
// 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`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user