Files
rust/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs
2025-09-26 16:33:15 +02:00

24 lines
535 B
Rust

//! 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() {}