-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make migrate mode work at item level granularity
- Loading branch information
1 parent
7e001e5
commit a046c38
Showing
7 changed files
with
127 additions
and
25 deletions.
There are no files selected for viewing
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
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
15 changes: 15 additions & 0 deletions
15
src/test/ui/borrowck/issue-58776-borrowck-scans-children.ast.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0597]: `**greeting` does not live long enough | ||
--> $DIR/issue-58776-borrowck-scans-children.rs:10:24 | ||
| | ||
LL | let res = (|| (|| &greeting)())(); | ||
| -- ^^^^^^^^ - borrowed value only lives until here | ||
| | | | ||
| | borrowed value does not live long enough | ||
| capture occurs here | ||
... | ||
LL | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
32 changes: 32 additions & 0 deletions
32
src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
error[E0506]: cannot assign to `greeting` because it is borrowed | ||
--> $DIR/issue-58776-borrowck-scans-children.rs:13:5 | ||
| | ||
LL | let res = (|| (|| &greeting)())(); | ||
| -- -------- borrow occurs due to use in closure | ||
| | | ||
| borrow of `greeting` occurs here | ||
... | ||
LL | greeting = "DEALLOCATED".to_string(); | ||
| ^^^^^^^^ assignment to borrowed `greeting` occurs here | ||
... | ||
LL | println!("thread result: {:?}", res); | ||
| --- borrow later used here | ||
|
||
error[E0505]: cannot move out of `greeting` because it is borrowed | ||
--> $DIR/issue-58776-borrowck-scans-children.rs:16:10 | ||
| | ||
LL | let res = (|| (|| &greeting)())(); | ||
| -- -------- borrow occurs due to use in closure | ||
| | | ||
| borrow of `greeting` occurs here | ||
... | ||
LL | drop(greeting); | ||
| ^^^^^^^^ move out of `greeting` occurs here | ||
... | ||
LL | println!("thread result: {:?}", res); | ||
| --- borrow later used here | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0505, E0506. | ||
For more information about an error, try `rustc --explain E0505`. |
32 changes: 32 additions & 0 deletions
32
src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
error[E0506]: cannot assign to `greeting` because it is borrowed | ||
--> $DIR/issue-58776-borrowck-scans-children.rs:13:5 | ||
| | ||
LL | let res = (|| (|| &greeting)())(); | ||
| -- -------- borrow occurs due to use in closure | ||
| | | ||
| borrow of `greeting` occurs here | ||
... | ||
LL | greeting = "DEALLOCATED".to_string(); | ||
| ^^^^^^^^ assignment to borrowed `greeting` occurs here | ||
... | ||
LL | println!("thread result: {:?}", res); | ||
| --- borrow later used here | ||
|
||
error[E0505]: cannot move out of `greeting` because it is borrowed | ||
--> $DIR/issue-58776-borrowck-scans-children.rs:16:10 | ||
| | ||
LL | let res = (|| (|| &greeting)())(); | ||
| -- -------- borrow occurs due to use in closure | ||
| | | ||
| borrow of `greeting` occurs here | ||
... | ||
LL | drop(greeting); | ||
| ^^^^^^^^ move out of `greeting` occurs here | ||
... | ||
LL | println!("thread result: {:?}", res); | ||
| --- borrow later used here | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0505, E0506. | ||
For more information about an error, try `rustc --explain E0505`. |
21 changes: 21 additions & 0 deletions
21
src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// ignore-compare-mode-nll | ||
|
||
// revisions: ast migrate nll | ||
|
||
//[migrate]compile-flags: -Z borrowck=migrate | ||
#![cfg_attr(nll, feature(nll))] | ||
|
||
fn main() { | ||
let mut greeting = "Hello world!".to_string(); | ||
let res = (|| (|| &greeting)())(); | ||
//[ast]~^ ERROR does not live long enough | ||
|
||
greeting = "DEALLOCATED".to_string(); | ||
//[migrate]~^ ERROR cannot assign | ||
//[nll]~^^ ERROR cannot assign | ||
drop(greeting); | ||
//[migrate]~^ ERROR cannot move | ||
//[nll]~^^ ERROR cannot move | ||
|
||
println!("thread result: {:?}", res); | ||
} |