Skip to content

Commit

Permalink
Remove impl_polarity query
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 12, 2024
1 parent b43fbe6 commit 74c9dff
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 13 deletions.
6 changes: 0 additions & 6 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ provide! { tcx, def_id, other, cdata,
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 => {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
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);
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ define_tables! {
promoted_mir: Table<DefIndex, LazyValue<IndexVec<mir::Promoted, mir::Body<'static>>>>,
thir_abstract_const: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::Const<'static>>>>,
impl_parent: Table<DefIndex, RawDefId>,
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
constness: Table<DefIndex, hir::Constness>,
defaultness: Table<DefIndex, hir::Defaultness>,
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,10 +853,6 @@ rustc_queries! {
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<ty::EarlyBinder<ty::Ty<'tcx>>> {
desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,11 @@ impl<'tcx> TyCtxt<'tcx> {
) -> Option<ty::EarlyBinder<ty::TraitRef<'tcx>>> {
Some(self.impl_trait_header(def_id)?.map_bound(|h| h.trait_ref))
}

pub fn impl_polarity(self, def_id: impl IntoQueryParam<DefId>) -> 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
Expand Down

0 comments on commit 74c9dff

Please sign in to comment.