about summary refs log tree commit diff
path: root/src/test/debuginfo
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-06-20 03:08:52 +0000
committerbors <bors@rust-lang.org>2022-06-20 03:08:52 +0000
commit9a0b7749665d925d8f533756149deba74f2db88b (patch)
treeeffe31dc7f7f37ef61ecd17ebc5ea0339470ee9a /src/test/debuginfo
parent17c6bde14eabdd61c35505ed6834ee9196c2fdc9 (diff)
parenta434e4c8f1a97482118f2b0ef833dc3e93bc5103 (diff)
Auto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisa
Fix `SourceScope` for `if let` bindings.

Fixes #97799.

I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from `ui` tests? I'm worried that they would be overlooked in the case of a regression.
Diffstat (limited to 'src/test/debuginfo')
-rw-r--r--src/test/debuginfo/lexical-scope-in-if-let.rs100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/test/debuginfo/lexical-scope-in-if-let.rs b/src/test/debuginfo/lexical-scope-in-if-let.rs
new file mode 100644
index 00000000000..cdc37ce48fb
--- /dev/null
+++ b/src/test/debuginfo/lexical-scope-in-if-let.rs
@@ -0,0 +1,100 @@
+// compile-flags:-g
+
+// === GDB TESTS ==================================================================================
+
+// gdb-command:run
+// gdb-command:info locals
+// gdb-check:a = 123
+
+// gdb-command:continue
+// gdb-command:info locals
+// gdb-check:x = 42
+// gdb-check:a = 123
+
+// gdb-command:continue
+// gdb-command:info locals
+// gdb-check:y = true
+// gdb-check:b = 456
+// gdb-check:x = 42
+// gdb-check:a = 123
+
+// gdb-command:continue
+// gdb-command:info locals
+// gdb-check:z = 10
+// gdb-check:c = 789
+// gdb-check:y = true
+// gdb-check:b = 456
+// gdb-check:x = 42
+// gdb-check:a = 123
+
+// === LLDB TESTS =================================================================================
+
+// lldb-command:run
+// lldb-command:frame variable
+// lldb-check:(int) a = 123
+
+// lldb-command:continue
+// lldb-command:frame variable
+// lldb-check:(int) a = 123 (int) x = 42
+
+// lldb-command:continue
+// lldb-command:frame variable
+// lldb-check:(int) a = 123 (int) x = 42 (int) b = 456 (bool) y = true
+
+// lldb-command:continue
+// lldb-command:frame variable
+// lldb-check:(int) a = 123 (int) x = 42 (int) b = 456 (bool) y = true (int) c = 789 (int) z = 10
+
+// === CDB TESTS ==================================================================================
+
+// cdb-command: g
+// cdb-command: dv
+// cdb-check:[...]a = 0n123
+
+// cdb-command: g
+// cdb-command: dv
+// cdb-check:[...]a = 0n123
+// cdb-check:[...]x = 0n42
+
+// cdb-command: g
+// cdb-command: dv
+// cdb-check:[...]y = true
+// cdb-check:[...]b = 0n456
+// cdb-check:[...]a = 0n123
+// cdb-check:[...]x = 0n42
+
+// cdb-command: g
+// cdb-command: dv
+// cdb-check:[...]z = 0n10
+// cdb-check:[...]c = 0n789
+// cdb-check:[...]y = true
+// cdb-check:[...]b = 0n456
+// cdb-check:[...]a = 0n123
+// cdb-check:[...]x = 0n42
+
+fn main() {
+    let a = id(123);
+
+    zzz(); // #break
+
+    if let Some(x) = id(Some(42)) {
+        zzz(); // #break
+
+        let b = id(456);
+
+        if let Ok(y) = id::<Result<bool, ()>>(Ok(true)) {
+            zzz(); // #break
+
+            let c = id(789);
+
+            if let (z, 42) = id((10, 42)) {
+                zzz(); // #break
+            }
+        }
+    }
+}
+
+#[inline(never)]
+fn id<T>(value: T) -> T { value }
+
+fn zzz() { }