about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBoxy <rust@boxyuwu.dev>2025-01-22 06:40:43 +0000
committerBoxy <rust@boxyuwu.dev>2025-01-22 06:55:38 +0000
commit3ef506fb4dc9415620d4f09be022834d02201257 (patch)
treefe46995cf169ed1acd7399a70116daf1642a789b
parentc234b839d1681a7aa3abb1bda6f6f350714eacfe (diff)
downloadrust-3ef506fb4dc9415620d4f09be022834d02201257.tar.gz
rust-3ef506fb4dc9415620d4f09be022834d02201257.zip
Don't pick `T: FnPtr` nested goals
-rw-r--r--compiler/rustc_trait_selection/src/solve/fulfill.rs23
-rw-r--r--tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.current.stderr17
-rw-r--r--tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.next.stderr17
-rw-r--r--tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.rs28
-rw-r--r--tests/ui/typeck/bad-index-due-to-nested.current.stderr (renamed from tests/ui/typeck/bad-index-due-to-nested.stderr)12
-rw-r--r--tests/ui/typeck/bad-index-due-to-nested.next.stderr76
-rw-r--r--tests/ui/typeck/bad-index-due-to-nested.rs7
-rw-r--r--tests/ui/union/union-derive-eq.current.stderr (renamed from tests/ui/union/union-derive-eq.stderr)2
-rw-r--r--tests/ui/union/union-derive-eq.next.stderr19
-rw-r--r--tests/ui/union/union-derive-eq.rs16
-rw-r--r--tests/ui/wf/wf-trait-fn-arg.current.stderr (renamed from tests/ui/wf/wf-trait-fn-arg.stderr)8
-rw-r--r--tests/ui/wf/wf-trait-fn-arg.next.stderr14
-rw-r--r--tests/ui/wf/wf-trait-fn-arg.rs16
-rw-r--r--tests/ui/wf/wf-trait-fn-ret.current.stderr (renamed from tests/ui/wf/wf-trait-fn-ret.stderr)8
-rw-r--r--tests/ui/wf/wf-trait-fn-ret.next.stderr14
-rw-r--r--tests/ui/wf/wf-trait-fn-ret.rs15
-rw-r--r--tests/ui/wf/wf-trait-fn-where-clause.current.stderr19
-rw-r--r--tests/ui/wf/wf-trait-fn-where-clause.next.stderr14
-rw-r--r--tests/ui/wf/wf-trait-fn-where-clause.rs23
-rw-r--r--tests/ui/wf/wf-trait-fn-where-clause.stderr19
-rw-r--r--tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr (renamed from tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr)11
-rw-r--r--tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr23
-rw-r--r--tests/ui/where-clauses/where-clauses-method-unsatisfied.rs10
-rw-r--r--tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr (renamed from tests/ui/where-clauses/where-clauses-unsatisfied.stderr)11
-rw-r--r--tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr23
-rw-r--r--tests/ui/where-clauses/where-clauses-unsatisfied.rs11
26 files changed, 388 insertions, 68 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs
index 4498beff4ea..2b7da4bc5ff 100644
--- a/compiler/rustc_trait_selection/src/solve/fulfill.rs
+++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs
@@ -513,8 +513,27 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
             _ => ChildMode::PassThrough,
         };
 
+        let nested_goals = candidate.instantiate_nested_goals(self.span());
+
+        // If the candidate requires some `T: FnPtr` bound which does not hold should not be treated as
+        // an actual candidate, instead we should treat them as if the impl was never considered to
+        // have potentially applied. As if `impl<A, R> Trait for for<..> fn(..A) -> R` was written
+        // instead of `impl<T: FnPtr> Trait for T`.
+        //
+        // We do this as a separate loop so that we do not choose to tell the user about some nested
+        // goal before we encounter a `T: FnPtr` nested goal.
+        for nested_goal in &nested_goals {
+            if let Some(fn_ptr_trait) = tcx.lang_items().fn_ptr_trait()
+                && let Some(poly_trait_pred) = nested_goal.goal().predicate.as_trait_clause()
+                && poly_trait_pred.def_id() == fn_ptr_trait
+                && let Err(NoSolution) = nested_goal.result()
+            {
+                return ControlFlow::Break(self.obligation.clone());
+            }
+        }
+
         let mut impl_where_bound_count = 0;
