]> git.proxmox.com Git - rustc.git/blob - src/test/ui/traits/trait-upcasting/type-checking-test-3.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / traits / trait-upcasting / type-checking-test-3.rs
1 #![feature(trait_upcasting)]
2 #![allow(incomplete_features)]
3
4 trait Foo<'a>: Bar<'a> {}
5 trait Bar<'a> {}
6
7 fn test_correct(x: &dyn Foo<'static>) {
8 let _ = x as &dyn Bar<'static>;
9 }
10
11 fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
12 let _ = x as &dyn Bar<'a>; // Error
13 //~^ ERROR lifetime may not live long enough
14 }
15
16 fn test_wrong2<'a>(x: &dyn Foo<'a>) {
17 let _ = x as &dyn Bar<'static>; // Error
18 //~^ ERROR lifetime may not live long enough
19 }
20
21 fn main() {}