]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/trait-upcasting/type-checking-test-3.rs
Rollup merge of #106701 - ibraheemdev:sync-sender-spin, r=Amanieu
[rust.git] / tests / ui / traits / trait-upcasting / type-checking-test-3.rs
1 #![feature(trait_upcasting)]
2
3 trait Foo<'a>: Bar<'a> {}
4 trait Bar<'a> {}
5
6 fn test_correct(x: &dyn Foo<'static>) {
7     let _ = x as &dyn Bar<'static>;
8 }
9
10 fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
11     let _ = x as &dyn Bar<'a>; // Error
12                                //~^ ERROR lifetime may not live long enough
13 }
14
15 fn test_wrong2<'a>(x: &dyn Foo<'a>) {
16     let _ = x as &dyn Bar<'static>; // Error
17                                     //~^ ERROR lifetime may not live long enough
18 }
19
20 fn main() {}