Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0b7ee3a

Browse files
committed
Drop ImplData.
1 parent c7c306f commit 0b7ee3a

File tree

4 files changed

+31
-76
lines changed

4 files changed

+31
-76
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,37 +1014,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10141014
self.root.tables.visibility.get(self, id).unwrap().decode(self)
10151015
}
10161016

1017-
fn get_impl_data(self, id: DefIndex) -> ImplData {
1018-
match self.kind(id) {
1019-
EntryKind::Impl(data) => data.decode(self),
1020-
_ => bug!(),
1021-
}
1022-
}
1023-
1024-
fn get_parent_impl(self, id: DefIndex) -> Option<DefId> {
1025-
self.get_impl_data(id).parent_impl
1026-
}
1027-
1028-
fn get_impl_polarity(self, id: DefIndex) -> ty::ImplPolarity {
1029-
self.get_impl_data(id).polarity
1030-
}
1031-
1032-
fn get_impl_defaultness(self, id: DefIndex) -> hir::Defaultness {
1033-
self.get_impl_data(id).defaultness
1034-
}
1035-
1036-
fn get_impl_constness(self, id: DefIndex) -> hir::Constness {
1037-
self.get_impl_data(id).constness
1038-
}
1039-
10401017
fn get_trait_item_def_id(self, id: DefIndex) -> Option<DefId> {
10411018
self.root.tables.trait_item_def_id.get(self, id).map(|d| d.decode(self))
10421019
}
10431020

