Rollup merge of #55792 - oli-obk:propsicle, r=RalfJung
Prevent ICE in const-prop array oob check fixes https://github.com/rust-lang/rust/issues/55772 fixes https://github.com/rust-lang/rust/issues/54541
This commit is contained in:
commit
e121305abd
5 changed files with 36 additions and 8 deletions
3
src/test/ui/consts/const-prop-ice.rs
Normal file
3
src/test/ui/consts/const-prop-ice.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
[0; 3][3u64 as usize]; //~ ERROR the len is 3 but the index is 3
|
||||
}
|
||||
10
src/test/ui/consts/const-prop-ice.stderr
Normal file
10
src/test/ui/consts/const-prop-ice.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: index out of bounds: the len is 3 but the index is 3
|
||||
--> $DIR/const-prop-ice.rs:2:5
|
||||
|
|
||||
LL | [0; 3][3u64 as usize]; //~ ERROR the len is 3 but the index is 3
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
5
src/test/ui/consts/const-prop-ice2.rs
Normal file
5
src/test/ui/consts/const-prop-ice2.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
enum Enum { One=1 }
|
||||
let xs=[0;1 as usize];
|
||||
println!("{}", xs[Enum::One as usize]); //~ ERROR the len is 1 but the index is 1
|
||||
}
|
||||
10
src/test/ui/consts/const-prop-ice2.stderr
Normal file
10
src/test/ui/consts/const-prop-ice2.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: index out of bounds: the len is 1 but the index is 1
|
||||
--> $DIR/const-prop-ice2.rs:4:20
|
||||
|
|
||||
LL | println!("{}", xs[Enum::One as usize]); //~ ERROR the len is 1 but the index is 1
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue