diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2022-11-24 18:14:58 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2022-11-25 00:04:54 -0300 |
| commit | 974e2837bb643a1213caeea4025f2f5681bd5f3e (patch) | |
| tree | ef25aad9b89c8cb4f8f618f153c04f3dd2aa8b87 /compiler/rustc_borrowck/src | |
| parent | 42cc8e8f4e5fe3864a9aca4f342ee2aff2ba696a (diff) | |
| download | rust-974e2837bb643a1213caeea4025f2f5681bd5f3e.tar.gz rust-974e2837bb643a1213caeea4025f2f5681bd5f3e.zip | |
Introduce PredicateKind::Clause
Diffstat (limited to 'compiler/rustc_borrowck/src')
4 files changed, 22 insertions, 18 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 5c645c66cd7..a53940070f7 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -666,15 +666,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let tcx = self.infcx.tcx; // Find out if the predicates show that the type is a Fn or FnMut - let find_fn_kind_from_did = - |predicates: ty::EarlyBinder<&[(ty::Predicate<'tcx>, Span)]>, substs| { - predicates.0.iter().find_map(|(pred, _)| { + let find_fn_kind_from_did = |predicates: ty::EarlyBinder< + &[(ty::Predicate<'tcx>, Span)], + >, + substs| { + predicates.0.iter().find_map(|(pred, _)| { let pred = if let Some(substs) = substs { predicates.rebind(*pred).subst(tcx, substs).kind().skip_binder() } else { pred.kind().skip_binder() }; - if let ty::PredicateKind::Trait(pred) = pred && pred.self_ty() == ty { + if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = pred && pred.self_ty() == ty { if Some(pred.def_id()) == tcx.lang_items().fn_trait() { return Some(hir::Mutability::Not); } else if Some(pred.def_id()) == tcx.lang_items().fn_mut_trait() { @@ -683,7 +685,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } None }) - }; + }; // If the type is opaque/param/closure, and it is Fn or FnMut, let's suggest (mutably) // borrowing the type, since `&mut F: FnMut` iff `F: FnMut` and similarly for `Fn`. @@ -784,13 +786,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let predicates: Result<Vec<_>, _> = errors .into_iter() .map(|err| match err.obligation.predicate.kind().skip_binder() { - PredicateKind::Trait(predicate) => match predicate.self_ty().kind() { - ty::Param(param_ty) => Ok(( - generics.type_param(param_ty, tcx), - predicate.trait_ref.print_only_trait_path().to_string(), - )), - _ => Err(()), - }, + PredicateKind::Clause(ty::Clause::Trait(predicate)) => { + match predicate.self_ty().kind() { + ty::Param(param_ty) => Ok(( + generics.type_param(param_ty, tcx), + predicate.trait_ref.print_only_trait_path().to_string(), + )), + _ => Err(()), + } + } _ => Err(()), }) .collect(); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index f9741bacd17..0adaabd0dbf 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -959,8 +959,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { { predicates.iter().any(|pred| { match pred.kind().skip_binder() { - ty::PredicateKind::Trait(data) if data.self_ty() == ty => {} - ty::PredicateKind::Projection(data) if data.projection_ty.self_ty() == ty => {} + ty::PredicateKind::Clause(ty::Clause::Trait(data)) if data.self_ty() == ty => {} + ty::PredicateKind::Clause(ty::Clause::Projection(data)) if data.projection_ty.self_ty() == ty => {} _ => return false, } tcx.any_free_region_meets(pred, |r| { diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index d0cf8622a44..1aad6738bba 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -88,11 +88,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { category: ConstraintCategory<'tcx>, ) { self.prove_predicate( - ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate { + ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate { trait_ref, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, - })), + }))), locations, category, ); diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index b268eac97d0..18e3cbbb86a 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -2013,8 +2013,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); let outlives_predicate = - tcx.mk_predicate(Binder::dummy(ty::PredicateKind::TypeOutlives( - ty::OutlivesPredicate(self_ty, *region), + tcx.mk_predicate(Binder::dummy(ty::PredicateKind::Clause( + ty::Clause::TypeOutlives(ty::OutlivesPredicate(self_ty, *region)), ))); self.prove_predicate( outlives_predicate, |