1044-
fn get_coerce_unsized_info(self, id: DefIndex) -> Option<ty::adjustment::CoerceUnsizedInfo> {
1045-
self.get_impl_data(id).coerce_unsized_info
1046-
}
1047-
10481021
fn get_expn_that_defined(self, id: DefIndex, sess: &Session) -> ExpnId {
10491022
self.root.tables.expn_that_defined.get(self, id).unwrap().decode((self, sess))
10501023
}

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ provide! { <'tcx> tcx, def_id, other, cdata,
131131
visibility => { table }
132132
unused_generic_params => { table }
133133
opt_def_kind => { table }
134+
impl_parent => { table }
135+
impl_polarity => { table }
136+
impl_defaultness => { table }
137+
impl_constness => { table }
138+
coerce_unsized_info => { table }
134139

135140
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
136141
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
@@ -140,12 +145,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
140145
}
141146
associated_item_def_ids => { cdata.get_associated_item_def_ids(tcx, def_id.index) }
142147
associated_item => { cdata.get_associated_item(def_id.index) }
143-
impl_polarity => { cdata.get_impl_polarity(def_id.index) }
144-
coerce_unsized_info => {
145-
cdata.get_coerce_unsized_info(def_id.index).unwrap_or_else(|| {
146-
bug!("coerce_unsized_info: `{:?}` is missing its info", def_id);
147-
})
148-
}
149148
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
150149
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
151150
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
@@ -156,7 +155,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
156155
item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) }
157156
fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) }
158157
rendered_const => { cdata.get_rendered_const(def_id.index) }
159-
impl_parent => { cdata.get_parent_impl(def_id.index) }
160158
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
161159
is_mir_available => { cdata.is_item_mir_available(def_id.index) }
162160
is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) }
@@ -176,8 +174,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
176174
}
177175
is_no_builtins => { cdata.root.no_builtins }
178176
symbol_mangling_version => { cdata.root.symbol_mangling_version }
179-
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
180-
impl_constness => { cdata.get_impl_constness(def_id.index) }
181177
reachable_non_generics => {
182178
let reachable_non_generics = tcx
183179
.exported_symbols(cdata.cnum)

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,39 +1468,31 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14681468
)
14691469
}
14701470
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
1471+
record!(self.tables.impl_defaultness[def_id] <- defaultness);
1472+
record!(self.tables.impl_constness[def_id] <- constness);
1473+
14711474
let trait_ref = self.tcx.impl_trait_ref(def_id);
1472-
let polarity = self.tcx.impl_polarity(def_id);
1473-
let parent = if let Some(trait_ref) = trait_ref {
1475+
if let Some(trait_ref) = trait_ref {
14741476
let trait_def = self.tcx.trait_def(trait_ref.def_id);
1475-
trait_def.ancestors(self.tcx, def_id).ok().and_then(|mut an| {
1476-
an.nth(1).and_then(|node| match node {
1477-
specialization_graph::Node::Impl(parent) => Some(parent),
1478-
_ => None,
1479-
})
1480-
})
1481-
} else {
1482-
None
1483-
};
1477+
if let Some(mut an) = trait_def.ancestors(self.tcx, def_id).ok() {
1478+
if let Some(specialization_graph::Node::Impl(parent)) = an.nth(1) {
1479+
record!(self.tables.impl_parent[def_id] <- parent);
1480+
}
1481+
}
14841482

1485-
// if this is an impl of `CoerceUnsized`, create its
1486-
// "unsized info", else just store None
1487-
let coerce_unsized_info = trait_ref.and_then(|t| {
1488-
if Some(t.def_id) == self.tcx.lang_items().coerce_unsized_trait() {
1489-
Some(self.tcx.at(item.span).coerce_unsized_info(def_id))
1490-
} else {
1491-
None
1483+
// if this is an impl of `CoerceUnsized`, create its
1484+
// "unsized info", else just store None
1485+
if Some(trait_ref.def_id) == self.tcx.lang_items().coerce_unsized_trait() {
1486+
let coerce_unsized_info =
1487+
self.tcx.at(item.span).coerce_unsized_info(def_id);
1488+
record!(self.tables.coerce_unsized_info[def_id] <- coerce_unsized_info);
14921489
}
1493-
});
1490+
}
14941491

1495-
let data = ImplData {
1496-
polarity,
1497-
defaultness,
1498-
constness,
1499-
parent_impl: parent,
1500-
coerce_unsized_info,
1501-
};
1492+
let polarity = self.tcx.impl_polarity(def_id);
1493+
record!(self.tables.impl_polarity[def_id] <- polarity);
15021494

1503-
EntryKind::Impl(self.lazy(data))
1495+
EntryKind::Impl
15041496
}
15051497
hir::ItemKind::Trait(..) => {
15061498
let trait_def = self.tcx.trait_def(def_id);

compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ define_tables! {
302302
mir_for_ctfe: Table<DefIndex, Lazy!(mir::Body<'tcx>)>,
303303
promoted_mir: Table<DefIndex, Lazy!(IndexVec<mir::Promoted, mir::Body<'tcx>>)>,
304304
thir_abstract_const: Table<DefIndex, Lazy!(&'tcx [thir::abstract_const::Node<'tcx>])>,
305+
impl_parent: Table<DefIndex, Lazy!(DefId)>,
306+
impl_polarity: Table<DefIndex, Lazy!(ty::ImplPolarity)>,
307+
impl_constness: Table<DefIndex, Lazy!(hir::Constness)>,
308+
impl_defaultness: Table<DefIndex, Lazy!(hir::Defaultness)>,
309+
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
310+
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
305311

306312
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
307313
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
@@ -344,7 +350,7 @@ enum EntryKind {
344350
Closure,
345351
Generator(hir::GeneratorKind),
346352
Trait(Lazy<TraitData>),
347-
Impl(Lazy<ImplData>),
353+
Impl,
348354
AssocFn(Lazy<AssocFnData>),
349355
AssocType(AssocContainer),
350356
AssocConst(AssocContainer, mir::ConstQualifs, Lazy<RenderedConst>),
@@ -383,18 +389,6 @@ struct TraitData {
383389
must_implement_one_of: Option<Box<[Ident]>>,
384390
}
385391

386-
#[derive(TyEncodable, TyDecodable)]
387-
struct ImplData {
388-
polarity: ty::ImplPolarity,
389-
constness: hir::Constness,
390-
defaultness: hir::Defaultness,
391-
parent_impl: Option<DefId>,
392-
393-
/// This is `Some` only for impls of `CoerceUnsized`.
394-
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
395-
coerce_unsized_info: Option<ty::adjustment::CoerceUnsizedInfo>,
396-
}
397-
398392
/// Describes whether the container of an associated item
399393
/// is a trait or an impl and whether, in a trait, it has
400394
/// a default, or an in impl, whether it's marked "default".

0 commit comments

Comments
 (0)