about summary refs log tree commit diff
path: root/tests/ui/impl-trait
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/impl-trait')
-rw-r--r--tests/ui/impl-trait/call_method_ambiguous.next.stderr17
-rw-r--r--tests/ui/impl-trait/call_method_ambiguous.rs3
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl.next.stderr17
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl.rs3
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.current.stderr2
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.next.stderr18
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.rs3
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.current.stderr (renamed from tests/ui/impl-trait/call_method_on_inherent_impl_ref.current.stderr)4
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.next.stderr19
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.rs24
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl_ref-ok.rs (renamed from tests/ui/impl-trait/call_method_on_inherent_impl_ref.rs)12
-rw-r--r--tests/ui/impl-trait/call_method_on_inherent_impl_ref.next.stderr31
-rw-r--r--tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr4
-rw-r--r--tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr4
-rw-r--r--tests/ui/impl-trait/method-resolution4.next.stderr9
-rw-r--r--tests/ui/impl-trait/method/broken-deref-chain.current.stderr19
-rw-r--r--tests/ui/impl-trait/method/broken-deref-chain.rs47
-rw-r--r--tests/ui/impl-trait/method/method-resolution.rs (renamed from tests/ui/impl-trait/method-resolution.rs)0
-rw-r--r--tests/ui/impl-trait/method/method-resolution2.next.stderr (renamed from tests/ui/impl-trait/method-resolution2.next.stderr)0
-rw-r--r--tests/ui/impl-trait/method/method-resolution2.rs (renamed from tests/ui/impl-trait/method-resolution2.rs)0
-rw-r--r--tests/ui/impl-trait/method/method-resolution3.current.stderr (renamed from tests/ui/impl-trait/method-resolution3.current.stderr)0
-rw-r--r--tests/ui/impl-trait/method/method-resolution3.next.stderr (renamed from tests/ui/impl-trait/method-resolution3.next.stderr)0
-rw-r--r--tests/ui/impl-trait/method/method-resolution3.rs (renamed from tests/ui/impl-trait/method-resolution3.rs)0
-rw-r--r--tests/ui/impl-trait/method/method-resolution4.rs (renamed from tests/ui/impl-trait/method-resolution4.rs)3
-rw-r--r--tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.current.stderr19
-rw-r--r--tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs23
-rw-r--r--tests/ui/impl-trait/method/method-resolution5-deref.rs30
-rw-r--r--tests/ui/impl-trait/method/would-constrain-opaque.current.stderr29
-rw-r--r--tests/ui/impl-trait/method/would-constrain-opaque.next.stderr27
-rw-r--r--tests/ui/impl-trait/method/would-constrain-opaque.rs39
-rw-r--r--tests/ui/impl-trait/recursive-bound-eval.next.stderr9
-rw-r--r--tests/ui/impl-trait/recursive-bound-eval.rs6
-rw-r--r--tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr17
-rw-r--r--tests/ui/impl-trait/recursive-coroutine-boxed.rs3
34 files changed, 299 insertions, 142 deletions
diff --git a/tests/ui/impl-trait/call_method_ambiguous.next.stderr b/tests/ui/impl-trait/call_method_ambiguous.next.stderr
deleted file mode 100644
index 5251555f574..00000000000
--- a/tests/ui/impl-trait/call_method_ambiguous.next.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0282]: type annotations needed
-  --> $DIR/call_method_ambiguous.rs:26:13
-   |
-LL |         let mut iter = foo(n - 1, m);
-   |             ^^^^^^^^
-LL |
-LL |         assert_eq!(iter.get(), 1);
-   |                    ---- type must be known at this point
-   |
-help: consider giving `iter` an explicit type
-   |
-LL |         let mut iter: /* Type */ = foo(n - 1, m);
-   |                     ++++++++++++
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/call_method_ambiguous.rs b/tests/ui/impl-trait/call_method_ambiguous.rs
index 6bcafc8ce14..021d6c22f79 100644
--- a/tests/ui/impl-trait/call_method_ambiguous.rs
+++ b/tests/ui/impl-trait/call_method_ambiguous.rs
@@ -1,6 +1,6 @@
 //@ revisions: current next
 //@[next] compile-flags: -Znext-solver
