about summary refs log tree commit diff
path: root/tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs')
-rw-r--r--tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs b/tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs
new file mode 100644
index 00000000000..2c41f62b9fd
--- /dev/null
+++ b/tests/ui/impl-trait/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() {}