1
Fork 0

Deduplicate errors in const to pat conversion

This commit is contained in:
Oliver Scherer 2020-09-23 17:03:31 +02:00
parent d486486afd
commit 177d0cef48
29 changed files with 55 additions and 200 deletions

View file

@ -252,7 +252,12 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
ty::Adt(adt_def, _) if adt_def.is_union() => { ty::Adt(adt_def, _) if adt_def.is_union() => {
// Matching on union fields is unsafe, we can't hide it in constants // Matching on union fields is unsafe, we can't hide it in constants
self.saw_const_match_error.set(true); self.saw_const_match_error.set(true);
tcx.sess.span_err(span, "cannot use unions in constant patterns"); let msg = "cannot use unions in constant patterns";
if self.include_lint_checks {
tcx.sess.span_err(span, msg);
} else {
tcx.sess.delay_span_bug(span, msg)
}
PatKind::Wild PatKind::Wild
} }
ty::Adt(..) ty::Adt(..)
@ -267,7 +272,11 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
cv.ty, cv.ty, cv.ty, cv.ty,
); );
self.saw_const_match_error.set(true); self.saw_const_match_error.set(true);
self.tcx().sess.span_err(self.span, &msg); if self.include_lint_checks {
tcx.sess.span_err(self.span, &msg);
} else {
tcx.sess.delay_span_bug(self.span, &msg)
}
PatKind::Wild PatKind::Wild
} }
// If the type is not structurally comparable, just emit the constant directly, // If the type is not structurally comparable, just emit the constant directly,
@ -308,7 +317,11 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
path, path, path, path,
); );
self.saw_const_match_error.set(true); self.saw_const_match_error.set(true);
if self.include_lint_checks {
tcx.sess.span_err(span, &msg); tcx.sess.span_err(span, &msg);
} else {
tcx.sess.delay_span_bug(span, &msg)
}
PatKind::Wild PatKind::Wild
} }
ty::Adt(adt_def, substs) if adt_def.is_enum() => { ty::Adt(adt_def, substs) if adt_def.is_enum() => {
@ -340,7 +353,12 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
// These are not allowed and will error elsewhere anyway. // These are not allowed and will error elsewhere anyway.
ty::Dynamic(..) => { ty::Dynamic(..) => {
self.saw_const_match_error.set(true); self.saw_const_match_error.set(true);
tcx.sess.span_err(span, &format!("`{}` cannot be used in patterns", cv.ty)); let msg = format!("`{}` cannot be used in patterns", cv.ty);
if self.include_lint_checks {
tcx.sess.span_err(span, &msg);
} else {
tcx.sess.delay_span_bug(span, &msg)
}
PatKind::Wild PatKind::Wild
} }
// `&str` and `&[u8]` are represented as `ConstValue::Slice`, let's keep using this // `&str` and `&[u8]` are represented as `ConstValue::Slice`, let's keep using this
@ -427,7 +445,12 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
} }
_ => { _ => {
self.saw_const_match_error.set(true); self.saw_const_match_error.set(true);
tcx.sess.span_err(span, &format!("`{}` cannot be used in patterns", cv.ty)); let msg = format!("`{}` cannot be used in patterns", cv.ty);
if self.include_lint_checks {
tcx.sess.span_err(span, &msg);
} else {
tcx.sess.delay_span_bug(span, &msg)
}
PatKind::Wild PatKind::Wild
} }
}; };

View file