-//@[current] run-pass
+//@ run-pass
 
 trait Get {
     fn get(&mut self) -> u32;
@@ -24,7 +24,6 @@ where
 fn foo(n: usize, m: &mut ()) -> impl Get + use<'_> {
     if n > 0 {
         let mut iter = foo(n - 1, m);
-        //[next]~^ ERROR type annotations needed
         assert_eq!(iter.get(), 1);
     }
     m
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl.next.stderr b/tests/ui/impl-trait/call_method_on_inherent_impl.next.stderr
deleted file mode 100644
index 271051f120a..00000000000
--- a/tests/ui/impl-trait/call_method_on_inherent_impl.next.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0282]: type annotations needed
-  --> $DIR/call_method_on_inherent_impl.rs:18:13
-   |
-LL |         let x = my_foo();
-   |             ^
-LL |
-LL |         x.my_debug();
-   |         - type must be known at this point
-   |
-help: consider giving `x` an explicit type
-   |
-LL |         let x: /* Type */ = my_foo();
-   |              ++++++++++++
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl.rs b/tests/ui/impl-trait/call_method_on_inherent_impl.rs
index 0e333c3260a..1dd38bc6717 100644
--- a/tests/ui/impl-trait/call_method_on_inherent_impl.rs
+++ b/tests/ui/impl-trait/call_method_on_inherent_impl.rs
@@ -1,6 +1,6 @@
 //@ revisions: current next
 //@[next] compile-flags: -Znext-solver
