1 // Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly with variants
2 // marked stable and unstable.
4 #![feature(non_exhaustive_omitted_patterns_lint)]
6 // aux-build:unstable.rs
9 use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct};
12 // OK: this matches all the stable variants
13 match UnstableEnum::Stable {
14 UnstableEnum::Stable => {}
15 UnstableEnum::Stable2 => {}
16 #[deny(non_exhaustive_omitted_patterns)]
20 match UnstableEnum::Stable {
21 UnstableEnum::Stable => {}
22 #[deny(non_exhaustive_omitted_patterns)]
25 //~^^ some variants are not matched explicitly
27 // Ok: although this is a bit odd, we don't have anything to report
28 // since there is no stable variants and the feature is off
29 #[deny(non_exhaustive_omitted_patterns)]
30 match OnlyUnstableEnum::new() {
34 // Ok: Same as the above enum (no fields can be matched on)
35 #[warn(non_exhaustive_omitted_patterns)]
36 let OnlyUnstableStruct { .. } = OnlyUnstableStruct::new();
38 #[warn(non_exhaustive_omitted_patterns)]
39 let UnstableStruct { stable, .. } = UnstableStruct::default();
40 //~^ some fields are not explicitly listed
42 // OK: stable field is matched
43 #[warn(non_exhaustive_omitted_patterns)]
44 let UnstableStruct { stable, stable2, .. } = UnstableStruct::default();