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
9 changed files with 9 additions and 9 deletions
|
@ -259,7 +259,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
err.help("consider adding an `else` block that evaluates to the expected type");
|
err.help("consider adding an `else` block that evaluates to the expected type");
|
||||||
error = true;
|
error = true;
|
||||||
},
|
},
|
||||||
ret_reason.is_none(),
|
false,
|
||||||
);
|
);
|
||||||
error
|
error
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0317]: `if` may be missing an `else` clause
|
||||||
LL | / if true {
|
LL | / if true {
|
||||||
LL | | return 0;
|
LL | | return 0;
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_____^ expected `()`, found `i32`
|
| |_____^ expected `i32`, found `()`
|
||||||
|
|
|
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= 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
|
--> $DIR/issue-50577.rs:3:16
|
||||||
|
|
|
|
||||||
LL | Drop = assert_eq!(1, 1),
|
LL | Drop = assert_eq!(1, 1),
|
||||||
| ^^^^^^^^^^^^^^^^ expected `()`, found `isize`
|
| ^^^^^^^^^^^^^^^^ expected `isize`, found `()`
|
||||||
|
|
|
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = if true { true };
|
let a = if true { true };
|
||||||
//~^ ERROR `if` may be missing an `else` clause [E0317]
|
//~^ ERROR `if` may be missing an `else` clause [E0317]
|
||||||
//~| expected `()`, found `bool`
|
//~| expected `bool`, found `()`
|
||||||
println!("{}", a);
|
println!("{}", a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | let a = if true { true };
|
||||||
| ^^^^^^^^^^----^^
|
| ^^^^^^^^^^----^^
|
||||||
| | |
|
| | |
|
||||||
| | found here
|
| | found here
|
||||||
| expected `()`, found `bool`
|
| expected `bool`, found `()`
|
||||||
|
|
|
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
|
@ -3,7 +3,7 @@ fn main() {
|
||||||
0
|
0
|
||||||
} else if false {
|
} else if false {
|
||||||
//~^ ERROR `if` may be missing an `else` clause
|
//~^ ERROR `if` may be missing an `else` clause
|
||||||
//~| expected `()`, found integer
|
//~| expected integer, found `()`
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ LL | |
|
||||||
LL | | 1
|
LL | | 1
|
||||||
| | - found here
|
| | - found here
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____^ expected `()`, found integer
|
| |_____^ expected integer, found `()`
|
||||||
|
|
|
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Some(homura) = Some("madoka") { //~ ERROR missing an `else` clause
|
if let Some(homura) = Some("madoka") { //~ ERROR missing an `else` clause
|
||||||
//~| expected `()`, found integer
|
//~| expected integer, found `()`
|
||||||
765
|
765
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ LL | |
|
||||||
LL | | 765
|
LL | | 765
|
||||||
| | --- found here
|
| | --- found here
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____^ expected `()`, found integer
|
| |_____^ expected integer, found `()`
|
||||||
|
|
|
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue