expand: Do not report cfg_attr
traces on macros as unused attributes
This commit is contained in:
parent
4ac032f857
commit
0ac2801f25
3 changed files with 15 additions and 8 deletions
|
@ -1941,7 +1941,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
||||||
let attr_name = attr.ident().unwrap().name;
|
let attr_name = attr.ident().unwrap().name;
|
||||||
// `#[cfg]` and `#[cfg_attr]` are special - they are
|
// `#[cfg]` and `#[cfg_attr]` are special - they are
|
||||||
// eagerly evaluated.
|
// eagerly evaluated.
|
||||||
if attr_name != sym::cfg && attr_name != sym::cfg_attr {
|
if attr_name != sym::cfg && attr_name != sym::cfg_attr_trace {
|
||||||
self.cx.sess.psess.buffer_lint(
|
self.cx.sess.psess.buffer_lint(
|
||||||
UNUSED_ATTRIBUTES,
|
UNUSED_ATTRIBUTES,
|
||||||
attr.span,
|
attr.span,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//@ check-pass
|
//@ check-pass
|
||||||
|
|
||||||
|
#![feature(cfg_boolean_literals)]
|
||||||
#![warn(unused)]
|
#![warn(unused)]
|
||||||
|
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
|
@ -17,4 +18,10 @@ fn main() {
|
||||||
// This does work, since the attribute is on a parent
|
// This does work, since the attribute is on a parent
|
||||||
// of the macro invocation.
|
// of the macro invocation.
|
||||||
#[allow(warnings)] { #[inline] foo!(); }
|
#[allow(warnings)] { #[inline] foo!(); }
|
||||||
|
|
||||||
|
// 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!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
warning: unused attribute `inline`
|
warning: unused attribute `inline`
|
||||||
--> $DIR/inert-attr-macro.rs:10:5
|
--> $DIR/inert-attr-macro.rs:11:5
|
||||||
|
|
|
|
||||||
LL | #[inline] foo!();
|
LL | #[inline] foo!();
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: the built-in attribute `inline` will be ignored, since it's applied to the macro invocation `foo`
|
note: the built-in attribute `inline` will be ignored, since it's applied to the macro invocation `foo`
|
||||||
--> $DIR/inert-attr-macro.rs:10:15
|
--> $DIR/inert-attr-macro.rs:11:15
|
||||||
|
|
|
|
||||||
LL | #[inline] foo!();
|
LL | #[inline] foo!();
|
||||||
| ^^^
|
| ^^^
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/inert-attr-macro.rs:3:9
|
--> $DIR/inert-attr-macro.rs:4:9
|
||||||
|
|
|
|
||||||
LL | #![warn(unused)]
|
LL | #![warn(unused)]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
= note: `#[warn(unused_attributes)]` implied by `#[warn(unused)]`
|
= note: `#[warn(unused_attributes)]` implied by `#[warn(unused)]`
|
||||||
|
|
||||||
warning: unused attribute `allow`
|
warning: unused attribute `allow`
|
||||||
--> $DIR/inert-attr-macro.rs:14:5
|
--> $DIR/inert-attr-macro.rs:15:5
|
||||||
|
|
|
|
||||||
LL | #[allow(warnings)] #[inline] foo!();
|
LL | #[allow(warnings)] #[inline] foo!();
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: the built-in attribute `allow` will be ignored, since it's applied to the macro invocation `foo`
|
note: the built-in attribute `allow` will be ignored, since it's applied to the macro invocation `foo`
|
||||||
--> $DIR/inert-attr-macro.rs:14:34
|
--> $DIR/inert-attr-macro.rs:15:34
|
||||||
|
|
|
|
||||||
LL | #[allow(warnings)] #[inline] foo!();
|
LL | #[allow(warnings)] #[inline] foo!();
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
warning: unused attribute `inline`
|
warning: unused attribute `inline`
|
||||||
--> $DIR/inert-attr-macro.rs:14:24
|
--> $DIR/inert-attr-macro.rs:15:24
|
||||||
|
|
|
|
||||||
LL | #[allow(warnings)] #[inline] foo!();
|
LL | #[allow(warnings)] #[inline] foo!();
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: the built-in attribute `inline` will be ignored, since it's applied to the macro invocation `foo`
|
note: the built-in attribute `inline` will be ignored, since it's applied to the macro invocation `foo`
|
||||||
--> $DIR/inert-attr-macro.rs:14:34
|
--> $DIR/inert-attr-macro.rs:15:34
|
||||||
|
|
|
|
||||||
LL | #[allow(warnings)] #[inline] foo!();
|
LL | #[allow(warnings)] #[inline] foo!();
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue