Skip to content

Deduplicate diagnostics in if-without-else-as-fn-expr.rs #60254

Closed
@Centril

Description

@Centril

#59288 introduces some duplicates in diagnostics in if-without-else-as-fn-expr.rs. Specifically, you have e.g.:

error[E0308]: mismatched types
  --> $DIR/if-without-else-as-fn-expr.rs:35:20
   |
LL |       let x: usize = if let 0 = 1 {
   |  ____________________^
LL | |         return 3;
LL | |     };
   | |_____^ expected usize, found ()
   |
   = note: expected type `usize`
              found type `()`

error[E0317]: if may be missing an else clause
  --> $DIR/if-without-else-as-fn-expr.rs:35:20
   |
LL |       let x: usize = if let 0 = 1 {
   |  _________-__________^
   | |         |
   | |         expected because of this assignment
LL | |         return 3;
LL | |     };
   | |_____^ expected usize, found ()
   |
   = note: expected type `usize`
              found type `()`
   = note: `if` expressions without `else` evaluate to `()`
   = help: consider adding an `else` block that evaluates to the expected type

We want to get rid of the first one since the second is better...

...but this is not done in #59288 since I wanted to avoid too many temporary changes for diagnostics that may get obsoleted quickly.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsF-let_chains`#![feature(let_chains)]`T-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