Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Span for asm error too large #34940

Closed
sophiajt opened this issue Jul 20, 2016 · 2 comments
Closed

Span for asm error too large #34940

sophiajt opened this issue Jul 20, 2016 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-inline-assembly Area: Inline assembly (`asm!(…)`) C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@sophiajt
Copy link
Contributor

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!
@nagisa
Copy link
Member

nagisa commented Jul 20, 2016

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

@sophiajt
Copy link
Contributor Author

@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.

@bstrie bstrie added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 24, 2016
@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the A-inline-assembly Area: Inline assembly (`asm!(…)`) label Jun 5, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 25, 2017
pietroalbini added a commit to pietroalbini/rust that referenced this issue Oct 10, 2018
Point to variable in `asm!` macro when failing borrowck

Fix rust-lang#34940.
bors added a commit that referenced this issue Oct 13, 2018
Point to variable in `asm!` macro when failing borrowck

Fix #34940.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-inline-assembly Area: Inline assembly (`asm!(…)`) C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

5 participants