Skip to content

Span for asm error too large #34940

Closed
Closed
@sophiajt

Description

@sophiajt

Looking around the compile-fail test suite, I noticed this example:

jturner-23759:rust jturner$ ./build/x86_64-apple-darwin/stage1/bin/rustc src/test/compile-fail/asm-out-assign-imm.rs 
error[E0384]: re-assignment of immutable variable `x`
  --> src/test/compile-fail/asm-out-assign-imm.rs:24:9
   |
21 |     x = 1; //~ NOTE first assignment
   |     ----- first assignment to `x`
...
24 |         asm!("mov $1, $0" : "=r"(x) : "r"(5));
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-assignment of immutable variable
src/test/compile-fail/asm-out-assign-imm.rs:24:9: 24:47 note: in this expansion of asm!

The span on the asm line seems a bit much. Ideally, I think we'd show them where the assignment is happening so they don't have to look for it. Something like:

24 |         asm!("mov $1, $0" : "=r"(x) : "r"(5));
   |                             ^^^^^^^ re-assignment of immutable variable
src/test/compile-fail/asm-out-assign-imm.rs:24:9: 24:47 note: in this expansion of asm!

Or even:

24 |         asm!("mov $1, $0" : "=r"(x) : "r"(5));
   |                                  ^ re-assignment of immutable variable
src/test/compile-fail/asm-out-assign-imm.rs:24:9: 24:47 note: in this expansion of asm!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-inline-assemblyArea: Inline assembly (`asm!(…)`)C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions