about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-08-26 15:40:29 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-08-26 16:54:28 +0000
commit930b2e72eeabf4cacf59d07999fac565836d05bd (patch)
tree4683351a1efe16973668aca90e2320f7f8710ec0 /compiler/rustc_codegen_ssa/src
parentf49494ecce9015a6b65a2a0c87a414b357e390c7 (diff)
downloadrust-930b2e72eeabf4cacf59d07999fac565836d05bd.tar.gz
rust-930b2e72eeabf4cacf59d07999fac565836d05bd.zip
Do not produce fragment for ZST.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/debuginfo.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs
index f087df4524d..4d3f1fbc91e 100644
--- a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs
@@ -584,17 +584,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                         }
 
                         let place = fragment.contents;
+                        let fragment = if fragment_layout.size == Size::ZERO {
+                            // Fragment is a ZST, so does not represent anything.
+                            continue;
+                        } else if fragment_layout.size == var_layout.size {
+                            // Fragment covers entire variable, so as far as
+                            // DWARF is concerned, it's not really a fragment.
+                            None
+                        } else {
+                            Some(fragment_start..fragment_start + fragment_layout.size)
+                        };
+
                         per_local[place.local].push(PerLocalVarDebugInfo {
                             name: var.name,
                             source_info: var.source_info,
                             dbg_var,
-                            fragment: if fragment_layout.size == var_layout.size {
-                                // Fragment covers entire variable, so as far as
-                                // DWARF is concerned, it's not really a fragment.
-                                None
-                            } else {
-                                Some(fragment_start..fragment_start + fragment_layout.size)
-                            },
+                            fragment,
                             projection: place.projection,
                         });
                     }