]> git.proxmox.com Git - rustc.git/blob - src/test/ui/impl-trait/dyn-trait-elided-two-inputs-ref-param.rs
New upstream version 1.39.0+dfsg1
[rustc.git] / src / test / ui / impl-trait / dyn-trait-elided-two-inputs-ref-param.rs
1 // Test that `impl Alpha<dyn Object>` resets the object-lifetime
2 // default to `'static`.
3 //
4 // check-pass
5
6 trait Alpha<Item: ?Sized> {
7 fn item(&self) -> Box<Item> {
8 panic!()
9 }
10 }
11
12 trait Object {}
13 impl<T> Alpha<dyn Object> for T {}
14 fn alpha(x: &str, y: &str) -> impl Alpha<dyn Object> { () }
15 fn is_static<T>(_: T) where T: 'static { }
16
17 fn bar(x: &str) -> &impl Alpha<dyn Object> { &() }
18
19 fn main() {
20 let s = format!("foo");
21 let r = bar(&s);
22 is_static(r.item());
23 }