about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src/diagnostics
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2022-11-24 18:14:58 -0300
committerSantiago Pastorino <spastorino@gmail.com>2022-11-25 00:04:54 -0300
commit974e2837bb643a1213caeea4025f2f5681bd5f3e (patch)
treeef25aad9b89c8cb4f8f618f153c04f3dd2aa8b87 /compiler/rustc_borrowck/src/diagnostics
parent42cc8e8f4e5fe3864a9aca4f342ee2aff2ba696a (diff)
downloadrust-974e2837bb643a1213caeea4025f2f5681bd5f3e.tar.gz
rust-974e2837bb643a1213caeea4025f2f5681bd5f3e.zip
Introduce PredicateKind::Clause
Diffstat (limited to 'compiler/rustc_borrowck/src/diagnostics')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs28
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/region_name.rs4
2 files changed, 18 insertions, 14 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| {