about summary refs log tree commit diff
path: root/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs
blob: 2c41f62b9fda53077f891a3e2b8b4998f8ed5828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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() {}