about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorKyle Huey <khuey@kylehuey.com>2025-03-21 17:34:45 -0700
committerKyle Huey <khuey@kylehuey.com>2025-03-21 17:34:45 -0700
commit8cab8e07bc94fb2fea8e1421d2d2e6de6398b69b (patch)
treed803c5598011e09f9d6b6f99c618e99947e9e633 /tests/codegen
parent01dc45c10e814c25207995a577359e3f137e78ae (diff)
downloadrust-8cab8e07bc94fb2fea8e1421d2d2e6de6398b69b.tar.gz
rust-8cab8e07bc94fb2fea8e1421d2d2e6de6398b69b.zip
Don't produce debug information for compiler-introduced-vars when desugaring assignments.
An assignment such as

(a, b) = (b, c);

desugars to the HIR

{ let (lhs, lhs) = (b, c); a = lhs; b = lhs; };

The repeated `lhs` leads to multiple Locals assigned to the same DILocalVariable. Rather than
attempting to fix that, get rid of the debug info for these bindings that don't even exist
in the program to begin with.

Fixes #138198
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/assign-desugar-debuginfo.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/codegen/assign-desugar-debuginfo.rs b/tests/codegen/assign-desugar-debuginfo.rs
new file mode 100644
index 00000000000..77ee8758b3b
--- /dev/null
+++ b/tests/codegen/assign-desugar-debuginfo.rs
@@ -0,0 +1,18 @@
+//@ compile-flags: -g -Zmir-opt-level=0
+
+#![crate_type = "lib"]
+
+#[inline(never)]
+fn swizzle(a: u32, b: u32, c: u32) -> (u32, (u32, u32)) {
+    (b, (c, a))
+}
+
+pub fn work() {
+    let mut a = 1;
+    let mut b = 2;
+    let mut c = 3;
+    (a, (b, c)) = swizzle(a, b, c);
+    println!("{a} {b} {c}");
+}
+
+// CHECK-NOT: !DILocalVariable(name: "lhs",