rust/tests/ui/impl-trait/call_method_on_inherent_impl_ref.rs
2024-06-13 10:41:52 +00:00

36 lines
608 B
Rust

//@ 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 {
//[current]~^ cycle
if false {
let x = my_foo();
//[next]~^ type annotations needed
x.my_debug();
//[current]~^ no method named `my_debug` found
}
()
}
fn my_bar() -> impl std::fmt::Debug {
if false {
let x = &my_bar();
//[next]~^ type annotations needed
x.my_debug();
}
()
}
fn main() {}