2015-01-08 10:54:35 +00:00
|
|
|
fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where 'b: 'a + 'c {
|
2014-12-20 10:48:43 +00:00
|
|
|
// Note: this is legal because of the `'b:'a` declaration.
|
|
|
|
*x = *y;
|
|
|
|
*z = *y;
|
|
|
|
}
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
2014-12-20 10:48:43 +00:00
|
|
|
// Illegal now because there is no `'b:'a` declaration.
|
2022-04-19 10:56:18 +00:00
|
|
|
*x = *y;
|
2022-04-01 17:13:25 +00:00
|
|
|
*z = *y;
|
2014-12-20 10:48:43 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
2014-12-20 10:48:43 +00:00
|
|
|
// Here we try to call `foo` but do not know that `'a` and `'b` are
|
|
|
|
// related as required.
|
2022-04-19 10:56:18 +00:00
|
|
|
a(x, y, z);
|
2014-12-20 10:48:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn d() {
|
|
|
|
// 'a and 'b are early bound in the function `a` because they appear
|
|
|
|
// inconstraints:
|
2022-04-19 10:56:18 +00:00
|
|
|
let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
|
|
|
//~^ ERROR E0308
|
2014-12-20 10:48:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn e() {
|
|
|
|
// 'a and 'b are late bound in the function `b` because there are
|
|
|
|
// no constraints:
|
2015-01-08 10:54:35 +00:00
|
|
|
let _: fn(&mut &isize, &mut &isize, &mut &isize) = b;
|
2014-12-20 10:48:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|