rust-lang / rust-lang/rust-analyzer

Feature request: Use Result alias in extract-to-function assist

Open
#12,307 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists A-ty C-feature S-unactionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Currently, when I use extract to function on some fallible code in a function that returns syn::Result<_>, anyhow::Result<_> or a similar type alias for Result<_, SomeError>, the generated function uses the expanded form of that type alias. It would be nice if it used the same result alias as the function it is extracted from.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the extract-to-function assist and the logic that determines the generated function's return type. Reproduce the case with a function returning a Result alias such as syn::Result<> or anyhow::Result<>, then verify that the extracted function preserves that alias instead of using the expanded Result form.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.