summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/region-object-lifetime-5.rs
blob: ad35936716806007b045b22d68a2933bf6f80750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Various tests related to testing how region inference works
// with respect to the object receivers.

trait Foo {
    fn borrowed<'a>(&'a self) -> &'a ();
}

// Here, the object is bounded by an anonymous lifetime and returned
// as `&'static`, so you get an error.
fn owned_receiver(x: Box<dyn Foo>) -> &'static () {
    x.borrowed() //~ ERROR cannot return reference to local data `*x`
}

fn main() {}