1
Fork 0

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>) { fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
let tcx = self.visited.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(_) => { ty::PredicateKind::ForAll(_) => {
bug!("unexpected predicate: {:?}", obligation.predicate) bug!("unexpected predicate: {:?}", obligation.predicate)
} }

View file

@ -1210,7 +1210,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
for &(predicate, span) in predicates.predicates { for &(predicate, span) in predicates.predicates {
// We don't actually look inside of the predicate, // We don't actually look inside of the predicate,
// so it is safe to skip this binder here. // 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", Trait(..) => "Trait",
TypeOutlives(..) | TypeOutlives(..) |
RegionOutlives(..) => "Lifetime", RegionOutlives(..) => "Lifetime",
@ -1500,7 +1500,7 @@ impl ExplicitOutlivesRequirements {
) -> Vec<ty::Region<'tcx>> { ) -> Vec<ty::Region<'tcx>> {
inferred_outlives inferred_outlives
.iter() .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::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b), ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
_ => None, _ => None,
@ -1516,7 +1516,7 @@ impl ExplicitOutlivesRequirements {
) -> Vec<ty::Region<'tcx>> { ) -> Vec<ty::Region<'tcx>> {
inferred_outlives inferred_outlives
.iter() .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)) => { &ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
a.is_param(index).then_some(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 { for (predicate, _) in cx.tcx.predicates_of(def).predicates {
// We only look at the `DefId`, so it is safe to skip the binder here. // We only look at the `DefId`, so it is safe to skip the binder here.
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) = 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 def_id = poly_trait_predicate.trait_ref.def_id;
let descr_pre = let descr_pre =

View file

@ -1050,7 +1050,7 @@ impl<'tcx> Predicate<'tcx> {
} }
/// Skips `PredicateKind::ForAll`. /// Skips `PredicateKind::ForAll`.
pub fn ignore_qualifiers(self) -> Binder<Predicate<'tcx>> { pub fn ignore_quantifiers(self) -> Binder<Predicate<'tcx>> {
match self.kind() { match self.kind() {
&PredicateKind::ForAll(binder) => binder, &PredicateKind::ForAll(binder) => binder,
ty::PredicateKind::Projection(..) 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 /// 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. /// 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() { match self.kind() {
&PredicateKind::ForAll(binder) => binder, &PredicateKind::ForAll(binder) => binder,
ty::PredicateKind::Projection(..) ty::PredicateKind::Projection(..)
@ -1090,7 +1093,7 @@ impl<'tcx> Predicate<'tcx> {
} }
/// Wraps `self` with the given qualifier if this predicate has any unbound variables. /// Wraps `self` with the given qualifier if this predicate has any unbound variables.
pub fn potentially_qualified( pub fn potentially_quantified(
self, self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
qualifier: impl FnOnce(Binder<Predicate<'tcx>>) -> PredicateKind<'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 // from the substitution and the value being substituted into, and
// this trick achieves that). // this trick achieves that).
let substs = trait_ref.skip_binder().substs; 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); 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> { impl<'tcx> Predicate<'tcx> {
pub fn to_opt_poly_trait_ref(self) -> Option<PolyTraitRef<'tcx>> { pub fn to_opt_poly_trait_ref(self) -> Option<PolyTraitRef<'tcx>> {
self.ignore_qualifiers() self.ignore_quantifiers()
.map_bound(|pred| match pred.kind() { .map_bound(|pred| match pred.kind() {
&PredicateKind::Trait(ref t, _) => Some(t.trait_ref), &PredicateKind::Trait(ref t, _) => Some(t.trait_ref),
PredicateKind::Projection(..) PredicateKind::Projection(..)
@ -1469,7 +1472,7 @@ impl<'tcx> Predicate<'tcx> {
} }
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> { pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
self.ignore_qualifiers() self.ignore_quantifiers()
.map_bound(|pred| match pred.kind() { .map_bound(|pred| match pred.kind() {
&PredicateKind::TypeOutlives(data) => Some(data), &PredicateKind::TypeOutlives(data) => Some(data),
PredicateKind::Trait(..) PredicateKind::Trait(..)

View file

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

View file

@ -590,7 +590,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let mut found = false; let mut found = false;
for predicate in bounds.predicates { for predicate in bounds.predicates {
if let ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_, r)) = 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 { if let ty::RegionKind::ReStatic = r {
found = true; 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 { loop {
let predicates = tcx.predicates_of(current); let predicates = tcx.predicates_of(current);
for (predicate, _) in predicates.predicates { 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::ForAll(_) => bug!("unexpected predicate: {:?}", predicate),
ty::PredicateKind::RegionOutlives(_) ty::PredicateKind::RegionOutlives(_)
| ty::PredicateKind::TypeOutlives(_) | ty::PredicateKind::TypeOutlives(_)

View file

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

View file

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

View file

@ -256,7 +256,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
return; return;
} }
match obligation.predicate.ignore_qualifiers().skip_binder().kind() { match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => { ty::PredicateKind::ForAll(_) => {
bug!("unexpected predicate: {:?}", obligation.predicate) 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. // FIXME: It should be possible to deal with `ForAll` in a cleaner way.
let (cond, error) = match ( let (cond, error) = match (
cond.ignore_qualifiers().skip_binder().kind(), cond.ignore_quantifiers().skip_binder().kind(),
error.ignore_qualifiers().skip_binder().kind(), error.ignore_quantifiers().skip_binder().kind(),
) { ) {
(ty::PredicateKind::Trait(..), &ty::PredicateKind::Trait(error, _)) => { (ty::PredicateKind::Trait(..), &ty::PredicateKind::Trait(error, _)) => {
(cond, ty::Binder::bind(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)) { for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
if let &ty::PredicateKind::Trait(implication, _) = 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 error = error.to_poly_trait_ref();
let implication = ty::Binder::bind(implication).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 // this can fail if the problem was higher-ranked, in which
// cause I have no idea for a good error message. // cause I have no idea for a good error message.
if let &ty::PredicateKind::Projection(data) = 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 mut selcx = SelectionContext::new(self);
let (data, _) = self.replace_bound_vars_with_fresh_vars( let (data, _) = self.replace_bound_vars_with_fresh_vars(
@ -1480,7 +1480,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
return; 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, _) => { &ty::PredicateKind::Trait(data, _) => {
let trait_ref = ty::Binder::bind(data.trait_ref); let trait_ref = ty::Binder::bind(data.trait_ref);
let self_ty = trait_ref.skip_binder().self_ty(); 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>, obligation: &PredicateObligation<'tcx>,
) { ) {
let (pred, item_def_id, span) = match ( 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(), 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 // bound was introduced. At least one generator should be present for this diagnostic to be
// modified. // modified.
let (mut trait_ref, mut target_ty) = 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())), ty::PredicateKind::Trait(p, _) => (Some(p.trait_ref), Some(p.self_ty())),
_ => (None, None), _ => (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 // This works fairly well because trait matching does not actually care about param-env
// TypeOutlives predicates - these are normally used by regionck. // TypeOutlives predicates - these are normally used by regionck.
let outlives_predicates: Vec<_> = predicates 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, ty::PredicateKind::TypeOutlives(..) => true,
_ => false, _ => false,
}) })

View file

@ -245,7 +245,7 @@ fn predicates_reference_self(
.iter() .iter()
.map(|(predicate, sp)| (predicate.subst_supertrait(tcx, &trait_ref), sp)) .map(|(predicate, sp)| (predicate.subst_supertrait(tcx, &trait_ref), sp))
.filter_map(|(predicate, &sp)| { .filter_map(|(predicate, &sp)| {
match predicate.ignore_qualifiers().skip_binder().kind() { match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(ref data, _) => { ty::PredicateKind::Trait(ref data, _) => {
// In the case of a trait predicate, we can skip the "self" type. // 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 } 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 = tcx.predicates_of(def_id);
let predicates = predicates.instantiate_identity(tcx).predicates; let predicates = predicates.instantiate_identity(tcx).predicates;
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| { 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, _) => { ty::PredicateKind::Trait(ref trait_pred, _) => {
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0) 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 .obligations
.iter() .iter()
.filter(|obligation| { .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 // We found a `T: Foo<X = U>` predicate, let's check
// if `U` references any unresolved type // if `U` references any unresolved type
// variables. In principle, we only care if this // variables. In principle, we only care if this
@ -934,7 +934,7 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
for predicate in env_predicates { for predicate in env_predicates {
debug!("assemble_candidates_from_predicates: predicate={:?}", predicate); debug!("assemble_candidates_from_predicates: predicate={:?}", predicate);
if let &ty::PredicateKind::Projection(data) = 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 data = ty::Binder::bind(data);
let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id; 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 // item with the correct name
let env_predicates = env_predicates.filter_map(|o| { 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) &ty::PredicateKind::Projection(data)
if data.projection_ty.item_def_id == obligation.predicate.item_def_id => 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 // we have to prove. No need to canonicalize and all that for
// such cases. // such cases.
if let ty::PredicateKind::Trait(trait_ref, _) = 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 let Some(sized_def_id) = tcx.lang_items().sized_trait() {
if trait_ref.def_id() == sized_def_id { 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)?, 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(_) => { ty::PredicateKind::ForAll(_) => {
bug!("unexpected predicate: {:?}", obligation.predicate) bug!("unexpected predicate: {:?}", obligation.predicate)
} }
@ -792,7 +792,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} }
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool { 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()), ty::PredicateKind::Trait(ref data, _) => self.tcx().trait_is_auto(data.def_id()),
_ => false, _ => false,
}; };
@ -1302,7 +1302,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let matching_bound = predicates.iter().find_map(|bound| { let matching_bound = predicates.iter().find_map(|bound| {
if let ty::PredicateKind::Trait(pred, _) = 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); let bound = ty::Binder::bind(pred.trait_ref);
if self.infcx.probe(|_| { 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. // 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) => { ty::PredicateKind::Projection(proj) => {
// The obligation comes not from the current `impl` nor the `trait` being implemented, // 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 // 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) => { ChalkEnvironmentClause::Predicate(predicate) => {
// FIXME(chalk): forall // FIXME(chalk): forall
match predicate match predicate
.ignore_qualifiers_with_unbound_vars(interner.tcx) .ignore_quantifiers_with_unbound_vars(interner.tcx)
.skip_binder() .skip_binder()
.kind() .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> { 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>> { fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> {
// FIXME(chalk): forall // 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::ForAll(_) => bug!("unexpected predicate: {:?}", self),
&ty::PredicateKind::Trait(predicate, _) => { &ty::PredicateKind::Trait(predicate, _) => {
ty::Binder::bind(predicate).lower_into(interner) ty::Binder::bind(predicate).lower_into(interner)
@ -561,7 +561,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
interner: &RustInterner<'tcx>, interner: &RustInterner<'tcx>,
) -> Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>> { ) -> Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>> {
// FIXME(chalk): forall // 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::ForAll(_) => bug!("unexpected predicate: {:?}", self),
&ty::PredicateKind::Trait(predicate, _) => { &ty::PredicateKind::Trait(predicate, _) => {
let predicate = ty::Binder::bind(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 { 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::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", p), ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", p),
ty::PredicateKind::Trait(..) ty::PredicateKind::Trait(..)

View file

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

View file

@ -1706,7 +1706,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
obligation.predicate obligation.predicate
); );
match obligation.predicate.ignore_qualifiers().skip_binder().kind() { match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
&ty::PredicateKind::Trait(pred, _) => { &ty::PredicateKind::Trait(pred, _) => {
let pred = ty::Binder::bind(pred); let pred = ty::Binder::bind(pred);
associated_types.entry(span).or_default().extend( 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) = 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 // Given a Projection predicate, we can potentially infer
// the complete signature. // the complete signature.
@ -632,7 +632,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// will be our output. // will be our output.
let output_ty = self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| { let output_ty = self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| {
if let &ty::PredicateKind::Projection(proj_predicate) = 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( self.deduce_future_output_from_projection(
obligation.cause.span, obligation.cause.span,

View file

@ -582,7 +582,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
while !queue.is_empty() { while !queue.is_empty() {
let obligation = queue.remove(0); let obligation = queue.remove(0);
debug!("coerce_unsized resolve step: {:?}", obligation); 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, _) &ty::PredicateKind::Trait(trait_pred, _)
if traits.contains(&trait_pred.def_id()) => 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 predicate_matches_closure = |p: Predicate<'tcx>| {
let mut relator: SimpleEqRelation<'tcx> = SimpleEqRelation::new(tcx, self_param_env); let mut relator: SimpleEqRelation<'tcx> = SimpleEqRelation::new(tcx, self_param_env);
match ( match (
predicate.ignore_qualifiers().skip_binder().kind(), predicate.ignore_quantifiers().skip_binder().kind(),
p.ignore_qualifiers().skip_binder().kind(), p.ignore_quantifiers().skip_binder().kind(),
) { ) {
(&ty::PredicateKind::Trait(a, _), &ty::PredicateKind::Trait(b, _)) => { (&ty::PredicateKind::Trait(a, _), &ty::PredicateKind::Trait(b, _)) => {
relator.relate(ty::Binder::bind(a), ty::Binder::bind(b)).is_ok() 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()) traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
// We don't care about regions here. // We don't care about regions here.
.filter_map(|obligation| { .filter_map(|obligation| {
match obligation.predicate.ignore_qualifiers().skip_binder().kind() { match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(trait_pred, _) ty::PredicateKind::Trait(trait_pred, _)
if trait_pred.def_id() == sized_def_id => 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. // We don't care about regions here, so it's fine to skip the binder here.
if let (ty::Param(_), ty::PredicateKind::Trait(p, _)) = ( if let (ty::Param(_), ty::PredicateKind::Trait(p, _)) = (
&self_ty.kind, &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 { if let ty::Adt(def, _) = p.trait_ref.self_ty().kind {
let node = def.did.as_local().map(|def_id| { 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>| { 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) => { &ty::PredicateKind::Projection(pred) => {
let pred = ty::Binder::bind(pred); let pred = ty::Binder::bind(pred);
// `<Foo as Iterator>::Item = String`. // `<Foo as Iterator>::Item = String`.
@ -959,7 +959,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// implementing a trait would be legal but is rejected // implementing a trait would be legal but is rejected
// here). // here).
unsatisfied_predicates.iter().all(|(p, _)| { 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 // Hide traits if they are present in predicates as they can be fixed without
// having to implement them. // having to implement them.
ty::PredicateKind::Trait(t, _) => t.def_id() == info.def_id, 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![]; let mut projections = vec![];
for (predicate, _) in predicates.predicates { for (predicate, _) in predicates.predicates {
debug!("predicate {:?}", predicate); debug!("predicate {:?}", predicate);
match predicate.ignore_qualifiers().skip_binder().kind() { match predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::Trait(trait_predicate, _) => { ty::PredicateKind::Trait(trait_predicate, _) => {
let entry = types.entry(trait_predicate.self_ty()).or_default(); let entry = types.entry(trait_predicate.self_ty()).or_default();
let def_id = trait_predicate.def_id(); let def_id = trait_predicate.def_id();
@ -3894,7 +3894,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.pending_obligations() .pending_obligations()
.into_iter() .into_iter()
.filter_map(move |obligation| { .filter_map(move |obligation| {
match obligation.predicate.ignore_qualifiers().skip_binder().kind() { match obligation.predicate.ignore_quantifiers().skip_binder().kind() {
ty::PredicateKind::ForAll(_) => { ty::PredicateKind::ForAll(_) => {
bug!("unexpected predicate: {:?}", obligation.predicate) bug!("unexpected predicate: {:?}", obligation.predicate)
} }
@ -4250,7 +4250,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
if let ty::PredicateKind::Trait(predicate, _) = 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 // Collect the argument position for all arguments that could have caused this
// `FulfillmentError`. // `FulfillmentError`.
@ -4299,7 +4299,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let hir::QPath::Resolved(_, path) = &qpath { if let hir::QPath::Resolved(_, path) = &qpath {
for error in errors { for error in errors {
if let ty::PredicateKind::Trait(predicate, _) = 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 // If any of the type arguments in this path segment caused the
// `FullfillmentError`, point at its span (#61860). // `FullfillmentError`, point at its span (#61860).
@ -5377,7 +5377,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty: expected, ty: expected,
}) })
.to_predicate(self.tcx) .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); let obligation = traits::Obligation::new(self.misc(sp), self.param_env, predicate);
debug!("suggest_missing_await: trying obligation {:?}", obligation); debug!("suggest_missing_await: trying obligation {:?}", obligation);

View file

@ -552,7 +552,7 @@ fn type_param_predicates(
let extra_predicates = extend.into_iter().chain( let extra_predicates = extend.into_iter().chain(
icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true)) icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true))
.into_iter() .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), ty::PredicateKind::Trait(data, _) => data.self_ty().is_param(index),
_ => false, _ => false,
}), }),
@ -1004,7 +1004,7 @@ fn super_predicates_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> ty::GenericPredi
// which will, in turn, reach indirect supertraits. // which will, in turn, reach indirect supertraits.
for &(pred, span) in superbounds { for &(pred, span) in superbounds {
debug!("superbound: {:?}", pred); 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()); 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(( predicates.push((
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, region)) ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, region))
.to_predicate(tcx) .to_predicate(tcx)
.potentially_qualified(tcx, ty::PredicateKind::ForAll), .potentially_quantified(tcx, ty::PredicateKind::ForAll),
lifetime.span, 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)) let pred = ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
.to_predicate(icx.tcx); .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 region = astconv.ast_region_to_region(lifetime, None);
let pred = ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(param_ty, region)) let pred = ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(param_ty, region))
.to_predicate(astconv.tcx()) .to_predicate(astconv.tcx())
.potentially_qualified(astconv.tcx(), ty::PredicateKind::ForAll); .potentially_quantified(astconv.tcx(), ty::PredicateKind::ForAll);
vec![(pred, lifetime.span)] 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, // Note that we don't have to care about binders here,
// as the impl trait ref never contains any late-bound regions. // as the impl trait ref never contains any late-bound regions.
if let ty::PredicateKind::Projection(projection) = 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 // Special case: watch out for some kind of sneaky attempt
// to project out an associated type defined by this very // to project out an associated type defined by this very

View file

@ -199,7 +199,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
// unconstrained parameters. // unconstrained parameters.
for (predicate, _) in impl_generic_predicates.predicates.iter() { for (predicate, _) in impl_generic_predicates.predicates.iter() {
if let ty::PredicateKind::Projection(proj) = 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 projection_ty = proj.projection_ty;
let projected_ty = proj.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) { fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tcx>, span: Span) {
debug!("can_specialize_on(predicate = {:?})", predicate); 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 // Global predicates are either always true or always false, so we
// are fine to specialize on. // are fine to specialize on.
_ if predicate.is_global() => (), _ if predicate.is_global() => (),
@ -394,7 +394,7 @@ fn trait_predicate_kind<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
predicate: ty::Predicate<'tcx>, predicate: ty::Predicate<'tcx>,
) -> Option<TraitSpecializationKind> { ) -> 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::ForAll(_) => bug!("unexpected predicate: {:?}", predicate),
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => { ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
Some(tcx.trait_def(pred.def_id()).specialization_kind) 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 // process predicates and convert to `RequiredPredicates` entry, see below
for &(predicate, span) in predicates.predicates { 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::ForAll(_) => bug!("unepected predicate: {:?}", predicate),
ty::PredicateKind::TypeOutlives(OutlivesPredicate(ref ty, ref reg)) => { 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(( GenericArgKind::Type(ty1) => Some((
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty1, region2)) ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty1, region2))
.to_predicate(tcx) .to_predicate(tcx)
.potentially_qualified(tcx, ty::PredicateKind::ForAll), .potentially_quantified(tcx, ty::PredicateKind::ForAll),
span, span,
)), )),
GenericArgKind::Lifetime(region1) => Some(( GenericArgKind::Lifetime(region1) => Some((
@ -95,7 +95,7 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredica
region1, region2, region1, region2,
)) ))
.to_predicate(tcx) .to_predicate(tcx)
.potentially_qualified(tcx, ty::PredicateKind::ForAll), .potentially_quantified(tcx, ty::PredicateKind::ForAll),
span, span,
)), )),
GenericArgKind::Const(_) => { GenericArgKind::Const(_) => {

View file

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

View file

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

View file

@ -141,7 +141,8 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
.predicates .predicates
.iter() .iter()
.filter_map(|(pred, _)| { .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 } if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
} else { } else {

View file

@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
cx.tcx.infer_ctxt().enter(|infcx| { cx.tcx.infer_ctxt().enter(|infcx| {
for FulfillmentError { obligation, .. } in send_errors { for FulfillmentError { obligation, .. } in send_errors {
infcx.maybe_note_obligation_cause_for_async_await(db, &obligation); 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!( db.note(&format!(
"`{}` doesn't implement `{}`", "`{}` doesn't implement `{}`",
trait_pred.self_ty(), 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 { if let ty::Opaque(def_id, _) = ret_ty.kind {
// one of the associated types must be Self // one of the associated types must be Self
for &(predicate, _span) in cx.tcx.predicates_of(def_id).predicates { 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 // walk the associated type and check for Self
if contains_self_ty(projection_predicate.ty) { if contains_self_ty(projection_predicate.ty) {
return; 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::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
ty::Opaque(ref def_id, _) => { ty::Opaque(ref def_id, _) => {
for (predicate, _) in cx.tcx.predicates_of(*def_id).predicates { 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() { if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
return true; return true;
} }