2015-01-08 10:54:35 +00:00
|
|
|
fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a {
|
2014-12-20 10:29:19 +00:00
|
|
|
// Note: this is legal because of the `'b:'a` declaration.
|
|
|
|
*x = *y;
|
|
|
|
}
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
|
2014-12-20 10:29:19 +00:00
|
|
|
// Illegal now because there is no `'b:'a` declaration.
|
2022-04-19 10:56:18 +00:00
|
|
|
*x = *y;
|
2014-12-20 10:29:19 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
|
2014-12-20 10:29:19 +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);
|
2014-12-20 10:29:19 +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) = a;
|
|
|
|
//~^ ERROR mismatched types [E0308]
|
2014-12-20 10:29:19 +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) = b;
|
2014-12-20 10:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|