Add tests for #[rustc_default_body_unstable]
This commit is contained in:
parent
9015a5110f
commit
d65fa276f3
29
src/test/ui/stability-attribute/auxiliary/default_body.rs
Normal file
29
src/test/ui/stability-attribute/auxiliary/default_body.rs
Normal file
@ -0,0 +1,29 @@
|
||||
#![crate_type = "lib"]
|
||||
#![feature(staged_api, rustc_attrs)]
|
||||
#![stable(feature = "stable_feature", since = "1.0.0")]
|
||||
|
||||
#[stable(feature = "stable_feature", since = "1.0.0")]
|
||||
pub trait JustTrait {
|
||||
#[stable(feature = "stable_feature", since = "1.0.0")]
|
||||
#[rustc_default_body_unstable(feature = "constant_default_body", issue = "none")]
|
||||
const CONSTANT: usize = 0;
|
||||
|
||||
#[rustc_default_body_unstable(feature = "fun_default_body", issue = "none")]
|
||||
#[stable(feature = "stable_feature", since = "1.0.0")]
|
||||
fn fun() {}
|
||||
}
|
||||
|
||||
#[rustc_must_implement_one_of(eq, neq)]
|
||||
#[stable(feature = "stable_feature", since = "1.0.0")]
|
||||
pub trait Equal {
|
||||
#[rustc_default_body_unstable(feature = "eq_default_body", issue = "none")]
|
||||
#[stable(feature = "stable_feature", since = "1.0.0")]
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
!self.neq(other)
|
||||
}
|
||||
|
||||
#[stable(feature = "stable_feature", since = "1.0.0")]
|
||||
fn neq(&self, other: &Self) -> bool {
|
||||
!self.eq(other)
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
// aux-build:default_body.rs
|
||||
#![crate_type = "lib"]
|
||||
|
||||
extern crate default_body;
|
||||
|
||||
use default_body::{Equal, JustTrait};
|
||||
|
||||
struct Type;
|
||||
|
||||
impl JustTrait for Type {}
|
||||
//~^ ERROR use of unstable library feature 'fun_default_body'
|
||||
//~| ERROR use of unstable library feature 'constant_default_body'
|
||||
|
||||
impl Equal for Type {
|
||||
//~^ ERROR use of unstable library feature 'eq_default_body'
|
||||
fn neq(&self, other: &Self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
error[E0658]: use of unstable library feature 'constant_default_body'
|
||||
--> $DIR/default-body-stability-err.rs:10:1
|
||||
|
|
||||
LL | impl JustTrait for Type {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(constant_default_body)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of unstable library feature 'fun_default_body'
|
||||
--> $DIR/default-body-stability-err.rs:10:1
|
||||
|
|
||||
LL | impl JustTrait for Type {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(fun_default_body)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of unstable library feature 'eq_default_body'
|
||||
--> $DIR/default-body-stability-err.rs:14:1
|
||||
|
|
||||
LL | / impl Equal for Type {
|
||||
LL | |
|
||||
LL | | fn neq(&self, other: &Self) -> bool {
|
||||
LL | | false
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
= help: add `#![feature(eq_default_body)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -0,0 +1,18 @@
|
||||
// check-pass
|
||||
// aux-build:default_body.rs
|
||||
#![crate_type = "lib"]
|
||||
#![feature(fun_default_body, eq_default_body, constant_default_body)]
|
||||
|
||||
extern crate default_body;
|
||||
|
||||
use default_body::{Equal, JustTrait};
|
||||
|
||||
struct Type;
|
||||
|
||||
impl JustTrait for Type {}
|
||||
|
||||
impl Equal for Type {
|
||||
fn neq(&self, other: &Self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// check-pass
|
||||
// aux-build:default_body.rs
|
||||
#![crate_type = "lib"]
|
||||
|
||||
extern crate default_body;
|
||||
|
||||
use default_body::{Equal, JustTrait};
|
||||
|
||||
struct Type;
|
||||
|
||||
impl JustTrait for Type {
|
||||
const CONSTANT: usize = 1;
|
||||
|
||||
fn fun() {}
|
||||
}
|
||||
|
||||
impl Equal for Type {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user