]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/in-trait/nested-rpitit.rs
Rollup merge of #100185 - compiler-errors:issue-100183, r=wesleywiser
[rust.git] / src / test / ui / impl-trait / in-trait / nested-rpitit.rs
1 // check-pass
2
3 #![feature(return_position_impl_trait_in_trait)]
4 #![allow(incomplete_features)]
5
6 use std::fmt::Display;
7 use std::ops::Deref;
8
9 trait Foo {
10     fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
11 }
12
13 struct A;
14
15 impl Foo for A {
16     fn bar(self) -> &'static str {
17         "Hello, world"
18     }
19 }
20
21 struct B;
22
23 impl Foo for B {
24     fn bar(self) -> Box<i32> {
25         Box::new(42)
26     }
27 }
28
29 fn main() {
30     println!("Message for you: {:?}", &*A.bar());
31     println!("Another for you: {:?}", &*B.bar());
32 }