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 extend Clippy coverage to include 3rd party libraries.
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, such as unlocking a mutex, making it important for users to be able to accurately understand their lifetimes. When a temporary is returned in a function call in a match scrutinee, its lifetime lasts until the end of the match block, which may be surprising.
0 commit comments