diff options
Diffstat (limited to '')
9 files changed, 38 insertions, 33 deletions
diff --git a/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.rs b/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.rs index d9657bac7..5dce8180f 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.rs @@ -1,5 +1,4 @@ // aux-build:enums.rs -// run-pass extern crate enums; @@ -7,11 +6,6 @@ use enums::FieldLessWithNonExhaustiveVariant; fn main() { let e = FieldLessWithNonExhaustiveVariant::default(); - // FIXME: https://github.com/rust-lang/rust/issues/91161 - // This `as` cast *should* be an error, since it would fail - // if the non-exhaustive variant got fields. But today it - // doesn't. The fix for that will update this test to - // show an error (and not be run-pass any more). - let d = e as u8; + let d = e as u8; //~ ERROR casting `FieldLessWithNonExhaustiveVariant` as `u8` is invalid [E0606] assert_eq!(d, 0); } diff --git a/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.stderr b/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.stderr new file mode 100644 index 000000000..a61dcf839 --- /dev/null +++ b/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.stderr @@ -0,0 +1,11 @@ +error[E0606]: casting `FieldLessWithNonExhaustiveVariant` as `u8` is invalid + --> $DIR/enum-as-cast.rs:9:13 + | +LL | let d = e as u8; + | ^^^^^^^ + | + = note: cannot cast an enum with a non-exhaustive variant when it's defined in another crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0606`. diff --git a/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs b/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs index 70253a4fc..69a283c31 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs @@ -31,7 +31,7 @@ fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) { fn main() { match NonExhaustiveEnum::Unit {} - //~^ ERROR `Unit`, `Tuple(_)` and `Struct { .. }` not covered [E0004] + //~^ ERROR `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered [E0004] match NormalEnum::Unit {} - //~^ ERROR `Unit`, `Tuple(_)` and `Struct { .. }` not covered [E0004] + //~^ ERROR `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered [E0004] } diff --git a/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr b/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr index 1f2090448..de1bf8be8 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr @@ -10,11 +10,11 @@ note: the lint level is defined here LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ -error[E0004]: non-exhaustive patterns: `Unit`, `Tuple(_)` and `Struct { .. }` not covered +error[E0004]: non-exhaustive patterns: `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered --> $DIR/enum_same_crate_empty_match.rs:33:11 | LL | match NonExhaustiveEnum::Unit {} - | ^^^^^^^^^^^^^^^^^^^^^^^ patterns `Unit`, `Tuple(_)` and `Struct { .. }` not covered + | ^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered | note: `NonExhaustiveEnum` defined here --> $DIR/enum_same_crate_empty_match.rs:5:5 @@ -33,15 +33,15 @@ LL | Struct { field: u32 } help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ match NonExhaustiveEnum::Unit { -LL + Unit | Tuple(_) | Struct { .. } => todo!(), +LL + NonExhaustiveEnum::Unit | NonExhaustiveEnum::Tuple(_) | NonExhaustiveEnum::Struct { .. } => todo!(), LL + } | -error[E0004]: non-exhaustive patterns: `Unit`, `Tuple(_)` and `Struct { .. }` not covered +error[E0004]: non-exhaustive patterns: `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered --> $DIR/enum_same_crate_empty_match.rs:35:11 | LL | match NormalEnum::Unit {} - | ^^^^^^^^^^^^^^^^ patterns `Unit`, `Tuple(_)` and `Struct { .. }` not covered + | ^^^^^^^^^^^^^^^^ patterns `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered | note: `NormalEnum` defined here --> $DIR/enum_same_crate_empty_match.rs:14:5 @@ -60,7 +60,7 @@ LL | Struct { field: u32 } help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ match NormalEnum::Unit { -LL + Unit | Tuple(_) | Struct { .. } => todo!(), +LL + NormalEnum::Unit | NormalEnum::Tuple(_) | NormalEnum::Struct { .. } => todo!(), LL + } | diff --git a/src/test/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr b/src/test/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr index a9885449f..4b9f8564d 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr @@ -81,7 +81,7 @@ error: some variants are not matched explicitly --> $DIR/omitted-patterns.rs:58:9 | LL | _ => {} - | ^ pattern `Struct { .. }` not covered + | ^ pattern `NonExhaustiveEnum::Struct { .. }` not covered | note: the lint level is defined here --> $DIR/omitted-patterns.rs:57:16 @@ -95,7 +95,7 @@ error: some variants are not matched explicitly --> $DIR/omitted-patterns.rs:65:9 | LL | _ => {} - | ^ pattern `Tuple(_)` not covered + | ^ pattern `NonExhaustiveEnum::Tuple(_)` not covered | note: the lint level is defined here --> $DIR/omitted-patterns.rs:64:16 @@ -109,7 +109,7 @@ error: some variants are not matched explicitly --> $DIR/omitted-patterns.rs:75:9 | LL | _ => {} - | ^ pattern `Unit` not covered + | ^ pattern `NonExhaustiveEnum::Unit` not covered | note: the lint level is defined here --> $DIR/omitted-patterns.rs:74:16 @@ -123,7 +123,7 @@ error: some variants are not matched explicitly --> $DIR/omitted-patterns.rs:92:32 | LL | NestedNonExhaustive::A(_) => {} - | ^ patterns `Tuple(_)` and `Struct { .. }` not covered + | ^ patterns `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered | note: the lint level is defined here --> $DIR/omitted-patterns.rs:89:12 @@ -137,7 +137,7 @@ error: some variants are not matched explicitly --> $DIR/omitted-patterns.rs:94:9 | LL | _ => {} - | ^ pattern `C` not covered + | ^ pattern `NestedNonExhaustive::C` not covered | = help: ensure that all variants are matched explicitly by adding the suggested match arms = note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found @@ -146,7 +146,7 @@ error: some variants are not matched explicitly --> $DIR/omitted-patterns.rs:132:9 | LL | _ => {} - | ^ pattern `A(_)` not covered + | ^ pattern `NonExhaustiveSingleVariant::A(_)` not covered | note: the lint level is defined here --> $DIR/omitted-patterns.rs:130:12 @@ -160,7 +160,7 @@ error: some variants are not matched explicitly --> $DIR/omitted-patterns.rs:144:9 | LL | _ => {} - | ^ pattern `Unstable` not covered + | ^ pattern `UnstableEnum::Unstable` not covered | note: the lint level is defined here --> $DIR/omitted-patterns.rs:143:16 @@ -174,7 +174,7 @@ error: some variants are not matched explicitly --> $DIR/omitted-patterns.rs:168:9 | LL | _ => {} - | ^ pattern `Unstable2` not covered + | ^ pattern `OnlyUnstableEnum::Unstable2` not covered | note: the lint level is defined here --> $DIR/omitted-patterns.rs:165:12 diff --git a/src/test/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr b/src/test/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr index 7cce17898..533e8abf2 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr @@ -16,7 +16,7 @@ error: some variants are not matched explicitly --> $DIR/stable-omitted-patterns.rs:23:9 | LL | _ => {} - | ^ pattern `Stable2` not covered + | ^ pattern `UnstableEnum::Stable2` not covered | note: the lint level is defined here --> $DIR/stable-omitted-patterns.rs:22:16 diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr index 32a5c07f1..a9c54af04 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr @@ -55,11 +55,11 @@ LL + _ => todo!(), LL ~ } | -error[E0004]: non-exhaustive patterns: `Tuple(_)` and `Struct { .. }` not covered +error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered --> $DIR/match.rs:31:11 | LL | match x {} - | ^ patterns `Tuple(_)` and `Struct { .. }` not covered + | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered | note: `UninhabitedVariants` defined here --> $DIR/auxiliary/uninhabited.rs:17:23 @@ -74,7 +74,7 @@ LL | #[non_exhaustive] Struct { x: ! } help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ match x { -LL + Tuple(_) | Struct { .. } => todo!(), +LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), LL ~ } | diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr index c89c70ae6..ec2a2f6f0 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr @@ -36,11 +36,11 @@ LL + _ => todo!(), LL ~ } | -error[E0004]: non-exhaustive patterns: `Tuple(_)` and `Struct { .. }` not covered +error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered --> $DIR/match_same_crate.rs:38:11 | LL | match x {} - | ^ patterns `Tuple(_)` and `Struct { .. }` not covered + | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered | note: `UninhabitedVariants` defined here --> $DIR/match_same_crate.rs:16:23 @@ -55,7 +55,7 @@ LL | #[non_exhaustive] Struct { x: ! } help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ match x { -LL + Tuple(_) | Struct { .. } => todo!(), +LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), LL ~ } | diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr index d854ea28f..b6b777ec5 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr @@ -55,11 +55,11 @@ LL + _ => todo!(), LL ~ } | -error[E0004]: non-exhaustive patterns: `Tuple(_)` and `Struct { .. }` not covered +error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered --> $DIR/match_with_exhaustive_patterns.rs:34:11 | LL | match x {} - | ^ patterns `Tuple(_)` and `Struct { .. }` not covered + | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered | note: `UninhabitedVariants` defined here --> $DIR/auxiliary/uninhabited.rs:17:23 @@ -74,7 +74,7 @@ LL | #[non_exhaustive] Struct { x: ! } help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ match x { -LL + Tuple(_) | Struct { .. } => todo!(), +LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), LL ~ } | |