-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Tag all format-like macros with #[clippy::format_args]
#137364
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
19fc60c
to
55b4991
Compare
This comment has been minimized.
This comment has been minimized.
I think the attribute shouldn't be clippy-specific — other tools might be able to use that as well. |
@tbu- not sure i understand. Anyone can use this attribute, but it would be quiet a challenge to introduce a new attribute namespace to the whole ecosystem, especially because now clippy utils is published as a crate, and can be reused by others... so it already expects this namespace. |
Since 1.85, Clippy [supports](See https://doc.rust-lang.org/nightly/clippy/attribs.html#clippyformat_args) attribute-based discovery of the `format!`-compatible macros, i.e. macros whose trailing arguments can be passed to `format_args!` as is. Tagging core library with the same attribute will allow clippy to stop maintaining a separate list of format-like macros - allowing Clippy to validate macro usage for all lints that work on format arguments. See also rust-lang/rust-clippy#14267
55b4991
to
cf98080
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
We need to benchmark this in Clippy, it may add way more work for the CPU than it's worth. I'll benchmark it in the coming days :) |
@@ -895,6 +897,7 @@ macro_rules! unreachable { | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
#[cfg_attr(not(test), rustc_diagnostic_item = "unimplemented_macro")] | |||
#[allow_internal_unstable(panic_internals)] | |||
#[clippy::format_args] |
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.
Is there a reason why this one is not gated on cfg(test)
but all others are?
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.
TBH, I do not think any usage of the clippy attribute should be gated on anything - e.g. if its a test, clippy should still do the format-related lints. The bigger issue is the #98291 - which blocks many crates as well as stdlib from usign this feature, and I have no idea if there is a workaround for it...
I don't feel qualified to review this. r? @m-ou-se |
☔ The latest upstream changes (presumably #138208) made this pull request unmergeable. Please resolve the merge conflicts. |
Help needed
Is there a workaround for #98291 ? The build errors here seem to be triggered by that issue.
Description
Since 1.85, Clippy supports attribute-based discovery of the
format!
-compatible macros, i.e. macros whose trailing arguments can be passed toformat_args!
as is.Tagging core library with the same attribute will allow clippy to stop maintaining a separate list of format-like macros - allowing Clippy to validate macro usage for all lints that work on format arguments. See also rust-lang/rust-clippy#14267