The const propagator cannot trace references.
Thus we avoid propagation of a local the moment we encounter references to it.
This commit is contained in:
parent
1a4e2b6f9c
commit
5fa8b08808
8 changed files with 204 additions and 56 deletions
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue