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
If the user writes some expression that uses format_args where any of the arguments could be captured, lint with a suggestion to have as many captures as possible.
This lint would have a suggestion category of MachineApplicable so it can be used to bulk move to using format args capture.
Not entirely sure which category this would belong in. I'm thinking either restriction (so you use this mostly as a refactoring tool, deny the lint and then cargo clippy fix), or style because it is a style matter. Depends how controversial the lint is.
I feel it would be incredibly noisy on any nontrivial crate, so making it warn by default might be a bad idea.
Lint Name
uncaptured_format_args
Category
style, restriction
Advantage
Shorter, and the name of the argument is inline directly in the code.
Drawbacks
If you have multiple arguments, and only some of them can be made inline, then the arguments will be out of order.
This could be mitigated against by only linting if we can move all of the arguments, with a configuration option to lint on all of them? That or 2 different lints.
Example
let x = 1;let y = format!("{}, {}", x,10);
Could be written as:
let x = 1;let y = format!("{x}, {}",10);
The text was updated successfully, but these errors were encountered:
What it does
If the user writes some expression that uses format_args where any of the arguments could be captured, lint with a suggestion to have as many captures as possible.
This lint would have a suggestion category of MachineApplicable so it can be used to bulk move to using format args capture.
Not entirely sure which category this would belong in. I'm thinking either
restriction
(so you use this mostly as a refactoring tool, deny the lint and thencargo clippy fix
), orstyle
because it is a style matter. Depends how controversial the lint is.I feel it would be incredibly noisy on any nontrivial crate, so making it warn by default might be a bad idea.
Lint Name
uncaptured_format_args
Category
style, restriction
Advantage
Shorter, and the name of the argument is inline directly in the code.
Drawbacks
If you have multiple arguments, and only some of them can be made inline, then the arguments will be out of order.
This could be mitigated against by only linting if we can move all of the arguments, with a configuration option to lint on all of them? That or 2 different lints.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: