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`

src/test/ui/issues/issue-16401.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-16401.rs:8:9
33
|
44
LL | match () {
5-
| -- this match expression has type `()`
5+
| -- this expression has type `()`
66
LL | Slice { data: data, len: len } => (),
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Slice`
88
|

src/test/ui/issues/issue-3680.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-3680.rs:3:9
33
|
44
LL | match None {
5-
| ---- this match expression has type `std::option::Option<_>`
5+
| ---- this expression has type `std::option::Option<_>`
66
LL | Err(_) => ()
77
| ^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
88
|

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ error[E0308]: mismatched types
2929
--> $DIR/issue-5100.rs:33:9
3030
|
3131
LL | match (true, false) {
32-
| ------------- this match expression has type `(bool, bool)`
32+
| ------------- this expression has type `(bool, bool)`
3333
LL | box (true, false) => ()
3434
| ^^^^^^^^^^^^^^^^^ expected tuple, found struct `std::boxed::Box`
3535
|

src/test/ui/issues/issue-5358-1.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-5358-1.rs:6:9
33
|
44
LL | match S(Either::Left(5)) {
5-
| ------------------ this match expression has type `S`
5+
| ------------------ this expression has type `S`
66
LL | Either::Right(_) => {}
77
| ^^^^^^^^^^^^^^^^ expected struct `S`, found enum `Either`
88
|

src/test/ui/issues/issue-57741-1.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-57741-1.rs:14:9
33
|
44
LL | let y = match x {
5-
| - this match expression has type `std::boxed::Box<u32>`
5+
| - this expression has type `std::boxed::Box<u32>`
66
LL | S::A { a } | S::B { b: a } => a,
77
| ^^^^^^^^^^ expected struct `std::boxed::Box`, found enum `S`
88
|
@@ -13,7 +13,7 @@ error[E0308]: mismatched types
1313
--> $DIR/issue-57741-1.rs:14:22
1414
|
1515
LL | let y = match x {
16-
| - this match expression has type `std::boxed::Box<u32>`
16+
| - this expression has type `std::boxed::Box<u32>`
1717
LL | S::A { a } | S::B { b: a } => a,
1818
| ^^^^^^^^^^^^^ expected struct `std::boxed::Box`, found enum `S`
1919
|

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | let y = match x {
55
| -
66
| |
7-
| this match expression has type `std::boxed::Box<T>`
7+
| this expression has type `std::boxed::Box<T>`
88
| help: consider dereferencing the boxed value: `*x`
99
LL | T::A(a) | T::B(a) => a,
1010
| ^^^^^^^ expected struct `std::boxed::Box`, found enum `T`
@@ -18,7 +18,7 @@ error[E0308]: mismatched types
1818
LL | let y = match x {
1919
| -
2020
| |
21-
| this match expression has type `std::boxed::Box<T>`
21+
| this expression has type `std::boxed::Box<T>`
2222
| help: consider dereferencing the boxed value: `*x`
2323
LL | T::A(a) | T::B(a) => a,
2424
| ^^^^^^^ expected struct `std::boxed::Box`, found enum `T`
@@ -32,7 +32,7 @@ error[E0308]: mismatched types
3232
LL | let y = match x {
3333
| -
3434
| |
35-
| this match expression has type `std::boxed::Box<S>`
35+
| this expression has type `std::boxed::Box<S>`
3636
| help: consider dereferencing the boxed value: `*x`
3737
LL | S::A { a } | S::B { b: a } => a,
3838
| ^^^^^^^^^^ expected struct `std::boxed::Box`, found enum `S`
@@ -46,7 +46,7 @@ error[E0308]: mismatched types
4646
LL | let y = match x {
4747
| -
4848
| |
49-
| this match expression has type `std::boxed::Box<S>`
49+
| this expression has type `std::boxed::Box<S>`
5050
| help: consider dereferencing the boxed value: `*x`
5151
LL | S::A { a } | S::B { b: a } => a,
5252
| ^^^^^^^^^^^^^ expected struct `std::boxed::Box`, found enum `S`

src/test/ui/issues/issue-7092.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-7092.rs:6:9
33
|
44
LL | match x {
5-
| - this match expression has type `Whatever`
5+
| - this expression has type `Whatever`
66
LL | Some(field) =>
77
| ^^^^^^^^^^^ expected enum `Whatever`, found enum `std::option::Option`
88
|

src/test/ui/match/match-struct.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/match-struct.rs:6:9
33
|
44
LL | match (S { a: 1 }) {
5-
| ------------ this match expression has type `S`
5+
| ------------ this expression has type `S`
66
LL | E::C(_) => (),
77
| ^^^^^^^ expected struct `S`, found enum `E`
88

src/test/ui/match/match-tag-unary.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn main() { let x: A = A::A(0); match x { B::B(y) => { } } }
55
| - ^^^^^^^ expected enum `A`, found enum `B`
66
| |
7-
| this match expression has type `A`
7+
| this expression has type `A`
88

99
error: aborting due to previous error
1010

src/test/ui/parser/pat-tuple-5.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error[E0308]: mismatched types
1717
--> $DIR/pat-tuple-5.rs:5:10
1818
|
1919
LL | match (0, 1) {
20-
| ------ this match expression has type `({integer}, {integer})`
20+
| ------ this expression has type `({integer}, {integer})`
2121
LL | (PAT ..) => {}
2222
| ^^^ expected tuple, found `u8`
2323
|

src/test/ui/pattern/pattern-error-continue.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ error[E0308]: mismatched types
2828
--> $DIR/pattern-error-continue.rs:22:9
2929
|
3030
LL | match 'c' {
31-
| --- this match expression has type `char`
31+
| --- this expression has type `char`
3232
LL | S { .. } => (),
3333
| ^^^^^^^^ expected `char`, found struct `S`
3434

src/test/ui/pattern/pattern-tyvar.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/pattern-tyvar.rs:5:18
33
|
44
LL | match t {
5-
| - this match expression has type `std::option::Option<std::vec::Vec<isize>>`
5+
| - this expression has type `std::option::Option<std::vec::Vec<isize>>`
66
LL | Bar::T1(_, Some::<isize>(x)) => {
77
| ^^^^^^^^^^^^^^^^ expected struct `std::vec::Vec`, found `isize`
88
|

src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ error[E0308]: mismatched types
630630
--> $DIR/disallowed-positions.rs:67:12
631631
|
632632
LL | if let Range { start: _, end: _ } = true..true && false {}
633-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this match expression has type `bool`
633+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
634634
| |
635635
| expected `bool`, found struct `std::ops::Range`
636636
|
@@ -650,7 +650,7 @@ error[E0308]: mismatched types
650650
--> $DIR/disallowed-positions.rs:71:12
651651
|
652652
LL | if let Range { start: _, end: _ } = true..true || false {}
653-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this match expression has type `bool`
653+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
654654
| |
655655
| expected `bool`, found struct `std::ops::Range`
656656
|
@@ -697,7 +697,7 @@ error[E0308]: mismatched types
697697
--> $DIR/disallowed-positions.rs:86:12
698698
|
699699
LL | if let Range { start: true, end } = t..&&false {}
700-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this match expression has type `bool`
700+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `bool`
701701
| |
702702
| expected `bool`, found struct `std::ops::Range`
703703
|
@@ -818,7 +818,7 @@ error[E0308]: mismatched types
818818
--> $DIR/disallowed-positions.rs:131:15
819819
|
820820
LL | while let Range { start: _, end: _ } = true..true && false {}
821-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this match expression has type `bool`
821+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
822822
| |
823823
| expected `bool`, found struct `std::ops::Range`
824824
|
@@ -838,7 +838,7 @@ error[E0308]: mismatched types
838838
--> $DIR/disallowed-positions.rs:135:15
839839
|
840840
LL | while let Range { start: _, end: _ } = true..true || false {}
841-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this match expression has type `bool`
841+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
842842
| |
843843
| expected `bool`, found struct `std::ops::Range`
844844
|
@@ -885,7 +885,7 @@ error[E0308]: mismatched types
885885
--> $DIR/disallowed-positions.rs:150:15
886886
|
887887
LL | while let Range { start: true, end } = t..&&false {}
888-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this match expression has type `bool`
888+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `bool`
889889
| |
890890
| expected `bool`, found struct `std::ops::Range`
891891
|
@@ -961,7 +961,7 @@ error[E0308]: mismatched types
961961
--> $DIR/disallowed-positions.rs:198:10
962962
|
963963
LL | (let Range { start: _, end: _ } = true..true || false);
964-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this match expression has type `bool`
964+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
965965
| |
966966
| expected `bool`, found struct `std::ops::Range`
967967
|

src/test/ui/structs/structure-constructor-type-mismatch.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ error[E0308]: mismatched types
8686
--> $DIR/structure-constructor-type-mismatch.rs:54:9
8787
|
8888
LL | match (Point { x: 1, y: 2 }) {
89-
| ---------------------- this match expression has type `Point<{integer}>`
89+
| ---------------------- this expression has type `Point<{integer}>`
9090
LL | PointF::<u32> { .. } => {}
9191
| ^^^^^^^^^^^^^^^^^^^^ expected integer, found `f32`
9292
|
@@ -97,7 +97,7 @@ error[E0308]: mismatched types
9797
--> $DIR/structure-constructor-type-mismatch.rs:59:9
9898
|
9999
LL | match (Point { x: 1, y: 2 }) {
100-
| ---------------------- this match expression has type `Point<{integer}>`
100+
| ---------------------- this expression has type `Point<{integer}>`
101101
LL | PointF { .. } => {}
102102
| ^^^^^^^^^^^^^ expected integer, found `f32`
103103
|
@@ -108,7 +108,7 @@ error[E0308]: mismatched types
108108
--> $DIR/structure-constructor-type-mismatch.rs:67:9
109109
|
110110
LL | match (Pair { x: 1, y: 2 }) {
111-
| --------------------- this match expression has type `Pair<{integer}, {integer}>`
111+
| --------------------- this expression has type `Pair<{integer}, {integer}>`
112112
LL | PairF::<u32> { .. } => {}
113113
| ^^^^^^^^^^^^^^^^^^^ expected integer, found `f32`
114114
|

0 commit comments

Comments
 (0)