forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#62736 - lqd:polonius_tests3, r=matthewjasper
Polonius: fix some cases of `killed` fact generation, and most of the `ui` test suite Since basic Polonius functionality was re-enabled by @matthewjasper in rust-lang#54468, some tests were still failing in the polonius compare-mode. This PR fixes all but one test in the `ui` suite by: - fixing some bugs in the fact generation code, related to the `killed` relation: Polonius would incorrectly reject some NLL-accepted code, because of these missing `killed` facts. - ignoring some tests in the polonius compare-mode: a lot of those manually test the NLL or migrate mode, and the failures were mostly artifacts of the test revisions, e.g. that `-Z polonius` requires full NLLs. Some others were also both failing with NLL and succeeding with Polonius, which we can't encode in tests at the moment. - blessing the output of some tests: whenever Polonius and NLL have basically the same errors, except for diagnostics differences, the Polonius output is blessed. Whenever we've advanced into a less experimental phase, we'll want to revisit these cases (much like we did on the NLL test suite last year) to specifically work on diagnostics. Fact generation changes: - we now kill loans on the destination place of `Call` terminators - we now kill loans on the locals destroyed by `StorageDead` - we now also handle assignments to projections: killing the loans on a either a deref-ed local, or the ones whose `borrowed_place` conflicts with the current place. One failing test remains: an overflow during fact generation, on a case of polymorphic recursion (and which I'll continue investigating later). This adds some tests for the fact generation changes, with some simple Polonius cases similar to the existing smoke tests, but also for some cases encountered in the wild (in the `rand` crate for example). A more detailed write-up is available [here](https://hackmd.io/CjYB0fs4Q9CweyeTdKWyEg?view) with an explanation for each test failure, the steps taken to resolve it (as a commit in the current PR), NLL and Polonius outputs (and diff), etc. Since they've worked on this before, and we've discussed some of these failures together: r? @matthewjasper
- Loading branch information
Showing
42 changed files
with
892 additions
and
49 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
16 changes: 16 additions & 0 deletions
16
src/test/ui/borrowck/borrowck-escaping-closure-error-2.polonius.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,16 @@ | ||
error[E0597]: `books` does not live long enough | ||
--> $DIR/borrowck-escaping-closure-error-2.rs:11:17 | ||
| | ||
LL | Box::new(|| books.push(4)) | ||
| ------------^^^^^--------- | ||
| | | | | ||
| | | borrowed value does not live long enough | ||
| | value captured here | ||
| borrow later used here | ||
LL | | ||
LL | } | ||
| - `books` dropped here while still borrowed | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
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
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
59 changes: 59 additions & 0 deletions
59
src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.polonius.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,59 @@ | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:5:21 | ||
| | ||
LL | let ref mut x = 1234543; | ||
| ^^^^^^^ creates a temporary which is freed while still in use | ||
LL | x | ||
| - borrow later used here | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: consider using a `let` binding to create a longer lived value | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:10:25 | ||
| | ||
LL | let (ref mut x, ) = (1234543, ); | ||
| ^^^^^^^^^^^ creates a temporary which is freed while still in use | ||
LL | x | ||
| - borrow later used here | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: consider using a `let` binding to create a longer lived value | ||
|
||
error[E0515]: cannot return value referencing temporary value | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:5 | ||
| | ||
LL | match 1234543 { | ||
| ^ ------- temporary value created here | ||
| _____| | ||
| | | ||
LL | | ref mut x => x | ||
LL | | } | ||
| |_____^ returns a value referencing data owned by the current function | ||
|
||
error[E0515]: cannot return value referencing temporary value | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:21:5 | ||
| | ||
LL | match (123443,) { | ||
| ^ --------- temporary value created here | ||
| _____| | ||
| | | ||
LL | | (ref mut x,) => x, | ||
LL | | } | ||
| |_____^ returns a value referencing data owned by the current function | ||
|
||
error[E0515]: cannot return reference to temporary value | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:27:5 | ||
| | ||
LL | &mut 1234543 | ||
| ^^^^^------- | ||
| | | | ||
| | temporary value created here | ||
| returns a reference to data owned by the current function | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
Some errors have detailed explanations: E0515, E0716. | ||
For more information about an error, try `rustc --explain E0515`. |
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
Oops, something went wrong.