-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d8a073
commit f9f3063
Showing
50 changed files
with
462 additions
and
883 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
4 changes: 2 additions & 2 deletions
4
...owck/regions-escape-bound-fn-2.nll.stderr → src/test/ui/borrowck/issue-45983.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
12
src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
Oops, something went wrong.