Add struct to stability ui tests in usefulness
This commit is contained in:
parent
4bf281a20c
commit
f481dba3d4
@ -2,7 +2,7 @@
|
|||||||
#![stable(feature = "stable_test_feature", since = "1.0.0")]
|
#![stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
|
|
||||||
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
pub enum Foo {
|
pub enum UnstableEnum {
|
||||||
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
Stable,
|
Stable,
|
||||||
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
@ -10,3 +10,14 @@ pub enum Foo {
|
|||||||
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
||||||
Unstable,
|
Unstable,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
16
src/test/ui/pattern/usefulness/stable-gated-fields.rs
Normal file
16
src/test/ui/pattern/usefulness/stable-gated-fields.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// aux-build:unstable.rs
|
||||||
|
|
||||||
|
extern crate unstable;
|
||||||
|
|
||||||
|
use unstable::UnstableStruct;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let UnstableStruct { stable } = UnstableStruct::default();
|
||||||
|
//~^ pattern does not mention field `stable2` and inaccessible fields
|
||||||
|
|
||||||
|
let UnstableStruct { stable, stable2 } = UnstableStruct::default();
|
||||||
|
//~^ pattern requires `..` due to inaccessible fields
|
||||||
|
|
||||||
|
// OK: stable field is matched
|
||||||
|
let UnstableStruct { stable, stable2, .. } = UnstableStruct::default();
|
||||||
|
}
|
@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
extern crate unstable;
|
extern crate unstable;
|
||||||
|
|
||||||
use unstable::Foo;
|
use unstable::UnstableEnum;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match Foo::Stable {
|
match UnstableEnum::Stable {
|
||||||
Foo::Stable => {}
|
UnstableEnum::Stable => {}
|
||||||
}
|
}
|
||||||
//~^^^ non-exhaustive patterns: `Stable2` and `_` not covered
|
//~^^^ non-exhaustive patterns: `Stable2` and `_` not covered
|
||||||
|
|
||||||
match Foo::Stable {
|
match UnstableEnum::Stable {
|
||||||
Foo::Stable => {}
|
UnstableEnum::Stable => {}
|
||||||
Foo::Stable2 => {}
|
UnstableEnum::Stable2 => {}
|
||||||
}
|
}
|
||||||
//~^^^^ non-exhaustive patterns: `_` not covered
|
//~^^^^ non-exhaustive patterns: `_` not covered
|
||||||
}
|
}
|
||||||
|
18
src/test/ui/pattern/usefulness/unstable-gated-fields.rs
Normal file
18
src/test/ui/pattern/usefulness/unstable-gated-fields.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#![feature(unstable_test_feature)]
|
||||||
|
|
||||||
|
// aux-build:unstable.rs
|
||||||
|
|
||||||
|
extern crate unstable;
|
||||||
|
|
||||||
|
use unstable::UnstableStruct;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let UnstableStruct { stable, stable2, } = UnstableStruct::default();
|
||||||
|
//~^ pattern does not mention field `unstable`
|
||||||
|
|
||||||
|
let UnstableStruct { stable, unstable, } = UnstableStruct::default();
|
||||||
|
//~^ pattern does not mention field `stable2`
|
||||||
|
|
||||||
|
// OK: stable field is matched
|
||||||
|
let UnstableStruct { stable, stable2, unstable } = UnstableStruct::default();
|
||||||
|
}
|
@ -4,19 +4,19 @@
|
|||||||
|
|
||||||
extern crate unstable;
|
extern crate unstable;
|
||||||
|
|
||||||
use unstable::Foo;
|
use unstable::UnstableEnum;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match Foo::Stable {
|
match UnstableEnum::Stable {
|
||||||
Foo::Stable => {}
|
UnstableEnum::Stable => {}
|
||||||
Foo::Stable2 => {}
|
UnstableEnum::Stable2 => {}
|
||||||
}
|
}
|
||||||
//~^^^^ non-exhaustive patterns: `Unstable` not covered
|
//~^^^^ non-exhaustive patterns: `Unstable` not covered
|
||||||
|
|
||||||
// Ok: all variants are explicitly matched
|
// Ok: all variants are explicitly matched
|
||||||
match Foo::Stable {
|
match UnstableEnum::Stable {
|
||||||
Foo::Stable => {}
|
UnstableEnum::Stable => {}
|
||||||
Foo::Stable2 => {}
|
UnstableEnum::Stable2 => {}
|
||||||
Foo::Unstable => {}
|
UnstableEnum::Unstable => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user