Warn on inert attributes used on bang macro invocation#87296
Merged
bors merged 2 commits intorust-lang:masterfrom Jul 24, 2021
Merged
Warn on inert attributes used on bang macro invocation#87296bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
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.
Contributor
|
r? @wesleywiser (rust-highfive has picked a reviewer for you, use r? to override) |
Contributor
Author
| 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 { |
Contributor
There was a problem hiding this comment.
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.
Contributor
|
@bors r+ |
Collaborator
|
📌 Commit b41672e has been approved by |
Collaborator
|
⌛ Testing commit b41672e with merge 498d85dce32af9ad484db3eefe3882125bc20156... |
Collaborator
|
💥 Test timed out |
Collaborator
Contributor
|
@bors retry |
LeSeulArtichaut
added a commit
to LeSeulArtichaut/rust
that referenced
this pull request
Jul 24, 2021
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.
Collaborator
Collaborator
|
☀️ Test successful - checks-actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.