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
This commit is contained in:
commit
20ca02569a
10 changed files with 156 additions and 58 deletions
|
|
@ -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 } => {},
|
||||
_ => {}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue