Get rid of predicates_defined_on
This commit is contained in:
parent
f167efad2f
commit
dbf06d2170
5 changed files with 22 additions and 63 deletions
|
@ -34,7 +34,7 @@ use rustc_infer::traits::ObligationCause;
|
|||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::util::{Discr, IntTypeExt};
|
||||
use rustc_middle::ty::{self, AdtKind, Const, IsSuggestable, Ty, TyCtxt, Upcast};
|
||||
use rustc_middle::ty::{self, AdtKind, Const, IsSuggestable, Ty, TyCtxt};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
@ -70,7 +70,6 @@ pub fn provide(providers: &mut Providers) {
|
|||
impl_super_outlives: item_bounds::impl_super_outlives,
|
||||
generics_of: generics_of::generics_of,
|
||||
predicates_of: predicates_of::predicates_of,
|
||||
predicates_defined_on,
|
||||
explicit_predicates_of: predicates_of::explicit_predicates_of,
|
||||
explicit_super_predicates_of: predicates_of::explicit_super_predicates_of,
|
||||
explicit_implied_predicates_of: predicates_of::explicit_implied_predicates_of,
|
||||
|
@ -1775,34 +1774,6 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>(
|
|||
})
|
||||
}
|
||||
|
||||
/// Returns a list of type predicates for the definition with ID `def_id`, including inferred
|
||||
/// lifetime constraints. This includes all predicates returned by `explicit_predicates_of`, plus
|
||||
/// inferred constraints concerning which regions outlive other regions.
|
||||
#[instrument(level = "debug", skip(tcx))]
|
||||
fn predicates_defined_on(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
|
||||
let mut result = tcx.explicit_predicates_of(def_id);
|
||||
debug!("predicates_defined_on: explicit_predicates_of({:?}) = {:?}", def_id, result);
|
||||
let inferred_outlives = tcx.inferred_outlives_of(def_id);
|
||||
if !inferred_outlives.is_empty() {
|
||||
debug!(
|
||||
"predicates_defined_on: inferred_outlives_of({:?}) = {:?}",
|
||||
def_id, inferred_outlives,
|
||||
);
|
||||
let inferred_outlives_iter =
|
||||
inferred_outlives.iter().map(|(clause, span)| ((*clause).upcast(tcx), *span));
|
||||
if result.predicates.is_empty() {
|
||||
result.predicates = tcx.arena.alloc_from_iter(inferred_outlives_iter);
|
||||
} else {
|
||||
result.predicates = tcx.arena.alloc_from_iter(
|
||||
result.predicates.into_iter().copied().chain(inferred_outlives_iter),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
debug!("predicates_defined_on({:?}) = {:?}", def_id, result);
|
||||
result
|
||||
}
|
||||
|
||||
fn compute_sig_of_foreign_fn_decl<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
|
|
|
@ -18,10 +18,26 @@ use crate::delegation::inherit_predicates_for_delegation_item;
|
|||
use crate::hir_ty_lowering::{HirTyLowerer, OnlySelfBounds, PredicateFilter, RegionInferReason};
|
||||
|
||||
/// Returns a list of all type predicates (explicit and implicit) for the definition with
|
||||
/// ID `def_id`. This includes all predicates returned by `predicates_defined_on`, plus
|
||||
/// `Self: Trait` predicates for traits.
|
||||
/// ID `def_id`. This includes all predicates returned by `explicit_predicates_of`, plus
|
||||
/// inferred constraints concerning which regions outlive other regions.
|
||||
#[instrument(level = "debug", skip(tcx))]
|
||||
pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
|
||||
let mut result = tcx.predicates_defined_on(def_id);
|
||||
let mut result = tcx.explicit_predicates_of(def_id);
|
||||
debug!("predicates_of: explicit_predicates_of({:?}) = {:?}", def_id, result);
|
||||
|
||||
let inferred_outlives = tcx.inferred_outlives_of(def_id);
|
||||
if !inferred_outlives.is_empty() {
|
||||
debug!("predicates_of: inferred_outlives_of({:?}) = {:?}", def_id, inferred_outlives,);
|
||||
let inferred_outlives_iter =
|
||||
inferred_outlives.iter().map(|(clause, span)| ((*clause).upcast(tcx), *span));
|
||||
if result.predicates.is_empty() {
|
||||
result.predicates = tcx.arena.alloc_from_iter(inferred_outlives_iter);
|
||||
} else {
|
||||
result.predicates = tcx.arena.alloc_from_iter(
|
||||
result.predicates.into_iter().copied().chain(inferred_outlives_iter),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if tcx.is_trait(def_id) {
|
||||
// For traits, add `Self: Trait` predicate. This is
|
||||
|
@ -51,7 +67,8 @@ pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredic
|
|||
.chain(std::iter::once((ty::TraitRef::identity(tcx, def_id).upcast(tcx), span))),
|
||||
);
|
||||
}
|
||||
debug!("predicates_of(def_id={:?}) = {:?}", def_id, result);
|
||||
|
||||
debug!("predicates_of({:?}) = {:?}", def_id, result);
|
||||
result
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue