summaryrefslogtreecommitdiffstats
path: root/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs
blob: b3aa2279a30a00d7c1899ed7b81ffe0091811f30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#![feature(trait_upcasting)]
#![allow(incomplete_features)]

trait Foo<'a>: Bar<'a> {}
trait Bar<'a> {}

fn test_correct(x: &dyn Foo<'static>) {
    let _ = x as &dyn Bar<'static>;
}

fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
    let _ = x as &dyn Bar<'a>; // Error
    //~^ ERROR lifetime may not live long enough
}

fn test_wrong2<'a>(x: &dyn Foo<'a>) {
    let _ = x as &dyn Bar<'static>; // Error
    //~^ ERROR lifetime may not live long enough
}

fn main() {}