Skip to content

Commit f9f3063

Browse files
committed
Update tests
1 parent 3d8a073 commit f9f3063

File tree

50 files changed

+462
-883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+462
-883
lines changed

src/test/ui/borrowck/issue-45983.migrate.stderr

-12
This file was deleted.

src/test/ui/borrowck/issue-45983.nll.stderr

-21
This file was deleted.

src/test/ui/borrowck/issue-45983.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
// As documented in Issue #45983, this test is evaluating the quality
22
// of our diagnostics on erroneous code using higher-ranked closures.
33

4-
// revisions: migrate nll
5-
6-
// Since we are testing nll (and migration) explicitly as a separate
7-
// revisions, don't worry about the --compare-mode=nll on this test.
8-
9-
// ignore-compare-mode-nll
10-
// ignore-compare-mode-polonius
11-
12-
//[nll]compile-flags: -Z borrowck=mir
13-
144
fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) {
155
f(&());
166
}
177

188
fn main() {
19-
let x = None;
9+
let mut x = None;
2010
give_any(|y| x = Some(y));
21-
//[migrate]~^ ERROR borrowed data cannot be stored outside of its closure
22-
//[nll]~^^ ERROR borrowed data escapes outside of closure
23-
//[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable
11+
//~^ ERROR borrowed data escapes outside of closure
2412
}

src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr renamed to src/test/ui/borrowck/issue-45983.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
error[E0521]: borrowed data escapes outside of closure
2-
--> $DIR/regions-escape-bound-fn-2.rs:8:18
2+
--> $DIR/issue-45983.rs:10:18
33
|
44
LL | let mut x = None;
55
| ----- `x` declared here, outside of the closure body
6-
LL | with_int(|y| x = Some(y));
6+
LL | give_any(|y| x = Some(y));
77
| - ^^^^^^^^^^^ `y` escapes the closure body here
88
| |
99
| `y` is a reference that is only valid in the closure body

src/test/ui/borrowck/issue-7573.nll.stderr

-14
This file was deleted.

src/test/ui/borrowck/issue-7573.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
pub struct CrateId {
22
local_path: String,
3-
junk: String
3+
junk: String,
44
}
55

66
impl CrateId {
77
fn new(s: &str) -> CrateId {
8-
CrateId {
9-
local_path: s.to_string(),
10-
junk: "wutevs".to_string()
11-
}
8+
CrateId { local_path: s.to_string(), junk: "wutevs".to_string() }
129
}
1310
}
1411

1512
pub fn remove_package_from_database() {
1613
let mut lines_to_use: Vec<&CrateId> = Vec::new();
17-
//~^ NOTE cannot infer an appropriate lifetime
14+
//~^ NOTE `lines_to_use` declared here, outside of the closure body
1815
let push_id = |installed_id: &CrateId| {
19-
//~^ NOTE borrowed data cannot outlive this closure
20-
//~| NOTE ...so that variable is valid at time of its declaration
16+
//~^ NOTE `installed_id` is a reference that is only valid in the closure body
2117
lines_to_use.push(installed_id);
22-
//~^ ERROR borrowed data cannot be stored outside of its closure
23-
//~| NOTE cannot be stored outside of its closure
18+
//~^ ERROR borrowed data escapes outside of closure
19+
//~| NOTE `installed_id` escapes the closure body here
2420
};
2521
list_database(push_id);
2622

2723
for l in &lines_to_use {
2824
println!("{}", l.local_path);
2925
}
30-
3126
}
3227

