diff options
| author | bors <bors@rust-lang.org> | 2018-09-06 06:42:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-06 06:42:19 +0000 |
| commit | 20ca02569ae3e1dc29962e92739fbab632abf241 (patch) | |
| tree | 00d5155617647e0d559f3180c23b5a4e16310011 /src/test | |
| parent | 27e5457f3fa6c6e322e05352f0109f2cd511396c (diff) | |
| parent | ae2ad30bf1f3f924ed9ef977b3d2782f85fe2593 (diff) | |
| download | rust-20ca02569ae3e1dc29962e92739fbab632abf241.tar.gz rust-20ca02569ae3e1dc29962e92739fbab632abf241.zip | |
Auto merge of #53721 - arielb1:exhaustively-unpun, r=nikomatsakis
fix `is_non_exhaustive` confusion between structs and enums Structs and enums can both be non-exhaustive, with a very different meaning. This PR splits `is_non_exhaustive` to 2 separate functions - 1 for structs, and another for enums, and fixes the places that got the usage confused. Fixes #53549. r? @eddyb
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/rfc-2008-non-exhaustive/enums.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/run-pass/rfc-2008-non-exhaustive/enums.rs b/src/test/run-pass/rfc-2008-non-exhaustive/enums.rs index 9d41eca8fe5..83fb24cda08 100644 --- a/src/test/run-pass/rfc-2008-non-exhaustive/enums.rs +++ b/src/test/run-pass/rfc-2008-non-exhaustive/enums.rs @@ -30,4 +30,33 @@ fn main() { match enum_unit { _ => "no error with only wildcard" }; + + + // issue #53549 - check that variant constructors can still be called normally. + + match NonExhaustiveEnum::Unit { + NonExhaustiveEnum::Unit => {}, + _ => {} + }; + + match NonExhaustiveEnum::Tuple(2) { + NonExhaustiveEnum::Tuple(2) => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Unit {}) { + NonExhaustiveEnum::Unit {} => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Tuple { 0: 2 }) { + NonExhaustiveEnum::Tuple { 0: 2 } => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Struct { field: 2 }) { + NonExhaustiveEnum::Struct { field: 2 } => {}, + _ => {} + }; + } |
