Skip to content

Suggest potentially missing value in empty conditional expression arms with inferred type #99525

Closed
@estebank

Description

@estebank

When given

fn d(opt_str: Option<String>) {
    let s = if let Some(s) = opt_str {
        //~^ ERROR mismatched types
    } else {
        String::new()
    };
}

we should mention that s might be missing in the if branch of the expression, like we do for

fn d(opt_str: Option<String>) {
    let s: String = if let Some(s) = opt_str {
        //~^ ERROR mismatched types
    } else {
        String::new()
    };
}

#98784 (comment)

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions