Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Should debuggers treat ZSTs initializers as code to step through? #97083

Closed

Description

@pnkfelix

Spawned off of #33013 (comment)

If you look at the beginning of the example there:

fn main () {
    let a = ();
    let b : [i32; 0] = [];
    let mut 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

  1. added
    A-debuginfo
    I-needs-decision
    T-compiler
    on May 16, 2022
  2. added
    C-discussion
    on Jul 11, 2025
  3. Enselic commented on Apr 16, 2026

    @Enselic
    Member

    This issue will be closed by #155377 when/if that gets merged.

  4. added 2 commits that reference this issue on Apr 16, 2026
    41da85a
    0eb0f81
  5. added a commit that references this issue on Apr 16, 2026
    5ad01e3
  6. added a commit that references this issue on Apr 17, 2026
    36351e1
  7. added a commit that references this issue on Apr 17, 2026
    1bbdcd6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoC-discussionI-needs-decisionT-compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions