mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-22 12:43:36 +00:00
Add unstable struct fields to ui tests
This commit is contained in:
parent
8663ee19e4
commit
3344833a61
@ -27,3 +27,34 @@ impl OnlyUnstableEnum {
|
|||||||
Self::Unstable
|
Self::Unstable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
|
#[non_exhaustive]
|
||||||
|
pub struct UnstableStruct {
|
||||||
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
|
pub stable: bool,
|
||||||
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
|
pub stable2: usize,
|
||||||
|
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
||||||
|
pub unstable: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
|
#[non_exhaustive]
|
||||||
|
pub struct OnlyUnstableStruct {
|
||||||
|
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
||||||
|
pub unstable: u8,
|
||||||
|
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
||||||
|
pub unstable2: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnlyUnstableStruct {
|
||||||
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
unstable: 0,
|
||||||
|
unstable2: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,7 +13,7 @@ use enums::{
|
|||||||
EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant,
|
EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant,
|
||||||
VariantNonExhaustive,
|
VariantNonExhaustive,
|
||||||
};
|
};
|
||||||
use unstable::{UnstableEnum, OnlyUnstableEnum};
|
use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct};
|
||||||
use structs::{FunctionalRecord, MixedVisFields, NestedStruct, NormalStruct};
|
use structs::{FunctionalRecord, MixedVisFields, NestedStruct, NormalStruct};
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
@ -145,6 +145,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
//~^^ some variants are not matched explicitly
|
//~^^ some variants are not matched explicitly
|
||||||
|
|
||||||
|
// Ok: the feature is on and all variants are matched
|
||||||
#[deny(non_exhaustive_omitted_patterns)]
|
#[deny(non_exhaustive_omitted_patterns)]
|
||||||
match UnstableEnum::Stable {
|
match UnstableEnum::Stable {
|
||||||
UnstableEnum::Stable => {}
|
UnstableEnum::Stable => {}
|
||||||
@ -167,4 +168,20 @@ fn main() {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
//~^^ some variants are not matched explicitly
|
//~^^ some variants are not matched explicitly
|
||||||
|
|
||||||
|
#[warn(non_exhaustive_omitted_patterns)]
|
||||||
|
let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new();
|
||||||
|
//~^ some fields are not explicitly listed
|
||||||
|
|
||||||
|
// OK: both unstable fields are matched with feature on
|
||||||
|
#[warn(non_exhaustive_omitted_patterns)]
|
||||||
|
let OnlyUnstableStruct { unstable, unstable2, .. } = OnlyUnstableStruct::new();
|
||||||
|
|
||||||
|
#[warn(non_exhaustive_omitted_patterns)]
|
||||||
|
let UnstableStruct { stable, stable2, .. } = UnstableStruct::default();
|
||||||
|
//~^ some fields are not explicitly listed
|
||||||
|
|
||||||
|
// OK: both unstable and stable fields are matched with feature on
|
||||||
|
#[warn(non_exhaustive_omitted_patterns)]
|
||||||
|
let UnstableStruct { stable, stable2, unstable, .. } = UnstableStruct::default();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
// aux-build:unstable.rs
|
// aux-build:unstable.rs
|
||||||
extern crate unstable;
|
extern crate unstable;
|
||||||
|
|
||||||
use unstable::{UnstableEnum, OnlyUnstableEnum};
|
use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// OK: this matches all the stable variants
|
// OK: this matches all the stable variants
|
||||||
@ -30,4 +30,16 @@ fn main() {
|
|||||||
match OnlyUnstableEnum::new() {
|
match OnlyUnstableEnum::new() {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ok: Same as the above enum (no fields can be matched on)
|
||||||
|
#[warn(non_exhaustive_omitted_patterns)]
|
||||||
|
let OnlyUnstableStruct { .. } = OnlyUnstableStruct::new();
|
||||||
|
|
||||||
|
#[warn(non_exhaustive_omitted_patterns)]
|
||||||
|
let UnstableStruct { stable, .. } = UnstableStruct::default();
|
||||||
|
//~^ some fields are not explicitly listed
|
||||||
|
|
||||||
|
// OK: stable field is matched
|
||||||
|
#[warn(non_exhaustive_omitted_patterns)]
|
||||||
|
let UnstableStruct { stable, stable2, .. } = UnstableStruct::default();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user