diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-05-10 18:27:54 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-05-13 10:14:38 +0000 |
| commit | 25ef27759442b84c90af08dba348611b04d10654 (patch) | |
| tree | 23b5f4658b73e64378a934258e8a111d34990dc3 /tests/mir-opt/reference_prop.rs | |
| parent | ccef802163ddc560a107371f256b1cbd82abeb00 (diff) | |
| download | rust-25ef27759442b84c90af08dba348611b04d10654.tar.gz rust-25ef27759442b84c90af08dba348611b04d10654.zip | |
Add mir-opt test.
Diffstat (limited to 'tests/mir-opt/reference_prop.rs')
| -rw-r--r-- | tests/mir-opt/reference_prop.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/mir-opt/reference_prop.rs b/tests/mir-opt/reference_prop.rs index 6301ee839e9..207658860d2 100644 --- a/tests/mir-opt/reference_prop.rs +++ b/tests/mir-opt/reference_prop.rs @@ -456,6 +456,26 @@ fn unique_with_copies() { unsafe { opaque(*y) }; } +fn debuginfo() { + struct T(u8); + + let ref_mut_u8 = &mut 5_u8; + let field = &T(0).0; + + // Verify that we don't emit `&*` in debuginfo. + let reborrow = &*ref_mut_u8; + + match Some(0) { + None => {} + Some(ref variant_field) => {} + } + + // `constant_index_from_end` and `subslice` should not be promoted, as their value depends + // on the slice length. + if let [_, ref constant_index, subslice @ .., ref constant_index_from_end] = &[6; 10][..] { + } +} + fn main() { let mut x = 5_usize; let mut y = 7_usize; @@ -469,6 +489,7 @@ fn main() { maybe_dead(true); mut_raw_then_mut_shr(); unique_with_copies(); + debuginfo(); } // EMIT_MIR reference_prop.reference_propagation.ReferencePropagation.diff @@ -481,3 +502,4 @@ fn main() { // EMIT_MIR reference_prop.maybe_dead.ReferencePropagation.diff // EMIT_MIR reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff // EMIT_MIR reference_prop.unique_with_copies.ReferencePropagation.diff +// EMIT_MIR reference_prop.debuginfo.ReferencePropagation.diff |
