rust-lang / rust-lang/rust-analyzer
Handle autocomplete better in macros accepting code blocks
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Related: #6097, #7402
I was writing some code recently using tokio::select! and, separately, proptest::proptest!, which are both macro_rules! macros, and the developer experience for these is quite poor: autocomplete simply does not work inside them. I understand that mostly macros are a quagmire for making completion work properly, but these seem like they could be different than the usual case.
The reason that these macros are interesting as a more interesting target for improving autocomplete behaviour than the other cases is that they are both accepting large blocks of code that are passed through unmodified which are most likely where most editing is happening and where it is most troublesome that completion doesn't work. Further, they are (mostly) declarative macros [the proc macro bits of tokio::select! appear to be limited enough that I think this is true] in the parts that deal with the code in the select branches.
Illustrative code example:
loop {
tokio::select! {
v = cap.select_next_some() => {
let (v, meta) = v?;
// Completion does not work in here, but maybe it could
}
s = tokio::signal::ctrl_c() => {
let _ = s?;
break Ok(());
}
};
}
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
Start by reproducing the illustrative tokio::select! example and a proptest::proptest! macro using the reported autocomplete scenarios. Trace how rust-analyzer handles code blocks passed through these macro_rules! macros, then verify that completion works inside those blocks without regressing the surrounding macro behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100