-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn on inert attributes used on bang macro invocation #87296
Conversation
These attributes are currently discarded. This may change in the future (see rust-lang#63221), but for now, placing inert attributes on a macro invocation does nothing, so we should warn users about it. Technically, it's possible for there to be attribute macro on the same macro invocation (or at a higher scope), which inspects the inert attribute. For example: ```rust #[look_for_inline_attr] #[inline] my_macro!() #[look_for_nested_inline] mod foo { #[inline] my_macro!() } ``` However, this would be a very strange thing to do. Anyone running into this can manually suppress the warning.
r? @wesleywiser (rust-highfive has picked a reviewer for you, use r? to override) |
let attr_name = attr.ident().unwrap().name; | ||
// `#[cfg]` and `#[cfg_attr]` are special - they are | ||
// eagerly evaluated. | ||
if attr_name != sym::cfg && attr_name != sym::cfg_attr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cfg
and cfg_attr
should be unreachable here in theory, but that's not entirely true right now because cfg(TRUE)
doesn't remove itself.
@bors r+ |
📌 Commit b41672e has been approved by |
⌛ Testing commit b41672e with merge 498d85dce32af9ad484db3eefe3882125bc20156... |
💥 Test timed out |
@bors retry |
Warn on inert attributes used on bang macro invocation These attributes are currently discarded. This may change in the future (see rust-lang#63221), but for now, placing inert attributes on a macro invocation does nothing, so we should warn users about it. Technically, it's possible for there to be attribute macro on the same macro invocation (or at a higher scope), which inspects the inert attribute. For example: ```rust #[look_for_inline_attr] #[inline] my_macro!() #[look_for_nested_inline] mod foo { #[inline] my_macro!() } ``` However, this would be a very strange thing to do. Anyone running into this can manually suppress the warning.
☀️ Test successful - checks-actions |
These attributes are currently discarded.
This may change in the future (see #63221), but for now,
placing inert attributes on a macro invocation does nothing,
so we should warn users about it.
Technically, it's possible for there to be attribute macro
on the same macro invocation (or at a higher scope), which
inspects the inert attribute. For example:
However, this would be a very strange thing to do.
Anyone running into this can manually suppress the warning.