Generalize cases where specific move error ocurrs

Trigger new diagnostic in `compile-fail/regions-escape-bound-fn.rs`
test, and not only in `compile-fail/regions-escape-bound-fn-2.rs`.
This commit is contained in:
Esteban Küber 2018-01-03 15:54:33 -08:00
parent c31c60cbb9
commit 2c5f2df201
6 changed files with 11 additions and 9 deletions

View file

@ -25,7 +25,7 @@ fn expect_bound_supply_nothing() {
// it to escape into `f`:
let mut f: Option<&u32> = None;
closure_expecting_bound(|x| {
f = Some(x); //~ ERROR E0495
f = Some(x); //~ ERROR borrowed data cannot be moved outside of its closure
});
}
@ -35,7 +35,7 @@ fn expect_bound_supply_bound() {
// closure:
let mut f: Option<&u32> = None;
closure_expecting_bound(|x: &u32| {
f = Some(x); //~ ERROR E0495
f = Some(x); //~ ERROR borrowed data cannot be moved outside of its closure
});
}
@ -50,7 +50,7 @@ fn expect_bound_supply_named<'x>() {
// And we still cannot let `x` escape into `f`.
f = Some(x);
//~^ ERROR cannot infer
//~^ ERROR borrowed data cannot be moved outside of its closure
});
}

View file

@ -24,7 +24,8 @@ impl CrateId {
}
pub fn remove_package_from_database() {
let mut lines_to_use: Vec<&CrateId> = Vec::new(); //~ ERROR E0495
let mut lines_to_use: Vec<&CrateId> = Vec::new();
//~^ ERROR borrowed data cannot be moved outside of its closure
let push_id = |installed_id: &CrateId| {
lines_to_use.push(installed_id);
};

View file

@ -16,5 +16,5 @@ fn with_int<F>(f: F) where F: FnOnce(&isize) {
fn main() {
let mut x = None;
with_int(|y| x = Some(y));
//~^ ERROR borrowed data cannot be moved outside of its closure
//~^ ERROR borrowed data cannot be moved outside of its closure
}

View file

@ -15,5 +15,6 @@ fn with_int<F>(f: F) where F: FnOnce(&isize) {
fn main() {
let mut x: Option<&isize> = None;
with_int(|y| x = Some(y)); //~ ERROR cannot infer
with_int(|y| x = Some(y));
//~^ ERROR borrowed data cannot be moved outside of its closure
}

View file

@ -13,5 +13,6 @@ fn with_int(f: &mut FnMut(&isize)) {
fn main() {
let mut x: Option<&isize> = None;
with_int(&mut |y| x = Some(y)); //~ ERROR cannot infer
with_int(&mut |y| x = Some(y));
//~^ ERROR borrowed data cannot be moved outside of its closure
}