Skip to content

Commit f738c20

Browse files
committed
Iterate on fn_sig.
1 parent 478da8f commit f738c20

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,9 @@ impl EncodeContext<'a, 'tcx> {
990990
record!(self.tables.ty[def_id] <- ty);
991991
}
992992
}
993+
if let Ok(sig) = tcx.try_fn_sig(def_id) {
994+
record!(self.tables.fn_sig[def_id] <- sig);
995+
}
993996
}
994997
let inherent_impls = tcx.crate_inherent_impls(LOCAL_CRATE);
995998
for (def_id, implementations) in inherent_impls.inherent_impls.iter() {
@@ -1005,7 +1008,6 @@ impl EncodeContext<'a, 'tcx> {
10051008
}
10061009

10071010
fn encode_enum_variant_info(&mut self, def: &ty::AdtDef, index: VariantIdx) {
1008-
let tcx = self.tcx;
10091011
let variant = &def.variants[index];
10101012
let def_id = variant.def_id;
10111013
debug!("EncodeContext::encode_enum_variant_info({:?})", def_id);
@@ -1023,16 +1025,9 @@ impl EncodeContext<'a, 'tcx> {
10231025
f.did.index
10241026
}));
10251027
self.encode_ident_span(def_id, variant.ident);
1026-
if variant.ctor_kind == CtorKind::Fn {
1027-
// FIXME(eddyb) encode signature only in `encode_enum_variant_ctor`.
1028-
if let Some(ctor_def_id) = variant.ctor_def_id {
1029-
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(ctor_def_id));
1030-
}
1031-
}
10321028
}
10331029

10341030
fn encode_enum_variant_ctor(&mut self, def: &ty::AdtDef, index: VariantIdx) {
1035-
let tcx = self.tcx;
10361031
let variant = &def.variants[index];
10371032
let def_id = variant.ctor_def_id.unwrap();
10381033
debug!("EncodeContext::encode_enum_variant_ctor({:?})", def_id);
@@ -1046,9 +1041,6 @@ impl EncodeContext<'a, 'tcx> {
10461041
};
10471042

10481043
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
1049-
if variant.ctor_kind == CtorKind::Fn {
1050-
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
1051-
}
10521044
}
10531045

10541046
fn encode_info_for_mod(&mut self, local_def_id: LocalDefId, md: &hir::Mod<'_>) {
@@ -1110,7 +1102,6 @@ impl EncodeContext<'a, 'tcx> {
11101102

11111103
fn encode_struct_ctor(&mut self, adt_def: &ty::AdtDef, def_id: DefId) {
11121104
debug!("EncodeContext::encode_struct_ctor({:?})", def_id);
1113-
let tcx = self.tcx;
11141105
let variant = adt_def.non_enum_variant();
11151106

11161107
let data = VariantData {
@@ -1121,9 +1112,6 @@ impl EncodeContext<'a, 'tcx> {
11211112
};
11221113

11231114
record!(self.tables.kind[def_id] <- EntryKind::Struct(self.lazy(data), adt_def.repr));
1124-
if variant.ctor_kind == CtorKind::Fn {
1125-
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
1126-
}
11271115
}
11281116

11291117
fn encode_explicit_item_bounds(&mut self, def_id: DefId) {
@@ -1188,15 +1176,10 @@ impl EncodeContext<'a, 'tcx> {
11881176
}
11891177
}
11901178
self.encode_ident_span(def_id, ast_item.ident);
1191-
if trait_item.kind == ty::AssocKind::Fn {
1192-
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
1193-
}
11941179
}
11951180

11961181
fn encode_info_for_impl_item(&mut self, def_id: DefId) {
11971182
debug!("EncodeContext::encode_info_for_impl_item({:?})", def_id);
1198-
let tcx = self.tcx;
1199-
12001183
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
12011184
let ast_item = self.tcx.hir().expect_impl_item(hir_id);
12021185
let impl_item = self.tcx.associated_item(def_id);
@@ -1244,9 +1227,6 @@ impl EncodeContext<'a, 'tcx> {
12441227
}
12451228
}
12461229
self.encode_ident_span(def_id, impl_item.ident);
1247-
if impl_item.kind == ty::AssocKind::Fn {
1248-
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
1249-
}
12501230
}
12511231

12521232
fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[Ident]> {
@@ -1343,8 +1323,6 @@ impl EncodeContext<'a, 'tcx> {
13431323
}
13441324

13451325
fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
1346-
let tcx = self.tcx;
1347-
13481326
debug!("EncodeContext::encode_info_for_item({:?})", def_id);
13491327

13501328
self.encode_ident_span(def_id, item.ident);
@@ -1491,9 +1469,6 @@ impl EncodeContext<'a, 'tcx> {
14911469
}
14921470
_ => {}
14931471
}
1494-
if let hir::ItemKind::Fn(..) = item.kind {
1495-
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
1496-
}
14971472
if let hir::ItemKind::Impl { .. } = item.kind {
14981473
if let Some(trait_ref) = self.tcx.impl_trait_ref(def_id) {
14991474
record!(self.tables.impl_trait_ref[def_id] <- trait_ref);
@@ -1532,9 +1507,6 @@ impl EncodeContext<'a, 'tcx> {
15321507

15331508
_ => bug!("closure that is neither generator nor closure"),
15341509
}
1535-
if let ty::Closure(def_id, substs) = *ty.kind() {
1536-
record!(self.tables.fn_sig[def_id] <- substs.as_closure().sig());
1537-
}
15381510
}
15391511

15401512
fn encode_info_for_anon_const(&mut self, def_id: LocalDefId) {
@@ -1792,8 +1764,6 @@ impl EncodeContext<'a, 'tcx> {
17921764
}
17931765

17941766
fn encode_info_for_foreign_item(&mut self, def_id: DefId, nitem: &hir::ForeignItem<'_>) {
1795-
let tcx = self.tcx;
1796-
17971767
debug!("EncodeContext::encode_info_for_foreign_item({:?})", def_id);
17981768

17991769
match nitem.kind {
@@ -1820,9 +1790,6 @@ impl EncodeContext<'a, 'tcx> {
18201790
}
18211791
}
18221792
self.encode_ident_span(def_id, nitem.ident);
1823-
if let hir::ForeignItemKind::Fn(..) = nitem.kind {
1824-
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
1825-
}
18261793
}
18271794
}
18281795

0 commit comments

Comments
 (0)