-//@[current] check-pass
+//@ check-pass
 
 trait MyDebug {
     fn my_debug(&self);
@@ -16,7 +16,6 @@ where
 fn my_foo() -> impl std::fmt::Debug {
     if false {
         let x = my_foo();
-        //[next]~^ ERROR type annotations needed
         x.my_debug();
     }
     ()
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.current.stderr b/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.current.stderr
index 6ecb2b05fc5..e7104664470 100644
--- a/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.current.stderr
+++ b/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.current.stderr
@@ -1,5 +1,5 @@
 error[E0599]: no method named `my_debug` found for reference `&impl Debug` in the current scope
-  --> $DIR/call_method_on_inherent_impl_on_rigid_type.rs:16:11
+  --> $DIR/call_method_on_inherent_impl_on_rigid_type.rs:15:11
    |
 LL |         x.my_debug();
    |           ^^^^^^^^ method not found in `&impl Debug`
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.next.stderr b/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.next.stderr
index 5fb0b8f1d14..de808259d40 100644
--- a/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.next.stderr
+++ b/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.next.stderr
@@ -1,17 +1,15 @@
-error[E0282]: type annotations needed for `&_`
-  --> $DIR/call_method_on_inherent_impl_on_rigid_type.rs:14:13
+error[E0599]: no method named `my_debug` found for reference `&_` in the current scope
+  --> $DIR/call_method_on_inherent_impl_on_rigid_type.rs:15:11
    |
-LL |         let x = &my_foo();
-   |             ^
-LL |
 LL |         x.my_debug();
-   |           -------- type must be known at this point
+   |           ^^^^^^^^ method not found in `&_`
    |
-help: consider giving `x` an explicit type, where the placeholders `_` are specified
+   = help: items from traits can only be used if the trait is implemented and in scope
+help: trait `MyDebug` which provides `my_debug` is implemented but not in scope; perhaps you want to import it
+   |
+LL + use MyDebug;
    |
-LL |         let x: &_ = &my_foo();
-   |              ++++
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0282`.
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.rs b/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.rs
index 7fb2ff3b2bc..0c9909efa1b 100644
--- a/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.rs
+++ b/tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.rs
@@ -12,9 +12,8 @@ impl MyDebug for &() {
 fn my_foo() -> impl std::fmt::Debug {
     if false {
         let x = &my_foo();
-        //[next]~^ ERROR: type annotations needed
         x.my_debug();
-        //[current]~^ ERROR: no method named `my_debug`
+        //~^ ERROR: no method named `my_debug`
     }
     ()
 }
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl_ref.current.stderr b/tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.current.stderr
index fb51bb7b417..71acbd1497d 100644
--- a/tests/ui/impl-trait/call_method_on_inherent_impl_ref.current.stderr
+++ b/tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.current.stderr
@@ -1,5 +1,5 @@
 error[E0599]: no method named `my_debug` found for opaque type `impl Debug` in the current scope
-  --> $DIR/call_method_on_inherent_impl_ref.rs:19:11
+  --> $DIR/call_method_on_inherent_impl_ref-err.rs:18:11
    |
 LL |     fn my_debug(&self);
    |        -------- the method is available for `&impl Debug` here
@@ -9,7 +9,7 @@ LL |         x.my_debug();
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `MyDebug` defines an item `my_debug`, perhaps you need to implement it
-  --> $DIR/call_method_on_inherent_impl_ref.rs:4:1
+  --> $DIR/call_method_on_inherent_impl_ref-err.rs:4:1
    |
 LL | trait MyDebug {
    | ^^^^^^^^^^^^^
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.next.stderr b/tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.next.stderr
new file mode 100644
index 00000000000..523505e9802
--- /dev/null
+++ b/tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.next.stderr
@@ -0,0 +1,19 @@
+error[E0599]: no method named `my_debug` found for type `_` in the current scope
+  --> $DIR/call_method_on_inherent_impl_ref-err.rs:18:11
+   |
+LL |     fn my_debug(&self);
+   |        -------- the method is available for `&_` here
+...
+LL |         x.my_debug();
+   |           ^^^^^^^^ method not found in `_`
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+note: `MyDebug` defines an item `my_debug`, perhaps you need to implement it
+  --> $DIR/call_method_on_inherent_impl_ref-err.rs:4:1
+   |
+LL | trait MyDebug {
+   | ^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.rs b/tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.rs
new file mode 100644
index 00000000000..0ed09bc76a4
--- /dev/null
+++ b/tests/ui/impl-trait/call_method_on_inherent_impl_ref-err.rs
@@ -0,0 +1,24 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+
+trait MyDebug {
+    fn my_debug(&self);
+}
+
+impl<T> MyDebug for &T
+where
+    T: std::fmt::Debug,
+{
+    fn my_debug(&self) {}
+}
+
+fn my_foo() -> impl std::fmt::Debug {
+    if false {
+        let x = my_foo();
+        x.my_debug();
+        //~^ ERROR no method named `my_debug` found
+    }
+    ()
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl_ref.rs b/tests/ui/impl-trait/call_method_on_inherent_impl_ref-ok.rs
index 4e4098b37f9..40739d6a0ce 100644
--- a/tests/ui/impl-trait/call_method_on_inherent_impl_ref.rs
+++ b/tests/ui/impl-trait/call_method_on_inherent_impl_ref-ok.rs
@@ -1,5 +1,6 @@
 //@ revisions: current next
 //@[next] compile-flags: -Znext-solver
+//@ check-pass
 
 trait MyDebug {
     fn my_debug(&self);
@@ -12,20 +13,9 @@ where
     fn my_debug(&self) {}
 }
 
-fn my_foo() -> impl std::fmt::Debug {
-    if false {
-        let x = my_foo();
-        //[next]~^ ERROR type annotations needed
-        x.my_debug();
-        //[current]~^ ERROR no method named `my_debug` found
-    }
-    ()
-}
-
 fn my_bar() -> impl std::fmt::Debug {
     if false {
         let x = &my_bar();
-        //[next]~^ ERROR type annotations needed
         x.my_debug();
     }
     ()
diff --git a/tests/ui/impl-trait/call_method_on_inherent_impl_ref.next.stderr b/tests/ui/impl-trait/call_method_on_inherent_impl_ref.next.stderr
deleted file mode 100644
index 7202cb6f90a..00000000000
--- a/tests/ui/impl-trait/call_method_on_inherent_impl_ref.next.stderr
+++ /dev/null
@@ -1,31 +0,0 @@
-error[E0282]: type annotations needed
-  --> $DIR/call_method_on_inherent_impl_ref.rs:17:13
-   |
-LL |         let x = my_foo();
-   |             ^
-LL |
-LL |         x.my_debug();
-   |         - type must be known at this point
-   |
-help: consider giving `x` an explicit type
-   |
-LL |         let x: /* Type */ = my_foo();
-   |              ++++++++++++
-
-error[E0282]: type annotations needed for `&_`
-  --> $DIR/call_method_on_inherent_impl_ref.rs:27:13
-   |
-LL |         let x = &my_bar();
-   |             ^
-LL |
-LL |         x.my_debug();
-   |           -------- type must be known at this point
-   |
-help: consider giving `x` an explicit type, where the placeholders `_` are specified
-   |
-LL |         let x: &_ = &my_bar();
-   |              ++++
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr b/tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr
index dca0a7b0a1a..cb383b2db38 100644
--- a/tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr
+++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr
@@ -5,7 +5,7 @@ LL |     Thunk::new(|mut cont| {
    |                 ^^^^^^^^
 LL |
 LL |         cont.reify_as();
-   |         ---- type must be known at this point
+   |              -------- type must be known at this point
    |
 help: consider giving this closure parameter an explicit type
    |
@@ -19,7 +19,7 @@ LL |     Thunk::new(|mut cont| {
    |                 ^^^^^^^^
 LL |
 LL |         cont.reify_as();
-   |         ---- type must be known at this point
+   |              -------- type must be known at this point
    |
 help: consider giving this closure parameter an explicit type
    |
diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr b/tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr
index dca0a7b0a1a..cb383b2db38 100644
--- a/tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr
+++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr
@@ -5,7 +5,7 @@ LL |     Thunk::new(|mut cont| {
    |                 ^^^^^^^^
 LL |
 LL |         cont.reify_as();
-   |         ---- type must be known at this point
+   |              -------- type must be known at this point
    |
 help: consider giving this closure parameter an explicit type
    |
@@ -19,7 +19,7 @@ LL |     Thunk::new(|mut cont| {
    |                 ^^^^^^^^
 LL |
 LL |         cont.reify_as();
-   |         ---- type must be known at this point
+   |              -------- type must be known at this point
    |
 help: consider giving this closure parameter an explicit type
    |
diff --git a/tests/ui/impl-trait/method-resolution4.next.stderr b/tests/ui/impl-trait/method-resolution4.next.stderr
deleted file mode 100644
index 0524f49f98e..00000000000
--- a/tests/ui/impl-trait/method-resolution4.next.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0282]: type annotations needed
-  --> $DIR/method-resolution4.rs:13:9
-   |
-LL |         foo(false).next().unwrap();
-   |         ^^^^^^^^^^ cannot infer type
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/method/broken-deref-chain.current.stderr b/tests/ui/impl-trait/method/broken-deref-chain.current.stderr
new file mode 100644
index 00000000000..726f076b183
--- /dev/null
+++ b/tests/ui/impl-trait/method/broken-deref-chain.current.stderr
@@ -0,0 +1,19 @@
+error[E0308]: mismatched types
+  --> $DIR/broken-deref-chain.rs:41:30
+   |
+LL | fn trait_method() -> impl Trait {
+   |                      ---------- the found opaque type
+...
+LL |         x.trait_method();
+   |         - here the type of `x` is inferred to be `Foo<u32, impl Trait>`
+LL |         let _: Foo<i32, _> = x; // Test that we did not apply the deref step
+   |                -----------   ^ expected `Foo<i32, _>`, found `Foo<u32, impl Trait>`
+   |                |
+   |                expected due to this
+   |
+   = note: expected struct `Foo<i32, _>`
+              found struct `Foo<u32, impl Trait>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/method/broken-deref-chain.rs b/tests/ui/impl-trait/method/broken-deref-chain.rs
new file mode 100644
index 00000000000..8b45e044f43
--- /dev/null
+++ b/tests/ui/impl-trait/method/broken-deref-chain.rs
@@ -0,0 +1,47 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@[next] check-pass
+
+// An annoying edge case of method selection. While computing the deref-chain
+// constrains `T` to `u32`, the final method candidate does not and instead
+// constrains to `i32`. In this case, we no longer check that the opaque
+// remains unconstrained. Both method calls in this test constrain the opaque
+// to `i32`.
+use std::ops::Deref;
+
+struct Foo<T, U>(T, U);
+impl<U> Deref for Foo<u32, U> {
+    type Target = U;
+    fn deref(&self) -> &Self::Target {
+        &self.1
+    }
+}
+
+impl Foo<i32, i32> {
+    fn method(&self) {}
+}
+fn inherent_method() -> impl Sized {
+    if false {
+        let x = Foo(Default::default(), inherent_method());
+        x.method();
+        let _: Foo<i32, _> = x; // Test that we did not apply the deref step
+    }
+    1i32
+}
+
+trait Trait {
+    fn trait_method(&self) {}
+}
+impl Trait for Foo<i32, i32> {}
+impl Trait for i32 {}
+fn trait_method() -> impl Trait {
+    if false {
+        let x = Foo(Default::default(), trait_method());
+        x.trait_method();
+        let _: Foo<i32, _> = x; // Test that we did not apply the deref step
+        //[current]~^ ERROR mismatched types
+    }
+    1i32
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/method-resolution.rs b/tests/ui/impl-trait/method/method-resolution.rs
index 60fbacd8646..60fbacd8646 100644
--- a/tests/ui/impl-trait/method-resolution.rs
+++ b/tests/ui/impl-trait/method/method-resolution.rs
diff --git a/tests/ui/impl-trait/method-resolution2.next.stderr b/tests/ui/impl-trait/method/method-resolution2.next.stderr
index 223430e1658..223430e1658 100644
--- a/tests/ui/impl-trait/method-resolution2.next.stderr
+++ b/tests/ui/impl-trait/method/method-resolution2.next.stderr
diff --git a/tests/ui/impl-trait/method-resolution2.rs b/tests/ui/impl-trait/method/method-resolution2.rs
index 88d4f3d9896..88d4f3d9896 100644
--- a/tests/ui/impl-trait/method-resolution2.rs
+++ b/tests/ui/impl-trait/method/method-resolution2.rs
diff --git a/tests/ui/impl-trait/method-resolution3.current.stderr b/tests/ui/impl-trait/method/method-resolution3.current.stderr
index 87dd862ef8f..87dd862ef8f 100644
--- a/tests/ui/impl-trait/method-resolution3.current.stderr
+++ b/tests/ui/impl-trait/method/method-resolution3.current.stderr
diff --git a/tests/ui/impl-trait/method-resolution3.next.stderr b/tests/ui/impl-trait/method/method-resolution3.next.stderr
index 87dd862ef8f..87dd862ef8f 100644
--- a/tests/ui/impl-trait/method-resolution3.next.stderr
+++ b/tests/ui/impl-trait/method/method-resolution3.next.stderr
diff --git a/tests/ui/impl-trait/method-resolution3.rs b/tests/ui/impl-trait/method/method-resolution3.rs
index 8c47ef4fc75..8c47ef4fc75 100644
--- a/tests/ui/impl-trait/method-resolution3.rs
+++ b/tests/ui/impl-trait/method/method-resolution3.rs
diff --git a/tests/ui/impl-trait/method-resolution4.rs b/tests/ui/impl-trait/method/method-resolution4.rs
index 90e7850cad5..f90a9309cda 100644
--- a/tests/ui/impl-trait/method-resolution4.rs
+++ b/tests/ui/impl-trait/method/method-resolution4.rs
@@ -6,12 +6,11 @@
 
 //@ revisions: current next
 //@[next] compile-flags: -Znext-solver
-//@[current] check-pass
+//@ check-pass
 
 fn foo(b: bool) -> impl Iterator<Item = ()> {
     if b {
         foo(false).next().unwrap();
-        //[next]~^ ERROR type annotations needed
     }
     std::iter::empty()
 }
diff --git a/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.current.stderr b/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.current.stderr
new file mode 100644
index 00000000000..08578de426a
--- /dev/null
+++ b/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.current.stderr
@@ -0,0 +1,19 @@
+error[E0308]: mismatched types
+  --> $DIR/method-resolution5-deref-no-constrain.rs:20:5
+   |
+LL | fn via_deref() -> impl Deref<Target = Foo> {
+   |                                       --- expected `&Foo` because of return type
+...
+LL |     Box::new(Foo)
+   |     ^^^^^^^^^^^^^ expected `&Foo`, found `Box<Foo>`
+   |
+   = note: expected reference `&Foo`
+                 found struct `Box<Foo>`
+help: consider borrowing here
+   |
+LL |     &Box::new(Foo)
+   |     +
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs b/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs
new file mode 100644
index 00000000000..2c41f62b9fd
--- /dev/null
+++ b/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs
@@ -0,0 +1,23 @@
+//! The recursive method call yields the opaque type. We want
+//! to use the impl candidate for `Foo` here without constraining
+//! the opaque to `&Foo`.
+
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@[next] check-pass
+
+use std::ops::Deref;
+struct Foo;
+impl Foo {
+    fn method(&self) {}
+}
+fn via_deref() -> impl Deref<Target = Foo> {
+    // Currently errors on stable, but should not
+    if false {
+        via_deref().method();
+    }
+
+    Box::new(Foo)
+    //[current]~^ ERROR mismatched types
+}
+fn main() {}
diff --git a/tests/ui/impl-trait/method/method-resolution5-deref.rs b/tests/ui/impl-trait/method/method-resolution5-deref.rs
new file mode 100644
index 00000000000..6133a8efe24
--- /dev/null
+++ b/tests/ui/impl-trait/method/method-resolution5-deref.rs
@@ -0,0 +1,30 @@
+//! The recursive method call yields the opaque type. We want
+//! to use the trait candidate for `impl Foo` here while not
+//! applying it for the `impl Deref`.
+
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+
+use std::ops::Deref;
+trait Foo {
+    fn method(&self) {}
+}
+impl Foo for u32 {}
+fn via_deref() -> impl Deref<Target = impl Foo> {
+    if false {
+        via_deref().method();
+    }
+
+    Box::new(1u32)
+}
+
+fn via_deref_nested() -> Box<impl Deref<Target = impl Foo>> {
+    if false {
+        via_deref_nested().method();
+    }
+
+    Box::new(Box::new(1u32))
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/method/would-constrain-opaque.current.stderr b/tests/ui/impl-trait/method/would-constrain-opaque.current.stderr
new file mode 100644
index 00000000000..60533a39c53
--- /dev/null
+++ b/tests/ui/impl-trait/method/would-constrain-opaque.current.stderr
@@ -0,0 +1,29 @@
+error[E0599]: no method named `method` found for reference `&impl Sized` in the current scope
+  --> $DIR/would-constrain-opaque.rs:28:11
+   |
+LL |         x.method();
+   |           ^^^^^^ method not found in `&impl Sized`
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+note: `Trait` defines an item `method`, perhaps you need to implement it
+  --> $DIR/would-constrain-opaque.rs:15:1
+   |
+LL | trait Trait: Sized {
+   | ^^^^^^^^^^^^^^^^^^
+
+error[E0599]: no method named `method` found for reference `&impl Sized` in the current scope
+  --> $DIR/would-constrain-opaque.rs:30:11
+   |
+LL |         x.method();
+   |           ^^^^^^ method not found in `&impl Sized`
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+note: `Trait` defines an item `method`, perhaps you need to implement it
+  --> $DIR/would-constrain-opaque.rs:15:1
+   |
+LL | trait Trait: Sized {
+   | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/impl-trait/method/would-constrain-opaque.next.stderr b/tests/ui/impl-trait/method/would-constrain-opaque.next.stderr
new file mode 100644
index 00000000000..23a4ceb826a
--- /dev/null
+++ b/tests/ui/impl-trait/method/would-constrain-opaque.next.stderr
@@ -0,0 +1,27 @@
+error[E0599]: no method named `method` found for reference `&_` in the current scope
+  --> $DIR/would-constrain-opaque.rs:28:11
+   |
+LL |         x.method();
+   |           ^^^^^^ method not found in `&_`
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+help: trait `Trait` which provides `method` is implemented but not in scope; perhaps you want to import it
+   |
+LL + use Trait;
+   |
+
+error[E0599]: no method named `method` found for reference `&_` in the current scope
+  --> $DIR/would-constrain-opaque.rs:30:11
+   |
+LL |         x.method();
+   |           ^^^^^^ method not found in `&_`
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+help: trait `Trait` which provides `method` is implemented but not in scope; perhaps you want to import it
+   |
+LL + use Trait;
+   |
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/impl-trait/method/would-constrain-opaque.rs b/tests/ui/impl-trait/method/would-constrain-opaque.rs
new file mode 100644
index 00000000000..8dd32282529
--- /dev/null
+++ b/tests/ui/impl-trait/method/would-constrain-opaque.rs
@@ -0,0 +1,39 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+
+// If we don't treat `impl Sized` as rigid, the first call would
+// resolve to the trait method, constraining the opaque, while the
+// second call would resolve to the inherent method.
+//
+// We avoid cases like this by rejecting candidates which constrain
+// opaque types encountered in the autoderef chain.
+//
+// FIXME(-Znext-solver): ideally we would note that the inference variable
+// is an opaque type in the error message and change this to a type annotations
+// needed error.
+
+trait Trait: Sized {
+    fn method(self) {}
+}
+impl Trait for &Foo {}
+
+struct Foo;
+impl Foo {
+    fn method(&self) {}
+}
+
+fn define_opaque(b: bool) -> impl Sized {
+    if b {
+        let x = &define_opaque(false);
+        x.method();
+        //~^ ERROR no method named `method` found for reference
+        x.method();
+        //~^ ERROR no method named `method` found for reference
+    }
+
+    Foo
+}
+
+fn main() {
+    define_opaque(true);
+}
diff --git a/tests/ui/impl-trait/recursive-bound-eval.next.stderr b/tests/ui/impl-trait/recursive-bound-eval.next.stderr
deleted file mode 100644
index 4bab290d71c..00000000000
--- a/tests/ui/impl-trait/recursive-bound-eval.next.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0282]: type annotations needed
-  --> $DIR/recursive-bound-eval.rs:20:13
-   |
-LL |     move || recursive_fn().parse()
-   |             ^^^^^^^^^^^^^^ cannot infer type
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/recursive-bound-eval.rs b/tests/ui/impl-trait/recursive-bound-eval.rs
index 7859c8983fc..058b12e5651 100644
--- a/tests/ui/impl-trait/recursive-bound-eval.rs
+++ b/tests/ui/impl-trait/recursive-bound-eval.rs
@@ -1,10 +1,9 @@
 //! Test that we can evaluate nested obligations when invoking methods on recursive calls on
 //! an RPIT.
 
-//@revisions: next current
+//@ revisions: next current
 //@[next] compile-flags: -Znext-solver
-
-//@[current] check-pass
+//@ check-pass
 
 pub trait Parser<E> {
     fn parse(&self) -> E;
@@ -18,7 +17,6 @@ impl<E, T: Fn() -> E> Parser<E> for T {
 
 pub fn recursive_fn<E>() -> impl Parser<E> {
     move || recursive_fn().parse()
-    //[next]~^ ERROR: type annotations needed
 }
 
 fn main() {}
diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr
deleted file mode 100644
index 5ce6eb0fc39..00000000000
--- a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0282]: type annotations needed
-  --> $DIR/recursive-coroutine-boxed.rs:11:23
-   |
-LL |         let mut gen = Box::pin(foo());
-   |                       ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Box`
-LL |
-LL |         let mut r = gen.as_mut().resume(());
-   |                         ------ type must be known at this point
-   |
-help: consider specifying the generic argument
-   |
-LL |         let mut gen = Box::<T>::pin(foo());
-   |                          +++++
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.rs b/tests/ui/impl-trait/recursive-coroutine-boxed.rs
index 306edc3591e..932023d103d 100644
--- a/tests/ui/impl-trait/recursive-coroutine-boxed.rs
+++ b/tests/ui/impl-trait/recursive-coroutine-boxed.rs
@@ -1,7 +1,7 @@
 //@ revisions: current next
 //@ ignore-compare-mode-next-solver (explicit revisions)
-//@[current] check-pass
 //@[next] compile-flags: -Znext-solver
+//@ check-pass
 #![feature(coroutines, coroutine_trait)]
 
 use std::ops::{Coroutine, CoroutineState};
@@ -9,7 +9,6 @@ use std::ops::{Coroutine, CoroutineState};
 fn foo() -> impl Coroutine<Yield = (), Return = ()> {
     #[coroutine] || {
         let mut gen = Box::pin(foo());
-        //[next]~^ ERROR type annotations needed
         let mut r = gen.as_mut().resume(());
         while let CoroutineState::Yielded(v) = r {
             yield v;