]>
Commit | Line | Data |
---|---|---|
04454e1e FG |
1 | // revisions: base nll |
2 | // ignore-compare-mode-nll | |
3 | //[nll] compile-flags: -Z borrowck=mir | |
4 | ||
1a4d82fc JJ |
5 | fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { |
6 | // Note: this is legal because of the `'b:'a` declaration. | |
7 | *x = *y; | |
8 | } | |
9 | ||
10 | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | |
11 | // Illegal now because there is no `'b:'a` declaration. | |
04454e1e FG |
12 | *x = *y; |
13 | //[base]~^ ERROR lifetime mismatch [E0623] | |
14 | //[nll]~^^ ERROR lifetime may not live long enough | |
1a4d82fc JJ |
15 | } |
16 | ||
17 | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | |
18 | // Here we try to call `foo` but do not know that `'a` and `'b` are | |
19 | // related as required. | |
04454e1e FG |
20 | a(x, y); |
21 | //[base]~^ ERROR lifetime mismatch [E0623] | |
22 | //[nll]~^^ ERROR lifetime may not live long enough | |
1a4d82fc JJ |
23 | } |
24 | ||
25 | fn d() { | |
26 | // 'a and 'b are early bound in the function `a` because they appear | |
27 | // inconstraints: | |
04454e1e FG |
28 | let _: fn(&mut &isize, &mut &isize) = a; |
29 | //~^ ERROR mismatched types [E0308] | |
30 | //[nll]~^^ ERROR mismatched types [E0308] | |
1a4d82fc JJ |
31 | } |
32 | ||
33 | fn e() { | |
34 | // 'a and 'b are late bound in the function `b` because there are | |
35 | // no constraints: | |
36 | let _: fn(&mut &isize, &mut &isize) = b; | |
37 | } | |
38 | ||
39 | fn main() { } |