33-
pub fn list_database<F>(mut f: F) where F: FnMut(&CrateId) {
28+
pub fn list_database<F>(mut f: F)
29+
where
30+
F: FnMut(&CrateId),
31+
{
3432
let stuff = ["foo", "bar"];
3533

3634
for l in &stuff {
+6-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
error: borrowed data cannot be stored outside of its closure
2-
--> $DIR/issue-7573.rs:21:27
1+
error[E0521]: borrowed data escapes outside of closure
2+
--> $DIR/issue-7573.rs:17:9
33
|
44
LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
5-
| - cannot infer an appropriate lifetime...
5+
| ---------------- `lines_to_use` declared here, outside of the closure body
66
LL |
77
LL | let push_id = |installed_id: &CrateId| {
8-
| ------- ------------------------ borrowed data cannot outlive this closure
9-
| |
10-
| ...so that variable is valid at time of its declaration
11-
...
8+
| ------------ `installed_id` is a reference that is only valid in the closure body
9+
LL |
1210
LL | lines_to_use.push(installed_id);
13-
| ^^^^^^^^^^^^ cannot be stored outside of its closure
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here
1412

1513
error: aborting due to previous error
1614

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
fn with_int<F>(f: F) where F: FnOnce(&isize) {
1+
fn with_int<F>(f: F)
2+
where
3+
F: FnOnce(&isize),
4+
{
25
let x = 3;
36
f(&x);
47
}
58

69
fn main() {
710
let mut x = None;
811
with_int(|y| x = Some(y));
9-
//~^ ERROR borrowed data cannot be stored outside of its closure
12+
//~^ ERROR borrowed data escapes outside of closure
1013
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error: borrowed data cannot be stored outside of its closure
2-
--> $DIR/regions-escape-bound-fn-2.rs:8:27
1+
error[E0521]: borrowed data escapes outside of closure
2+
--> $DIR/regions-escape-bound-fn-2.rs:11:18
33
|
44
LL | let mut x = None;
5-
| ----- borrowed data cannot be stored into here...
5+
| ----- `x` declared here, outside of the closure body
66
LL | with_int(|y| x = Some(y));
7-
| --- ^ cannot be stored outside of its closure
8-
| |
9-
| ...because it cannot outlive this closure
7+
| - ^^^^^^^^^^^ `y` escapes the closure body here
8+
| |
9+
| `y` is a reference that is only valid in the closure body
1010

1111
error: aborting due to previous error
1212

src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
fn with_int<F>(f: F) where F: FnOnce(&isize) {
1+
fn with_int<F>(f: F)
2+
where
3+
F: FnOnce(&isize),
4+
{
25
let x = 3;
36
f(&x);
47
}
58

69
fn main() {
710
let mut x: Option<&isize> = None;
811
with_int(|y| x = Some(y));
9-
//~^ ERROR borrowed data cannot be stored outside of its closure
12+
//~^ ERROR borrowed data escapes outside of closure
1013
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error: borrowed data cannot be stored outside of its closure
2-
--> $DIR/regions-escape-bound-fn.rs:8:27
1+
error[E0521]: borrowed data escapes outside of closure
2+
--> $DIR/regions-escape-bound-fn.rs:11:18
33
|
44
LL | let mut x: Option<&isize> = None;
5-
| ----- borrowed data cannot be stored into here...
5+
| ----- `x` declared here, outside of the closure body
66
LL | with_int(|y| x = Some(y));
7-
| --- ^ cannot be stored outside of its closure
8-
| |
9-
| ...because it cannot outlive this closure
7+
| - ^^^^^^^^^^^ `y` escapes the closure body here
8+
| |
9+
| `y` is a reference that is only valid in the closure body
1010

1111
error: aborting due to previous error
1212

src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
fn with_int(f: &mut dyn FnMut(&isize)) {
2-
}
1+
fn with_int(f: &mut dyn FnMut(&isize)) {}
32

43
fn main() {
54
let mut x: Option<&isize> = None;
65
with_int(&mut |y| x = Some(y));
7-
//~^ ERROR borrowed data cannot be stored outside of its closure
6+
//~^ ERROR borrowed data escapes outside of closure
87
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error: borrowed data cannot be stored outside of its closure
2-
--> $DIR/regions-escape-unboxed-closure.rs:6:32
1+
error[E0521]: borrowed data escapes outside of closure
2+
--> $DIR/regions-escape-unboxed-closure.rs:5:23
33
|
44
LL | let mut x: Option<&isize> = None;
5-
| ----- borrowed data cannot be stored into here...
5+
| ----- `x` declared here, outside of the closure body
66
LL | with_int(&mut |y| x = Some(y));
7-
| --- ^ cannot be stored outside of its closure
8-
| |
9-
| ...because it cannot outlive this closure
7+
| - ^^^^^^^^^^^ `y` escapes the closure body here
8+
| |
9+
| `y` is a reference that is only valid in the closure body
1010

1111
error: aborting due to previous error
1212

0 commit comments

Comments
 (0)