Skip to content

MIR codegen attributes cleanups to beginning of the lexical block. #37032

Closed
@vadimcn

Description

@vadimcn

Compile this code with debug info (-g):

1: fn main() {
2:     zzz();
3:     let s = String::from("sss");
4:     zzz();
5: }
6: 
7: fn zzz() {}

Set a breakpoint on line 2 and start line-stepping. The line position order will be something like this: 2, 3, 4, 3 (cleanup for s), 1 (epilogue for main).
I think everyone will agree that it would make much more sense to attribute the last two to line 5.

The fix will probably need to be done in rustc_trans::mir::MirContext::trans_block.
Also, this probably means that mir::SourceInfo should carry a Pos, not a Span (we only ever use span.lo anyways).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions