1
Fork 0

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
This commit is contained in:
Kyle Huey 2025-03-21 17:34:45 -07:00
parent 01dc45c10e
commit 8cab8e07bc
2 changed files with 60 additions and 16 deletions

View file

@ -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",