Skip to content

Commit 2c5f2df

Browse files
committed
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`.
1 parent c31c60c commit 2c5f2df

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10711071
// #45983: when trying to assign the contents of an argument to a binding outside of a
10721072
// closure, provide a specific message pointing this out.
10731073
if let (&SubregionOrigin::BindingTypeIsNotValidAtDecl(ref external_span),
1074-
&SubregionOrigin::Subtype(_),
1075-
&RegionKind::ReFree(ref free_region)) = (&sub_origin, &sup_origin, sup_region) {
1074+
&RegionKind::ReFree(ref free_region)) = (&sub_origin, sup_region) {
10761075
let hir = &self.tcx.hir;
10771076
if let Some(node_id) = hir.as_local_node_id(free_region.scope) {
10781077
match hir.get(node_id) {

src/test/compile-fail/closure-expected-type/expect-region-supply-region.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn expect_bound_supply_nothing() {
2525
// it to escape into `f`:
2626
let mut f: Option<&u32> = None;
2727
closure_expecting_bound(|x| {
28-
f = Some(x); //~ ERROR E0495
28+
f = Some(x); //~ ERROR borrowed data cannot be moved outside of its closure
2929
});
3030
}
3131

@@ -35,7 +35,7 @@ fn expect_bound_supply_bound() {
3535
// closure:
3636
let mut f: Option<&u32> = None;
3737
closure_expecting_bound(|x: &u32| {
38-
f = Some(x); //~ ERROR E0495
38+
f = Some(x); //~ ERROR borrowed data cannot be moved outside of its closure
3939
});
4040
}
4141

@@ -50,7 +50,7 @@ fn expect_bound_supply_named<'x>() {
5050

5151
// And we still cannot let `x` escape into `f`.
5252
f = Some(x);
53-
//~^ ERROR cannot infer
53+
//~^ ERROR borrowed data cannot be moved outside of its closure
5454
});
5555
}
5656

src/test/compile-fail/issue-7573.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ impl CrateId {
2424
}
2525

2626
pub fn remove_package_from_database() {
27-
let mut lines_to_use: Vec<&CrateId> = Vec::new(); //~ ERROR E0495
27+
let mut lines_to_use: Vec<&CrateId> = Vec::new();
28+
//~^ ERROR borrowed data cannot be moved outside of its closure
2829
let push_id = |installed_id: &CrateId| {
2930
lines_to_use.push(installed_id);
3031
};

src/test/compile-fail/regions-escape-bound-fn-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ fn with_int<F>(f: F) where F: FnOnce(&isize) {
1616
fn main() {
1717
let mut x = None;
1818
with_int(|y| x = Some(y));
19-
//~^ ERROR borrowed data cannot be moved outside of its closure
19+
//~^ ERROR borrowed data cannot be moved outside of its closure
2020
}

src/test/compile-fail/regions-escape-bound-fn.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ fn with_int<F>(f: F) where F: FnOnce(&isize) {
1515

1616
fn main() {
1717
let mut x: Option<&isize> = None;
18-
with_int(|y| x = Some(y)); //~ ERROR cannot infer
18+
with_int(|y| x = Some(y));
19+
//~^ ERROR borrowed data cannot be moved outside of its closure
1920
}

src/test/compile-fail/regions-escape-unboxed-closure.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ fn with_int(f: &mut FnMut(&isize)) {
1313

1414
fn main() {
1515
let mut x: Option<&isize> = None;
16-
with_int(&mut |y| x = Some(y)); //~ ERROR cannot infer
16+
with_int(&mut |y| x = Some(y));
17+
//~^ ERROR borrowed data cannot be moved outside of its closure
1718
}

0 commit comments

Comments
 (0)