diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-02-17 22:00:03 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-02-19 15:41:41 +0100 |
| commit | 0b7ee3aca28e4036bb0045b14d8b807a7400bd28 (patch) | |
| tree | fd39083b6cf060ac76b521c6c79bcf54ed380d3d /compiler/rustc_metadata/src | |
| parent | c7c306f94a426c945e870753a8ea6510ab43e9c2 (diff) | |
| download | rust-0b7ee3aca28e4036bb0045b14d8b807a7400bd28.tar.gz rust-0b7ee3aca28e4036bb0045b14d8b807a7400bd28.zip | |
Drop ImplData.
Diffstat (limited to 'compiler/rustc_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 27 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 46 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/mod.rs | 20 |
4 files changed, 31 insertions, 76 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index e77b3ee1d1e..4036cb9ae95 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1014,37 +1014,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { self.root.tables.visibility.get(self, id).unwrap().decode(self) } - fn get_impl_data(self, id: DefIndex) -> ImplData { - match self.kind(id) { - EntryKind::Impl(data) => data.decode(self), - _ => bug!(), - } - } - - fn get_parent_impl(self, id: DefIndex) -> Option<DefId> { - self.get_impl_data(id).parent_impl - } - - fn get_impl_polarity(self, id: DefIndex) -> ty::ImplPolarity { - self.get_impl_data(id).polarity - } - - fn get_impl_defaultness(self, id: DefIndex) -> hir::Defaultness { - self.get_impl_data(id).defaultness - } - - fn get_impl_constness(self, id: DefIndex) -> hir::Constness { - self.get_impl_data(id).constness - } - fn get_trait_item_def_id(self, id: DefIndex) -> Option<DefId> { self.root.tables.trait_item_def_id.get(self, id).map(|d| d.decode(self)) } - fn get_coerce_unsized_info(self, id: DefIndex) -> Option<ty::adjustment::CoerceUnsizedInfo> { - self.get_impl_data(id).coerce_unsized_info - } - fn get_expn_that_defined(self, id: DefIndex, sess: &Session) -> ExpnId { self.root.tables.expn_that_defined.get(self, id).unwrap().decode((self, sess)) } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 8427961165d..430720ac2db 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -131,6 +131,11 @@ provide! { <'tcx> tcx, def_id, other, cdata, visibility => { table } unused_generic_params => { table } opt_def_kind => { table } + impl_parent => { table } + impl_polarity => { table } + impl_defaultness => { table } + impl_constness => { table } + coerce_unsized_info => { table } trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) } adt_def => { cdata.get_adt_def(def_id.index, tcx) } @@ -140,12 +145,6 @@ provide! { <'tcx> tcx, def_id, other, cdata, } associated_item_def_ids => { cdata.get_associated_item_def_ids(tcx, def_id.index) } associated_item => { cdata.get_associated_item(def_id.index) } - impl_polarity => { cdata.get_impl_polarity(def_id.index) } - coerce_unsized_info => { - cdata.get_coerce_unsized_info(def_id.index).unwrap_or_else(|| { - bug!("coerce_unsized_info: `{:?}` is missing its info", def_id); - }) - } mir_const_qualif => { cdata.mir_const_qualif(def_id.index) } inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) } is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) } @@ -156,7 +155,6 @@ provide! { <'tcx> tcx, def_id, other, cdata, item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) } fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) } rendered_const => { cdata.get_rendered_const(def_id.index) } - impl_parent => { cdata.get_parent_impl(def_id.index) } trait_of_item => { cdata.get_trait_of_item(def_id.index) } is_mir_available => { cdata.is_item_mir_available(def_id.index) } is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) } @@ -176,8 +174,6 @@ provide! { <'tcx> tcx, def_id, other, cdata, } is_no_builtins => { cdata.root.no_builtins } symbol_mangling_version => { cdata.root.symbol_mangling_version } - impl_defaultness => { cdata.get_impl_defaultness(def_id.index) } - impl_constness => { cdata.get_impl_constness(def_id.index) } reachable_non_generics => { let reachable_non_generics = tcx .exported_symbols(cdata.cnum) diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index c0bf2b60b9c..172ba904536 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1468,39 +1468,31 @@ 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); + let trait_ref = self.tcx.impl_trait_ref(def_id); - let polarity = self.tcx.impl_polarity(def_id); - let parent = if let Some(trait_ref) = trait_ref { + if let Some(trait_ref) = trait_ref { let trait_def = self.tcx.trait_def(trait_ref.def_id); - trait_def.ancestors(self.tcx, def_id).ok().and_then(|mut an| { - an.nth(1).and_then(|node| match node { - specialization_graph::Node::Impl(parent) => Some(parent), - _ => None, - }) - }) - } else { - None - }; + if let Some(mut an) = trait_def.ancestors(self.tcx, def_id).ok() { + if let Some(specialization_graph::Node::Impl(parent)) = an.nth(1) { + record!(self.tables.impl_parent[def_id] <- parent); + } + } - // if this is an impl of `CoerceUnsized`, create its - // "unsized info", else just store None - let coerce_unsized_info = trait_ref.and_then(|t| { - if Some(t.def_id) == self.tcx.lang_items().coerce_unsized_trait() { - Some(self.tcx.at(item.span).coerce_unsized_info(def_id)) - } else { - None + // if this is an impl of `CoerceUnsized`, create its + // "unsized info", else just store None + if Some(trait_ref.def_id) == self.tcx.lang_items().coerce_unsized_trait() { + let coerce_unsized_info = + self.tcx.at(item.span).coerce_unsized_info(def_id); + record!(self.tables.coerce_unsized_info[def_id] <- coerce_unsized_info); } - }); + } - let data = ImplData { - polarity, - defaultness, - constness, - parent_impl: parent, - coerce_unsized_info, - }; + let polarity = self.tcx.impl_polarity(def_id); + record!(self.tables.impl_polarity[def_id] <- polarity); - EntryKind::Impl(self.lazy(data)) + EntryKind::Impl } hir::ItemKind::Trait(..) => { let trait_def = self.tcx.trait_def(def_id); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 6dbab8b0a27..924f194ce85 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -302,6 +302,12 @@ define_tables! { mir_for_ctfe: Table<DefIndex, Lazy!(mir::Body<'tcx>)>, promoted_mir: Table<DefIndex, Lazy!(IndexVec<mir::Promoted, mir::Body<'tcx>>)>, thir_abstract_const: Table<DefIndex, Lazy!(&'tcx [thir::abstract_const::Node<'tcx>])>, + impl_parent: Table<DefIndex, Lazy!(DefId)>, + impl_polarity: Table<DefIndex, Lazy!(ty::ImplPolarity)>, + impl_constness: Table<DefIndex, Lazy!(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)>, trait_item_def_id: Table<DefIndex, Lazy<DefId>>, inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>, @@ -344,7 +350,7 @@ enum EntryKind { Closure, Generator(hir::GeneratorKind), Trait(Lazy<TraitData>), - Impl(Lazy<ImplData>), + Impl, AssocFn(Lazy<AssocFnData>), AssocType(AssocContainer), AssocConst(AssocContainer, mir::ConstQualifs, Lazy<RenderedConst>), @@ -383,18 +389,6 @@ struct TraitData { must_implement_one_of: Option<Box<[Ident]>>, } -#[derive(TyEncodable, TyDecodable)] -struct ImplData { - polarity: ty::ImplPolarity, - constness: hir::Constness, - defaultness: hir::Defaultness, - parent_impl: Option<DefId>, - - /// This is `Some` only for impls of `CoerceUnsized`. - // FIXME(eddyb) perhaps compute this on the fly if cheap enough? - coerce_unsized_info: Option<ty::adjustment::CoerceUnsizedInfo>, -} - /// Describes whether the container of an associated item /// is a trait or an impl and whether, in a trait, it has /// a default, or an in impl, whether it's marked "default". |
