diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index f042b5ad8e4..101a9dc1b68 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -906,6 +906,10 @@ fn encode_def_ids(&mut self) { let g = tcx.generics_of(def_id); record!(self.tables.generics[def_id] <- g); record!(self.tables.explicit_predicates[def_id] <- self.tcx.explicit_predicates_of(def_id)); + let inferred_outlives = self.tcx.inferred_outlives_of(def_id); + if !inferred_outlives.is_empty() { + record!(self.tables.inferred_outlives[def_id] <- inferred_outlives); + } } let inherent_impls = tcx.crate_inherent_impls(LOCAL_CRATE); for (def_id, implementations) in inherent_impls.inherent_impls.iter() { @@ -951,7 +955,6 @@ fn encode_enum_variant_info(&mut self, def: &ty::AdtDef, index: VariantIdx) { record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(ctor_def_id)); } } - self.encode_inferred_outlives(def_id); } fn encode_enum_variant_ctor(&mut self, def: &ty::AdtDef, index: VariantIdx) { @@ -973,7 +976,6 @@ fn encode_enum_variant_ctor(&mut self, def: &ty::AdtDef, index: VariantIdx) { if variant.ctor_kind == CtorKind::Fn { record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); } - self.encode_inferred_outlives(def_id); } fn encode_info_for_mod(&mut self, local_def_id: LocalDefId, md: &hir::Mod<'_>) { @@ -1032,7 +1034,6 @@ fn encode_field( record!(self.tables.kind[def_id] <- EntryKind::Field); self.encode_ident_span(def_id, field.ident); self.encode_item_type(def_id); - self.encode_inferred_outlives(def_id); } fn encode_struct_ctor(&mut self, adt_def: &ty::AdtDef, def_id: DefId) { @@ -1052,15 +1053,6 @@ fn encode_struct_ctor(&mut self, adt_def: &ty::AdtDef, def_id: DefId) { if variant.ctor_kind == CtorKind::Fn { record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); } - self.encode_inferred_outlives(def_id); - } - - fn encode_inferred_outlives(&mut self, def_id: DefId) { - debug!("EncodeContext::encode_inferred_outlives({:?})", def_id); - let inferred_outlives = self.tcx.inferred_outlives_of(def_id); - if !inferred_outlives.is_empty() { - record!(self.tables.inferred_outlives[def_id] <- inferred_outlives); - } } fn encode_super_predicates(&mut self, def_id: DefId) { @@ -1143,7 +1135,6 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) { if trait_item.kind == ty::AssocKind::Fn { record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); } - self.encode_inferred_outlives(def_id); } fn encode_info_for_impl_item(&mut self, def_id: DefId) { @@ -1201,7 +1192,6 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) { if impl_item.kind == ty::AssocKind::Fn { record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); } - self.encode_inferred_outlives(def_id); } fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[Ident]> { @@ -1466,22 +1456,6 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) { record!(self.tables.impl_trait_ref[def_id] <- trait_ref); } } - match item.kind { - hir::ItemKind::Static(..) - | hir::ItemKind::Const(..) - | hir::ItemKind::Fn(..) - | hir::ItemKind::TyAlias(..) - | hir::ItemKind::Enum(..) - | hir::ItemKind::Struct(..) - | hir::ItemKind::Union(..) - | hir::ItemKind::Impl { .. } - | hir::ItemKind::OpaqueTy(..) - | hir::ItemKind::Trait(..) - | hir::ItemKind::TraitAlias(..) => { - self.encode_inferred_outlives(def_id); - } - _ => {} - } match item.kind { hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) => { self.encode_super_predicates(def_id); @@ -1539,7 +1513,6 @@ fn encode_info_for_anon_const(&mut self, def_id: LocalDefId) { record!(self.tables.kind[def_id.to_def_id()] <- EntryKind::AnonConst(qualifs, const_data)); self.encode_item_type(def_id.to_def_id()); - self.encode_inferred_outlives(def_id.to_def_id()); } fn encode_native_libraries(&mut self) -> Lazy<[NativeLib]> { @@ -1819,7 +1792,6 @@ fn encode_info_for_foreign_item(&mut self, def_id: DefId, nitem: &hir::ForeignIt if let hir::ForeignItemKind::Fn(..) = nitem.kind { record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); } - self.encode_inferred_outlives(def_id); } }