@ -12,7 +12,6 @@ fn main() {
match None { match None {
consts::SOME => panic!(), consts::SOME => panic!(),
//~^ must be annotated with `#[derive(PartialEq, Eq)]` //~^ must be annotated with `#[derive(PartialEq, Eq)]`
//~| must be annotated with `#[derive(PartialEq, Eq)]`
_ => {} _ => {}
} }
@ -20,7 +19,6 @@ fn main() {
match None { match None {
<Defaulted as consts::AssocConst>::SOME => panic!(), <Defaulted as consts::AssocConst>::SOME => panic!(),
//~^ must be annotated with `#[derive(PartialEq, Eq)]` //~^ must be annotated with `#[derive(PartialEq, Eq)]`
//~| must be annotated with `#[derive(PartialEq, Eq)]`
_ => {} _ => {}
} }

View file

@ -5,22 +5,10 @@ LL | consts::SOME => panic!(),
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/cross-crate-fail.rs:21:9 --> $DIR/cross-crate-fail.rs:20:9
| |
LL | <Defaulted as consts::AssocConst>::SOME => panic!(), LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]` error: aborting due to 2 previous errors
--> $DIR/cross-crate-fail.rs:13:9
|
LL | consts::SOME => panic!(),
| ^^^^^^^^^^^^
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/cross-crate-fail.rs:21:9
|
LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors

View file

@ -20,7 +20,6 @@ fn main() {
match Foo::Qux(NoEq) { match Foo::Qux(NoEq) {
BAR_BAZ => panic!(), BAR_BAZ => panic!(),
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
_ => {} _ => {}
} }
} }

View file

@ -4,11 +4,5 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit
LL | BAR_BAZ => panic!(), LL | BAR_BAZ => panic!(),
| ^^^^^^^ | ^^^^^^^
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` error: aborting due to previous error
--> $DIR/no-eq-branch-fail.rs:21:9
|
LL | BAR_BAZ => panic!(),
| ^^^^^^^
error: aborting due to 2 previous errors

View file

@ -27,7 +27,6 @@ fn main() {
match None { match None {
NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"), NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
_ => panic!("whoops"), _ => panic!("whoops"),
} }
} }

View file

@ -4,11 +4,5 @@ error: to use a constant of type `Option<NoPartialEq>` in a pattern, `Option<NoP
LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"), LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: to use a constant of type `Option<NoPartialEq>` in a pattern, `Option<NoPartialEq>` must be annotated with `#[derive(PartialEq, Eq)]` error: aborting due to previous error
--> $DIR/reject_non_partial_eq.rs:28:9
|
LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -39,51 +39,41 @@ fn main() {
const ENUM: Derive<NoDerive> = Derive::Some(NoDerive); const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), }; match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const FIELD: OND = TrivialEq(Some(NoDerive)).0; const FIELD: OND = TrivialEq(Some(NoDerive)).0;
match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const NO_DERIVE_SOME: OND = Some(NoDerive); const NO_DERIVE_SOME: OND = Some(NoDerive);
const INDIRECT: OND = NO_DERIVE_SOME; const INDIRECT: OND = NO_DERIVE_SOME;
match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), }; match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const TUPLE: (OND, OND) = (None, Some(NoDerive)); const TUPLE: (OND, OND) = (None, Some(NoDerive));
match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const TYPE_ASCRIPTION: OND = Some(NoDerive): OND; const TYPE_ASCRIPTION: OND = Some(NoDerive): OND;
match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const ARRAY: [OND; 2] = [None, Some(NoDerive)]; const ARRAY: [OND; 2] = [None, Some(NoDerive)];
match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), }; match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const REPEAT: [OND; 2] = [Some(NoDerive); 2]; const REPEAT: [OND; 2] = [Some(NoDerive); 2];
match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
trait Trait: Sized { const ASSOC: Option<Self>; } trait Trait: Sized { const ASSOC: Option<Self>; }
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); } impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), }; match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const BLOCK: OND = { NoDerive; Some(NoDerive) }; const BLOCK: OND = { NoDerive; Some(NoDerive) };
match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const ADDR_OF: &OND = &Some(NoDerive); const ADDR_OF: &OND = &Some(NoDerive);
match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };

View file

