Rollup merge of #73613 - oli-obk:const_prop_miscompile, r=wesleywiser

The const propagator cannot trace references.

Thus we avoid propagation of a local the moment we encounter references to it.

fixes #73609

cc @RalfJung

r? @wesleywiser
This commit is contained in:
Manish Goregaokar 2020-06-23 13:10:13 -07:00 committed by GitHub
commit d8b4604f41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 204 additions and 56 deletions

View file

@ -19,6 +19,6 @@ fn mod_by_zero() {
fn oob_error_for_slices() {
let a: *const [_] = &[1, 2, 3];
unsafe {
let _b = (*a)[3]; //~ ERROR this operation will panic at runtime [unconditional_panic]
let _b = (*a)[3];
}
}

View file

@ -12,11 +12,5 @@ error: this operation will panic at runtime
LL | let _z = 1 % y;
| ^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/mir_detects_invalid_ops.rs:22:18
|
LL | let _b = (*a)[3];
| ^^^^^^^ index out of bounds: the len is 3 but the index is 3
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors