Auto merge of #70743 - oli-obk:eager_const_to_pat_conversion, r=eddyb

Fully destructure constants into patterns

r? `@varkor`

as discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/constants.20in.20patterns/near/192789924

we should probably crater it once reviewed
This commit is contained in:
bors 2020-09-26 06:44:28 +00:00
commit fd15e6180d
66 changed files with 796 additions and 435 deletions

View file

@ -12,7 +12,6 @@ fn main() {
match None {
consts::SOME => panic!(),
//~^ must be annotated with `#[derive(PartialEq, Eq)]`
//~| must be annotated with `#[derive(PartialEq, Eq)]`
_ => {}
}
@ -20,7 +19,6 @@ fn main() {
match None {
<Defaulted as consts::AssocConst>::SOME => panic!(),
//~^ 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)]`
--> $DIR/cross-crate-fail.rs:21:9
--> $DIR/cross-crate-fail.rs:20:9
|
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)]`
--> $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
error: aborting due to 2 previous errors

View file

@ -1,8 +1,5 @@
// check-pass
#![warn(indirect_structural_match)]
//~^ NOTE lint level is defined here
struct CustomEq;
impl Eq for CustomEq {}
@ -32,7 +29,8 @@ fn main() {
BAR_BAZ => panic!(),
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
//~| WARN this was previously accepted
//~| NOTE see issue #62411
//~| NOTE see issue #73448
//~| NOTE `#[warn(nontrivial_structural_match)]` on by default
_ => {}
}
}

View file

@ -1,16 +1,12 @@
warning: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/custom-eq-branch-warn.rs:32:9
warning: to use a constant of type `CustomEq` in a pattern, the constant's initializer must be trivial or `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/custom-eq-branch-warn.rs:29:9
|
LL | BAR_BAZ => panic!(),
| ^^^^^^^
|
note: the lint level is defined here
--> $DIR/custom-eq-branch-warn.rs:3:9
|
LL | #![warn(indirect_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(nontrivial_structural_match)]` on by default
= 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 #73448 <https://github.com/rust-lang/rust/issues/73448>
warning: 1 warning emitted

View file

@ -1,9 +1,7 @@
// FIXME: This still ICEs.
//
// ignore-test
#![deny(indirect_structural_match)]
// check-pass
#[derive(PartialEq, Eq)]
enum O<T> {
Some(*const T), // Can also use PhantomData<T>

View file

@ -1,15 +0,0 @@
error[E0601]: `main` function not found in crate `issue_65466`
--> $DIR/issue-65466.rs:1:1
|
LL | / #![deny(indirect_structural_match)]
LL | |
LL | | #[derive(PartialEq, Eq)]
LL | | enum O<T> {
... |
LL | | }
LL | | }
| |_^ consider adding a `main` function to `$DIR/issue-65466.rs`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0601`.

View file

@ -20,7 +20,6 @@ fn main() {
match Foo::Qux(NoEq) {
BAR_BAZ => panic!(),
//~^ 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!(),
| ^^^^^^^
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/no-eq-branch-fail.rs:21:9
|
LL | BAR_BAZ => panic!(),
| ^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to previous error

View file

@ -39,51 +39,41 @@ fn main() {
const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
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)]`
const FIELD: OND = TrivialEq(Some(NoDerive)).0;
match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const NO_DERIVE_SOME: OND = Some(NoDerive);
const INDIRECT: OND = NO_DERIVE_SOME;
match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const TUPLE: (OND, OND) = (None, Some(NoDerive));
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)]`
const TYPE_ASCRIPTION: OND = Some(NoDerive): OND;
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)]`
const ARRAY: [OND; 2] = [None, Some(NoDerive)];
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)]`
const REPEAT: [OND; 2] = [Some(NoDerive); 2];
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)]`
trait Trait: Sized { const ASSOC: Option<Self>; }
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
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)]`
const BLOCK: OND = { NoDerive; Some(NoDerive) };
match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
const ADDR_OF: &OND = &Some(NoDerive);
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)]`
--> $DIR/reject_non_structural.rs:45:28
--> $DIR/reject_non_structural.rs:44: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
--> $DIR/reject_non_structural.rs:49: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
--> $DIR/reject_non_structural.rs:53: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
--> $DIR/reject_non_structural.rs:57: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
--> $DIR/reject_non_structural.rs:61: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
--> $DIR/reject_non_structural.rs:65: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
--> $DIR/reject_non_structural.rs:65: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
--> $DIR/reject_non_structural.rs:71: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
--> $DIR/reject_non_structural.rs:75:28
|
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)]`
--> $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"), };
| ^^^^^^^
@ -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!
= 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)]`
--> $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
error: aborting due to 10 previous errors; 1 warning emitted

