Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed May 22, 2020
1 parent 3d8a073 commit f9f3063
Show file tree
Hide file tree
Showing 50 changed files with 462 additions and 883 deletions.
12 changes: 0 additions & 12 deletions src/test/ui/borrowck/issue-45983.migrate.stderr

This file was deleted.

21 changes: 0 additions & 21 deletions src/test/ui/borrowck/issue-45983.nll.stderr

This file was deleted.

16 changes: 2 additions & 14 deletions src/test/ui/borrowck/issue-45983.rs
@@ -1,24 +1,12 @@
// As documented in Issue #45983, this test is evaluating the quality
// of our diagnostics on erroneous code using higher-ranked closures.

// revisions: migrate nll

// Since we are testing nll (and migration) explicitly as a separate
// revisions, don't worry about the --compare-mode=nll on this test.

// ignore-compare-mode-nll
// ignore-compare-mode-polonius

//[nll]compile-flags: -Z borrowck=mir

fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) {
f(&());
}

fn main() {
let x = None;
let mut x = None;
give_any(|y| x = Some(y));
//[migrate]~^ ERROR borrowed data cannot be stored outside of its closure
//[nll]~^^ ERROR borrowed data escapes outside of closure
//[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable
//~^ ERROR borrowed data escapes outside of closure
}
@@ -1,9 +1,9 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn-2.rs:8:18
--> $DIR/issue-45983.rs:10:18
|
LL | let mut x = None;
| ----- `x` declared here, outside of the closure body
LL | with_int(|y| x = Some(y));
LL | give_any(|y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
Expand Down
14 changes: 0 additions & 14 deletions src/test/ui/borrowck/issue-7573.nll.stderr

This file was deleted.

22 changes: 10 additions & 12 deletions src/test/ui/borrowck/issue-7573.rs
@@ -1,36 +1,34 @@
pub struct CrateId {
local_path: String,
junk: String
junk: String,
}

impl CrateId {
fn new(s: &str) -> CrateId {
CrateId {
local_path: s.to_string(),
junk: "wutevs".to_string()
}
CrateId { local_path: s.to_string(), junk: "wutevs".to_string() }
}
}

pub fn remove_package_from_database() {
let mut lines_to_use: Vec<&CrateId> = Vec::new();
//~^ NOTE cannot infer an appropriate lifetime
//~^ NOTE `lines_to_use` declared here, outside of the closure body
let push_id = |installed_id: &CrateId| {
//~^ NOTE borrowed data cannot outlive this closure
//~| NOTE ...so that variable is valid at time of its declaration
//~^ NOTE `installed_id` is a reference that is only valid in the closure body
lines_to_use.push(installed_id);
//~^ ERROR borrowed data cannot be stored outside of its closure
//~| NOTE cannot be stored outside of its closure
//~^ ERROR borrowed data escapes outside of closure
//~| NOTE `installed_id` escapes the closure body here
};
list_database(push_id);

for l in &lines_to_use {
println!("{}", l.local_path);
}

}

pub fn list_database<F>(mut f: F) where F: FnMut(&CrateId) {
pub fn list_database<F>(mut f: F)
where
F: FnMut(&CrateId),
{
let stuff = ["foo", "bar"];

for l in &stuff {
Expand Down
14 changes: 6 additions & 8 deletions src/test/ui/borrowck/issue-7573.stderr
@@ -1,16 +1,14 @@
error: borrowed data cannot be stored outside of its closure
--> $DIR/issue-7573.rs:21:27
error[E0521]: borrowed data escapes outside of closure
--> $DIR/issue-7573.rs:17:9
|
LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
| - cannot infer an appropriate lifetime...
| ---------------- `lines_to_use` declared here, outside of the closure body
LL |
LL | let push_id = |installed_id: &CrateId| {
| ------- ------------------------ borrowed data cannot outlive this closure
| |
| ...so that variable is valid at time of its declaration
...
| ------------ `installed_id` is a reference that is only valid in the closure body
LL |
LL | lines_to_use.push(installed_id);
| ^^^^^^^^^^^^ cannot be stored outside of its closure
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here

error: aborting due to previous error

7 changes: 5 additions & 2 deletions src/test/ui/borrowck/regions-escape-bound-fn-2.rs
@@ -1,10 +1,13 @@
fn with_int<F>(f: F) where F: FnOnce(&isize) {
fn with_int<F>(f: F)
where
F: FnOnce(&isize),
{
let x = 3;
f(&x);
}

fn main() {
let mut x = None;
with_int(|y| x = Some(y));
//~^ ERROR borrowed data cannot be stored outside of its closure
//~^ ERROR borrowed data escapes outside of closure
}
12 changes: 6 additions & 6 deletions src/test/ui/borrowck/regions-escape-bound-fn-2.stderr
@@ -1,12 +1,12 @@
error: borrowed data cannot be stored outside of its closure
--> $DIR/regions-escape-bound-fn-2.rs:8:27
error[E0521]: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn-2.rs:11:18
|
LL | let mut x = None;
| ----- borrowed data cannot be stored into here...
| ----- `x` declared here, outside of the closure body
LL | with_int(|y| x = Some(y));
| --- ^ cannot be stored outside of its closure
| |
| ...because it cannot outlive this closure
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body

error: aborting due to previous error

12 changes: 0 additions & 12 deletions src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr

This file was deleted.

7 changes: 5 additions & 2 deletions src/test/ui/borrowck/regions-escape-bound-fn.rs
@@ -1,10 +1,13 @@
fn with_int<F>(f: F) where F: FnOnce(&isize) {
fn with_int<F>(f: F)
where
F: FnOnce(&isize),
{
let x = 3;
f(&x);
}

fn main() {
let mut x: Option<&isize> = None;
with_int(|y| x = Some(y));
//~^ ERROR borrowed data cannot be stored outside of its closure
//~^ ERROR borrowed data escapes outside of closure
}
12 changes: 6 additions & 6 deletions src/test/ui/borrowck/regions-escape-bound-fn.stderr
@@ -1,12 +1,12 @@
error: borrowed data cannot be stored outside of its closure
--> $DIR/regions-escape-bound-fn.rs:8:27
error[E0521]: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn.rs:11:18
|
LL | let mut x: Option<&isize> = None;
| ----- borrowed data cannot be stored into here...
| ----- `x` declared here, outside of the closure body
LL | with_int(|y| x = Some(y));
| --- ^ cannot be stored outside of its closure
| |
| ...because it cannot outlive this closure
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body

error: aborting due to previous error

12 changes: 0 additions & 12 deletions src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr

This file was deleted.

5 changes: 2 additions & 3 deletions src/test/ui/borrowck/regions-escape-unboxed-closure.rs
@@ -1,8 +1,7 @@
fn with_int(f: &mut dyn FnMut(&isize)) {
}
fn with_int(f: &mut dyn FnMut(&isize)) {}

fn main() {
let mut x: Option<&isize> = None;
with_int(&mut |y| x = Some(y));
//~^ ERROR borrowed data cannot be stored outside of its closure
//~^ ERROR borrowed data escapes outside of closure
}
12 changes: 6 additions & 6 deletions src/test/ui/borrowck/regions-escape-unboxed-closure.stderr
@@ -1,12 +1,12 @@
error: borrowed data cannot be stored outside of its closure
--> $DIR/regions-escape-unboxed-closure.rs:6:32
error[E0521]: borrowed data escapes outside of closure
--> $DIR/regions-escape-unboxed-closure.rs:5:23
|
LL | let mut x: Option<&isize> = None;
| ----- borrowed data cannot be stored into here...
| ----- `x` declared here, outside of the closure body
LL | with_int(&mut |y| x = Some(y));
| --- ^ cannot be stored outside of its closure
| |
| ...because it cannot outlive this closure
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body

error: aborting due to previous error

0 comments on commit f9f3063

Please sign in to comment.