You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for `#[clippy::format_args]` attribute that can be attached to any macro to indicate that it functions the same as the built-in format macros like `format!`, `println!` and `write!`
In some cases it is possible to extend Clippy coverage to 3rd party libraries. To do this, Clippy provides attributes that can be applied to items in the 3rd party crate.
4
+
5
+
## `#[clippy::format_args]`
6
+
7
+
_Available since Clippy v1.84_
8
+
9
+
This attribute can be added to a macro that supports `format!`-like syntax.
10
+
It tells Clippy that the macro is a formatting macro, and that the arguments to the macro
11
+
should be linted as if they were arguments to `format!`. Any lint that would apply to a
12
+
`format!` call will also apply to the macro call. The macro may have additional arguments
13
+
before the format string, and these will be ignored.
14
+
15
+
### Example
16
+
17
+
```rust
18
+
/// A macro that prints a message if a condition is true.
19
+
#[macro_export]
20
+
#[clippy::format_args]
21
+
macro_rules!print_if {
22
+
($condition:expr, $($args:tt)+) => {{
23
+
if$condition {
24
+
println!($($args)+)
25
+
}
26
+
}};
27
+
}
28
+
```
29
+
30
+
## `#[clippy::has_significant_drop]`
31
+
32
+
_Available since Clippy v1.60_
33
+
34
+
The `clippy::has_significant_drop` attribute can be added to types whose Drop impls have an important side effect,
35
+
such as unlocking a mutex, making it important for users to be able to accurately understand their lifetimes.
36
+
When a temporary is returned in a function call in a match scrutinee, its lifetime lasts until the end of the match
0 commit comments