rust-lang / rust-lang/rust-analyzer

TypeMismatch quickfix position error

Open
#22,152 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics 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 0.3.2870-standalone

rustc version: rustc 1.97.0-nightly (913e4bea8 2026-04-22)

editor or extension: Vim

code snippet to reproduce:

fn main() {
    if true { "".to_owned() } else { "" };
    if true { "".to_owned() } else { "" }.to_owned(); // fixed
    if false { "" } else { "".to_owned() };
    if false { "" } else &{ "".to_owned() }; // fixed
}

Similar to #19428, but not a macro, which may be easier to fix

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 Rust snippet in Vim with rust-analyzer 0.3.2870-standalone and inspect the TypeMismatch quickfix position for each conditional expression. Compare the affected cases with the already-fixed cases and issue #19428. Done means the quickfix points to the intended expression or type mismatch location in both branch orders.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.