Tag all format-like macros with #[clippy::format_args]#137364
Tag all format-like macros with #[clippy::format_args]#137364nyurik wants to merge 1 commit intorust-lang:mainfrom
#[clippy::format_args]#137364Conversation
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 :) |
| #[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.
Is there a reason why this one is not gated on cfg(test) but all others are?
There was a problem hiding this comment.
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. |
|
Marking this as blocked on #98291 |
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