rust-lang / rust-lang/rust-analyzer
Import insertion on signature for cfg attributed function puts import into the function
Open
Nobody has claimed this yet.
A-assists
C-bug
S-actionable
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
#[cfg(test)]
fn check(expect: Expect$0) {
}
becomes
#[cfg(test)]
fn check(expect: Expect$0) {
use expect_test::Expect;
}
which is wrong.
In this case we still have to move the import out and attribute it unfortunately.
It also works incorrectly for macro created items https://github.com/rust-analyzer/rust-analyzer/issues/9391#issuecomment-881208834
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 signature import insertion with the Rust snippet in this issue, then trace the import insertion handling for cfg-attributed functions. Confirm that the import is moved outside the function and appropriately attributed, and check the reported behavior for macro-created items.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100