Skip to content

Commit ab17829

Browse files
committed
Iterate on crate_inherent_impls for metadata.
1 parent 17a07d7 commit ab17829

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,17 @@ impl EncodeContext<'a, 'tcx> {
865865
self.encode_deprecation(def_id);
866866
}
867867
}
868+
let inherent_impls = tcx.crate_inherent_impls(LOCAL_CRATE);
869+
for (def_id, implementations) in inherent_impls.inherent_impls.iter() {
870+
assert!(def_id.is_local());
871+
if implementations.is_empty() {
872+
continue;
873+
}
874+
record!(self.tables.inherent_impls[def_id] <- implementations.iter().map(|&def_id| {
875+
assert!(def_id.is_local());
876+
def_id.index
877+
}));
878+
}
868879
}
869880

870881
fn encode_variances_of(&mut self, def_id: DefId) {
@@ -1237,18 +1248,6 @@ impl EncodeContext<'a, 'tcx> {
12371248
}
12381249
}
12391250

1240-
// Encodes the inherent implementations of a structure, enumeration, or trait.
1241-
fn encode_inherent_implementations(&mut self, def_id: DefId) {
1242-
debug!("EncodeContext::encode_inherent_implementations({:?})", def_id);
1243-
let implementations = self.tcx.inherent_impls(def_id);
1244-
if !implementations.is_empty() {
1245-
record!(self.tables.inherent_impls[def_id] <- implementations.iter().map(|&def_id| {
1246-
assert!(def_id.is_local());
1247-
def_id.index
1248-
}));
1249-
}
1250-
}
1251-
12521251
fn encode_stability(&mut self, def_id: DefId) {
12531252
debug!("EncodeContext::encode_stability({:?})", def_id);
12541253

@@ -1459,7 +1458,6 @@ impl EncodeContext<'a, 'tcx> {
14591458
record!(self.tables.impl_trait_ref[def_id] <- trait_ref);
14601459
}
14611460
}
1462-
self.encode_inherent_implementations(def_id);
14631461
match item.kind {
14641462
hir::ItemKind::Enum(..)
14651463
| hir::ItemKind::Struct(..)
@@ -1822,7 +1820,6 @@ impl EncodeContext<'a, 'tcx> {
18221820
}
18231821
self.encode_ident_span(def_id, nitem.ident);
18241822
self.encode_item_type(def_id);
1825-
self.encode_inherent_implementations(def_id);
18261823
if let hir::ForeignItemKind::Fn(..) = nitem.kind {
18271824
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
18281825
self.encode_variances_of(def_id);

0 commit comments

Comments
 (0)