Skip to content

Commit 047ff20

Browse files
authored
Rollup merge of #102720 - lyming2007:issue-102397-fix, r=compiler-errors
do not reverse the expected type and found type for ObligationCauseCo… …de of IfExpressionWithNoElse this will fix #102397
2 parents 1a2a324 + 0501d61 commit 047ff20

File tree

9 files changed

+9
-9
lines changed

9 files changed

+9
-9
lines changed

compiler/rustc_hir_analysis/src/check/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
259259
err.help("consider adding an `else` block that evaluates to the expected type");
260260
error = true;
261261
},
262-
ret_reason.is_none(),
262+
false,
263263
);
264264
error
265265
}

src/test/ui/async-await/issue-66387-if-without-else.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0317]: `if` may be missing an `else` clause
44
LL | / if true {
55
LL | | return 0;
66
LL | | }
7-
| |_____^ expected `()`, found `i32`
7+
| |_____^ expected `i32`, found `()`
88
|
99
= note: `if` expressions without `else` evaluate to `()`
1010
= help: consider adding an `else` block that evaluates to the expected type

src/test/ui/consts/control-flow/issue-50577.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0317]: `if` may be missing an `else` clause
22
--> $DIR/issue-50577.rs:3:16
33
|
44
LL | Drop = assert_eq!(1, 1),
5-
| ^^^^^^^^^^^^^^^^ expected `()`, found `isize`
5+
| ^^^^^^^^^^^^^^^^ expected `isize`, found `()`
66
|
77
= note: `if` expressions without `else` evaluate to `()`
88
= help: consider adding an `else` block that evaluates to the expected type
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn main() {
22
let a = if true { true };
33
//~^ ERROR `if` may be missing an `else` clause [E0317]
4-
//~| expected `()`, found `bool`
4+
//~| expected `bool`, found `()`
55
println!("{}", a);
66
}

src/test/ui/expr/if/if-without-else-result.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let a = if true { true };
55
| ^^^^^^^^^^----^^
66
| | |
77
| | found here
8-
| expected `()`, found `bool`
8+
| expected `bool`, found `()`
99
|
1010
= note: `if` expressions without `else` evaluate to `()`
1111
= help: consider adding an `else` block that evaluates to the expected type

src/test/ui/expr/if/issue-4201.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fn main() {
33
0
44
} else if false {
55
//~^ ERROR `if` may be missing an `else` clause
6-
//~| expected `()`, found integer
6+
//~| expected integer, found `()`
77
1
88
};
99
}

src/test/ui/expr/if/issue-4201.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | |
88
LL | | 1
99
| | - found here
1010
LL | | };
11-
| |_____^ expected `()`, found integer
11+
| |_____^ expected integer, found `()`
1212
|
1313
= note: `if` expressions without `else` evaluate to `()`
1414
= help: consider adding an `else` block that evaluates to the expected type

src/test/ui/issues/issue-19991.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
fn main() {
55
if let Some(homura) = Some("madoka") { //~ ERROR missing an `else` clause
6-
//~| expected `()`, found integer
6+
//~| expected integer, found `()`
77
765
88
};
99
}

src/test/ui/issues/issue-19991.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | |
66
LL | | 765
77
| | --- found here
88
LL | | };
9-
| |_____^ expected `()`, found integer
9+
| |_____^ expected integer, found `()`
1010
|
1111
= note: `if` expressions without `else` evaluate to `()`
1212
= help: consider adding an `else` block that evaluates to the expected type

0 commit comments

Comments
 (0)