Skip to content

Commit ab050d6

Browse files
committed
MatchExpressionArmPattern: Use more generic wording.
The existing wording was inappropriate for e.g. `if let Ok(_) = expr { .. }`. The diagnostic would leak the fact that we desugar to a `match`.
1 parent 73db83a commit ab050d6

24 files changed

+38
-38
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
584584
ObligationCauseCode::MatchExpressionArmPattern { span, ty } => {
585585
if ty.is_suggestable() {
586586
// don't show type `_`
587-
err.span_label(span, format!("this match expression has type `{}`", ty));
587+
err.span_label(span, format!("this expression has type `{}`", ty));
588588
}
589589
if let Some(ty::error::ExpectedFound { found, .. }) = exp_found {
590590
if ty.is_box() && ty.boxed_ty() == found {

src/test/ui/block-result/issue-13624.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0308]: mismatched types
1010
--> $DIR/issue-13624.rs:20:9
1111
|
1212
LL | match enum_struct_variant {
13-
| ------------------- this match expression has type `()`
13+
| ------------------- this expression has type `()`
1414
LL | a::Enum::EnumStructVariant { x, y, z } => {
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found enum `a::Enum`
1616

src/test/ui/error-codes/E0308-4.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/E0308-4.rs:4:15
33
|
44
LL | match x {
5-
| - this match expression has type `u8`
5+
| - this expression has type `u8`
66
LL | 0u8..=3i8 => (),
77
| --- ^^^ expected `u8`, found `i8`
88
| |

src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0308]: mismatched types
88
--> $DIR/exclusive_range_pattern_syntax_collision.rs:5:13
99
|
1010
LL | match [5..4, 99..105, 43..44] {
11-
| ----------------------- this match expression has type `std::ops::Range<{integer}>`
11+
| ----------------------- this expression has type `std::ops::Range<{integer}>`
1212
LL | [_, 99.., _] => {},
1313
| ^^ expected struct `std::ops::Range`, found integer
1414
|

src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error[E0308]: mismatched types
1414
--> $DIR/exclusive_range_pattern_syntax_collision2.rs:5:13
1515
|
1616
LL | match [5..4, 99..105, 43..44] {
17-
| ----------------------- this match expression has type `std::ops::Range<{integer}>`
17+
| ----------------------- this expression has type `std::ops::Range<{integer}>`
1818
LL | [_, 99..] => {},
1919
| ^^ expected struct `std::ops::Range`, found integer
2020
|

src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0308]: mismatched types
88
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:12
99
|
1010
LL | match [5..4, 99..105, 43..44] {
11-
| ----------------------- this match expression has type `std::ops::Range<{integer}>`
11+
| ----------------------- this expression has type `std::ops::Range<{integer}>`
1212
LL | [..9, 99..100, _] => {},
1313
| ^ expected struct `std::ops::Range`, found integer
1414
|
@@ -19,7 +19,7 @@ error[E0308]: mismatched types
1919
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:15
2020
|
2121
LL | match [5..4, 99..105, 43..44] {
22-
| ----------------------- this match expression has type `std::ops::Range<{integer}>`
22+
| ----------------------- this expression has type `std::ops::Range<{integer}>`
2323
LL | [..9, 99..100, _] => {},
2424
| ^^ --- this is of type `{integer}`
2525
| |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-11844.rs:6:9
33
|
44
LL | match a {
5-
| - this match expression has type `std::option::Option<std::boxed::Box<{integer}>>`
5+
| - this expression has type `std::option::Option<std::boxed::Box<{integer}>>`
66
LL | Ok(a) =>
77
| ^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
88
|

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-12552.rs:6:5
33
|
44
LL | match t {
5-
| - this match expression has type `std::result::Result<_, {integer}>`
5+
| - this expression has type `std::result::Result<_, {integer}>`
66
LL | Some(k) => match k {
77
| ^^^^^^^ expected enum `std::result::Result`, found enum `std::option::Option`
88
|

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-13466.rs:8:9
33
|
44
LL | let _x: usize = match Some(1) {
5-
| ------- this match expression has type `std::option::Option<{integer}>`
5+
| ------- this expression has type `std::option::Option<{integer}>`
66
LL | Ok(u) => u,
77
| ^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
88
|
@@ -13,7 +13,7 @@ error[E0308]: mismatched types
1313
--> $DIR/issue-13466.rs:14:9
1414
|
1515
LL | let _x: usize = match Some(1) {
16-
| ------- this match expression has type `std::option::Option<{integer}>`
16+
| ------- this expression has type `std::option::Option<{integer}>`
1717
...
1818
LL | Err(e) => panic!(e)
1919
| ^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-15896.rs:11:11
33
|
44
LL | let u = match e {
5-
| - this match expression has type `main::R`
5+
| - this expression has type `main::R`
66
LL | E::B(
77
LL | Tau{t: x},
88
| ^^^^^^^^^ expected enum `main::R`, found struct `main::Tau`

0 commit comments

Comments
 (0)