View file

@ -1,34 +1,30 @@
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, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/warn_corner_cases.rs:26:47
|
LL | match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), };
| ^^^^^
|
note: the lint level is defined here
--> $DIR/warn_corner_cases.rs:15:9
|
LL | #![warn(indirect_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(nontrivial_structural_match)]` on by default
= 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 #73448 <https://github.com/rust-lang/rust/issues/73448>
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, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/warn_corner_cases.rs:32:47
|
LL | match None { Some(_) => panic!("whoops"), CALL => dbg!(CALL), };
| ^^^^
|
= 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 #73448 <https://github.com/rust-lang/rust/issues/73448>
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, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/warn_corner_cases.rs:38:47
|
LL | match None { Some(_) => panic!("whoops"), METHOD_CALL => dbg!(METHOD_CALL), };
| ^^^^^^^^^^^
|
= 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 #73448 <https://github.com/rust-lang/rust/issues/73448>
warning: 3 warnings emitted

View file

@ -19,8 +19,6 @@ pub fn main() {
assert_eq!(y, 2);
let z = match &() {
ZST => 9,
// FIXME: this should not be required
_ => 42,
};
assert_eq!(z, 9);
let z = match b"" {

View file

@ -9,11 +9,10 @@ fn main() {
const C: &S = &S;
match C {
C => {}
//~^ ERROR to use a constant of type `S` in a pattern, `S` must be annotated with
//~| ERROR to use a constant of type `S` in a pattern, `S` must be annotated with
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
}
const K: &T = &T;
match K { //~ ERROR non-exhaustive patterns: `&T` not covered
match K {
K => {}
}
}

View file

@ -4,24 +4,5 @@ error: to use a constant of type `S` in a pattern, `S` must be annotated with `#
LL | C => {}
| ^
error[E0004]: non-exhaustive patterns: `&T` not covered
--> $DIR/match_ice.rs:16:11
|
LL | struct T;
| --------- `T` defined here
...
LL | match K {
| ^ pattern `&T` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&T`
error: aborting due to previous error
error: to use a constant of type `S` in a pattern, `S` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/match_ice.rs:11:9
|
LL | C => {}
| ^
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0004`.

View file

@ -1,4 +1,6 @@
// run-pass
#![warn(pointer_structural_match)]
#![allow(dead_code)]
const C: *const u8 = &0;

View file

@ -1,4 +1,7 @@
// run-pass
#![warn(pointer_structural_match)]
type Func = fn(usize, usize) -> usize;
fn foo(a: usize, b: usize) -> usize { a + b }
@ -13,8 +16,10 @@ const BAR: Func = bar;
fn main() {
match test(std::env::consts::ARCH.len()) {
FOO => println!("foo"),
BAR => println!("bar"),
FOO => println!("foo"), //~ WARN pointers in patterns behave unpredictably
//~^ WARN will become a hard error
BAR => println!("bar"), //~ WARN pointers in patterns behave unpredictably
//~^ WARN will become a hard error
_ => unreachable!(),
}
}

View file

@ -0,0 +1,25 @@
warning: function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
--> $DIR/issue-44333.rs:19:9
|
LL | FOO => println!("foo"),
| ^^^
|
note: the lint level is defined here
--> $DIR/issue-44333.rs:3:9
|
LL | #![warn(pointer_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!
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
warning: function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
--> $DIR/issue-44333.rs:21:9
|
LL | BAR => println!("bar"),
| ^^^
|
= 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/70861>
warning: 2 warnings emitted

View file

@ -4,7 +4,7 @@ fn main() {
let a: &dyn Send = &7u32;
match a {
F => panic!(),
//~^ ERROR trait objects cannot be used in patterns
//~^ ERROR `&dyn Send` cannot be used in patterns
_ => {}
}
}

View file

@ -1,4 +1,4 @@
error: trait objects cannot be used in patterns
error: `&dyn Send` cannot be used in patterns
--> $DIR/issue-70972-dyn-trait.rs:6:9
|
LL | F => panic!(),

View file

@ -0,0 +1,46 @@
// run-pass
fn main() {
match b"." as &[u8] {
b"." if true => {},
b"." => panic!(),
b".." => panic!(),
b"" => panic!(),
_ => panic!(),
}
match b"." as &[u8] {
b"." if false => panic!(),
b"." => {},
b".." => panic!(),
b"" => panic!(),
_ => panic!(),
}
match b".." as &[u8] {
b"." if true => panic!(), // the miscompile caused this arm to be reached
b"." => panic!(),
b".." => {},
b"" => panic!(),
_ => panic!(),
}
match b".." as &[u8] {
b"." if false => panic!(),
b"." => panic!(),
b".." => {},
b"" => panic!(),
_ => panic!(),
}
match b"" as &[u8] {
b"." if true => panic!(),
b"." => panic!(),
b".." => panic!(),
b"" => {},
_ => panic!(),
}
match b"" as &[u8] {
b"." if false => panic!(),
b"." => panic!(),
b".." => panic!(),
b"" => {},
_ => panic!(),
}
}

View file

@ -1,10 +1,4 @@
// failure-status: 101
// rustc-env:RUST_BACKTRACE=0
// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET"
// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS"
// normalize-stderr-test "/_match.rs:[0-9]+:[0-9]+" -> "/_match.rs:LL:CC"
// This is a repro test for an ICE in our pattern handling of constants.
// check-pass
const FOO: &&&u32 = &&&42;

View file

@ -1,13 +0,0 @@
thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', compiler/rustc_mir_build/src/thir/pattern/_match.rs:LL:CC
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc VERSION running on TARGET
note: compiler flags: FLAGS

View file

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

View file

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

View file

@ -160,7 +160,7 @@ fn main() {
match &0 {
&42 => {}
&FOO => {} //~ ERROR unreachable pattern
BAR => {} // Not detected as unreachable because `try_eval_bits` fails on `BAR`.
BAR => {} //~ ERROR unreachable pattern
_ => {}
}

View file

@ -135,6 +135,12 @@ error: unreachable pattern
LL | &FOO => {}
| ^^^^
error: aborting due to 15 previous errors
error: unreachable pattern
--> $DIR/exhaustive_integer_patterns.rs:163:9
|
LL | BAR => {}
| ^^^
error: aborting due to 16 previous errors
For more information about this error, try `rustc --explain E0004`.

View file

@ -6,19 +6,19 @@ fn main() {
match s {
MAGIC_TEST => (),
[0x00, 0x00, 0x00, 0x00] => (),
[4, 5, 6, 7] => (), // FIXME(oli-obk): this should warn, but currently does not
[4, 5, 6, 7] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
MAGIC_TEST => (),
[4, 5, 6, 7] => (), // FIXME(oli-obk): this should warn, but currently does not
[4, 5, 6, 7] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
[4, 5, 6, 7] => (),
MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
MAGIC_TEST => (), //~ ERROR unreachable pattern
_ => (),
}
const FOO: [u32; 1] = [4];

View file

@ -1,8 +1,8 @@
error: unreachable pattern
--> $DIR/slice-pattern-const-2.rs:28:9
--> $DIR/slice-pattern-const-2.rs:9:9
|
LL | FOO => (),
| ^^^
LL | [4, 5, 6, 7] => (),
| ^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/slice-pattern-const-2.rs:1:9
@ -10,5 +10,23 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: unreachable pattern
--> $DIR/slice-pattern-const-2.rs:15:9
|
LL | [4, 5, 6, 7] => (),
| ^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/slice-pattern-const-2.rs:21:9
|
LL | MAGIC_TEST => (),
| ^^^^^^^^^^
error: unreachable pattern
--> $DIR/slice-pattern-const-2.rs:28:9
|
LL | FOO => (),
| ^^^
error: aborting due to 4 previous errors

View file

@ -6,19 +6,19 @@ fn main() {
match s {
MAGIC_TEST => (),
["0x00", "0x00", "0x00", "0x00"] => (),
["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
["4", "5", "6", "7"] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
["0x00", "0x00", "0x00", "0x00"] => (),
MAGIC_TEST => (),
["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
["4", "5", "6", "7"] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
["0x00", "0x00", "0x00", "0x00"] => (),
["4", "5", "6", "7"] => (),
MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
MAGIC_TEST => (), //~ ERROR unreachable pattern
_ => (),
}
const FOO: [&str; 1] = ["boo"];

View file

@ -1,8 +1,8 @@
error: unreachable pattern
--> $DIR/slice-pattern-const-3.rs:28:9
--> $DIR/slice-pattern-const-3.rs:9:9
|
LL | FOO => (),
| ^^^
LL | ["4", "5", "6", "7"] => (),
| ^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/slice-pattern-const-3.rs:1:9
@ -10,5 +10,23 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: unreachable pattern
--> $DIR/slice-pattern-const-3.rs:15:9
|
LL | ["4", "5", "6", "7"] => (),
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/slice-pattern-const-3.rs:21:9
|
LL | MAGIC_TEST => (),
| ^^^^^^^^^^
error: unreachable pattern
--> $DIR/slice-pattern-const-3.rs:28:9
|
LL | FOO => (),
| ^^^
error: aborting due to 4 previous errors

View file

@ -6,15 +6,15 @@ fn main() {
let s10: &[bool; 10] = &[false; 10];
match s2 {
//~^ ERROR `&[false, _]` not covered
//~^ ERROR `&[false, _]` not covered
[true, .., true] => {}
}
match s3 {
//~^ ERROR `&[false, ..]` not covered
//~^ ERROR `&[false, ..]` not covered
[true, .., true] => {}
}
match s10 {
//~^ ERROR `&[false, ..]` not covered
//~^ ERROR `&[false, ..]` not covered
[true, .., true] => {}
}
@ -23,58 +23,58 @@ fn main() {
[.., false] => {}
}
match s2 {
//~^ ERROR `&[false, true]` not covered
//~^ ERROR `&[false, true]` not covered
[true, ..] => {}
[.., false] => {}
}
match s3 {
//~^ ERROR `&[false, .., true]` not covered
//~^ ERROR `&[false, .., true]` not covered
[true, ..] => {}
[.., false] => {}
}
match s {
//~^ ERROR `&[false, .., true]` not covered
//~^ ERROR `&[false, .., true]` not covered
[] => {}
[true, ..] => {}
[.., false] => {}
}
match s {
//~^ ERROR `&[_, ..]` not covered
//~^ ERROR `&[_, ..]` not covered
[] => {}
}
match s {
//~^ ERROR `&[_, _, ..]` not covered
//~^ ERROR `&[_, _, ..]` not covered
[] => {}
[_] => {}
}
match s {
//~^ ERROR `&[false, ..]` not covered
//~^ ERROR `&[false, ..]` not covered
[] => {}
[true, ..] => {}
}
match s {
//~^ ERROR `&[false, _, ..]` not covered
//~^ ERROR `&[false, _, ..]` not covered
[] => {}
[_] => {}
[true, ..] => {}
}
match s {
//~^ ERROR `&[_, .., false]` not covered
//~^ ERROR `&[_, .., false]` not covered
[] => {}
[_] => {}
[.., true] => {}
}
match s {
//~^ ERROR `&[_, _, .., true]` not covered
//~^ ERROR `&[_, _, .., true]` not covered
[] => {}
[_] => {}
[_, _] => {}
[.., false] => {}
}
match s {
//~^ ERROR `&[true, _, .., _]` not covered
//~^ ERROR `&[true, _, .., _]` not covered
[] => {}
[_] => {}
[_, _] => {}
@ -83,19 +83,43 @@ fn main() {
const CONST: &[bool] = &[true];
match s {
//~^ ERROR `&[..]` not covered
//~^ ERROR `&[]` and `&[_, _, ..]` not covered
&[true] => {}
}
match s {
//~^ ERROR `&[]` and `&[_, _, ..]` not covered
CONST => {}
}
match s {
//~^ ERROR `&[true]` not covered
[] => {},
[false] => {},
CONST => {},
//~^ ERROR `&[]` and `&[_, _, ..]` not covered
CONST => {}
&[false] => {}
}
match s {
//~^ ERROR `&[]` and `&[_, _, ..]` not covered
&[false] => {}
CONST => {}
}
match s {
//~^ ERROR `&[_, _, ..]` not covered
&[] => {}
CONST => {}
}
match s {
//~^ ERROR `&[false]` not covered
&[] => {}
CONST => {}
&[_, _, ..] => {}
}
match s {
[] => {}
[false] => {}
CONST => {}
[_, _, ..] => {}
}
const CONST1: &[bool; 1] = &[true];
match s1 {
//~^ ERROR `&[false]` not covered
//~^ ERROR `&[false]` not covered
CONST1 => {}
}
match s1 {

View file

@ -115,26 +115,62 @@ LL | match s {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&[bool]`
error[E0004]: non-exhaustive patterns: `&[..]` not covered
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:85:11
|
LL | match s {
| ^ pattern `&[..]` not covered
| ^ patterns `&[]` and `&[_, _, ..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&[bool]`
error[E0004]: non-exhaustive patterns: `&[true]` not covered
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:89:11
|
LL | match s {
| ^ pattern `&[true]` not covered
| ^ patterns `&[]` and `&[_, _, ..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&[bool]`
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:93:11
|
LL | match s {
| ^ patterns `&[]` and `&[_, _, ..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&[bool]`
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:98:11
|
LL | match s {
| ^ patterns `&[]` and `&[_, _, ..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&[bool]`
error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:103:11
|
LL | match s {
| ^ pattern `&[_, _, ..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&[bool]`
error[E0004]: non-exhaustive patterns: `&[false]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:97:11
--> $DIR/slice-patterns-exhaustiveness.rs:108:11
|
LL | match s {
| ^ pattern `&[false]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&[bool]`
error[E0004]: non-exhaustive patterns: `&[false]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:121:11
|
LL | match s1 {
| ^^ pattern `&[false]` not covered
@ -142,6 +178,6 @@ LL | match s1 {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&[bool; 1]`
error: aborting due to 16 previous errors
error: aborting due to 20 previous errors
For more information about this error, try `rustc --explain E0004`.

View file

@ -3,6 +3,8 @@
// run-pass
#![warn(pointer_structural_match)]
struct NoDerive(i32);
// This impl makes NoDerive irreflexive

View file

@ -3,6 +3,8 @@
// run-pass
#![warn(pointer_structural_match)]
struct NoDerive(i32);
// This impl makes NoDerive irreflexive

View file

@ -3,6 +3,8 @@
// run-pass
#![warn(pointer_structural_match)]
struct NoDerive(i32);
// This impl makes NoDerive irreflexive

View file

@ -3,6 +3,8 @@
// run-pass
#![warn(pointer_structural_match)]
struct NoDerive(i32);
// This impl makes NoDerive irreflexive

View file

@ -21,7 +21,6 @@ fn main() {
match WRAP_DIRECT_INLINE {
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)]`
_ => { 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"); }
| ^^^^^^^^^^^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $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
error: aborting due to previous error

View file

@ -21,7 +21,6 @@ fn main() {
match WRAP_DIRECT_PARAM {
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)]`
_ => { 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"); }
| ^^^^^^^^^^^^^^^^^
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
--> $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
error: aborting due to previous error

View file

@ -23,7 +23,7 @@ fn main() {
match WRAP_DOUBLY_INDIRECT_INLINE {
WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
//~| WARN will become a hard error in a future release
//~| WARN this was previously accepted
_ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); }
}
}

View file

@ -23,7 +23,7 @@ fn main() {
match WRAP_DOUBLY_INDIRECT_PARAM {
WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
//~| WARN will become a hard error in a future release
//~| WARN this was previously accepted
_ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); }
}
}

View file

@ -23,7 +23,7 @@ fn main() {
match WRAP_INDIRECT_INLINE {
WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
//~| WARN will become a hard error in a future release
//~| WARN this was previously accepted
_ => { println!("WRAP_INDIRECT_INLINE did not match itself"); }
}
}

View file

@ -23,7 +23,7 @@ fn main() {
match WRAP_INDIRECT_PARAM {
WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
//~| WARN will become a hard error in a future release
//~| WARN this was previously accepted
_ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); }
}
}

View file

@ -10,7 +10,7 @@
// Issue 62307 pointed out a case where the structural-match checking
// was too shallow.
#![warn(indirect_structural_match)]
#![warn(indirect_structural_match, nontrivial_structural_match)]
// run-pass
#[derive(Debug)]
@ -30,14 +30,14 @@ fn main() {
match RR_B0 {
RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
//~| WARN will become a hard error in a future release
//~| WARN this was previously accepted
_ => { }
}
match RR_B1 {
RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
//~| WARN will become a hard error in a future release
//~| WARN this was previously accepted
_ => { }
}
}

View file

@ -7,7 +7,7 @@ LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0);
note: the lint level is defined here
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:13:9
|
LL | #![warn(indirect_structural_match)]
LL | #![warn(indirect_structural_match, nontrivial_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!
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>

View file

@ -5,6 +5,8 @@
// cover the case this hit; I've since expanded it accordingly, but the
// experience left me wary of leaving this regression test out.)
#![warn(pointer_structural_match)]
#[derive(Eq)]
struct A {
a: i64
@ -31,6 +33,8 @@ fn main() {
let s = B(my_fn);
match s {
B(TEST) => println!("matched"),
//~^ WARN pointers in patterns behave unpredictably
//~| WARN this was previously accepted by the compiler but is being phased out
_ => panic!("didn't match")
};
}

View file

@ -0,0 +1,16 @@
warning: function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
--> $DIR/issue-63479-match-fnptr.rs:35:7
|
LL | B(TEST) => println!("matched"),
| ^^^^
|
note: the lint level is defined here
--> $DIR/issue-63479-match-fnptr.rs:8:9
|
LL | #![warn(pointer_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!
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
warning: 1 warning emitted

View file

@ -12,7 +12,6 @@ fn main() {
match y {
FOO => { }
//~^ 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
--> $DIR/match-forbidden-without-eq.rs:21:9
--> $DIR/match-forbidden-without-eq.rs:20:9
|
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!
= 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
--> $DIR/match-forbidden-without-eq.rs:21:9
--> $DIR/match-forbidden-without-eq.rs:20:9
|
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!
= 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)] {
FOO => { }
//~^ 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 => { }
| ^^^
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/match-nonempty-array-forbidden-without-eq.rs:16:9
|
LL | FOO => { }
| ^^^
error: aborting due to 2 previous errors
error: aborting due to previous error

View file

@ -16,7 +16,6 @@ fn main() {
match y {
FOO => { }
//~^ 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 => { }
| ^^^
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/match-requires-both-partialeq-and-eq.rs:17:9
|
LL | FOO => { }
| ^^^
error: aborting due to 2 previous errors
error: aborting due to previous error

View file

@ -12,9 +12,9 @@ const LEAK_FREE: Bar = leak_free();
fn leak_free_test() {
match todo!() {
LEAK_FREE => (),
//~^ opaque types cannot be used in patterns
//~^ `impl Send` cannot be used in patterns
_ => (),
}
}
fn main() { }
fn main() {}

View file

@ -1,4 +1,4 @@
error: opaque types cannot be used in patterns
error: `impl Send` cannot be used in patterns
--> $DIR/structural-match-no-leak.rs:14:9
|
LL | LEAK_FREE => (),

View file

@ -13,9 +13,9 @@ const VALUE: Foo = value();
fn test() {
match todo!() {
VALUE => (),
//~^ opaque types cannot be used in patterns
//~^ `impl Send` cannot be used in patterns
_ => (),
}
}
fn main() { }
fn main() {}

View file

@ -1,4 +1,4 @@
error: opaque types cannot be used in patterns
error: `impl Send` cannot be used in patterns
--> $DIR/structural-match.rs:15:9
|
LL | VALUE => (),

View file

@ -8,7 +8,6 @@ const C: U = U { a: 10 };
fn main() {
match C {
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 => {}
| ^
error: cannot use unions in constant patterns
--> $DIR/union-const-pat.rs:10:9
|
LL | C => {}
| ^
error: aborting due to 2 previous errors
error: aborting due to previous error