Skip to content

Commit c535b85

Browse files
wip
1 parent 764746e commit c535b85

File tree

7 files changed

+46
-30
lines changed

7 files changed

+46
-30
lines changed

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
3333
Allow(Target::Enum),
3434
Allow(Target::Union),
3535
Allow(Target::Method(MethodKind::Inherent)),
36+
Allow(Target::Method(MethodKind::Trait {body: false})),
37+
Allow(Target::Method(MethodKind::Trait {body: true})),
3638
Allow(Target::Impl { of_trait: false }),
3739
Allow(Target::Impl { of_trait: true }),
3840
Allow(Target::MacroDef),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(trait_alias, marker_trait_attr)]
22

33
#[marker]
4-
//~^ ERROR attribute should be applied to a trait
4+
//~^ ERROR this attribute is not allowed on this target
55
trait Foo = Send;
66

77
fn main() {}

tests/ui/traits/const-traits/attr-misuse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#[const_trait]
44
trait A {
5-
#[const_trait] //~ ERROR attribute should be applied
5+
#[const_trait] //~ ERROR this attribute is not allowed on this target
66
fn foo(self);
77
}
88

9-
#[const_trait] //~ ERROR attribute should be applied
9+
#[const_trait] //~ ERROR this attribute is not allowed on this target
1010
fn main() {}
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
error: attribute should be applied to a trait
2-
--> $DIR/attr-misuse.rs:9:1
1+
error: this attribute is not allowed on this target
2+
--> $DIR/attr-misuse.rs:5:7
33
|
4-
LL | #[const_trait]
5-
| ^^^^^^^^^^^^^^
6-
LL | fn main() {}
7-
| ------------ not a trait
4+
LL | #[const_trait]
5+
| ^^^^^^^^^^^
86

9-
error: attribute should be applied to a trait
10-
--> $DIR/attr-misuse.rs:5:5
7+
error: this attribute is not allowed on this target
8+
--> $DIR/attr-misuse.rs:9:3
119
|
12-
LL | #[const_trait]
13-
| ^^^^^^^^^^^^^^
14-
LL | fn foo(self);
15-
| ------------- not a trait
10+
LL | #[const_trait]
11+
| ^^^^^^^^^^^
1612

1713
error: aborting due to 2 previous errors
1814

tests/ui/unstable-feature-bound/unstable_inherent_method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
pub trait Trait {
1010
#[unstable(feature = "feat", issue = "none" )]
1111
#[unstable_feature_bound(foo)]
12-
//~^ ERROR: attribute should be applied to `impl` or free function outside of any `impl` or trait
12+
//~^ ERROR: this attribute is not allowed on this target
1313
fn foo();
1414
}
1515

1616
#[stable(feature = "a", since = "1.1.1" )]
1717
impl Trait for u8 {
1818
#[unstable_feature_bound(foo)]
19-
//~^ ERROR: attribute should be applied to `impl` or free function outside of any `impl` or trait
19+
//~^ ERROR: this attribute is not allowed on this target
2020
fn foo() {}
2121
}
2222

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
error: attribute should be applied to `impl` or free function outside of any `impl` or trait
2-
--> $DIR/unstable_inherent_method.rs:11:5
1+
error: this attribute is not allowed on this target
2+
--> $DIR/unstable_inherent_method.rs:11:7
33
|
44
LL | #[unstable_feature_bound(foo)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
LL |
7-
LL | fn foo();
8-
| --------- not an `impl` or free function
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
96

10-
error: attribute should be applied to `impl` or free function outside of any `impl` or trait
11-
--> $DIR/unstable_inherent_method.rs:18:5
7+
error: this attribute is not allowed on this target
8+
--> $DIR/unstable_inherent_method.rs:18:7
129
|
1310
LL | #[unstable_feature_bound(foo)]
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15-
LL |
16-
LL | fn foo() {}
17-
| ----------- not an `impl` or free function
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1812

1913
error: aborting due to 2 previous errors
2014

tests/ui/where-clauses/unsupported_attribute.stderr

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@ error: expected non-macro attribute, found attribute macro `derive`
1010
LL | #[derive(Clone)] 'a: 'static,
1111
| ^^^^^^ not a non-macro attribute
1212

13+
error: this attribute is not allowed on this target
14+
--> $DIR/unsupported_attribute.rs:16:7
15+
|
16+
LL | #[ignore] T: Trait,
17+
| ^^^^^^
18+
19+
error: this attribute is not allowed on this target
20+
--> $DIR/unsupported_attribute.rs:17:7
21+
|
22+
LL | #[ignore] 'a: 'static,
23+
| ^^^^^^
24+
25+
error: this attribute is not allowed on this target
26+
--> $DIR/unsupported_attribute.rs:26:7
27+
|
28+
LL | #[automatically_derived] T: Trait,
29+
| ^^^^^^^^^^^^^^^^^^^^^
30+
31+
error: this attribute is not allowed on this target
32+
--> $DIR/unsupported_attribute.rs:27:7
33+
|
34+
LL | #[automatically_derived] 'a: 'static,
35+
| ^^^^^^^^^^^^^^^^^^^^^
36+
1337
error: most attributes are not supported in `where` clauses
1438
--> $DIR/unsupported_attribute.rs:14:5
1539
|
@@ -154,5 +178,5 @@ LL | #[rustfmt::skip] 'a: 'static,
154178
|
155179
= help: only `#[cfg]` and `#[cfg_attr]` are supported
156180

157-
error: aborting due to 20 previous errors
181+
error: aborting due to 24 previous errors
158182

0 commit comments

Comments
 (0)