forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#97206 - jackh726:issue-73154, r=nikomatsakis
Do leak check after function pointer coercion cc rust-lang#73154 I still need to clean diagnostics just a tad, but figured I would put this up anyways. This change is made in order to make match arm coercion order-independent. Basically, any time we do function pointer coercion, we follow it by doing a leak check. This is necessary because the LUB code doesn't handler higher-ranked things correctly, leading us to "coerce", but use the wrong type. A proper fix is to actually fix that code (so the type returned by `unify_and` is a supertype of both `a` and `b` if `Ok`). However, that requires a more in-depth fix, likely heavily overlapping with the new subtyping changes. Here, I've been conservative and error early if we generate unsatisfiable constraints. Note, this should *mostly* only affect NLL, since migrate mode falls back to the LUB implementation (followed by leak check), whereas NLL only does sub. There could be other coercion code that has an order-dependence where a leak check in the coercion code might be useful. However, this is more of a spot-fix for rust-lang#73154 than a "permanent" fix, since we likely want to go the other way long-term, and allow this pattern without error. r? `@nikomatsakis`
- Loading branch information
Showing
29 changed files
with
268 additions
and
228 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
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
5 changes: 4 additions & 1 deletion
5
...t/ui/lub-glb/old-lub-glb-hr-noteq1.stderr → ...glb/old-lub-glb-hr-noteq1.baseleak.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
21 changes: 21 additions & 0 deletions
21
src/test/ui/lub-glb/old-lub-glb-hr-noteq1.basenoleak.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,21 @@ | ||
error[E0308]: `match` arms have incompatible types | ||
--> $DIR/old-lub-glb-hr-noteq1.rs:17:14 | ||
| | ||
LL | let z = match 22 { | ||
| _____________- | ||
LL | | 0 => x, | ||
| | - this is found to be of type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` | ||
LL | | _ => y, | ||
| | ^ one type is more general than the other | ||
LL | | | ||
... | | ||
LL | | | ||
LL | | }; | ||
| |_____- `match` arms have incompatible types | ||
| | ||
= note: expected fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` | ||
found fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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 @@ | ||
error[E0308]: `match` arms have incompatible types | ||
--> $DIR/old-lub-glb-hr-noteq1.rs:17:14 | ||
| | ||
LL | let z = match 22 { | ||
| _____________- | ||
LL | | 0 => x, | ||
| | - this is found to be of type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` | ||
LL | | _ => y, | ||
| | ^ one type is more general than the other | ||
LL | | | ||
... | | ||
LL | | | ||
LL | | }; | ||
| |_____- `match` arms have incompatible types | ||
| | ||
= note: expected fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` | ||
found fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
2 changes: 1 addition & 1 deletion
2
.../lub-glb/old-lub-glb-hr-noteq1.nll.stderr → ...lb/old-lub-glb-hr-noteq1.nllnoleak.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
Oops, something went wrong.