diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 67d5064ff02..58fc4ceaa4a 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -79,7 +79,6 @@ pub fn provide(providers: &mut Providers) { adt_def, fn_sig, impl_trait_header, - impl_polarity, coroutine_kind, coroutine_for_closure, collect_mod_item_types, @@ -1394,11 +1393,6 @@ fn check_impl_constness( })) } -fn impl_polarity(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::ImplPolarity { - let item = tcx.hir().expect_item(def_id); - polarity_of_impl(tcx, def_id, item.expect_impl(), item.span) -} - fn polarity_of_impl( tcx: TyCtxt<'_>, def_id: LocalDefId, diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 058f28a3ee9..d79d4b226a5 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -234,7 +234,6 @@ fn into_args(self) -> (DefId, SimplifiedType) { unused_generic_params => { cdata.root.tables.unused_generic_params.get(cdata, def_id.index) } def_kind => { cdata.def_kind(def_id.index) } impl_parent => { table } - impl_polarity => { table_direct } defaultness => { table_direct } constness => { table_direct } coerce_unsized_info => { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 5630566676b..4a24c038f7a 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1969,7 +1969,6 @@ fn encode_impls(&mut self) -> LazyArray { let def_id = id.owner_id.to_def_id(); self.tables.defaultness.set_some(def_id.index, tcx.defaultness(def_id)); - self.tables.impl_polarity.set_some(def_id.index, tcx.impl_polarity(def_id)); if of_trait && let Some(header) = tcx.impl_trait_header(def_id) { record!(self.tables.impl_trait_header[def_id] <- header); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 88a749da156..4d0a6cb60ee 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -433,7 +433,6 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { promoted_mir: Table>>>, thir_abstract_const: Table>>>, impl_parent: Table, - impl_polarity: Table, constness: Table, defaultness: Table, // FIXME(eddyb) perhaps compute this on the fly if cheap enough? diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 2f947f96c26..63db3250c94 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -853,10 +853,6 @@ cache_on_disk_if { impl_id.is_local() } separate_provide_extern } - query impl_polarity(impl_id: DefId) -> ty::ImplPolarity { - desc { |tcx| "computing implementation polarity of `{}`", tcx.def_path_str(impl_id) } - separate_provide_extern - } query issue33140_self_ty(key: DefId) -> Option>> { desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 7c91da292cb..52db913f36e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2317,6 +2317,11 @@ pub fn impl_trait_ref( ) -> Option>> { Some(self.impl_trait_header(def_id)?.map_bound(|h| h.trait_ref)) } + + pub fn impl_polarity(self, def_id: impl IntoQueryParam) -> ty::ImplPolarity { + self.impl_trait_header(def_id) + .map_or(ty::ImplPolarity::Positive, |h| h.skip_binder().polarity) + } } /// Parameter attributes that can only be determined by examining the body of a function instead