-        for nested_goal in candidate.instantiate_nested_goals(self.span()) {
+        for nested_goal in nested_goals {
             trace!(nested_goal = ?(nested_goal.goal(), nested_goal.source(), nested_goal.result()));
 
             let make_obligation = |cause| Obligation {
@@ -605,7 +624,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
     }
 }
 
-#[derive(Copy, Clone)]
+#[derive(Debug, Copy, Clone)]
 enum ChildMode<'tcx> {
     // Try to derive an `ObligationCause::{ImplDerived,BuiltinDerived}`,
     // and skip all `GoalSource::Misc`, which represent useless obligations
diff --git a/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.current.stderr b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.current.stderr
new file mode 100644
index 00000000000..a863886181c
--- /dev/null
+++ b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.current.stderr
@@ -0,0 +1,17 @@
+error[E0277]: the trait bound `Foo: Trait` is not satisfied
+  --> $DIR/dont-pick-fnptr-bound-as-leaf.rs:24:20
+   |
+LL |     requires_trait(Foo);
+   |     -------------- ^^^ the trait `Trait` is not implemented for `Foo`
+   |     |
+   |     required by a bound introduced by this call
+   |
+note: required by a bound in `requires_trait`
+  --> $DIR/dont-pick-fnptr-bound-as-leaf.rs:19:22
+   |
+LL | fn requires_trait<T: Trait>(_: T) {}
+   |                      ^^^^^ required by this bound in `requires_trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.next.stderr b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.next.stderr
new file mode 100644
index 00000000000..a863886181c
--- /dev/null
+++ b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.next.stderr
@@ -0,0 +1,17 @@
+error[E0277]: the trait bound `Foo: Trait` is not satisfied
+  --> $DIR/dont-pick-fnptr-bound-as-leaf.rs:24:20
+   |
+LL |     requires_trait(Foo);
+   |     -------------- ^^^ the trait `Trait` is not implemented for `Foo`
+   |     |
+   |     required by a bound introduced by this call
+   |
+note: required by a bound in `requires_trait`
+  --> $DIR/dont-pick-fnptr-bound-as-leaf.rs:19:22
+   |
+LL | fn requires_trait<T: Trait>(_: T) {}
+   |                      ^^^^^ required by this bound in `requires_trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.rs b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.rs
new file mode 100644
index 00000000000..995f2c9fbee
--- /dev/null
+++ b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.rs
@@ -0,0 +1,28 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+
+// When emitting an error for `Foo: Trait` not holding we attempt to find a nested goal
+// to give as the reason why the bound does not hold. This test checks that we do not
+// try to tell the user that `Foo: FnPtr` is unimplemented as that would be confusing.
+
+#![feature(fn_ptr_trait)]
+
+use std::marker::FnPtr;
+
+trait Trait {}
+
+impl<T: FnPtr> Trait for T {}
+
+struct Foo;
+
+fn requires_trait<T: Trait>(_: T) {}
+//~^ NOTE: required by a bound in `requires_trait`
+//~| NOTE: required by this bound in `requires_trait`
+
+fn main() {
+    requires_trait(Foo);
+    //~^ ERROR: the trait bound `Foo: Trait` is not satisfied
+    //~| NOTE: the trait `Trait` is not implemented for `Foo`
+    //~| NOTE: required by a bound introduced by this call
+}
diff --git a/tests/ui/typeck/bad-index-due-to-nested.stderr b/tests/ui/typeck/bad-index-due-to-nested.current.stderr
index dd2ce092368..dc3d998c399 100644
--- a/tests/ui/typeck/bad-index-due-to-nested.stderr
+++ b/tests/ui/typeck/bad-index-due-to-nested.current.stderr
@@ -1,11 +1,11 @@
 error[E0277]: the trait bound `K: Hash` is not satisfied
-  --> $DIR/bad-index-due-to-nested.rs:20:5
+  --> $DIR/bad-index-due-to-nested.rs:24:5
    |
 LL |     map[k]
    |     ^^^ the trait `Hash` is not implemented for `K`
    |
 note: required for `HashMap<K, V>` to implement `Index<&K>`
-  --> $DIR/bad-index-due-to-nested.rs:7:12
+  --> $DIR/bad-index-due-to-nested.rs:11:12
    |
 LL | impl<K, V> Index<&K> for HashMap<K, V>
    |            ^^^^^^^^^     ^^^^^^^^^^^^^
@@ -18,13 +18,13 @@ LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap<K, V>, k: K) -> &'a V
    |               +++++++++++++++++
 
 error[E0277]: the trait bound `V: Copy` is not satisfied
