rust-lang / rust-lang/rust-analyzer
autocomplete breaks in an item identity macro.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
consider the following macro:
macro_rules! item_ident {
($($item:item)*) => {
$( $item )*
}
}
When writing code within this macro, syntax as we're typing might not be considered a valid "item". for example:
item_ident! {
fn baz() {
let x = <|>
}
}
Of course rust-analyzer complains about this:
expected Item
rust-analyzer[macro-error](https://rust-analyzer.github.io/manual.html#macro-error)
This is a fairly common pattern, for example, used in tokio to wrap code blocks with valid #[cfg(...)]s: https://github.com/tokio-rs/tokio/blob/master/tokio-util%2Fsrc%2Fcfg.rs
I wonder if we can recover from these syntax errors such that autocomplete and the likes work in this situation.
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 issue with the item_ident! macro shown in the report and compare behavior with the Tokio tokio-util/src/cfg.rs example. Investigate rust-analyzer's macro parsing and recovery around an incomplete expression such as <|>. Done means autocomplete and related IDE features work inside the macro despite the temporary item syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100