提交 f481dba3 编写于 作者: D Devin Ragotzy

Add struct to stability ui tests in usefulness

上级 4bf281a2
......@@ -2,7 +2,7 @@
#![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,
#[stable(feature = "stable_test_feature", since = "1.0.0")]
......@@ -10,3 +10,14 @@ pub enum Foo {
#[unstable(feature = "unstable_test_feature", issue = "none")]
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,
}
// 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;
use unstable::Foo;
use unstable::UnstableEnum;
fn main() {
match Foo::Stable {
Foo::Stable => {}
match UnstableEnum::Stable {
UnstableEnum::Stable => {}
}
//~^^^ non-exhaustive patterns: `Stable2` and `_` not covered
match Foo::Stable {
Foo::Stable => {}
Foo::Stable2 => {}
match UnstableEnum::Stable {
UnstableEnum::Stable => {}
UnstableEnum::Stable2 => {}
}
//~^^^^ non-exhaustive patterns: `_` not covered
}
#![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;
use unstable::Foo;
use unstable::UnstableEnum;
fn main() {
match Foo::Stable {
Foo::Stable => {}
Foo::Stable2 => {}
match UnstableEnum::Stable {
UnstableEnum::Stable => {}
UnstableEnum::Stable2 => {}
}
//~^^^^ non-exhaustive patterns: `Unstable` not covered
// Ok: all variants are explicitly matched
match Foo::Stable {
Foo::Stable => {}
Foo::Stable2 => {}
Foo::Unstable => {}
match UnstableEnum::Stable {
UnstableEnum::Stable => {}
UnstableEnum::Stable2 => {}
UnstableEnum::Unstable => {}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册