about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-14 14:16:21 +0000
committerbors <bors@rust-lang.org>2021-03-14 14:16:21 +0000
commit9320b121b5b20d2201c9f5ec40fb3c241fcac6f0 (patch)
tree6533c9881e2e29ed30d9cb91930c610b2f4b1511
parent84c08f82b46986fcd5cbd1a637582bd1325fa970 (diff)
parentab1782975ab787cac2366539e9e09a451470d97c (diff)
downloadrust-9320b121b5b20d2201c9f5ec40fb3c241fcac6f0.tar.gz
rust-9320b121b5b20d2201c9f5ec40fb3c241fcac6f0.zip
Auto merge of #83082 - cjgillot:defkey-ii, r=oli-obk
Iterate on crate_inherent_impls for metadata.

Split from #80347

r? `@oli-obk`
-rw-r--r--compiler/rustc_metadata/src/rmeta/encoder.rs25
1 files changed, 11 insertions, 14 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 9336add9692..06f53bb9282 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -865,6 +865,17 @@ impl EncodeContext<'a, 'tcx> {
                 self.encode_deprecation(def_id);
             }
         }
+        let inherent_impls = tcx.crate_inherent_impls(LOCAL_CRATE);
+        for (def_id, implementations) in inherent_impls.inherent_impls.iter() {
+            assert!(def_id.is_local());
+            if implementations.is_empty() {
+                continue;
+            }
+            record!(self.tables.inherent_impls[def_id] <- implementations.iter().map(|&def_id| {
+                assert!(def_id.is_local());
+                def_id.index
+            }));
+        }
     }
 
     fn encode_variances_of(&mut self, def_id: DefId) {
@@ -1237,18 +1248,6 @@ impl EncodeContext<'a, 'tcx> {
         }
     }
 
-    // Encodes the inherent implementations of a structure, enumeration, or trait.
-    fn encode_inherent_implementations(&mut self, def_id: DefId) {
-        debug!("EncodeContext::encode_inherent_implementations({:?})", def_id);
-        let implementations = self.tcx.inherent_impls(def_id);
-        if !implementations.is_empty() {
-            record!(self.tables.inherent_impls[def_id] <- implementations.iter().map(|&def_id| {
-                assert!(def_id.is_local());
-                def_id.index
-            }));
-        }
-    }
-
     fn encode_stability(&mut self, def_id: DefId) {
         debug!("EncodeContext::encode_stability({:?})", def_id);
 
@@ -1459,7 +1458,6 @@ impl EncodeContext<'a, 'tcx> {
                 record!(self.tables.impl_trait_ref[def_id] <- trait_ref);
             }
         }
-        self.encode_inherent_implementations(def_id);
         match item.kind {
             hir::ItemKind::Enum(..)
             | hir::ItemKind::Struct(..)
@@ -1822,7 +1820,6 @@ impl EncodeContext<'a, 'tcx> {
         }
         self.encode_ident_span(def_id, nitem.ident);
         self.encode_item_type(def_id);
-        self.encode_inherent_implementations(def_id);
         if let hir::ForeignItemKind::Fn(..) = nitem.kind {
             record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
             self.encode_variances_of(def_id);