-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Spurious "expected integer or floating pointer number after -
(rust-analyzer macro-error)" (with reproduction)
#19993
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
Comments
Specifically the problem seems to come from the combination of
Since it compiles fine I think it's probably a RA bug.
The problem still reproduces whether I have backticks or not, i.e. /// A docstring with a -- causes a problem.
/// A docstring with a `--` causes a problem.
|
Grepping in the r-a codebase the thing that causes that error is |
Likely our |
I got a backtrace in case that helps:
|
And it seems to be coming from this |
I poked around but it looks like it'll take more time than I have free at the moment to understand how RA does macro expansion. I don't understand why it is ever treating this text as something that should be parsed. It's only ever inside a docstring or quoted string, as far as I can see. |
Without digging deep, I suspect the problem is that r-a adds parentheses in the call to This will likely require a big fix, so if you don't want to invest a lot of time in it I suggest you don't try to fix this. |
Thanks, I won't claim this. I tried a couple more things, one of which was to make the proc macro print out what it's getting as input. From rustc it gets the right doc attribute:
versus RA
The same problem shows up if I make it an explicit attribute rather than a docstring: #[doc = "A docstring with a - causes a problem."] I wonder if there's some code that's trying to interpret or preprocess attributes before they're passed to proc macros? |
rust-analyzer version: rust-analyzer 1.89.0-nightly (573a015 2025-06-12)
rustc version: rustc 1.89.0-nightly (573a01569 2025-06-12)
binary: rustc
commit-hash: 573a01569000d395498a5f98f916d6e5305ac81a
commit-date: 2025-06-12
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5
editor or extension: Zed 0.190.5 901b05221cf3f1946638c44a81c93cffdaf1cdf5, also
reproducible on VS Code 1.100.3 258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3
relevant settings: (eg. client settings, or environment variables like
CARGO
,RUSTC
,RUSTUP_HOME
orCARGO_HOME
)repository link (if public, optional): (eg. rust-analyzer) https://github.com/sourcefrog/rust-analyzer-repro (minimized from https://github.com/sourcefrog/cargo-mutants)
code snippet to reproduce:
errors:
cargo build
doesn't error on this code.Incidentally there's a typo "floating pointer" rather than "floating point".
The text was updated successfully, but these errors were encountered: