Skip to content

Commit 699748b

Browse files
Add regression test for codegen attributes on required trait methods
Signed-off-by: Jonathan Brouwer <[email protected]>
1 parent 60d8902 commit 699748b

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![deny(unused_attributes)]
2+
#![feature(linkage)]
3+
#![feature(fn_align)]
4+
5+
trait Test {
6+
#[cold]
7+
//~^ ERROR cannot be used on required trait methods [unused_attributes]
8+
//~| WARN previously accepted
9+
fn method1(&self);
10+
#[link_section = ".text"]
11+
//~^ ERROR cannot be used on required trait methods [unused_attributes]
12+
//~| WARN previously accepted
13+
fn method2(&self);
14+
#[linkage = "common"]
15+
//~^ ERROR cannot be used on required trait methods [unused_attributes]
16+
//~| WARN previously accepted
17+
fn method3(&self);
18+
#[track_caller]
19+
fn method4(&self);
20+
#[rustc_align(1)]
21+
fn method5(&self);
22+
}
23+
24+
fn main() {}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error: `#[cold]` attribute cannot be used on required trait methods
2+
--> $DIR/codegen_attr_on_required_trait_method.rs:6:5
3+
|
4+
LL | #[cold]
5+
| ^^^^^^^
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= help: `#[cold]` can be applied to closures, foreign functions, functions, inherent methods, provided trait methods, and trait methods in impl blocks
9+
note: the lint level is defined here
10+
--> $DIR/codegen_attr_on_required_trait_method.rs:1:9
11+
|
12+
LL | #![deny(unused_attributes)]
13+
| ^^^^^^^^^^^^^^^^^
14+
15+
error: `#[link_section]` attribute cannot be used on required trait methods
16+
--> $DIR/codegen_attr_on_required_trait_method.rs:10:5
17+
|
18+
LL | #[link_section = ".text"]
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
20+
|
21+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
22+
= help: `#[link_section]` can be applied to functions, inherent methods, provided trait methods, statics, and trait methods in impl blocks
23+
24+
error: `#[linkage]` attribute cannot be used on required trait methods
25+
--> $DIR/codegen_attr_on_required_trait_method.rs:14:5
26+
|
27+
LL | #[linkage = "common"]
28+
| ^^^^^^^^^^^^^^^^^^^^^
29+
|
30+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31+
= help: `#[linkage]` can be applied to foreign functions, foreign statics, functions, inherent methods, provided trait methods, statics, and trait methods in impl blocks
32+
33+
error: aborting due to 3 previous errors
34+

0 commit comments

Comments
 (0)