diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 00d9fe72cfcb3..e9c6eb0c724fe 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -191,8 +191,15 @@ impl<'tcx> ConstToPat<'tcx> { } } else { let err = InvalidPattern { span: self.span, non_sm_ty }; - self.tcx().sess.emit_err(err); - return Box::new(Pat { span: self.span, ty: cv.ty(), kind: PatKind::Wild }); + let e = self.tcx().sess.emit_err(err); + let kind = PatKind::Constant { + value: mir::ConstantKind::Ty(ty::Const::new_error( + self.tcx(), + e, + cv.ty(), + )), + }; + return Box::new(Pat { span: self.span, ty: cv.ty(), kind }); } } else if !self.saw_const_match_lint.get() { if let Some(mir_structural_match_violation) = mir_structural_match_violation { @@ -327,15 +334,15 @@ impl<'tcx> ConstToPat<'tcx> { } ty::FnDef(..) => { self.saw_const_match_error.set(true); - tcx.sess.emit_err(InvalidPattern { span, non_sm_ty: ty }); - PatKind::Wild + let e = tcx.sess.emit_err(InvalidPattern { span, non_sm_ty: ty }); + PatKind::Constant { value: mir::ConstantKind::Ty(ty::Const::new_error(tcx, e, ty)) } } ty::Adt(adt_def, _) if !self.type_marked_structural(ty) => { debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty,); self.saw_const_match_error.set(true); let err = TypeNotStructural { span, non_sm_ty: ty }; - tcx.sess.emit_err(err); - PatKind::Wild + let e = tcx.sess.emit_err(err); + PatKind::Constant { value: mir::ConstantKind::Ty(ty::Const::new_error(tcx, e, ty)) } } ty::Adt(adt_def, args) if adt_def.is_enum() => { let (&variant_index, fields) = cv.unwrap_branch().split_first().unwrap(); @@ -406,12 +413,18 @@ impl<'tcx> ConstToPat<'tcx> { } return Err(FallbackToConstRef); } else { - if !self.saw_const_match_error.get() { + if self.saw_const_match_error.get() { + PatKind::Constant { + value: mir::ConstantKind::Ty(ty::Const::new_misc_error(tcx, ty)), + } + } else { self.saw_const_match_error.set(true); let err = TypeNotStructural { span, non_sm_ty: *pointee_ty }; - tcx.sess.emit_err(err); + let e = tcx.sess.emit_err(err); + PatKind::Constant { + value: mir::ConstantKind::Ty(ty::Const::new_error(tcx, e, ty)), + } } - PatKind::Wild } } // All other references are converted into deref patterns and then recursively @@ -420,10 +433,10 @@ impl<'tcx> ConstToPat<'tcx> { _ => { if !pointee_ty.is_sized(tcx, param_env) && !pointee_ty.is_slice() { let err = UnsizedPattern { span, non_sm_ty: *pointee_ty }; - tcx.sess.emit_err(err); - - // FIXME: introduce PatKind::Error to silence follow up diagnostics due to unreachable patterns. - PatKind::Wild + let e = tcx.sess.emit_err(err); + PatKind::Constant { + value: mir::ConstantKind::Ty(ty::Const::new_error(tcx, e, ty)), + } } else { let old = self.behind_reference.replace(true); // `b"foo"` produces a `&[u8; 3]`, but you can't use constants of array type when @@ -452,8 +465,8 @@ impl<'tcx> ConstToPat<'tcx> { _ => { self.saw_const_match_error.set(true); let err = InvalidPattern { span, non_sm_ty: ty }; - tcx.sess.emit_err(err); - PatKind::Wild + let e = tcx.sess.emit_err(err); + PatKind::Constant { value: mir::ConstantKind::Ty(ty::Const::new_error(tcx, e, ty)) } } }; diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr index 8cbd12654480a..69bc174b6beeb 100644 --- a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr +++ b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr @@ -7,5 +7,17 @@ LL | WHAT_A_TYPE => 0, = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -error: aborting due to previous error +error[E0015]: cannot match on `TypeId` in constant functions + --> $DIR/typeid-equality-by-subtyping.rs:18:9 + | +LL | WHAT_A_TYPE => 0, + | ^^^^^^^^^^^ + | + = note: `TypeId` cannot be compared in compile-time, and therefore cannot be used in `match`es +note: impl defined here, but it is not `const` + --> $SRC_DIR/core/src/any.rs:LL:COL + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const_in_pattern/issue-78057.rs b/tests/ui/consts/const_in_pattern/issue-78057.rs index 69cf8404da18e..88b5d68cb6017 100644 --- a/tests/ui/consts/const_in_pattern/issue-78057.rs +++ b/tests/ui/consts/const_in_pattern/issue-78057.rs @@ -12,6 +12,5 @@ fn main() { FOO => {}, //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` _ => {} - //~^ ERROR unreachable pattern } } diff --git a/tests/ui/consts/const_in_pattern/issue-78057.stderr b/tests/ui/consts/const_in_pattern/issue-78057.stderr index df155bdb625e6..5ec68719a9732 100644 --- a/tests/ui/consts/const_in_pattern/issue-78057.stderr +++ b/tests/ui/consts/const_in_pattern/issue-78057.stderr @@ -7,20 +7,5 @@ LL | FOO => {}, = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -error: unreachable pattern - --> $DIR/issue-78057.rs:14:9 - | -LL | FOO => {}, - | --- matches any value -LL | -LL | _ => {} - | ^ unreachable pattern - | -note: the lint level is defined here - --> $DIR/issue-78057.rs:1:9 - | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/consts/match_ice.rs b/tests/ui/consts/match_ice.rs index 632335c841e3a..bb31fe2212616 100644 --- a/tests/ui/consts/match_ice.rs +++ b/tests/ui/consts/match_ice.rs @@ -7,7 +7,7 @@ struct T; fn main() { const C: &S = &S; - match C { + match C { //~ ERROR: non-exhaustive patterns: `&_` not covered C => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` } diff --git a/tests/ui/consts/match_ice.stderr b/tests/ui/consts/match_ice.stderr index 342d94ed31c87..cb0d22303ac89 100644 --- a/tests/ui/consts/match_ice.stderr +++ b/tests/ui/consts/match_ice.stderr @@ -7,5 +7,24 @@ LL | C => {} = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -error: aborting due to previous error +error[E0004]: non-exhaustive patterns: `&_` not covered + --> $DIR/match_ice.rs:10:11 + | +LL | match C { + | ^ pattern `&_` not covered + | +note: `S` defined here + --> $DIR/match_ice.rs:3:8 + | +LL | struct S; + | ^ + = note: the matched value is of type `&S` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ C => {}, +LL + &_ => todo!() + | + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/issue-72565.rs b/tests/ui/pattern/issue-72565.rs index 21edb26de082e..a9a5427d2ca5b 100644 --- a/tests/ui/pattern/issue-72565.rs +++ b/tests/ui/pattern/issue-72565.rs @@ -2,7 +2,7 @@ const F: &'static dyn PartialEq = &7u32; fn main() { let a: &dyn PartialEq = &7u32; - match a { + match a { //~ ERROR: non-exhaustive patterns: `&_` not covered F => panic!(), //~ ERROR: `dyn PartialEq` cannot be used in patterns } } diff --git a/tests/ui/pattern/issue-72565.stderr b/tests/ui/pattern/issue-72565.stderr index 0519720694d70..fc9ffc0630115 100644 --- a/tests/ui/pattern/issue-72565.stderr +++ b/tests/ui/pattern/issue-72565.stderr @@ -4,5 +4,18 @@ error: `dyn PartialEq` cannot be used in patterns LL | F => panic!(), | ^ -error: aborting due to previous error +error[E0004]: non-exhaustive patterns: `&_` not covered + --> $DIR/issue-72565.rs:5:11 + | +LL | match a { + | ^ pattern `&_` not covered + | + = note: the matched value is of type `&dyn PartialEq` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | F => panic!(), &_ => todo!(), + | +++++++++++++++ + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/non-structural-match-types.rs b/tests/ui/pattern/non-structural-match-types.rs index 5c33154736650..e822a402931b8 100644 --- a/tests/ui/pattern/non-structural-match-types.rs +++ b/tests/ui/pattern/non-structural-match-types.rs @@ -5,10 +5,10 @@ #![feature(inline_const_pat)] fn main() { - match loop {} { + match loop {} { //~ ERROR: non-exhaustive patterns: `_` not covered const { || {} } => {}, //~ ERROR cannot be used in patterns } - match loop {} { + match loop {} { //~ ERROR: non-exhaustive patterns: `_` not covered const { async {} } => {}, //~ ERROR cannot be used in patterns } } diff --git a/tests/ui/pattern/non-structural-match-types.stderr b/tests/ui/pattern/non-structural-match-types.stderr index dea7c4695cc18..ff65438d61d50 100644 --- a/tests/ui/pattern/non-structural-match-types.stderr +++ b/tests/ui/pattern/non-structural-match-types.stderr @@ -10,5 +10,30 @@ error: `[async block@$DIR/non-structural-match-types.rs:12:17: 12:25]` cannot be LL | const { async {} } => {}, | ^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/non-structural-match-types.rs:8:11 + | +LL | match loop {} { + | ^^^^^^^ pattern `_` not covered + | + = note: the matched value is of type `[closure@$DIR/non-structural-match-types.rs:9:17: 9:19]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | const { || {} } => {}, _ => todo!(), + | ++++++++++++++ + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/non-structural-match-types.rs:11:11 + | +LL | match loop {} { + | ^^^^^^^ pattern `_` not covered + | + = note: the matched value is of type `[async block@$DIR/non-structural-match-types.rs:12:17: 12:25]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | const { async {} } => {}, _ => todo!(), + | ++++++++++++++ + +error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/consts-opaque.rs b/tests/ui/pattern/usefulness/consts-opaque.rs index c10c6205a084b..2032cf13bc26e 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.rs +++ b/tests/ui/pattern/usefulness/consts-opaque.rs @@ -30,15 +30,13 @@ fn main() { match FOO { FOO => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - _ => {} // should not be emitting unreachable warning - //~^ ERROR unreachable pattern + _ => {} } match FOO_REF { FOO_REF => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - Foo(_) => {} // should not be emitting unreachable warning - //~^ ERROR unreachable pattern + Foo(_) => {} } // This used to cause an ICE (https://github.com/rust-lang/rust/issues/78071) @@ -51,9 +49,8 @@ fn main() { match BAR { Bar => {} - BAR => {} // should not be emitting unreachable warning + BAR => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - //~| ERROR unreachable pattern _ => {} //~^ ERROR unreachable pattern } @@ -61,8 +58,7 @@ fn main() { match BAR { BAR => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - Bar => {} // should not be emitting unreachable warning - //~^ ERROR unreachable pattern + Bar => {} _ => {} //~^ ERROR unreachable pattern } @@ -70,20 +66,16 @@ fn main() { match BAR { BAR => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - BAR => {} // should not be emitting unreachable warning + BAR => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - //~| ERROR unreachable pattern - _ => {} // should not be emitting unreachable warning - //~^ ERROR unreachable pattern + _ => {} } match BAZ { BAZ => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - Baz::Baz1 => {} // should not be emitting unreachable warning - //~^ ERROR unreachable pattern + Baz::Baz1 => {} _ => {} - //~^ ERROR unreachable pattern } match BAZ { @@ -91,16 +83,13 @@ fn main() { BAZ => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` _ => {} - //~^ ERROR unreachable pattern } match BAZ { BAZ => {} //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - Baz::Baz2 => {} // should not be emitting unreachable warning - //~^ ERROR unreachable pattern - _ => {} // should not be emitting unreachable warning - //~^ ERROR unreachable pattern + Baz::Baz2 => {} + _ => {} } type Quux = fn(usize, usize) -> usize; diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr index e01b06ccc82e4..cd88e6a22e4a5 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.stderr +++ b/tests/ui/pattern/usefulness/consts-opaque.stderr @@ -8,7 +8,7 @@ LL | FOO => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:38:9 + --> $DIR/consts-opaque.rs:37:9 | LL | FOO_REF => {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | FOO_REF => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details warning: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:46:9 + --> $DIR/consts-opaque.rs:44:9 | LL | FOO_REF_REF => {} | ^^^^^^^^^^^ @@ -29,16 +29,16 @@ LL | FOO_REF_REF => {} = note: `#[warn(indirect_structural_match)]` on by default error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:54:9 + --> $DIR/consts-opaque.rs:52:9 | -LL | BAR => {} // should not be emitting unreachable warning +LL | BAR => {} | ^^^ | = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:62:9 + --> $DIR/consts-opaque.rs:59:9 | LL | BAR => {} | ^^^ @@ -47,7 +47,7 @@ LL | BAR => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:71:9 + --> $DIR/consts-opaque.rs:67:9 | LL | BAR => {} | ^^^ @@ -56,16 +56,16 @@ LL | BAR => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:73:9 + --> $DIR/consts-opaque.rs:69:9 | -LL | BAR => {} // should not be emitting unreachable warning +LL | BAR => {} | ^^^ | = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:81:9 + --> $DIR/consts-opaque.rs:75:9 | LL | BAZ => {} | ^^^ @@ -74,7 +74,7 @@ LL | BAZ => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:91:9 + --> $DIR/consts-opaque.rs:83:9 | LL | BAZ => {} | ^^^ @@ -83,7 +83,7 @@ LL | BAZ => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:98:9 + --> $DIR/consts-opaque.rs:89:9 | LL | BAZ => {} | ^^^ @@ -92,12 +92,12 @@ LL | BAZ => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: unreachable pattern - --> $DIR/consts-opaque.rs:33:9 + --> $DIR/consts-opaque.rs:54:9 | -LL | FOO => {} +LL | Bar => {} | --- matches any value -LL | -LL | _ => {} // should not be emitting unreachable warning +... +LL | _ => {} | ^ unreachable pattern | note: the lint level is defined here @@ -107,120 +107,21 @@ LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/consts-opaque.rs:40:9 - | -LL | FOO_REF => {} - | ------- matches any value -LL | -LL | Foo(_) => {} // should not be emitting unreachable warning - | ^^^^^^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:54:9 - | -LL | Bar => {} - | --- matches any value -LL | BAR => {} // should not be emitting unreachable warning - | ^^^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:57:9 + --> $DIR/consts-opaque.rs:62:9 | LL | Bar => {} | --- matches any value -... -LL | _ => {} - | ^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:64:9 - | -LL | BAR => {} - | --- matches any value -LL | -LL | Bar => {} // should not be emitting unreachable warning - | ^^^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:66:9 - | -LL | BAR => {} - | --- matches any value -... -LL | _ => {} - | ^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:73:9 - | -LL | BAR => {} - | --- matches any value -LL | -LL | BAR => {} // should not be emitting unreachable warning - | ^^^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:76:9 - | -LL | BAR => {} - | --- matches any value -... -LL | _ => {} // should not be emitting unreachable warning - | ^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:83:9 - | -LL | BAZ => {} - | --- matches any value -LL | -LL | Baz::Baz1 => {} // should not be emitting unreachable warning - | ^^^^^^^^^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:85:9 - | -LL | BAZ => {} - | --- matches any value -... -LL | _ => {} - | ^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:93:9 - | -LL | BAZ => {} - | --- matches any value -LL | LL | _ => {} | ^ unreachable pattern -error: unreachable pattern - --> $DIR/consts-opaque.rs:100:9 - | -LL | BAZ => {} - | --- matches any value -LL | -LL | Baz::Baz2 => {} // should not be emitting unreachable warning - | ^^^^^^^^^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:102:9 - | -LL | BAZ => {} - | --- matches any value -... -LL | _ => {} // should not be emitting unreachable warning - | ^ unreachable pattern - error[E0004]: non-exhaustive patterns: `Wrap(_)` not covered - --> $DIR/consts-opaque.rs:135:11 + --> $DIR/consts-opaque.rs:124:11 | LL | match WRAPQUUX { | ^^^^^^^^ pattern `Wrap(_)` not covered | note: `Wrap usize>` defined here - --> $DIR/consts-opaque.rs:117:12 + --> $DIR/consts-opaque.rs:106:12 | LL | struct Wrap(T); | ^^^^ @@ -231,6 +132,6 @@ LL ~ WRAPQUUX => {}, LL + Wrap(_) => todo!() | -error: aborting due to 23 previous errors; 1 warning emitted +error: aborting due to 12 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs index 151a475c91906..91a5e5a58e1dc 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs @@ -12,7 +12,7 @@ struct B(i32); fn main() { const FOO: [B; 1] = [B(0)]; - match [B(1)] { + match [B(1)] { //~ ERROR: non-exhaustive patterns: `[_]` not covered FOO => { } //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr index 6adebada0437d..5b81af98dfa88 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr @@ -7,5 +7,19 @@ LL | FOO => { } = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -error: aborting due to previous error +error[E0004]: non-exhaustive patterns: `[_]` not covered + --> $DIR/match-nonempty-array-forbidden-without-eq.rs:15:11 + | +LL | match [B(1)] { + | ^^^^^^ pattern `[_]` not covered + | + = note: the matched value is of type `[B; 1]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ FOO => { }, +LL + [_] => todo!() + | + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0004`.