rust-lang / rust-lang/rust-analyzer
r-a fails to parse `as u8<<` expression within macro
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version:
rust-analyzer version: 0.3.2237-standalone and rust-analyzer 0.3.2284-standalone
rustc version:
rustc 1.85.0-nightly (7f75bfa1a 2024-12-30)
editor or extension:
Both VSCode and Neovim
repository link (if public, optional):
https://github.com/dzamlo/rust-bitfield/
When calling my macro bitfield, as shown in the code snippet below, I get a "generic arguments are not allowed on builtin types" error from rust-analyzer.
But the code compile without any error or warnings.
If I copy the generated code as outputted by cargo expand in my editor, I don't get the error.
code snippet to reproduce:
use bitfield::bitfield;
bitfield! {
struct Foo([u8]);
}
If the type in parentheses is a simple type, like u8 and not a slice like type, there is no error. A slice like type in parentheses is handled differently by the macro
You can also check the examples in the "examples" folder of the repo.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic with the bitfield! example from the linked rust-bitfield repository, especially the examples folder and the struct Foo([u8]); case. Compare rust-analyzer's result with the code produced by cargo expand; done means the valid macro invocation no longer reports an error in VSCode or Neovim while rustc continues to compile it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100