Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ impl SingleAttributeParser for ExportNameParser {
Allow(Target::Static),
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Warn(Target::Field),
Warn(Target::Arm),
Warn(Target::MacroDef),
Warn(Target::MacroCall),
]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
const STABILITY: AttributeStability = AttributeStability::Stable;
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/attributes/attr-on-mac-call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

fn main() {
#[export_name = "x"]
//~^ WARN attribute cannot be used on macro calls
//~| WARN previously accepted
//~^ ERROR attribute cannot be used on macro calls
unreachable!();
#[unsafe(naked)]
//~^ WARN attribute cannot be used on macro calls
Expand Down
109 changes: 54 additions & 55 deletions tests/ui/attributes/attr-on-mac-call.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
error: the `export_name` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:8:7
|
LL | #[export_name = "x"]
| ^^^^^^^^^^^
LL |
LL | unreachable!();
|
= help: the `export_name` attribute can be applied to functions and statics
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

error: the `sanitize` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:100:7
--> $DIR/attr-on-mac-call.rs:99:7
|
LL | #[sanitize(address = "off")]
| ^^^^^^^^
Expand All @@ -10,7 +21,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

error[E0658]: SIMD types are experimental and possibly buggy
--> $DIR/attr-on-mac-call.rs:129:12
--> $DIR/attr-on-mac-call.rs:128:12
|
LL | #[repr(simd)]
| ^^^^
Expand All @@ -20,7 +31,7 @@ LL | #[repr(simd)]
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: the `repr(simd)` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:129:7
--> $DIR/attr-on-mac-call.rs:128:7
|
LL | #[repr(simd)]
| ^^^^^^^^^^
Expand All @@ -31,31 +42,31 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![register_tool]`
--> $DIR/attr-on-mac-call.rs:133:5
--> $DIR/attr-on-mac-call.rs:132:5
|
LL | #[register_tool(xyz)]
| ^^^^^^^^^^^^^^^^^^^^^
|
note: this attribute does not have an `!`, which means it is applied to this macro call
--> $DIR/attr-on-mac-call.rs:135:5
--> $DIR/attr-on-mac-call.rs:134:5
|
LL | unreachable!();
| ^^^^^^^^^^^^^^

error: attribute value must be a literal
--> $DIR/attr-on-mac-call.rs:136:20
--> $DIR/attr-on-mac-call.rs:135:20
|
LL | #[deprecated = concat!("woah", "dude")]
| ^^^^^^^^^^^^^^^^^^^^^^^

error: attribute value must be a literal
--> $DIR/attr-on-mac-call.rs:138:13
--> $DIR/attr-on-mac-call.rs:137:13
|
LL | #[doc = concat!("woah", "dude")]
| ^^^^^^^^^^^^^^^^^^^^^^^

error: attribute value must be a literal
--> $DIR/attr-on-mac-call.rs:141:13
--> $DIR/attr-on-mac-call.rs:140:13
|
LL | #[doc = {
| _____________^
Expand All @@ -67,23 +78,23 @@ LL | | }]
| |_____^

error: attribute value must be a literal
--> $DIR/attr-on-mac-call.rs:149:13
--> $DIR/attr-on-mac-call.rs:148:13
|
LL | #[doc = {
| _____________^
LL | | let expressions @ r#in @ doc @ attributes @ at = home;
LL | | }]
| |_____^

warning: the `export_name` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:8:7
warning: the `naked` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:11:14
|
LL | #[export_name = "x"]
| ^^^^^^^^^^^
LL | #[unsafe(naked)]
| ^^^^^
...
LL | unreachable!();
|
= help: the `export_name` attribute can be applied to functions and statics
= help: the `naked` attribute can only be applied to functions
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion
note: the lint level is defined here
Expand All @@ -92,20 +103,8 @@ note: the lint level is defined here
LL | #![warn(unused_attributes)]
| ^^^^^^^^^^^^^^^^^

warning: the `naked` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:12:14
|
LL | #[unsafe(naked)]
| ^^^^^
...
LL | unreachable!();
|
= help: the `naked` attribute can only be applied to functions
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `track_caller` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:16:7
--> $DIR/attr-on-mac-call.rs:15:7
|
LL | #[track_caller]
| ^^^^^^^^^^^^
Expand All @@ -117,7 +116,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `used` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:20:7
--> $DIR/attr-on-mac-call.rs:19:7
|
LL | #[used]
| ^^^^
Expand All @@ -129,7 +128,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `target_feature` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:24:7
--> $DIR/attr-on-mac-call.rs:23:7
|
LL | #[target_feature(enable = "x")]
| ^^^^^^^^^^^^^^
Expand All @@ -141,7 +140,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `deprecated` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:28:7
--> $DIR/attr-on-mac-call.rs:27:7
|
LL | #[deprecated]
| ^^^^^^^^^^
Expand All @@ -153,7 +152,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `inline` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:32:7
--> $DIR/attr-on-mac-call.rs:31:7
|
LL | #[inline]
| ^^^^^^
Expand All @@ -165,7 +164,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `link_name` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:36:7
--> $DIR/attr-on-mac-call.rs:35:7
|
LL | #[link_name = "x"]
| ^^^^^^^^^
Expand All @@ -177,7 +176,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `link_section` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:40:7
--> $DIR/attr-on-mac-call.rs:39:7
|
LL | #[link_section = "__TEXT,__text"]
| ^^^^^^^^^^^^
Expand All @@ -189,7 +188,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `link_ordinal` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:44:7
--> $DIR/attr-on-mac-call.rs:43:7
|
LL | #[link_ordinal(42)]
| ^^^^^^^^^^^^
Expand All @@ -201,7 +200,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `non_exhaustive` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:48:7
--> $DIR/attr-on-mac-call.rs:47:7
|
LL | #[non_exhaustive]
| ^^^^^^^^^^^^^^
Expand All @@ -213,7 +212,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `proc_macro` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:52:7
--> $DIR/attr-on-mac-call.rs:51:7
|
LL | #[proc_macro]
| ^^^^^^^^^^
Expand All @@ -225,7 +224,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `cold` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:56:7
--> $DIR/attr-on-mac-call.rs:55:7
|
LL | #[cold]
| ^^^^
Expand All @@ -237,7 +236,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `no_mangle` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:60:7
--> $DIR/attr-on-mac-call.rs:59:7
|
LL | #[no_mangle]
| ^^^^^^^^^
Expand All @@ -249,7 +248,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `deprecated` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:64:7
--> $DIR/attr-on-mac-call.rs:63:7
|
LL | #[deprecated]
| ^^^^^^^^^^
Expand All @@ -261,7 +260,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `automatically_derived` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:68:7
--> $DIR/attr-on-mac-call.rs:67:7
|
LL | #[automatically_derived]
| ^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -273,7 +272,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `macro_use` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:72:7
--> $DIR/attr-on-mac-call.rs:71:7
|
LL | #[macro_use]
| ^^^^^^^^^
Expand All @@ -285,7 +284,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `must_use` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:76:7
--> $DIR/attr-on-mac-call.rs:75:7
|
LL | #[must_use]
| ^^^^^^^^
Expand All @@ -297,7 +296,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `no_implicit_prelude` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:80:7
--> $DIR/attr-on-mac-call.rs:79:7
|
LL | #[no_implicit_prelude]
| ^^^^^^^^^^^^^^^^^^^
Expand All @@ -309,7 +308,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `path` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:84:7
--> $DIR/attr-on-mac-call.rs:83:7
|
LL | #[path = ""]
| ^^^^
Expand All @@ -321,7 +320,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `ignore` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:88:7
--> $DIR/attr-on-mac-call.rs:87:7
|
LL | #[ignore]
| ^^^^^^
Expand All @@ -333,7 +332,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `should_panic` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:92:7
--> $DIR/attr-on-mac-call.rs:91:7
|
LL | #[should_panic]
| ^^^^^^^^^^^^
Expand All @@ -345,7 +344,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `link_name` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:96:7
--> $DIR/attr-on-mac-call.rs:95:7
|
LL | #[link_name = "x"]
| ^^^^^^^^^
Expand All @@ -357,7 +356,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `repr()` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:104:7
--> $DIR/attr-on-mac-call.rs:103:7
|
LL | #[repr()]
| ^^^^^^
Expand All @@ -369,15 +368,15 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: unused attribute
--> $DIR/attr-on-mac-call.rs:104:5
--> $DIR/attr-on-mac-call.rs:103:5
|
LL | #[repr()]
| ^^^^^^^^^ help: remove this attribute
|
= note: using `repr` with an empty list has no effect

warning: the `repr(u8)` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:109:7
--> $DIR/attr-on-mac-call.rs:108:7
|
LL | #[repr(u8)]
| ^^^^^^^^
Expand All @@ -389,7 +388,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `repr(align(...))` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:113:7
--> $DIR/attr-on-mac-call.rs:112:7
|
LL | #[repr(align(8))]
| ^^^^^^^^^^^^^^
Expand All @@ -401,7 +400,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `repr(packed)` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:117:7
--> $DIR/attr-on-mac-call.rs:116:7
|
LL | #[repr(packed)]
| ^^^^^^^^^^^^
Expand All @@ -413,7 +412,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `repr(C)` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:121:7
--> $DIR/attr-on-mac-call.rs:120:7
|
LL | #[repr(C)]
| ^^^^^^^
Expand All @@ -425,7 +424,7 @@ LL | unreachable!();
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

warning: the `repr(Rust)` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:125:7
--> $DIR/attr-on-mac-call.rs:124:7
|
LL | #[repr(Rust)]
| ^^^^^^^^^^
Expand All @@ -436,6 +435,6 @@ LL | unreachable!();
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion

error: aborting due to 8 previous errors; 30 warnings emitted
error: aborting due to 9 previous errors; 29 warnings emitted

For more information about this error, try `rustc --explain E0658`.
Loading
Loading