]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-lifetime-bounds-on-fns.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / regions / regions-lifetime-bounds-on-fns.rs
1 fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) {
2     // Note: this is legal because of the `'b:'a` declaration.
3     *x = *y;
4 }
5
6 fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
7     // Illegal now because there is no `'b:'a` declaration.
8     *x = *y; //~ ERROR E0623
9 }
10
11 fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
12     // Here we try to call `foo` but do not know that `'a` and `'b` are
13     // related as required.
14     a(x, y); //~ ERROR lifetime mismatch [E0623]
15 }
16
17 fn d() {
18     // 'a and 'b are early bound in the function `a` because they appear
19     // inconstraints:
20     let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR E0308
21 }
22
23 fn e() {
24     // 'a and 'b are late bound in the function `b` because there are
25     // no constraints:
26     let _: fn(&mut &isize, &mut &isize) = b;
27 }
28
29 fn main() { }