-  --> $DIR/bad-index-due-to-nested.rs:20:5
+  --> $DIR/bad-index-due-to-nested.rs:24:5
    |
 LL |     map[k]
    |     ^^^ the trait `Copy` is not implemented for `V`
    |
 note: required for `HashMap<K, V>` to implement `Index<&K>`
-  --> $DIR/bad-index-due-to-nested.rs:7:12
+  --> $DIR/bad-index-due-to-nested.rs:11:12
    |
 LL | impl<K, V> Index<&K> for HashMap<K, V>
    |            ^^^^^^^^^     ^^^^^^^^^^^^^
@@ -37,7 +37,7 @@ LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a
    |                  +++++++++++++++++++
 
 error[E0308]: mismatched types
-  --> $DIR/bad-index-due-to-nested.rs:20:9
+  --> $DIR/bad-index-due-to-nested.rs:24:9
    |
 LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
    |              - found this type parameter
@@ -52,7 +52,7 @@ LL |     map[&k]
    |         +
 
 error[E0308]: mismatched types
-  --> $DIR/bad-index-due-to-nested.rs:20:5
+  --> $DIR/bad-index-due-to-nested.rs:24:5
    |
 LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
    |                 - found this type parameter         ----- expected `&'a V` because of return type
diff --git a/tests/ui/typeck/bad-index-due-to-nested.next.stderr b/tests/ui/typeck/bad-index-due-to-nested.next.stderr
new file mode 100644
index 00000000000..a0b275b7852
--- /dev/null
+++ b/tests/ui/typeck/bad-index-due-to-nested.next.stderr
@@ -0,0 +1,76 @@
+error[E0277]: the trait bound `K: Hash` is not satisfied
+  --> $DIR/bad-index-due-to-nested.rs:24:5
+   |
+LL |     map[k]
+   |     ^^^ the trait `Hash` is not implemented for `K`
+   |
+note: required for `HashMap<K, V>` to implement `Index<&K>`
+  --> $DIR/bad-index-due-to-nested.rs:11:12
+   |
+LL | impl<K, V> Index<&K> for HashMap<K, V>
+   |            ^^^^^^^^^     ^^^^^^^^^^^^^
+LL | where
+LL |     K: Hash,
+   |        ---- unsatisfied trait bound introduced here
+help: consider restricting type parameter `K` with trait `Hash`
+   |
+LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
+   |               +++++++++++++++++
+
+error[E0277]: the trait bound `V: Copy` is not satisfied
+  --> $DIR/bad-index-due-to-nested.rs:24:5
+   |
+LL |     map[k]
+   |     ^^^ the trait `Copy` is not implemented for `V`
+   |
+note: required for `HashMap<K, V>` to implement `Index<&K>`
+  --> $DIR/bad-index-due-to-nested.rs:11:12
+   |
+LL | impl<K, V> Index<&K> for HashMap<K, V>
+   |            ^^^^^^^^^     ^^^^^^^^^^^^^
+...
+LL |     V: Copy,
+   |        ---- unsatisfied trait bound introduced here
+help: consider restricting type parameter `V` with trait `Copy`
+   |
+LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V {
+   |                  +++++++++++++++++++
+
+error[E0308]: mismatched types
+  --> $DIR/bad-index-due-to-nested.rs:24:9
+   |
+LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
+   |              - found this type parameter
+LL |     map[k]
+   |         ^ expected `&K`, found type parameter `K`
+   |
+   = note:   expected reference `&_`
+           found type parameter `_`
+help: consider borrowing here
+   |
+LL |     map[&k]
+   |         +
+
+error[E0277]: the trait bound `K: Hash` is not satisfied
+  --> $DIR/bad-index-due-to-nested.rs:24:5
+   |
+LL |     map[k]
+   |     ^^^^^^ the trait `Hash` is not implemented for `K`
+   |
+note: required for `HashMap<K, V>` to implement `Index<&K>`
+  --> $DIR/bad-index-due-to-nested.rs:11:12
+   |
+LL | impl<K, V> Index<&K> for HashMap<K, V>
+   |            ^^^^^^^^^     ^^^^^^^^^^^^^
+LL | where
+LL |     K: Hash,
+   |        ---- unsatisfied trait bound introduced here
+help: consider restricting type parameter `K` with trait `Hash`
+   |
+LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
+   |               +++++++++++++++++
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0277, E0308.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/typeck/bad-index-due-to-nested.rs b/tests/ui/typeck/bad-index-due-to-nested.rs
index 2564b530004..e7f385865af 100644
--- a/tests/ui/typeck/bad-index-due-to-nested.rs
+++ b/tests/ui/typeck/bad-index-due-to-nested.rs
@@ -1,3 +1,7 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+
 use std::hash::Hash;
 use std::marker::PhantomData;
 use std::ops::Index;
@@ -21,7 +25,8 @@ fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
     //~^ ERROR the trait bound `K: Hash` is not satisfied
     //~| ERROR the trait bound `V: Copy` is not satisfied
     //~| ERROR mismatched types
-    //~| ERROR mismatched types
+    //[current]~| ERROR mismatched types
+    //[next]~^^^^^ ERROR the trait bound `K: Hash` is not satisfied
 }
 
 fn main() {}
