"Wrap in Some" with if/else and inferred assignment incorrect

Author: goodsparkCreated Sep 17, 2026Updated Sep 17, 2026
Labelsgood first issueE-easyA-assistsC-bug

rust-analyzer version: rust-analyzer version: 0.3.3049-standalone

rustc version: rustc 1.98.1 (48a229cea 2026-09-01)

editor or extension: VSCode, rust-analyzer 0.3.3049

relevant settings:

repository link (if public, optional):

code snippet to reproduce:

rust
// Run the "Wrap in Some" action on '123'
let x = if { None } else { 123 };

Result:

rust
let x = if true { None } else Some({ 123 });

rust-analyzer wraps the entire block for the else branch with Some, instead of just the 123 that gets returned for the variable assignment.

If I set a type on x: Option<_>, this doesn't happen.