2014-11-15 18:10:22 -06:00
|
|
|
// Test that the `'a` in the where clause correctly links the region
|
|
|
|
// of the output to the region of the input.
|
|
|
|
|
|
|
|
trait FnLike<A,R> {
|
|
|
|
fn call(&self, arg: A) -> R;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn call_repeatedly<F>(f: F)
|
2015-01-08 04:54:35 -06:00
|
|
|
where F : for<'a> FnLike<&'a isize, &'a isize>
|
2014-11-15 18:10:22 -06:00
|
|
|
{
|
|
|
|
// Result is stored: cannot re-assign `x`
|
|
|
|
let mut x = 3;
|
|
|
|
let y = f.call(&x);
|
2019-04-22 02:40:08 -05:00
|
|
|
x = 5; //~ ERROR cannot assign to `x` because it is borrowed
|
2014-11-15 18:10:22 -06:00
|
|
|
|
|
|
|
// Result is not stored: can re-assign `x`
|
|
|
|
let mut x = 3;
|
|
|
|
f.call(&x);
|
|
|
|
f.call(&x);
|
|
|
|
f.call(&x);
|
|
|
|
x = 5;
|
2018-04-09 04:28:00 -05:00
|
|
|
drop(y);
|
2014-11-15 18:10:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|