diff --git a/tests/ui/union/union-derive-eq.stderr b/tests/ui/union/union-derive-eq.current.stderr
index b068edd6d69..151ceebe1ba 100644
--- a/tests/ui/union/union-derive-eq.stderr
+++ b/tests/ui/union/union-derive-eq.current.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `PartialEqNotEq: Eq` is not satisfied
-  --> $DIR/union-derive-eq.rs:13:5
+  --> $DIR/union-derive-eq.rs:21:5
    |
 LL | #[derive(Eq)]
    |          -- in this derive macro expansion
diff --git a/tests/ui/union/union-derive-eq.next.stderr b/tests/ui/union/union-derive-eq.next.stderr
new file mode 100644
index 00000000000..3952b1f1284
--- /dev/null
+++ b/tests/ui/union/union-derive-eq.next.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `PartialEqNotEq: Eq` is not satisfied
+  --> $DIR/union-derive-eq.rs:21:5
+   |
+LL | #[derive(Eq)]
+   |          -- in this derive macro expansion
+LL | union U2 {
+LL |     a: PartialEqNotEq,
+   |     ^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `PartialEqNotEq`
+   |
+   = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider annotating `PartialEqNotEq` with `#[derive(Eq)]`
+   |
+LL + #[derive(Eq)]
+LL | struct PartialEqNotEq;
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/union/union-derive-eq.rs b/tests/ui/union/union-derive-eq.rs
index e689f8c27d7..085262a72a1 100644
--- a/tests/ui/union/union-derive-eq.rs
+++ b/tests/ui/union/union-derive-eq.rs
@@ -1,9 +1,17 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+
 #[derive(Eq)] // OK
 union U1 {
     a: u8,
 }
 
-impl PartialEq for U1 { fn eq(&self, rhs: &Self) -> bool { true } }
+impl PartialEq for U1 {
+    fn eq(&self, rhs: &Self) -> bool {
+        true
+    }
+}
 
 #[derive(PartialEq, Copy, Clone)]
 struct PartialEqNotEq;
@@ -13,6 +21,10 @@ union U2 {
     a: PartialEqNotEq, //~ ERROR the trait bound `PartialEqNotEq: Eq` is not satisfied
 }
 
-impl PartialEq for U2 { fn eq(&self, rhs: &Self) -> bool { true } }
+impl PartialEq for U2 {
+    fn eq(&self, rhs: &Self) -> bool {
+        true
+    }
+}
 
 fn main() {}
diff --git a/tests/ui/wf/wf-trait-fn-arg.stderr b/tests/ui/wf/wf-trait-fn-arg.current.stderr
index 8b35f36fa68..d5dd36fad6d 100644
--- a/tests/ui/wf/wf-trait-fn-arg.stderr
+++ b/tests/ui/wf/wf-trait-fn-arg.current.stderr
@@ -1,14 +1,14 @@
 error[E0277]: the trait bound `Self: Eq` is not satisfied
-  --> $DIR/wf-trait-fn-arg.rs:10:23
+  --> $DIR/wf-trait-fn-arg.rs:16:23
    |
 LL |     fn bar(&self, x: &Bar<Self>);
    |                       ^^^^^^^^^ the trait `Eq` is not implemented for `Self`
    |
 note: required by a bound in `Bar`
-  --> $DIR/wf-trait-fn-arg.rs:7:14
+  --> $DIR/wf-trait-fn-arg.rs:11:15
    |
-LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
-   |              ^^ required by this bound in `Bar`
+LL | struct Bar<T: Eq + ?Sized> {
+   |               ^^ required by this bound in `Bar`
 help: consider further restricting `Self`
    |
 LL |     fn bar(&self, x: &Bar<Self>) where Self: Eq;
diff --git a/tests/ui/wf/wf-trait-fn-arg.next.stderr b/tests/ui/wf/wf-trait-fn-arg.next.stderr
new file mode 100644
index 00000000000..c55dc5c8a12
--- /dev/null
+++ b/tests/ui/wf/wf-trait-fn-arg.next.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `Self: Eq` is not satisfied
+  --> $DIR/wf-trait-fn-arg.rs:16:23
+   |
+LL |     fn bar(&self, x: &Bar<Self>);
+   |                       ^^^^^^^^^ the trait `Eq` is not implemented for `Self`
+   |
+help: consider further restricting `Self`
+   |
+LL |     fn bar(&self, x: &Bar<Self>) where Self: Eq;
+   |                                  ++++++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/wf/wf-trait-fn-arg.rs b/tests/ui/wf/wf-trait-fn-arg.rs
index 0445699427e..13a5b32828d 100644
--- a/tests/ui/wf/wf-trait-fn-arg.rs
+++ b/tests/ui/wf/wf-trait-fn-arg.rs
@@ -1,16 +1,22 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+
 // Check that we test WF conditions for fn arguments in a trait definition.
 
 #![feature(rustc_attrs)]
 #![allow(dead_code)]
 #![allow(unused_variables)]
 
-struct Bar<T:Eq+?Sized> { value: Box<T> }
+struct Bar<T: Eq + ?Sized> {
+    value: Box<T>,
+}
 
 trait Foo {
     fn bar(&self, x: &Bar<Self>);
-        //~^ ERROR E0277
-        //
-        // Here, Eq ought to be implemented.
+    //~^ ERROR E0277
+    //
+    // Here, Eq ought to be implemented.
 }
 
-fn main() { }
+fn main() {}
diff --git a/tests/ui/wf/wf-trait-fn-ret.stderr b/tests/ui/wf/wf-trait-fn-ret.current.stderr
index 3d70f04def2..0ad786c2fd5 100644
--- a/tests/ui/wf/wf-trait-fn-ret.stderr
+++ b/tests/ui/wf/wf-trait-fn-ret.current.stderr
@@ -1,14 +1,14 @@
 error[E0277]: the trait bound `Self: Eq` is not satisfied
-  --> $DIR/wf-trait-fn-ret.rs:10:23
+  --> $DIR/wf-trait-fn-ret.rs:15:23
    |
 LL |     fn bar(&self) -> &Bar<Self>;
    |                       ^^^^^^^^^ the trait `Eq` is not implemented for `Self`
    |
 note: required by a bound in `Bar`
-  --> $DIR/wf-trait-fn-ret.rs:7:14
+  --> $DIR/wf-trait-fn-ret.rs:10:15
    |
-LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
-   |              ^^ required by this bound in `Bar`
+LL | struct Bar<T: Eq + ?Sized> {
+   |               ^^ required by this bound in `Bar`
 help: consider further restricting `Self`
    |
 LL |     fn bar(&self) -> &Bar<Self> where Self: Eq;
diff --git a/tests/ui/wf/wf-trait-fn-ret.next.stderr b/tests/ui/wf/wf-trait-fn-ret.next.stderr
new file mode 100644
index 00000000000..b3dca17672d
--- /dev/null
+++ b/tests/ui/wf/wf-trait-fn-ret.next.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `Self: Eq` is not satisfied
+  --> $DIR/wf-trait-fn-ret.rs:15:23
+   |
+LL |     fn bar(&self) -> &Bar<Self>;
+   |                       ^^^^^^^^^ the trait `Eq` is not implemented for `Self`
+   |
+help: consider further restricting `Self`
+   |
+LL |     fn bar(&self) -> &Bar<Self> where Self: Eq;
+   |                                 ++++++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/wf/wf-trait-fn-ret.rs b/tests/ui/wf/wf-trait-fn-ret.rs
index f49e4308770..c00f6dd10af 100644
--- a/tests/ui/wf/wf-trait-fn-ret.rs
+++ b/tests/ui/wf/wf-trait-fn-ret.rs
@@ -1,16 +1,21 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
 // Check that we test WF conditions for fn return types in a trait definition.
 
 #![feature(rustc_attrs)]
 #![allow(dead_code)]
 #![allow(unused_variables)]
 
-struct Bar<T:Eq+?Sized> { value: Box<T> }
+struct Bar<T: Eq + ?Sized> {
+    value: Box<T>,
+}
 
 trait Foo {
     fn bar(&self) -> &Bar<Self>;
-        //~^ ERROR E0277
-        //
-        // Here, Eq ought to be implemented.
+    //~^ ERROR E0277
+    //
+    // Here, Eq ought to be implemented.
 }
 
-fn main() { }
+fn main() {}
diff --git a/tests/ui/wf/wf-trait-fn-where-clause.current.stderr b/tests/ui/wf/wf-trait-fn-where-clause.current.stderr
new file mode 100644
index 00000000000..db5454d0f3c
--- /dev/null
+++ b/tests/ui/wf/wf-trait-fn-where-clause.current.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `Self: Eq` is not satisfied
+  --> $DIR/wf-trait-fn-where-clause.rs:18:20
+   |
+LL |         Bar<Self>: Copy;
+   |                    ^^^^ the trait `Eq` is not implemented for `Self`
+   |
+note: required by a bound in `Bar`
+  --> $DIR/wf-trait-fn-where-clause.rs:10:15
+   |
+LL | struct Bar<T: Eq + ?Sized> {
+   |               ^^ required by this bound in `Bar`
+help: consider further restricting `Self`
+   |
+LL |         Bar<Self>: Copy, Self: Eq;
+   |                        ++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/wf/wf-trait-fn-where-clause.next.stderr b/tests/ui/wf/wf-trait-fn-where-clause.next.stderr
new file mode 100644
index 00000000000..8c8a5fa3e70
--- /dev/null
+++ b/tests/ui/wf/wf-trait-fn-where-clause.next.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `Self: Eq` is not satisfied
+  --> $DIR/wf-trait-fn-where-clause.rs:18:20
+   |
+LL |         Bar<Self>: Copy;
+   |                    ^^^^ the trait `Eq` is not implemented for `Self`
+   |
+help: consider further restricting `Self`
+   |
+LL |         Bar<Self>: Copy, Self: Eq;
+   |                        ++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/wf/wf-trait-fn-where-clause.rs b/tests/ui/wf/wf-trait-fn-where-clause.rs
index 1d2427ff981..9e36682e449 100644
--- a/tests/ui/wf/wf-trait-fn-where-clause.rs
+++ b/tests/ui/wf/wf-trait-fn-where-clause.rs
@@ -1,17 +1,24 @@
-// Check that we test WF conditions for fn where clauses in a trait definition.
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
 
+// Check that we test WF conditions for fn where clauses in a trait definition.
 
 #![allow(dead_code)]
 #![allow(unused_variables)]
 
-struct Bar<T:Eq+?Sized> { value: Box<T> }
+struct Bar<T: Eq + ?Sized> {
+    value: Box<T>,
+}
 
 trait Foo {
-    fn bar(&self) where Self: Sized, Bar<Self>: Copy;
-        //~^ ERROR E0277
-        //
-        // Here, Eq ought to be implemented.
+    fn bar(&self)
+    where
+        Self: Sized,
+        Bar<Self>: Copy;
+    //~^ ERROR E0277
+    //
+    // Here, Eq ought to be implemented.
 }
 
-
-fn main() { }
+fn main() {}
diff --git a/tests/ui/wf/wf-trait-fn-where-clause.stderr b/tests/ui/wf/wf-trait-fn-where-clause.stderr
deleted file mode 100644
index 0ad3b58e7c7..00000000000
--- a/tests/ui/wf/wf-trait-fn-where-clause.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0277]: the trait bound `Self: Eq` is not satisfied
-  --> $DIR/wf-trait-fn-where-clause.rs:10:49
-   |
-LL |     fn bar(&self) where Self: Sized, Bar<Self>: Copy;
-   |                                                 ^^^^ the trait `Eq` is not implemented for `Self`
-   |
-note: required by a bound in `Bar`
-  --> $DIR/wf-trait-fn-where-clause.rs:7:14
-   |
-LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
-   |              ^^ required by this bound in `Bar`
-help: consider further restricting `Self`
-   |
-LL |     fn bar(&self) where Self: Sized, Bar<Self>: Copy, Self: Eq;
-   |                                                     ++++++++++
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr
index 840df342ef9..d1de813a2d9 100644
--- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr
+++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr
@@ -1,14 +1,17 @@
 error[E0277]: the trait bound `Bar: Eq` is not satisfied
-  --> $DIR/where-clauses-method-unsatisfied.rs:18:7
+  --> $DIR/where-clauses-method-unsatisfied.rs:24:7
    |
 LL |     x.equals(&x);
    |       ^^^^^^ the trait `Eq` is not implemented for `Bar`
    |
 note: required by a bound in `Foo::<T>::equals`
-  --> $DIR/where-clauses-method-unsatisfied.rs:11:52
+  --> $DIR/where-clauses-method-unsatisfied.rs:16:12
    |
-LL |     fn equals(&self, u: &Foo<T>) -> bool where T : Eq {
-   |                                                    ^^ required by this bound in `Foo::<T>::equals`
+LL |     fn equals(&self, u: &Foo<T>) -> bool
+   |        ------ required by a bound in this associated function
+LL |     where
+LL |         T: Eq,
+   |            ^^ required by this bound in `Foo::<T>::equals`
 help: consider annotating `Bar` with `#[derive(Eq)]`
    |
 LL + #[derive(Eq)]
diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr
new file mode 100644
index 00000000000..d1de813a2d9
--- /dev/null
+++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr
@@ -0,0 +1,23 @@
+error[E0277]: the trait bound `Bar: Eq` is not satisfied
+  --> $DIR/where-clauses-method-unsatisfied.rs:24:7
+   |
+LL |     x.equals(&x);
+   |       ^^^^^^ the trait `Eq` is not implemented for `Bar`
+   |
+note: required by a bound in `Foo::<T>::equals`
+  --> $DIR/where-clauses-method-unsatisfied.rs:16:12
+   |
+LL |     fn equals(&self, u: &Foo<T>) -> bool
+   |        ------ required by a bound in this associated function
+LL |     where
+LL |         T: Eq,
+   |            ^^ required by this bound in `Foo::<T>::equals`
+help: consider annotating `Bar` with `#[derive(Eq)]`
+   |
+LL + #[derive(Eq)]
+LL | struct Bar; // does not implement Eq
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.rs b/tests/ui/where-clauses/where-clauses-method-unsatisfied.rs
index a8ae0296407..34e9d9b57d1 100644
--- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.rs
+++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.rs
@@ -1,14 +1,20 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
 // Test that a where clause attached to a method allows us to add
 // additional constraints to a parameter out of scope.
 
 struct Foo<T> {
-    value: T
+    value: T,
 }
 
 struct Bar; // does not implement Eq
 
 impl<T> Foo<T> {
-    fn equals(&self, u: &Foo<T>) -> bool where T : Eq {
+    fn equals(&self, u: &Foo<T>) -> bool
+    where
+        T: Eq,
+    {
         self.value == u.value
     }
 }
diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.stderr b/tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr
index 205b82d49bf..485b9459ddd 100644
--- a/tests/ui/where-clauses/where-clauses-unsatisfied.stderr
+++ b/tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr
@@ -1,14 +1,17 @@
 error[E0277]: the trait bound `Struct: Eq` is not satisfied
-  --> $DIR/where-clauses-unsatisfied.rs:6:10
+  --> $DIR/where-clauses-unsatisfied.rs:15:10
    |
 LL |     drop(equal(&Struct, &Struct))
    |          ^^^^^ the trait `Eq` is not implemented for `Struct`
    |
 note: required by a bound in `equal`
-  --> $DIR/where-clauses-unsatisfied.rs:1:45
+  --> $DIR/where-clauses-unsatisfied.rs:7:8
    |
-LL | fn equal<T>(a: &T, b: &T) -> bool where T : Eq { a == b }
-   |                                             ^^ required by this bound in `equal`
+LL | fn equal<T>(a: &T, b: &T) -> bool
+   |    ----- required by a bound in this function
+LL | where
+LL |     T: Eq,
+   |        ^^ required by this bound in `equal`
 help: consider annotating `Struct` with `#[derive(Eq)]`
    |
 LL + #[derive(Eq)]
diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr b/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr
new file mode 100644
index 00000000000..485b9459ddd
--- /dev/null
+++ b/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr
@@ -0,0 +1,23 @@
+error[E0277]: the trait bound `Struct: Eq` is not satisfied
+  --> $DIR/where-clauses-unsatisfied.rs:15:10
+   |
+LL |     drop(equal(&Struct, &Struct))
+   |          ^^^^^ the trait `Eq` is not implemented for `Struct`
+   |
+note: required by a bound in `equal`
+  --> $DIR/where-clauses-unsatisfied.rs:7:8
+   |
+LL | fn equal<T>(a: &T, b: &T) -> bool
+   |    ----- required by a bound in this function
+LL | where
+LL |     T: Eq,
+   |        ^^ required by this bound in `equal`
+help: consider annotating `Struct` with `#[derive(Eq)]`
+   |
+LL + #[derive(Eq)]
+LL | struct Struct;
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.rs b/tests/ui/where-clauses/where-clauses-unsatisfied.rs
index 8b067d30a2a..48798e2a15d 100644
--- a/tests/ui/where-clauses/where-clauses-unsatisfied.rs
+++ b/tests/ui/where-clauses/where-clauses-unsatisfied.rs
@@ -1,4 +1,13 @@
-fn equal<T>(a: &T, b: &T) -> bool where T : Eq { a == b }
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+
+fn equal<T>(a: &T, b: &T) -> bool
+where
+    T: Eq,
+{
+    a == b
+}
 
 struct Struct;