diff --git a/compiler/rustc_hir_analysis/src/check/_match.rs b/compiler/rustc_hir_analysis/src/check/_match.rs index 201927091a6..143508b785f 100644 --- a/compiler/rustc_hir_analysis/src/check/_match.rs +++ b/compiler/rustc_hir_analysis/src/check/_match.rs @@ -259,7 +259,7 @@ pub(super) fn if_fallback_coercion( err.help("consider adding an `else` block that evaluates to the expected type"); error = true; }, - ret_reason.is_none(), + false, ); error } diff --git a/src/test/ui/async-await/issue-66387-if-without-else.stderr b/src/test/ui/async-await/issue-66387-if-without-else.stderr index e8e2a48983c..8155fcb56b6 100644 --- a/src/test/ui/async-await/issue-66387-if-without-else.stderr +++ b/src/test/ui/async-await/issue-66387-if-without-else.stderr @@ -4,7 +4,7 @@ error[E0317]: `if` may be missing an `else` clause LL | / if true { LL | | return 0; LL | | } - | |_____^ expected `()`, found `i32` + | |_____^ expected `i32`, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/consts/control-flow/issue-50577.stderr b/src/test/ui/consts/control-flow/issue-50577.stderr index b6e73f889ad..a931c89f47e 100644 --- a/src/test/ui/consts/control-flow/issue-50577.stderr +++ b/src/test/ui/consts/control-flow/issue-50577.stderr @@ -2,7 +2,7 @@ error[E0317]: `if` may be missing an `else` clause --> $DIR/issue-50577.rs:3:16 | LL | Drop = assert_eq!(1, 1), - | ^^^^^^^^^^^^^^^^ expected `()`, found `isize` + | ^^^^^^^^^^^^^^^^ expected `isize`, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/expr/if/if-without-else-result.rs b/src/test/ui/expr/if/if-without-else-result.rs index cf84a99e53f..95604758a6b 100644 --- a/src/test/ui/expr/if/if-without-else-result.rs +++ b/src/test/ui/expr/if/if-without-else-result.rs @@ -1,6 +1,6 @@ fn main() { let a = if true { true }; //~^ ERROR `if` may be missing an `else` clause [E0317] - //~| expected `()`, found `bool` + //~| expected `bool`, found `()` println!("{}", a); } diff --git a/src/test/ui/expr/if/if-without-else-result.stderr b/src/test/ui/expr/if/if-without-else-result.stderr index 821635d3768..317faf7c619 100644 --- a/src/test/ui/expr/if/if-without-else-result.stderr +++ b/src/test/ui/expr/if/if-without-else-result.stderr @@ -5,7 +5,7 @@ LL | let a = if true { true }; | ^^^^^^^^^^----^^ | | | | | found here - | expected `()`, found `bool` + | expected `bool`, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/expr/if/issue-4201.rs b/src/test/ui/expr/if/issue-4201.rs index 1f292229fd6..59c465b9e14 100644 --- a/src/test/ui/expr/if/issue-4201.rs +++ b/src/test/ui/expr/if/issue-4201.rs @@ -3,7 +3,7 @@ fn main() { 0 } else if false { //~^ ERROR `if` may be missing an `else` clause -//~| expected `()`, found integer +//~| expected integer, found `()` 1 }; } diff --git a/src/test/ui/expr/if/issue-4201.stderr b/src/test/ui/expr/if/issue-4201.stderr index bc638ddf55b..612fe77642c 100644 --- a/src/test/ui/expr/if/issue-4201.stderr +++ b/src/test/ui/expr/if/issue-4201.stderr @@ -8,7 +8,7 @@ LL | | LL | | 1 | | - found here LL | | }; - | |_____^ expected `()`, found integer + | |_____^ expected integer, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/issues/issue-19991.rs b/src/test/ui/issues/issue-19991.rs index 1f3b73f96d8..dd0efa972ba 100644 --- a/src/test/ui/issues/issue-19991.rs +++ b/src/test/ui/issues/issue-19991.rs @@ -3,7 +3,7 @@ fn main() { if let Some(homura) = Some("madoka") { //~ ERROR missing an `else` clause - //~| expected `()`, found integer + //~| expected integer, found `()` 765 }; } diff --git a/src/test/ui/issues/issue-19991.stderr b/src/test/ui/issues/issue-19991.stderr index 6e92be87a02..57b0882b636 100644 --- a/src/test/ui/issues/issue-19991.stderr +++ b/src/test/ui/issues/issue-19991.stderr @@ -6,7 +6,7 @@ LL | | LL | | 765 | | --- found here LL | | }; - | |_____^ expected `()`, found integer + | |_____^ expected integer, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type