rust-lang / rust-lang/rust-analyzer
`implement missing members` doesn't apply feature flags
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: 0add6e95e 2021-12-20 stable
rustc version: rustc 1.56.1 (59eed8a2a 2021-11-01)
rust-analyzer doesn't respect cfg(test) (or other feature flags) when applying the implement missing members assist. In practice this means that if I have this code:
trait Foo {
#[cfg(test)]
fn foo_method();
}
struct Bar;
impl Foo for Bar {}
Then applying "implement missing members" on that impl block gives:
trait Foo {
#[cfg(test)]
fn foo_method();
}
struct Bar;
impl Foo for Bar {
fn foo_method() {
todo!()
}
}
Whereas I would like to get:
trait Foo {
#[cfg(test)]
fn foo_method();
}
struct Bar;
impl Foo for Bar {
#[cfg(test)]
fn foo_method() {
todo!()
}
}
I'm guessing this is a non-trivial problem, but it would be super nice if rust-analyzer could pick up on some of these cases (even if it's just cfg(test)) and handle them correctly.
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 at the implement missing members assist and trace how it copies trait members into the impl. Check how cfg(test) and feature flags are handled there; done when generated methods preserve applicable cfg attributes, with tests covering the shown case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100