rust-lang / rust-lang/rust-analyzer
"Implement missing members" produces invalid syntactic constructs for traits generated by a macro-by-example
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
The wasmparser::VisitOperator (for the crate version 0.93) trait is largely defined with a help of a macro-by-example.
When activating the "Implement missing members" action (neovim, built-in LSP client) the filled-in methods can contain constructs that aren't valid outside of a macro definition.
In particular it can produce methods like these:
fn visit_try(&mut self,offset:usize,blockty:$crate::BlockType) -> Self::Output { todo!() }
fn visit_br_table(&mut self,offset:usize,targets:$crate::BrTable<'a>) -> Self::Output { todo!() }
which refer to the $crate::BlockType and $crate::BrTable rather than wasmparser::BlockType,
Another issue is that the lifetime reference in BrTable is incorrect in some instances. For example it still says 'a when the action is invoked for an impl like this:
struct Banana;
impl<'b> VisitOperator<'b> for Banana {}
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 Neovim built-in LSP “Implement missing members” action with the macro-generated wasmparser::VisitOperator trait, including the shown impl lifetime case. Inspect how generated method signatures preserve macro paths and lifetimes; done means the inserted methods use valid wasmparser paths and the impl’s lifetime rather than $crate or a stale 'a.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100