about summary refs log tree commit diff
path: root/tests/mir-opt/reference_prop.rs
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-05-10 18:27:54 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-05-13 10:14:38 +0000
commit25ef27759442b84c90af08dba348611b04d10654 (patch)
tree23b5f4658b73e64378a934258e8a111d34990dc3 /tests/mir-opt/reference_prop.rs
parentccef802163ddc560a107371f256b1cbd82abeb00 (diff)
downloadrust-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.rs22
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