Skip to content

Commit d65fa27

Browse files
committed
Add tests for #[rustc_default_body_unstable]
1 parent 9015a51 commit d65fa27

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![crate_type = "lib"]
2+
#![feature(staged_api, rustc_attrs)]
3+
#![stable(feature = "stable_feature", since = "1.0.0")]
4+
5+
#[stable(feature = "stable_feature", since = "1.0.0")]
6+
pub trait JustTrait {
7+
#[stable(feature = "stable_feature", since = "1.0.0")]
8+
#[rustc_default_body_unstable(feature = "constant_default_body", issue = "none")]
9+
const CONSTANT: usize = 0;
10+
11+
#[rustc_default_body_unstable(feature = "fun_default_body", issue = "none")]
12+
#[stable(feature = "stable_feature", since = "1.0.0")]
13+
fn fun() {}
14+
}
15+
16+
#[rustc_must_implement_one_of(eq, neq)]
17+
#[stable(feature = "stable_feature", since = "1.0.0")]
18+
pub trait Equal {
19+
#[rustc_default_body_unstable(feature = "eq_default_body", issue = "none")]
20+
#[stable(feature = "stable_feature", since = "1.0.0")]
21+
fn eq(&self, other: &Self) -> bool {
22+
!self.neq(other)
23+
}
24+
25+
#[stable(feature = "stable_feature", since = "1.0.0")]
26+
fn neq(&self, other: &Self) -> bool {
27+
!self.eq(other)
28+
}
29+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// aux-build:default_body.rs
2+
#![crate_type = "lib"]
3+
4+
extern crate default_body;
5+
6+
use default_body::{Equal, JustTrait};
7+
8+
struct Type;
9+
10+
impl JustTrait for Type {}
11+
//~^ ERROR use of unstable library feature 'fun_default_body'
12+
//~| ERROR use of unstable library feature 'constant_default_body'
13+
14+
impl Equal for Type {
15+
//~^ ERROR use of unstable library feature 'eq_default_body'
16+
fn neq(&self, other: &Self) -> bool {
17+
false
18+
}
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0658]: use of unstable library feature 'constant_default_body'
2+
--> $DIR/default-body-stability-err.rs:10:1
3+
|
4+
LL | impl JustTrait for Type {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add `#![feature(constant_default_body)]` to the crate attributes to enable
8+
9+
error[E0658]: use of unstable library feature 'fun_default_body'
10+
--> $DIR/default-body-stability-err.rs:10:1
11+
|
12+
LL | impl JustTrait for Type {}
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
|
15+
= help: add `#![feature(fun_default_body)]` to the crate attributes to enable
16+
17+
error[E0658]: use of unstable library feature 'eq_default_body'
18+
--> $DIR/default-body-stability-err.rs:14:1
19+
|
20+
LL | / impl Equal for Type {
21+
LL | |
22+
LL | | fn neq(&self, other: &Self) -> bool {
23+
LL | | false
24+
LL | | }
25+
LL | | }
26+
| |_^
27+
|
28+
= help: add `#![feature(eq_default_body)]` to the crate attributes to enable
29+
30+
error: aborting due to 3 previous errors
31+
32+
For more information about this error, try `rustc --explain E0658`.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// check-pass
2+
// aux-build:default_body.rs
3+
#![crate_type = "lib"]
4+
#![feature(fun_default_body, eq_default_body, constant_default_body)]
5+
6+
extern crate default_body;
7+
8+
use default_body::{Equal, JustTrait};
9+
10+
struct Type;
11+
12+
impl JustTrait for Type {}
13+
14+
impl Equal for Type {
15+
fn neq(&self, other: &Self) -> bool {
16+
false
17+
}
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// check-pass
2+
// aux-build:default_body.rs
3+
#![crate_type = "lib"]
4+
5+
extern crate default_body;
6+
7+
use default_body::{Equal, JustTrait};
8+
9+
struct Type;
10+
11+
impl JustTrait for Type {
12+
const CONSTANT: usize = 1;
13+
14+
fn fun() {}
15+
}
16+
17+
impl Equal for Type {
18+
fn eq(&self, other: &Self) -> bool {
19+
false
20+
}
21+
}

0 commit comments

Comments
 (0)