]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/region-object-lifetime-2.rs
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
[rust.git] / src / test / ui / regions / region-object-lifetime-2.rs
1 // Various tests related to testing how region inference works
2 // with respect to the object receivers.
3
4 // revisions: base nll
5 // ignore-compare-mode-nll
6 //[nll] compile-flags: -Z borrowck=mir
7
8 trait Foo {
9     fn borrowed<'a>(&'a self) -> &'a ();
10 }
11
12 // Borrowed receiver but two distinct lifetimes, we get an error.
13 fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () {
14     x.borrowed()
15     //[base]~^ ERROR cannot infer
16     //[nll]~^^ ERROR lifetime may not live long enough
17 }
18
19 fn main() {}