-
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.
Auto merge of #69330 - Centril:literally-melting-ice, r=eddyb
`lit_to_const`: gracefully bubble up type errors. Fixes #69310 which was injected by #68118. r? @pnkfelix @varkor @eddyb cc @Skinny121
- Loading branch information
Showing
7 changed files
with
56 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This is a regression test for #69310, which was injected by #68118. | ||
// The issue here was that as a performance optimization, | ||
// we call the query `lit_to_const(input);`. | ||
// However, the literal `input.lit` would not be of the type expected by `input.ty`. | ||
// As a result, we immediately called `bug!(...)` instead of bubbling up the problem | ||
// so that it could be handled by the caller of `lit_to_const` (`ast_const_to_const`). | ||
|
||
fn main() {} | ||
|
||
const A: [(); 0.1] = [()]; //~ ERROR mismatched types | ||
const B: [(); b"a"] = [()]; //~ ERROR mismatched types |
15 changes: 15 additions & 0 deletions
15
src/test/ui/consts/issue-69310-array-size-lit-wrong-ty.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[E0308]: mismatched types | ||
--> $DIR/issue-69310-array-size-lit-wrong-ty.rs:10:15 | ||
| | ||
LL | const A: [(); 0.1] = [()]; | ||
| ^^^ expected `usize`, found floating-point number | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-69310-array-size-lit-wrong-ty.rs:11:15 | ||
| | ||
LL | const B: [(); b"a"] = [()]; | ||
| ^^^^ expected `usize`, found `&[u8; 1]` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |