rust-lang / rust-lang/rust-analyzer
Extract function ignores `Self` types
Open
Nobody has claimed this yet.
A-assists
C-bug
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: rust-analyzer 1.73.0 (cc66ad4 2023-10-03)
rustc version: rustc 1.73.0 (cc66ad468 2023-10-03)
relevant settings: n/a
Input
struct Foo {}
impl Foo {
fn bar() {}
fn baz() {
$0Self::bar();$0
}
}
Expected output
struct Foo {}
impl Foo {
fn bar() {}
fn baz() {
Self::fun_name();
}
fn fun_name() {
Self::bar();
}
}
Output
struct Foo {}
impl Foo {
fn bar() {}
fn baz() {
fun_name();
}
}
fn fun_name() {
Self::bar();
}
Explanation
fun_name() should be defined inside an impl Foo, preferably the same one it was extracted from, otherwise Self is not defined
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 extract-function assist with the Rust input shown and locate the extraction implementation and its existing tests. The work is done when extracting a call using Self keeps the new function inside the appropriate impl block and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100