rust/tests/ui/attributes/invalid_macro_export_argument.rs
Nicholas Nethercote 7e1f2f9c54 Augment some tests involving attributes.
This shows places where the use of `name_or_empty` causes problems, i.e.
we print empty identifiers in error messages:
```
error: unrecognized field name ``
error: `` isn't a valid `#[macro_export]` argument
`#[no_sanitize()]` should be applied to a function
```
(The last one is about an attribute `#[no_sanitize("address")]`.)

The next commit will fix these.
2025-04-17 09:50:52 +10:00

39 lines
750 B
Rust

//@ revisions: deny allow
//@[allow] check-pass
#![cfg_attr(deny, deny(invalid_macro_export_arguments))]
#![cfg_attr(allow, allow(invalid_macro_export_arguments))]
#[macro_export(hello, world)]
//[deny]~^ ERROR `#[macro_export]` can only take 1 or 0 arguments
macro_rules! a {
() => ()
}
#[macro_export(not_local_inner_macros)]
//[deny]~^ ERROR `not_local_inner_macros` isn't a valid `#[macro_export]` argument
macro_rules! b {
() => ()
}
#[macro_export]
macro_rules! c {
() => ()
}
#[macro_export(local_inner_macros)]
macro_rules! d {
() => ()
}
#[macro_export()]
macro_rules! e {
() => ()
}
#[macro_export("blah")]
//[deny]~^ ERROR `` isn't a valid `#[macro_export]` argument
macro_rules! f {
() => ()
}
fn main() {}