Skip to content

Commit 9d80797

Browse files
committed
Reword message for non-structural type constant in pattern
1 parent 8e8d1bd commit 9d80797

9 files changed

+9
-11
lines changed

compiler/rustc_mir_build/messages.ftl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ mir_build_non_exhaustive_patterns_type_not_empty = non-exhaustive patterns: type
263263
.suggestion = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
264264
.help = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
265265
266-
mir_build_non_partial_eq_match =
267-
to use a constant of type `{$non_peq_ty}` in a pattern, the type must implement `PartialEq`
266+
mir_build_non_partial_eq_match = constant of non-structural type `{$non_peq_ty}` in a pattern
268267
.label = constant of non-structural type
269268
270269
mir_build_pattern_not_covered = refutable pattern in {$origin}

tests/ui/consts/const_in_pattern/issue-65466.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const C: &[O<B>] = &[O::None];
1111
fn main() {
1212
let x = O::None;
1313
match &[x][..] {
14-
C => (), //~ERROR: the type must implement `PartialEq`
14+
C => (), //~ ERROR constant of non-structural type `&[O<B>]` in a pattern
1515
_ => (),
1616
}
1717
}

tests/ui/consts/const_in_pattern/issue-65466.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: to use a constant of type `&[O<B>]` in a pattern, the type must implement `PartialEq`
1+
error: constant of non-structural type `&[O<B>]` in a pattern
22
--> $DIR/issue-65466.rs:14:9
33
|
44
LL | const C: &[O<B>] = &[O::None];

tests/ui/consts/const_in_pattern/reject_non_partial_eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() {
2626

2727
match None {
2828
NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
29-
//~^ ERROR must implement `PartialEq`
29+
//~^ ERROR constant of non-structural type `Option<NoPartialEq>` in a pattern
3030
_ => panic!("whoops"),
3131
}
3232
}

tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: to use a constant of type `Option<NoPartialEq>` in a pattern, the type must implement `PartialEq`
1+
error: constant of non-structural type `Option<NoPartialEq>` in a pattern
22
--> $DIR/reject_non_partial_eq.rs:28:9
33
|
44
LL | const NO_PARTIAL_EQ_NONE: Option<NoPartialEq> = None;

tests/ui/match/issue-72896-non-partial-eq-const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const CONST_SET: EnumSet<Enum8> = EnumSet { __enumset_underlying: 3 };
1616

1717
fn main() {
1818
match CONST_SET {
19-
CONST_SET => { /* ok */ } //~ERROR: must implement `PartialEq`
19+
CONST_SET => { /* ok */ } //~ ERROR constant of non-structural type `EnumSet<Enum8>` in a pattern
2020
_ => panic!("match fell through?"),
2121
}
2222
}

tests/ui/match/issue-72896-non-partial-eq-const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: to use a constant of type `EnumSet<Enum8>` in a pattern, the type must implement `PartialEq`
1+
error: constant of non-structural type `EnumSet<Enum8>` in a pattern
22
--> $DIR/issue-72896-non-partial-eq-const.rs:19:9
33
|
44
LL | const CONST_SET: EnumSet<Enum8> = EnumSet { __enumset_underlying: 3 };

tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const A: &[B] = &[];
1212

1313
pub fn main() {
1414
match &[][..] {
15-
A => (),
16-
//~^ ERROR must implement `PartialEq`
15+
A => (), //~ ERROR constant of non-structural type `&[B]` in a pattern
1716
_ => (),
1817
}
1918
}

tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: to use a constant of type `&[B]` in a pattern, the type must implement `PartialEq`
1+
error: constant of non-structural type `&[B]` in a pattern
22
--> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9
33
|
44
LL | const A: &[B] = &[];

0 commit comments

Comments
 (0)