mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
c9c80d2c5f
The only non-obvious changes: - `building/storage_live_dead_in_statics.rs` has a `#[rustfmt::skip]` attribute to avoid reformating a table of data. - Two `.mir` files have slight changes involving line numbers. - In `unusual_item_types.rs` an `EMIT_MIR` annotation is moved to outside a function, which is the usual spot, because `tidy` complains if such a comment is indented. The commit also tweaks the comments in `rustfmt.toml`.
25 lines
724 B
Rust
25 lines
724 B
Rust
//@ test-mir-pass: SimplifyCfg-pre-optimizations
|
|
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
|
// Retagging (from Stacked Borrows) relies on the array index being a fresh
|
|
// temporary, so that side-effects cannot change it.
|
|
// Test that this is indeed the case.
|
|
|
|
unsafe fn foo(z: *mut usize) -> u32 {
|
|
*z = 2;
|
|
99
|
|
}
|
|
|
|
// EMIT_MIR array_index_is_temporary.main.SimplifyCfg-pre-optimizations.after.mir
|
|
fn main() {
|
|
// CHECK-LABEL: fn main(
|
|
// CHECK: debug x => [[x:_.*]];
|
|
// CHECK: debug y => [[y:_.*]];
|
|
// CHECK: [[y]] = const 1_usize;
|
|
// CHECK: [[tmp:_.*]] = [[y]];
|
|
// CHECK: [[x]][[[tmp]]] =
|
|
let mut x = [42, 43, 44];
|
|
let mut y = 1;
|
|
let z: *mut usize = &mut y;
|
|
x[y] = unsafe { foo(z) };
|
|
}
|