summaryrefslogtreecommitdiffstats
path: root/src/test/ui/traits/coercion-generic-regions.rs
blob: af478df6dfa995f671dc2c003d30366f662fa86a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
struct Struct {
    person: &'static str
}

trait Trait<T> {
    fn f(&self, x: T);
}

impl Trait<&'static str> for Struct {
    fn f(&self, x: &'static str) {
        println!("Hello, {}!", x);
    }
}

fn main() {
    let person = "Fred".to_string();
    let person: &str = &person;  //~ ERROR `person` does not live long enough
    let s: Box<dyn Trait<&'static str>> = Box::new(Struct { person: person });
}