]> git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / regions / regions-bounded-method-type-parameters-trait-bound.rs
1 // Check that explicit region bounds are allowed on the various
2 // nominal types (but not on other types) and that they are type
3 // checked.
4
5 // revisions: base nll
6 // ignore-compare-mode-nll
7 //[nll] compile-flags: -Z borrowck=mir
8
9 struct Inv<'a> { // invariant w/r/t 'a
10 x: &'a mut &'a isize
11 }
12
13 trait Foo<'x> {
14 fn method<'y:'x>(self, y: Inv<'y>);
15 }
16
17 fn caller1<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) {
18 // Here the value provided for 'y is 'a, and hence 'a:'a holds.
19 f.method(a);
20 }
21
22 fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) {
23 // Here the value provided for 'y is 'b, and hence 'b:'a does not hold.
24 f.method(b);
25 //[base]~^ ERROR lifetime mismatch [E0623]
26 //[nll]~^^ ERROR lifetime may not live long enough
27 }
28
29 fn caller3<'a,'b:'a,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) {
30 // Here the value provided for 'y is 'b, and hence 'b:'a holds.
31 f.method(b);
32 }
33
34 fn main() { }