rust-lang / rust-lang/rust-analyzer

Inline assist on `.into()` produces wrong code

Open
#21,601 3 comments 0 reactions 0 assignees View on GitHub

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

struct Foo {
    x: u32,
}

impl From<u32> for Foo {
    fn from(x: u32) -> Self {
        Foo { x }
    }
}

fn make(x: u32) -> Foo {
    x.into()
}

Consider this example. Attempting to use "inline assist" in into() result in this:

fn make(x: u32) -> Foo {
      U::from(x)
  }

While technically correct - it's not helpful. I'd expect to see Foo instead of U.

rust-analyzer version: rust-analyzer 1.93.0 (254b596 2026-01-19)

rustc version: rustc 1.93.0 (254b59607 2026-01-19)

editor or extension: neovim, rustaceanvim

relevant settings: Nothing really

repository link (if public, optional): (eg. rust-analyzer)

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

Reproduce the reported Rust snippet in rust-analyzer and invoke the inline assist on x.into(). Trace the inline-assist handling for into() and compare the generated U::from(x) with the expected Foo-based result. Done means the assist produces a useful concrete target type for this example.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.