-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check_attrs: Warn when #[macro_export] is used on macros 2.0
The compiler should emit a more specific error when the `#[macro_export]` attribute is present on a decl macro, instead of silently ignoring it. This commit adds the required error message in rustc_passes/messages.ftl, as well as a note. A new variant is added to the `errors::MacroExport` enum, specifically for the case where the attribute is added to a macro 2.0.
- Loading branch information
1 parent
f177625
commit bdf4e3d
Showing
5 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Using #[macro_export] on a decl macro has no effect and should warn | ||
|
||
#![feature(decl_macro)] | ||
#![deny(unused)] | ||
|
||
#[macro_export] //~ ERROR `#[macro_export]` has no effect on declarative macro definitions | ||
pub macro foo() {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error: `#[macro_export]` has no effect on declarative macro definitions | ||
--> $DIR/macro_export_on_decl_macro.rs:6:1 | ||
| | ||
LL | #[macro_export] | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= note: declarative macros follow the same exporting rules as regular items | ||
note: the lint level is defined here | ||
--> $DIR/macro_export_on_decl_macro.rs:4:9 | ||
| | ||
LL | #![deny(unused)] | ||
| ^^^^^^ | ||
= note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]` | ||
|
||
error: aborting due to previous error | ||
|