Skip to content

Commit 4e816e1

Browse files
committed
Add test for disallowed attribute
1 parent b2eabf2 commit 4e816e1

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

tests/ui/internal/unstable_inherent_method.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
#![feature(impl_stability)]
44
#![stable(feature = "a", since = "1.1.1" )]
55

6-
7-
/// FIXME(tiif): we haven't allowed marking impl method as
6+
/// FIXME(tiif): we haven't allowed marking trait and impl method as
87
/// unstable yet, but it should be possible.
98
109
#[stable(feature = "a", since = "1.1.1" )]
1110
pub trait Trait {
1211
#[unstable(feature = "feat", issue = "none" )]
1312
#[unstable_feature_bound(foo)]
13+
//~^ ERROR: attribute should be applied to `impl` or free function outside of any `impl` or trait
1414
fn foo();
1515
}
1616

1717
#[stable(feature = "a", since = "1.1.1" )]
1818
impl Trait for u8 {
1919
#[unstable_feature_bound(foo)]
20+
//~^ ERROR: attribute should be applied to `impl` or free function outside of any `impl` or trait
2021
fn foo() {}
2122
}
2223

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: attribute should be applied to `impl` or free function outside of any `impl` or trait
2+
--> $DIR/unstable_inherent_method.rs:12:5
3+
|
4+
LL | #[unstable_feature_bound(foo)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
LL |
7+
LL | fn foo();
8+
| --------- not an `impl` or free function
9+
10+
error: attribute should be applied to `impl` or free function outside of any `impl` or trait
11+
--> $DIR/unstable_inherent_method.rs:19:5
12+
|
13+
LL | #[unstable_feature_bound(foo)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
LL |
16+
LL | fn foo() {}
17+
| ----------- not an `impl` or free function
18+
19+
error: aborting due to 2 previous errors
20+

0 commit comments

Comments
 (0)