rust-lang / rust-lang/rust-analyzer
Add adjust return type assist
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Hey folks, what do you think about adding above-mentioned assist? It could be useful when doing some refactors. If this makes sense, I can try to do it as this will boost my dev workflow. If not, feel free to close this issue.
silly example: If I change Ok(Foo) to Ok(Bar) I have to adjust return type by myself, but I'd like to quick fix it, if possible. I browsed through already existing assists and there is add_return_type but I can't see anything which suits my case.
struct Foo;
struct Bar;
fn foo() -> Foo {
Foo // -> change to Bar
}
struct Foo;
struct Bar;
fn foo() -> Foo {
Bar // offer quick fix action
}
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 reviewing the existing add_return_type assist and other assist implementations; the issue does not name specific files or tests. Determine how an assist could detect a returned expression whose type differs from the declared return type, then define tests for the Foo/Bar example and verify that a quick fix offers to adjust the return type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100