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

Span for asm error too large #34940

Closed
Closed

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!

Activity

  1. nagisa commented on Jul 20, 2016

    @nagisa
    Member

    In the compiler inline assembly is one big opaque blob. I doubt its worth much spending effort on such unstable feature yet.

  2. sophiajt commented on Jul 20, 2016

    @sophiajt
    ContributorAuthor

    @nagisa - I was wondering. It does open up questions about how to make macros give better errors but perhaps there is a better forum for that design question.

  3. added
    A-diagnostics
    on Aug 24, 2016
  4. removed
    T-compiler
    on Mar 9, 2017
  5. added
    A-inline-assembly
    on Jun 5, 2017
  6. added
    C-enhancement
    on Jul 25, 2017
  7. added a commit that references this issue on Oct 10, 2018
    c6cef8a
  8. added a commit that references this issue on Oct 13, 2018
    c47785f
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-diagnosticsA-inline-assemblyC-enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions