2022-09-02 16:02:59 -05:00
|
|
|
// check-pass
|
|
|
|
|
|
|
|
#![feature(return_position_impl_trait_in_trait)]
|
|
|
|
#![allow(incomplete_features)]
|
|
|
|
|
|
|
|
use std::fmt::Display;
|
|
|
|
use std::ops::Deref;
|
|
|
|
|
|
|
|
trait Foo {
|
|
|
|
fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct A;
|
|
|
|
|
|
|
|
impl Foo for A {
|
2023-09-01 23:02:11 -05:00
|
|
|
#[allow(refining_impl_trait)]
|
2022-09-02 16:02:59 -05:00
|
|
|
fn bar(self) -> &'static str {
|
|
|
|
"Hello, world"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct B;
|
|
|
|
|
|
|
|
impl Foo for B {
|
2023-09-01 23:02:11 -05:00
|
|
|
#[allow(refining_impl_trait)]
|
2022-09-02 16:02:59 -05:00
|
|
|
fn bar(self) -> Box<i32> {
|
|
|
|
Box::new(42)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
println!("Message for you: {:?}", &*A.bar());
|
|
|
|
println!("Another for you: {:?}", &*B.bar());
|
|
|
|
}
|