this might be unqualified, but at least it's now quantified

This commit is contained in:
Bastian Kauschke 2020-06-24 17:40:28 +02:00
parent 562d478421
commit 3ba61922d2
38 changed files with 87 additions and 83 deletions

View File

@ -138,7 +138,7 @@ impl Elaborator<'tcx> {
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
let tcx = self.visited.tcx;
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => {
bug!("unexpected predicate: {:?}", obligation.predicate)
}

View File

@ -1210,7 +1210,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
for &(predicate, span) in predicates.predicates {
// We don't actually look inside of the predicate,
// so it is safe to skip this binder here.
let predicate_kind_name = match predicate.ignore_qualifiers().skip_binder().kind() {
let predicate_kind_name = match predicate.ignore_quantifiers().skip_binder().kind() {
Trait(..) => "Trait",
TypeOutlives(..) |
RegionOutlives(..) => "Lifetime",
@ -1500,7 +1500,7 @@ impl ExplicitOutlivesRequirements {
) -> Vec<ty::Region<'tcx>> {
inferred_outlives
.iter()
.filter_map(|(pred, _)| match pred.ignore_qualifiers().skip_binder().kind() {
.filter_map(|(pred, _)| match pred.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
_ => None,
@ -1516,7 +1516,7 @@ impl ExplicitOutlivesRequirements {
) -> Vec<ty::Region<'tcx>> {
inferred_outlives
.iter()
.filter_map(|(pred, _)| match pred.ignore_qualifiers().skip_binder().kind() {
.filter_map(|(pred, _)| match pred.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
a.is_param(index).then_some(b)
}

View File

@ -148,7 +148,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
for (predicate, _) in cx.tcx.predicates_of(def).predicates {
// We only look at the `DefId`, so it is safe to skip the binder here.
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) =
predicate.ignore_qualifiers().skip_binder().kind()
predicate.ignore_quantifiers().skip_binder().kind()
{
let def_id = poly_trait_predicate.trait_ref.def_id;
let descr_pre =

View File

@ -1050,7 +1050,7 @@ impl<'tcx> Predicate<'tcx> {
}
/// Skips `PredicateKind::ForAll`.
pub fn ignore_qualifiers(self) -> Binder<Predicate<'tcx>> {
pub fn ignore_quantifiers(self) -> Binder<Predicate<'tcx>> {
match self.kind() {
&PredicateKind::ForAll(binder) => binder,
ty::PredicateKind::Projection(..)
@ -1073,7 +1073,10 @@ impl<'tcx> Predicate<'tcx> {
///
/// Do not use this method if you may end up just skipping the binder, as this
/// would leave the unbound variables at an incorrect binding level.
pub fn ignore_qualifiers_with_unbound_vars(self, tcx: TyCtxt<'tcx>) -> Binder<Predicate<'tcx>> {
pub fn ignore_quantifiers_with_unbound_vars(
self,
tcx: TyCtxt<'tcx>,
) -> Binder<Predicate<'tcx>> {
match self.kind() {
&PredicateKind::ForAll(binder) => binder,
ty::PredicateKind::Projection(..)
@ -1090,7 +1093,7 @@ impl<'tcx> Predicate<'tcx> {
}
/// Wraps `self` with the given qualifier if this predicate has any unbound variables.
pub fn potentially_qualified(
pub fn potentially_quantified(
self,
tcx: TyCtxt<'tcx>,
qualifier: impl FnOnce(Binder<Predicate<'tcx>>) -> PredicateKind<'tcx>,
@ -1249,9 +1252,9 @@ impl<'tcx> Predicate<'tcx> {
// from the substitution and the value being substituted into, and
// this trick achieves that).
let substs = trait_ref.skip_binder().substs;
let pred = *self.ignore_qualifiers().skip_binder();
let pred = *self.ignore_quantifiers().skip_binder();
let new = pred.subst(tcx, substs);
if new != pred { new.potentially_qualified(tcx, PredicateKind::ForAll) } else { self }
if new != pred { new.potentially_quantified(tcx, PredicateKind::ForAll) } else { self }
}
}
@ -1451,7 +1454,7 @@ impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
impl<'tcx> Predicate<'tcx> {
pub fn to_opt_poly_trait_ref(self) -> Option<PolyTraitRef<'tcx>> {
self.ignore_qualifiers()
self.ignore_quantifiers()
.map_bound(|pred| match pred.kind() {
&PredicateKind::Trait(ref t, _) => Some(t.trait_ref),
PredicateKind::Projection(..)
@ -1469,7 +1472,7 @@ impl<'tcx> Predicate<'tcx> {
}
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
self.ignore_qualifiers()
self.ignore_quantifiers()
.map_bound(|pred| match pred.kind() {
&PredicateKind::TypeOutlives(data) => Some(data),
PredicateKind::Trait(..)

View File

@ -577,7 +577,7 @@ pub trait PrettyPrinter<'tcx>:
//
// FIXME(lcnr): Find out why exactly this is the case :)
if let ty::PredicateKind::Trait(pred, _) = predicate
.ignore_qualifiers_with_unbound_vars(self.tcx())
.ignore_quantifiers_with_unbound_vars(self.tcx())
.skip_binder()
.kind()
{

View File

@ -590,7 +590,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let mut found = false;
for predicate in bounds.predicates {
if let ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_, r)) =
predicate.ignore_qualifiers().skip_binder().kind()
predicate.ignore_quantifiers().skip_binder().kind()
{
if let ty::RegionKind::ReStatic = r {
found = true;

View File

@ -24,7 +24,7 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>) -
loop {
let predicates = tcx.predicates_of(current);
for (predicate, _) in predicates.predicates {
match predicate.ignore_qualifiers().skip_binder().kind() {
match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", predicate),
ty::PredicateKind::RegionOutlives(_)
| ty::PredicateKind::TypeOutlives(_)

View File

@ -1155,7 +1155,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
for predicate in &bounds.predicates {
if let ty::PredicateKind::Projection(projection) =
predicate.ignore_qualifiers().skip_binder().kind()
predicate.ignore_quantifiers().skip_binder().kind()
{
if projection.ty.references_error() {
// No point on adding these obligations since there's a type error involved.
@ -1254,7 +1254,7 @@ crate fn required_region_bounds(
traits::elaborate_predicates(tcx, predicates)
.filter_map(|obligation| {
debug!("required_region_bounds(obligation={:?})", obligation);
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Projection(..)
| ty::PredicateKind::Trait(..)
| ty::PredicateKind::Subtype(..)

View File

@ -418,8 +418,8 @@ impl AutoTraitFinder<'tcx> {
ty::PredicateKind::Trait(new_trait, _),
ty::PredicateKind::Trait(old_trait, _),
) = (
new_pred.ignore_qualifiers().skip_binder().kind(),
old_pred.ignore_qualifiers().skip_binder().kind(),
new_pred.ignore_quantifiers().skip_binder().kind(),
old_pred.ignore_quantifiers().skip_binder().kind(),
) {
if new_trait.def_id() == old_trait.def_id() {
let new_substs = new_trait.trait_ref.substs;
@ -639,7 +639,7 @@ impl AutoTraitFinder<'tcx> {
// We check this by calling is_of_param on the relevant types
// from the various possible predicates
match predicate.ignore_qualifiers().skip_binder().kind() {
match predicate.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Trait(p, _) => {
if self.is_param_no_infer(p.trait_ref.substs)
&& !only_projections

View File

@ -256,7 +256,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
return;
}
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => {
bug!("unexpected predicate: {:?}", obligation.predicate)
}
@ -1091,8 +1091,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
// FIXME: It should be possible to deal with `ForAll` in a cleaner way.
let (cond, error) = match (
cond.ignore_qualifiers().skip_binder().kind(),
error.ignore_qualifiers().skip_binder().kind(),
cond.ignore_quantifiers().skip_binder().kind(),
error.ignore_quantifiers().skip_binder().kind(),
) {
(ty::PredicateKind::Trait(..), &ty::PredicateKind::Trait(error, _)) => {
(cond, ty::Binder::bind(error))
@ -1105,7 +1105,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
if let &ty::PredicateKind::Trait(implication, _) =
obligation.predicate.ignore_qualifiers().skip_binder().kind()
obligation.predicate.ignore_quantifiers().skip_binder().kind()
{
let error = error.to_poly_trait_ref();
let implication = ty::Binder::bind(implication).to_poly_trait_ref();
@ -1187,7 +1187,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
// this can fail if the problem was higher-ranked, in which
// cause I have no idea for a good error message.
if let &ty::PredicateKind::Projection(data) =
predicate.ignore_qualifiers().skip_binder().kind()
predicate.ignore_quantifiers().skip_binder().kind()
{
let mut selcx = SelectionContext::new(self);
let (data, _) = self.replace_bound_vars_with_fresh_vars(
@ -1480,7 +1480,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
return;
}
let mut err = match predicate.ignore_qualifiers().skip_binder().kind() {
let mut err = match predicate.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Trait(data, _) => {
let trait_ref = ty::Binder::bind(data.trait_ref);
let self_ty = trait_ref.skip_binder().self_ty();
@ -1734,7 +1734,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
obligation: &PredicateObligation<'tcx>,
) {
let (pred, item_def_id, span) = match (
obligation.predicate.ignore_qualifiers().skip_binder().kind(),
obligation.predicate.ignore_quantifiers().skip_binder().kind(),
obligation.cause.code.peel_derives(),
) {
(

View File

@ -1300,7 +1300,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
// bound was introduced. At least one generator should be present for this diagnostic to be
// modified.
let (mut trait_ref, mut target_ty) =
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(p, _) => (Some(p.trait_ref), Some(p.self_ty())),
_ => (None, None),
};

View File

@ -328,7 +328,7 @@ pub fn normalize_param_env_or_error<'tcx>(
// This works fairly well because trait matching does not actually care about param-env
// TypeOutlives predicates - these are normally used by regionck.
let outlives_predicates: Vec<_> = predicates
.drain_filter(|predicate| match predicate.ignore_qualifiers().skip_binder().kind() {
.drain_filter(|predicate| match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::TypeOutlives(..) => true,
_ => false,
})

View File

@ -245,7 +245,7 @@ fn predicates_reference_self(
.iter()
.map(|(predicate, sp)| (predicate.subst_supertrait(tcx, &trait_ref), sp))
.filter_map(|(predicate, &sp)| {
match predicate.ignore_qualifiers().skip_binder().kind() {
match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(ref data, _) => {
// In the case of a trait predicate, we can skip the "self" type.
if data.trait_ref.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None }
@ -299,7 +299,7 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
let predicates = tcx.predicates_of(def_id);
let predicates = predicates.instantiate_identity(tcx).predicates;
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| {
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(ref trait_pred, _) => {
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
}

View File

@ -665,7 +665,7 @@ fn prune_cache_value_obligations<'a, 'tcx>(
.obligations
.iter()
.filter(|obligation| {
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
// We found a `T: Foo<X = U>` predicate, let's check
// if `U` references any unresolved type
// variables. In principle, we only care if this
@ -934,7 +934,7 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
for predicate in env_predicates {
debug!("assemble_candidates_from_predicates: predicate={:?}", predicate);
if let &ty::PredicateKind::Projection(data) =
predicate.ignore_qualifiers().skip_binder().kind()
predicate.ignore_quantifiers().skip_binder().kind()
{
let data = ty::Binder::bind(data);
let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id;
@ -1228,7 +1228,7 @@ fn confirm_object_candidate<'cx, 'tcx>(
// item with the correct name
let env_predicates = env_predicates.filter_map(|o| {
match o.predicate.ignore_qualifiers().skip_binder().kind() {
match o.predicate.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Projection(data)
if data.projection_ty.item_def_id == obligation.predicate.item_def_id =>
{

View File

@ -16,7 +16,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
// we have to prove. No need to canonicalize and all that for
// such cases.
if let ty::PredicateKind::Trait(trait_ref, _) =
key.value.predicate.ignore_qualifiers().skip_binder().kind()
key.value.predicate.ignore_quantifiers().skip_binder().kind()
{
if let Some(sized_def_id) = tcx.lang_items().sized_trait() {
if trait_ref.def_id() == sized_def_id {

View File

@ -408,7 +408,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
None => self.check_recursion_limit(&obligation, &obligation)?,
}
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => {
bug!("unexpected predicate: {:?}", obligation.predicate)
}
@ -792,7 +792,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
let result = match predicate.ignore_qualifiers().skip_binder().kind() {
let result = match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(ref data, _) => self.tcx().trait_is_auto(data.def_id()),
_ => false,
};
@ -1302,7 +1302,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let matching_bound = predicates.iter().find_map(|bound| {
if let ty::PredicateKind::Trait(pred, _) =
bound.ignore_qualifiers().skip_binder().kind()
bound.ignore_quantifiers().skip_binder().kind()
{
let bound = ty::Binder::bind(pred.trait_ref);
if self.infcx.probe(|_| {

View File

@ -196,7 +196,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
};
// It is fine to skip the binder as we don't care about regions here.
match pred.ignore_qualifiers().skip_binder().kind() {
match pred.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Projection(proj) => {
// The obligation comes not from the current `impl` nor the `trait` being implemented,
// but rather from a "second order" obligation, where an associated type has a

View File

@ -80,7 +80,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
ChalkEnvironmentClause::Predicate(predicate) => {
// FIXME(chalk): forall
match predicate
.ignore_qualifiers_with_unbound_vars(interner.tcx)
.ignore_quantifiers_with_unbound_vars(interner.tcx)
.skip_binder()
.kind()
{
@ -191,7 +191,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predicate<'tcx> {
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> {
// FIXME(chalk): forall
match self.ignore_qualifiers_with_unbound_vars(interner.tcx).skip_binder().kind() {
match self.ignore_quantifiers_with_unbound_vars(interner.tcx).skip_binder().kind() {
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", self),
&ty::PredicateKind::Trait(predicate, _) => {
ty::Binder::bind(predicate).lower_into(interner)
@ -561,7 +561,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
interner: &RustInterner<'tcx>,
) -> Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>> {
// FIXME(chalk): forall
match self.ignore_qualifiers_with_unbound_vars(interner.tcx).skip_binder().kind() {
match self.ignore_quantifiers_with_unbound_vars(interner.tcx).skip_binder().kind() {
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", self),
&ty::PredicateKind::Trait(predicate, _) => {
let predicate = ty::Binder::bind(predicate);

View File

@ -40,7 +40,7 @@ fn normalize_generic_arg_after_erasing_regions<'tcx>(
}
fn not_outlives_predicate(p: &ty::Predicate<'tcx>) -> bool {
match p.ignore_qualifiers().skip_binder().kind() {
match p.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", p),
ty::PredicateKind::Trait(..)

View File

@ -392,7 +392,7 @@ fn associated_type_projection_predicates(
let predicates = item_predicates.filter_map(|obligation| {
let pred = obligation.predicate;
match pred.ignore_qualifiers().skip_binder().kind() {
match pred.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(tr, _) => {
if let ty::Projection(p) = tr.self_ty().kind {
if p == assoc_item_ty {
@ -443,7 +443,7 @@ fn opaque_type_projection_predicates(
let filtered_predicates = predicates.filter_map(|obligation| {
let pred = obligation.predicate;
match pred.ignore_qualifiers().skip_binder().kind() {
match pred.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(tr, _) => {
if let ty::Opaque(opaque_def_id, opaque_substs) = tr.self_ty().kind {
if opaque_def_id == def_id && opaque_substs == substs {

View File

@ -1706,7 +1706,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
obligation.predicate
);
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Trait(pred, _) => {
let pred = ty::Binder::bind(pred);
associated_types.entry(span).or_default().extend(

View File

@ -207,7 +207,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
if let &ty::PredicateKind::Projection(proj_predicate) =
obligation.predicate.ignore_qualifiers().skip_binder().kind()
obligation.predicate.ignore_quantifiers().skip_binder().kind()
{
// Given a Projection predicate, we can potentially infer
// the complete signature.
@ -632,7 +632,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// will be our output.
let output_ty = self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| {
if let &ty::PredicateKind::Projection(proj_predicate) =
obligation.predicate.ignore_qualifiers().skip_binder().kind()
obligation.predicate.ignore_quantifiers().skip_binder().kind()
{
self.deduce_future_output_from_projection(
obligation.cause.span,

View File

@ -582,7 +582,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
while !queue.is_empty() {
let obligation = queue.remove(0);
debug!("coerce_unsized resolve step: {:?}", obligation);
let trait_pred = match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
let trait_pred = match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Trait(trait_pred, _)
if traits.contains(&trait_pred.def_id()) =>
{

View File

@ -227,8 +227,8 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
let predicate_matches_closure = |p: Predicate<'tcx>| {
let mut relator: SimpleEqRelation<'tcx> = SimpleEqRelation::new(tcx, self_param_env);
match (
predicate.ignore_qualifiers().skip_binder().kind(),
p.ignore_qualifiers().skip_binder().kind(),
predicate.ignore_quantifiers().skip_binder().kind(),
p.ignore_quantifiers().skip_binder().kind(),
) {
(&ty::PredicateKind::Trait(a, _), &ty::PredicateKind::Trait(b, _)) => {
relator.relate(ty::Binder::bind(a), ty::Binder::bind(b)).is_ok()

View File

@ -449,7 +449,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
// We don't care about regions here.
.filter_map(|obligation| {
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(trait_pred, _)
if trait_pred.def_id() == sized_def_id =>
{

View File

@ -578,7 +578,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// We don't care about regions here, so it's fine to skip the binder here.
if let (ty::Param(_), ty::PredicateKind::Trait(p, _)) = (
&self_ty.kind,
parent_pred.ignore_qualifiers().skip_binder().kind(),
parent_pred.ignore_quantifiers().skip_binder().kind(),
) {
if let ty::Adt(def, _) = p.trait_ref.self_ty().kind {
let node = def.did.as_local().map(|def_id| {
@ -631,7 +631,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
};
let mut format_pred = |pred: ty::Predicate<'tcx>| {
match pred.ignore_qualifiers().skip_binder().kind() {
match pred.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Projection(pred) => {
let pred = ty::Binder::bind(pred);
// `<Foo as Iterator>::Item = String`.
@ -959,7 +959,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// implementing a trait would be legal but is rejected
// here).
unsatisfied_predicates.iter().all(|(p, _)| {
match p.ignore_qualifiers().skip_binder().kind() {
match p.ignore_quantifiers().skip_binder().kind() {
// Hide traits if they are present in predicates as they can be fixed without
// having to implement them.
ty::PredicateKind::Trait(t, _) => t.def_id() == info.def_id,

View File

@ -2400,7 +2400,7 @@ fn bounds_from_generic_predicates<'tcx>(
let mut projections = vec![];
for (predicate, _) in predicates.predicates {
debug!("predicate {:?}", predicate);
match predicate.ignore_qualifiers().skip_binder().kind() {
match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(trait_predicate, _) => {
let entry = types.entry(trait_predicate.self_ty()).or_default();
let def_id = trait_predicate.def_id();
@ -3894,7 +3894,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.pending_obligations()
.into_iter()
.filter_map(move |obligation| {
match obligation.predicate.ignore_qualifiers().skip_binder().kind() {
match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => {
bug!("unexpected predicate: {:?}", obligation.predicate)
}
@ -4250,7 +4250,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
if let ty::PredicateKind::Trait(predicate, _) =
error.obligation.predicate.ignore_qualifiers().skip_binder().kind()
error.obligation.predicate.ignore_quantifiers().skip_binder().kind()
{
// Collect the argument position for all arguments that could have caused this
// `FulfillmentError`.
@ -4299,7 +4299,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let hir::QPath::Resolved(_, path) = &qpath {
for error in errors {
if let ty::PredicateKind::Trait(predicate, _) =
error.obligation.predicate.ignore_qualifiers().skip_binder().kind()
error.obligation.predicate.ignore_quantifiers().skip_binder().kind()
{
// If any of the type arguments in this path segment caused the
// `FullfillmentError`, point at its span (#61860).
@ -5377,7 +5377,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty: expected,
})
.to_predicate(self.tcx)
.potentially_qualified(self.tcx, ty::PredicateKind::ForAll);
.potentially_quantified(self.tcx, ty::PredicateKind::ForAll);
let obligation = traits::Obligation::new(self.misc(sp), self.param_env, predicate);
debug!("suggest_missing_await: trying obligation {:?}", obligation);

View File

@ -552,7 +552,7 @@ fn type_param_predicates(
let extra_predicates = extend.into_iter().chain(
icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true))
.into_iter()
.filter(|(predicate, _)| match predicate.ignore_qualifiers().skip_binder().kind() {
.filter(|(predicate, _)| match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(data, _) => data.self_ty().is_param(index),
_ => false,
}),
@ -1004,7 +1004,7 @@ fn super_predicates_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> ty::GenericPredi
// which will, in turn, reach indirect supertraits.
for &(pred, span) in superbounds {
debug!("superbound: {:?}", pred);
if let ty::PredicateKind::Trait(bound, _) = pred.ignore_qualifiers().skip_binder().kind() {
if let ty::PredicateKind::Trait(bound, _) = pred.ignore_quantifiers().skip_binder().kind() {
tcx.at(span).super_predicates_of(bound.def_id());
}
}
@ -1962,7 +1962,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
predicates.push((
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, region))
.to_predicate(tcx)
.potentially_qualified(tcx, ty::PredicateKind::ForAll),
.potentially_quantified(tcx, ty::PredicateKind::ForAll),
lifetime.span,
))
}
@ -1982,7 +1982,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
let pred = ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
.to_predicate(icx.tcx);
(pred.potentially_qualified(icx.tcx, ty::PredicateKind::ForAll), span)
(pred.potentially_quantified(icx.tcx, ty::PredicateKind::ForAll), span)
}))
}
@ -2112,7 +2112,7 @@ fn predicates_from_bound<'tcx>(
let region = astconv.ast_region_to_region(lifetime, None);
let pred = ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(param_ty, region))
.to_predicate(astconv.tcx())
.potentially_qualified(astconv.tcx(), ty::PredicateKind::ForAll);
.potentially_quantified(astconv.tcx(), ty::PredicateKind::ForAll);
vec![(pred, lifetime.span)]
}
}

View File

@ -183,7 +183,7 @@ pub fn setup_constraining_predicates<'tcx>(
// Note that we don't have to care about binders here,
// as the impl trait ref never contains any late-bound regions.
if let ty::PredicateKind::Projection(projection) =
predicates[j].0.ignore_qualifiers().skip_binder().kind()
predicates[j].0.ignore_quantifiers().skip_binder().kind()
{
// Special case: watch out for some kind of sneaky attempt
// to project out an associated type defined by this very

View File

@ -199,7 +199,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
// unconstrained parameters.
for (predicate, _) in impl_generic_predicates.predicates.iter() {
if let ty::PredicateKind::Projection(proj) =
predicate.ignore_qualifiers().skip_binder().kind()
predicate.ignore_quantifiers().skip_binder().kind()
{
let projection_ty = proj.projection_ty;
let projected_ty = proj.ty;
@ -361,7 +361,7 @@ fn check_predicates<'tcx>(
fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tcx>, span: Span) {
debug!("can_specialize_on(predicate = {:?})", predicate);
match predicate.ignore_qualifiers().skip_binder().kind() {
match predicate.ignore_quantifiers().skip_binder().kind() {
// Global predicates are either always true or always false, so we
// are fine to specialize on.
_ if predicate.is_global() => (),
@ -394,7 +394,7 @@ fn trait_predicate_kind<'tcx>(
tcx: TyCtxt<'tcx>,
predicate: ty::Predicate<'tcx>,
) -> Option<TraitSpecializationKind> {
match predicate.ignore_qualifiers().skip_binder().kind() {
match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", predicate),
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
Some(tcx.trait_def(pred.def_id()).specialization_kind)

View File

@ -29,7 +29,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
// process predicates and convert to `RequiredPredicates` entry, see below
for &(predicate, span) in predicates.predicates {
match predicate.ignore_qualifiers().skip_binder().kind() {
match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => bug!("unepected predicate: {:?}", predicate),
ty::PredicateKind::TypeOutlives(OutlivesPredicate(ref ty, ref reg)) => {

View File

@ -87,7 +87,7 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredica
GenericArgKind::Type(ty1) => Some((
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty1, region2))
.to_predicate(tcx)
.potentially_qualified(tcx, ty::PredicateKind::ForAll),
.potentially_quantified(tcx, ty::PredicateKind::ForAll),
span,
)),
GenericArgKind::Lifetime(region1) => Some((
@ -95,7 +95,7 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredica
region1, region2,
))
.to_predicate(tcx)
.potentially_qualified(tcx, ty::PredicateKind::ForAll),
.potentially_quantified(tcx, ty::PredicateKind::ForAll),
span,
)),
GenericArgKind::Const(_) => {

View File

@ -315,7 +315,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
pred: ty::Predicate<'tcx>,
) -> FxHashSet<GenericParamDef> {
let regions = match pred.ignore_qualifiers().skip_binder().kind() {
let regions = match pred.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Trait(poly_trait_pred, _) => {
tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(poly_trait_pred))
}
@ -465,7 +465,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
.iter()
.filter(|p| {
!orig_bounds.contains(p)
|| match p.ignore_qualifiers().skip_binder().kind() {
|| match p.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(pred, _) => pred.def_id() == sized_trait,
_ => false,
}

View File

@ -480,7 +480,7 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> {
match self.ignore_qualifiers().skip_binder().kind() {
match self.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Trait(pred, _) => Some(ty::Binder::bind(pred).clean(cx)),
&ty::PredicateKind::Subtype(pred) => Some(ty::Binder::bind(pred).clean(cx)),
&ty::PredicateKind::RegionOutlives(pred) => ty::Binder::bind(pred).clean(cx),
@ -755,7 +755,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
.flat_map(|(p, _)| {
let mut projection = None;
let param_idx = (|| {
match p.ignore_qualifiers().skip_binder().kind() {
match p.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Trait(pred, _constness) => {
if let ty::Param(param) = pred.self_ty().kind {
return Some(param.index);
@ -1662,9 +1662,9 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
.iter()
.filter_map(|predicate| {
// Note: The substs of opaque types can contain unbound variables,
// meaning that we have to use `ignore_qualifiers_with_unbound_vars` here.
// meaning that we have to use `ignore_quantifiers_with_unbound_vars` here.
let trait_ref = match predicate
.ignore_qualifiers_with_unbound_vars(cx.tcx)
.ignore_quantifiers_with_unbound_vars(cx.tcx)
.skip_binder()
.kind()
{
@ -1692,7 +1692,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
.iter()
.filter_map(|pred| {
if let ty::PredicateKind::Projection(proj) = pred
.ignore_qualifiers_with_unbound_vars(cx.tcx)
.ignore_quantifiers_with_unbound_vars(cx.tcx)
.skip_binder()
.kind()
{

View File

@ -141,7 +141,8 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
.predicates
.iter()
.filter_map(|(pred, _)| {
if let ty::PredicateKind::Trait(pred, _) = pred.ignore_qualifiers().skip_binder().kind()
if let ty::PredicateKind::Trait(pred, _) =
pred.ignore_quantifiers().skip_binder().kind()
{
if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
} else {

View File

@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
cx.tcx.infer_ctxt().enter(|infcx| {
for FulfillmentError { obligation, .. } in send_errors {
infcx.maybe_note_obligation_cause_for_async_await(db, &obligation);
if let Trait(trait_pred, _) = obligation.predicate.ignore_qualifiers().skip_binder().kind() {
if let Trait(trait_pred, _) = obligation.predicate.ignore_quantifiers().skip_binder().kind() {
db.note(&format!(
"`{}` doesn't implement `{}`",
trait_pred.self_ty(),

View File

@ -1559,7 +1559,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
if let ty::Opaque(def_id, _) = ret_ty.kind {
// one of the associated types must be Self
for &(predicate, _span) in cx.tcx.predicates_of(def_id).predicates {
if let ty::PredicateKind::Projection(projection_predicate) = predicate.ignore_qualifiers().skip_binder().kind() {
if let ty::PredicateKind::Projection(projection_predicate) = predicate.ignore_quantifiers().skip_binder().kind() {
// walk the associated type and check for Self
if contains_self_ty(projection_predicate.ty) {
return;

View File

@ -1263,7 +1263,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
ty::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
ty::Opaque(ref def_id, _) => {
for (predicate, _) in cx.tcx.predicates_of(*def_id).predicates {
if let ty::PredicateKind::Trait(trait_predicate, _) = predicate.ignore_qualifiers().skip_binder().kind() {
if let ty::PredicateKind::Trait(trait_predicate, _) = predicate.ignore_quantifiers().skip_binder().kind() {
if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
return true;
}