-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not panic in
ty::consts::Const::try_to_target_usize()
in case of…
… size mismatch Fixes an ICE when we try to relate an array size of type u8 to usize
- Loading branch information
Showing
4 changed files
with
37 additions
and
10 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 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Regression test for ICE #126359 | ||
|
||
// Tests that there is no ICE when the generic const | ||
// specifying the size of an array is of a non-usize type | ||
|
||
struct OppOrder<const N: u8 = 3, T = u32> { | ||
arr: [T; N], // Array size is u8 instead of usize | ||
//~^ ERROR mismatched types | ||
} | ||
|
||
fn main() { | ||
let _ = OppOrder::<3, u32> { arr: [0, 0, 0] }; | ||
//~^ ERROR mismatched types | ||
} |
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,18 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/ice-const-size-relate-126359.rs:12:39 | ||
| | ||
LL | let _ = OppOrder::<3, u32> { arr: [0, 0, 0] }; | ||
| ^^^^^^^^^ expected `3`, found `3` | ||
| | ||
= note: expected array `[u32; 3]` | ||
found array `[u32; 3]` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/ice-const-size-relate-126359.rs:7:14 | ||
| | ||
LL | arr: [T; N], // Array size is u8 instead of usize | ||
| ^ expected `usize`, found `u8` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |