]> git.proxmox.com Git - rustc.git/blob - tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / object-lifetime / object-lifetime-default-dyn-binding-nonstatic3.rs
1 // Test that `dyn Bar<Item = XX>` uses `'static` as the default object
2 // lifetime bound for the type `XX`.
3
4 trait Foo<'a> {
5 type Item: ?Sized;
6
7 fn item(&self) -> Box<Self::Item> { panic!() }
8 }
9
10 trait Bar { }
11
12 fn is_static<T>(_: T) where T: 'static { }
13
14 // Here, we should default to `dyn Bar + 'static`, but the current
15 // code forces us into a conservative, hacky path.
16 fn bar(x: &str) -> &dyn Foo<Item = dyn Bar> { &() }
17 //~^ ERROR please supply an explicit bound
18
19 fn main() {
20 let s = format!("foo");
21 let r = bar(&s);
22 is_static(r.item());
23 }