2022-09-02 16:02:59 -05:00
|
|
|
// check-pass
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
#![feature(return_position_impl_trait_in_trait, lint_reasons)]
|
2022-09-02 16:02:59 -05:00
|
|
|
#![allow(incomplete_features)]
|
|
|
|
|
|
|
|
use std::fmt::Display;
|
|
|
|
use std::ops::Deref;
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
pub trait Foo {
|
2022-09-02 16:02:59 -05:00
|
|
|
fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
|
|
|
|
}
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
pub struct A;
|
2022-09-02 16:02:59 -05:00
|
|
|
|
|
|
|
impl Foo for A {
|
2023-09-06 19:45:12 -05:00
|
|
|
#[expect(refining_impl_trait)]
|
2022-09-02 16:02:59 -05:00
|
|
|
fn bar(self) -> &'static str {
|
|
|
|
"Hello, world"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
pub struct B;
|
2022-09-02 16:02:59 -05:00
|
|
|
|
|
|
|
impl Foo for B {
|
2023-09-06 19:45:12 -05:00
|
|
|
#[expect(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());
|
|
|
|
}
|