@ -5,61 +5,61 @@ LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"
| ^^^^ | ^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:45:28 --> $DIR/reject_non_structural.rs:44:28
| |
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
| ^^^^^ | ^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:51:27 --> $DIR/reject_non_structural.rs:49:27
| |
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), }; LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
| ^^^^^^^^ | ^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:56:36 --> $DIR/reject_non_structural.rs:53:36
| |
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
| ^^^^^ | ^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:61:28 --> $DIR/reject_non_structural.rs:57:28
| |
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:66:36 --> $DIR/reject_non_structural.rs:61:36
| |
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), }; LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
| ^^^^^ | ^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:71:33 --> $DIR/reject_non_structural.rs:65:33
| |
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
| ^^^^^^ | ^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:71:33 --> $DIR/reject_non_structural.rs:65:33
| |
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
| ^^^^^^ | ^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:79:28 --> $DIR/reject_non_structural.rs:71:28
| |
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), }; LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:84:28 --> $DIR/reject_non_structural.rs:75:28
| |
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
| ^^^^^ | ^^^^^
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:89:29 --> $DIR/reject_non_structural.rs:79:29
| |
LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
| ^^^^^^^ | ^^^^^^^
@ -72,65 +72,5 @@ LL | #![warn(indirect_structural_match)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: aborting due to 10 previous errors; 1 warning emitted
--> $DIR/reject_non_structural.rs:40:36
|
LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
| ^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:45:28
|
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
| ^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:51:27
|
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
| ^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:56:36
|
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
| ^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:61:28
|
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
| ^^^^^^^^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:66:36
|
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
| ^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:71:33
|
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
| ^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:71:33
|
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
| ^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:79:28
|
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
| ^^^^^^^^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/reject_non_structural.rs:84:28
|
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
| ^^^^^
error: aborting due to 20 previous errors; 1 warning emitted

View file

@ -5,7 +5,6 @@ fn main() {
match a { match a {
F => panic!(), F => panic!(),
//~^ ERROR `&dyn Send` cannot be used in patterns //~^ ERROR `&dyn Send` cannot be used in patterns
//~| ERROR `&dyn Send` cannot be used in patterns
_ => {} _ => {}
} }
} }

View file

@ -4,11 +4,5 @@ error: `&dyn Send` cannot be used in patterns
LL | F => panic!(), LL | F => panic!(),
| ^ | ^
error: `&dyn Send` cannot be used in patterns error: aborting due to previous error
--> $DIR/issue-70972-dyn-trait.rs:6:9
|
LL | F => panic!(),
| ^
error: aborting due to 2 previous errors

View file

@ -5,7 +5,6 @@ fn main() {
const C: impl Copy = 0; const C: impl Copy = 0;
match C { match C {
C => {} //~ ERROR: `impl Copy` cannot be used in patterns C => {} //~ ERROR: `impl Copy` cannot be used in patterns
//~^ ERROR: `impl Copy` cannot be used in patterns
_ => {} _ => {}
} }
} }

View file

@ -4,11 +4,5 @@ error: `impl Copy` cannot be used in patterns
LL | C => {} LL | C => {}
| ^ | ^
error: `impl Copy` cannot be used in patterns error: aborting due to previous error
--> $DIR/issue-71042-opaquely-typed-constant-used-in-pattern.rs:7:9
|
LL | C => {}
| ^
error: aborting due to 2 previous errors

View file

@ -21,7 +21,6 @@ fn main() {
match WRAP_DIRECT_INLINE { match WRAP_DIRECT_INLINE {
WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
_ => { println!("WRAP_DIRECT_INLINE did not match itself"); } _ => { println!("WRAP_DIRECT_INLINE did not match itself"); }
} }
} }

View file

@ -4,11 +4,5 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be ann
LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: aborting due to previous error
--> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9
|
LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -21,7 +21,6 @@ fn main() {
match WRAP_DIRECT_PARAM { match WRAP_DIRECT_PARAM {
WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
_ => { println!("WRAP_DIRECT_PARAM did not match itself"); } _ => { println!("WRAP_DIRECT_PARAM did not match itself"); }
} }
} }

View file

