You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should debuggers treat ZSTs initializers as code to step through? #97083
If you look at the beginning of the example there:
fnmain(){let a = ();let b :[i32;0] = [];letmut c = 27;let d = c = 99;[...]}
the first two variables, a and b, are both ZSTs.
When you run this in a debugger and try to step though each statement, like so:
(gdb) break step::main
(gdb) run
Breakpoint 1, step::main () at step.rs:4
4 let mut c = 27;
(gdb) next
5 let d = c = 99;
you can see that the gdb next command has "skipped" the initialization of a and b.
This is understandable to a Rust expert, because a and b are both zero-sized types, and so no code is generated for initializing those local variables.
But for a Rust beginner, it is confusing.
If we wanted to, we could make -g mode deal with this. For example, we could generate nop's for such initializers, and then give the nop's corresponding debug info. But that is also pessimizing the code generation to accommodate beginners.
This is something we need to make a decision on whether it is an actual bug we would like to fix or not.
Activity
Enselic commentedon Apr 16, 2026
This issue will be closed by #155377 when/if that gets merged.
Rollup merge of rust-lang#155377 - Enselic:stepping-zsts, r=petrochenkov
Rollup merge of rust-lang#155377 - Enselic:stepping-zsts, r=petrochenkov
Rollup merge of rust-lang#155377 - Enselic:stepping-zsts, r=petrochenkov
Rollup merge of rust-lang#155377 - Enselic:stepping-zsts, r=petrochenkov
Unrolled build for #155377