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:
Pietro Albini 2018-11-11 00:21:14 +01:00 committed by GitHub
commit e121305abd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 8 deletions

View file

@ -0,0 +1,3 @@
fn main() {
[0; 3][3u64 as usize]; //~ ERROR the len is 3 but the index is 3
}

View 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

View 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
}

View 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