2021-07-14 19:51:45 -05:00
|
|
|
//@ check-pass
|
|
|
|
|
|
|
|
|
|
#![warn(unused)]
|
|
|
|
|
|
|
|
|
|
macro_rules! foo {
|
|
|
|
|
() => {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
2025-08-23 13:12:01 +02:00
|
|
|
#[inline] foo!(); //~ WARN `#[inline]` attribute cannot be used on macro calls
|
|
|
|
|
//~^ WARN previously accepted
|
2021-07-14 19:51:45 -05:00
|
|
|
|
|
|
|
|
// This does nothing, since `#[allow(warnings)]` is itself
|
|
|
|
|
// an inert attribute on a macro call
|
2025-08-23 13:12:01 +02:00
|
|
|
#[allow(warnings)] #[inline] foo!(); //~ WARN unused attribute `allow`
|
|
|
|
|
//~^ WARN `#[inline]` attribute cannot be used on macro calls
|
|
|
|
|
//~| WARN previously accepted
|
2021-07-14 19:51:45 -05:00
|
|
|
|
|
|
|
|
// This does work, since the attribute is on a parent
|
|
|
|
|
// of the macro invocation.
|
2025-08-23 13:12:01 +02:00
|
|
|
#[allow(warnings)] { #[inline] foo!(); }
|
2025-03-21 18:14:27 +03:00
|
|
|
|
|
|
|
|
// Ok, `cfg` and `cfg_attr` are expanded eagerly and do not warn.
|
|
|
|
|
#[cfg(true)] foo!();
|
|
|
|
|
#[cfg(false)] foo!();
|
|
|
|
|
#[cfg_attr(true, cfg(true))] foo!();
|
|
|
|
|
#[cfg_attr(false, nonexistent)] foo!();
|
2021-07-14 19:51:45 -05:00
|
|
|
}
|