]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/region-object-lifetime-4.rs
Auto merge of #106143 - matthiaskrgr:rollup-3kpy1dc, r=matthiaskrgr
[rust.git] / src / test / ui / regions / region-object-lifetime-4.rs
1 // Various tests related to testing how region inference works
2 // with respect to the object receivers.
3
4 trait Foo {
5     fn borrowed<'a>(&'a self) -> &'a ();
6 }
7
8 // Here we have two distinct lifetimes, but we try to return a pointer
9 // with the longer lifetime when (from the signature) we only know
10 // that it lives as long as the shorter lifetime. Therefore, error.
11 fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () {
12     x.borrowed()
13     //~^ ERROR lifetime may not live long enough
14 }
15
16 fn main() {}