@ -4,11 +4,5 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be ann
LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` error: aborting due to previous error
--> $DIR/cant-hide-behind-direct-struct-param.rs:22:9
|
LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
| ^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -12,7 +12,6 @@ fn main() {
match y { match y {
FOO => { } FOO => { }
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
_ => { } _ => { }
} }

View file

@ -5,7 +5,7 @@ LL | FOO => { }
| ^^^ | ^^^
warning: floating-point types cannot be used in patterns warning: floating-point types cannot be used in patterns
--> $DIR/match-forbidden-without-eq.rs:21:9 --> $DIR/match-forbidden-without-eq.rs:20:9
| |
LL | f32::INFINITY => { } LL | f32::INFINITY => { }
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
@ -14,14 +14,8 @@ LL | f32::INFINITY => { }
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/match-forbidden-without-eq.rs:13:9
|
LL | FOO => { }
| ^^^
warning: floating-point types cannot be used in patterns warning: floating-point types cannot be used in patterns
--> $DIR/match-forbidden-without-eq.rs:21:9 --> $DIR/match-forbidden-without-eq.rs:20:9
| |
LL | f32::INFINITY => { } LL | f32::INFINITY => { }
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
@ -29,5 +23,5 @@ LL | f32::INFINITY => { }
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
error: aborting due to 2 previous errors; 2 warnings emitted error: aborting due to previous error; 2 warnings emitted

View file

@ -15,6 +15,5 @@ fn main() {
match [B(1)] { match [B(1)] {
FOO => { } FOO => { }
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
} }
} }

View file

@ -4,11 +4,5 @@ error: to use a constant of type `B` in a pattern, `B` must be annotated with `#
LL | FOO => { } LL | FOO => { }
| ^^^ | ^^^
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` error: aborting due to previous error
--> $DIR/match-nonempty-array-forbidden-without-eq.rs:16:9
|
LL | FOO => { }
| ^^^
error: aborting due to 2 previous errors

View file

@ -16,7 +16,6 @@ fn main() {
match y { match y {
FOO => { } FOO => { }
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
_ => { } _ => { }
} }
} }

View file

@ -4,11 +4,5 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit
LL | FOO => { } LL | FOO => { }
| ^^^ | ^^^
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` error: aborting due to previous error
--> $DIR/match-requires-both-partialeq-and-eq.rs:17:9
|
LL | FOO => { }
| ^^^
error: aborting due to 2 previous errors

View file

@ -13,7 +13,6 @@ fn leak_free_test() {
match todo!() { match todo!() {
LEAK_FREE => (), LEAK_FREE => (),
//~^ `impl Send` cannot be used in patterns //~^ `impl Send` cannot be used in patterns
//~| `impl Send` cannot be used in patterns
_ => (), _ => (),
} }
} }

View file

@ -4,11 +4,5 @@ error: `impl Send` cannot be used in patterns
LL | LEAK_FREE => (), LL | LEAK_FREE => (),
| ^^^^^^^^^ | ^^^^^^^^^
error: `impl Send` cannot be used in patterns error: aborting due to previous error
--> $DIR/structural-match-no-leak.rs:14:9
|
LL | LEAK_FREE => (),
| ^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -14,7 +14,6 @@ fn test() {
match todo!() { match todo!() {
VALUE => (), VALUE => (),
//~^ `impl Send` cannot be used in patterns //~^ `impl Send` cannot be used in patterns
//~| `impl Send` cannot be used in patterns
_ => (), _ => (),
} }
} }

View file

@ -4,11 +4,5 @@ error: `impl Send` cannot be used in patterns
LL | VALUE => (), LL | VALUE => (),
| ^^^^^ | ^^^^^
error: `impl Send` cannot be used in patterns error: aborting due to previous error
--> $DIR/structural-match.rs:15:9
|
LL | VALUE => (),
| ^^^^^
error: aborting due to 2 previous errors

View file

@ -8,7 +8,6 @@ const C: U = U { a: 10 };
fn main() { fn main() {
match C { match C {
C => {} //~ ERROR cannot use unions in constant patterns C => {} //~ ERROR cannot use unions in constant patterns
//~| ERROR cannot use unions in constant patterns
_ => {} _ => {}
} }
} }

View file

@ -4,11 +4,5 @@ error: cannot use unions in constant patterns
LL | C => {} LL | C => {}
| ^ | ^
error: cannot use unions in constant patterns error: aborting due to previous error
--> $DIR/union-const-pat.rs:10:9
|
LL | C => {}
| ^
error: aborting due to 2 previous errors