Skip to content

Commit ee2fe37

Browse files
compiler-errorsbindsdev
authored andcommitted
Add invalid_macro_export_arguments to built-in macro list
1 parent 73fd14e commit ee2fe37

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,6 +3377,7 @@ declare_lint_pass! {
33773377
IMPLIED_BOUNDS_ENTAILMENT,
33783378
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
33793379
AMBIGUOUS_GLOB_REEXPORTS,
3380+
INVALID_MACRO_EXPORT_ARGUMENTS,
33803381
]
33813382
}
33823383

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: `#[macro_export]` can only take 1 or 0 arguments
2+
--> $DIR/invalid_macro_export_argument.rs:7:1
3+
|
4+
LL | #[macro_export(hello, world)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/invalid_macro_export_argument.rs:4:24
9+
|
10+
LL | #![cfg_attr(deny, deny(invalid_macro_export_arguments))]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: `not_local_inner_macros` isn't a valid `#[macro_export]` argument
14+
--> $DIR/invalid_macro_export_argument.rs:13:16
15+
|
16+
LL | #[macro_export(not_local_inner_macros)]
17+
| ^^^^^^^^^^^^^^^^^^^^^^
18+
19+
error: aborting due to 2 previous errors
20+

tests/ui/attributes/invalid_macro_export_argument.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
// check-pass
2-
#[macro_export(hello, world)] //~ WARN `#[macro_export]` can only take 1 or 0 arguments
1+
// revisions: deny allow
2+
//[allow] check-pass
3+
4+
#![cfg_attr(deny, deny(invalid_macro_export_arguments))]
5+
#![cfg_attr(allow, allow(invalid_macro_export_arguments))]
6+
7+
#[macro_export(hello, world)]
8+
//[deny]~^ ERROR `#[macro_export]` can only take 1 or 0 arguments
39
macro_rules! a {
410
() => ()
511
}
612

7-
#[macro_export(not_local_inner_macros)] //~ WARN `not_local_inner_macros` isn't a valid `#[macro_export]` argument
13+
#[macro_export(not_local_inner_macros)]
14+
//[deny]~^ ERROR `not_local_inner_macros` isn't a valid `#[macro_export]` argument
815
macro_rules! b {
916
() => ()
1017
}

tests/ui/attributes/invalid_macro_export_argument.stderr

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)