do not reverse the expected type and found type for ObligationCauseCode of IfExpressionWithNoElse
this will fix #102397
This commit is contained in:
parent
8c71b67159
commit
0501d615bb
@ -259,7 +259,7 @@ pub(super) fn if_fallback_coercion<T>(
|
||||
err.help("consider adding an `else` block that evaluates to the expected type");
|
||||
error = true;
|
||||
},
|
||||
ret_reason.is_none(),
|
||||
false,
|
||||
);
|
||||
error
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
fn main() {
|
||||
if let Some(homura) = Some("madoka") { //~ ERROR missing an `else` clause
|
||||
//~| expected `()`, found integer
|
||||
//~| expected integer, found `()`
|
||||
765
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user