Commit Graph

16 Commits

Author SHA1 Message Date
Yuri Astrakhan
5a71bbdf3f new uninlined_format_args lint to inline explicit arguments
Implement https://github.com/rust-lang/rust-clippy/issues/8368 - a new
lint to inline format arguments such as `print!("{}", var)` into
`print!("{var}")`.

code | suggestion | comment
---|---|---
`print!("{}", var)` | `print!("{var}")` |  simple variables
`print!("{0}", var)` | `print!("{var}")` |  positional variables
`print!("{v}", v=var)` | `print!("{var}")` |  named variables
`print!("{0} {0}", var)` | `print!("{var} {var}")` |  aliased variables
`print!("{0:1$}", var, width)` | `print!("{var:width$}")` |  width
support
`print!("{0:.1$}", var, prec)` | `print!("{var:.prec$}")` |  precision
support
`print!("{:.*}", prec, var)` | `print!("{var:.prec$}")` |  asterisk
support

code | suggestion | comment
---|---|---
`print!("{0}={1}", var, 1+2)` | `print!("{var}={0}", 1+2)` | Format
string uses an indexed argument that cannot be inlined.  Supporting this
case requires re-indexing of the format string.

changelog: [`uninlined_format_args`]: A new lint to inline format
arguments, i.e. `print!("{}", var)` into `print!("{var}")`
2022-09-25 19:53:03 -04:00
Yuri Astrakhan
59d0e8caba and a few more from other dirs 2022-09-23 14:25:03 -04:00
Jason Newcomb
2ae8b300a7 Don't lint unit_arg when expanded from a proc-macro 2022-08-07 21:52:25 -04:00
Josh Triplett
b7230d4f44 Dogfood fixes to use bool::then_some 2022-07-06 02:03:56 -07:00
Jason Newcomb
eb2908b4ea Add lint almost_complete_letter_range 2022-05-30 23:20:04 -04:00
xFrednet
03960ebab2
Replace #[allow] with #[expect] in Clippy 2022-05-07 17:39:21 +02:00
whodi
29ef80c78a adding spell checking 2022-04-15 14:18:09 -07:00
Jason Newcomb
63f6a79bf8 Don't lint various match lints when expanded by a proc-macro 2022-04-08 16:51:40 -04:00
Cameron Steffen
02ec39b2ff Stop using in_band_lifetimes 2022-01-11 09:52:23 -06:00
5225225
96db1d6bea fix dogfood lint on clippy_utils 2021-11-09 17:30:15 +00:00
xFrednet
d134dddf70
Improve clippy_utils function docs 2021-11-04 12:42:29 +01:00
Jade
11ef04728c Add unwrap_or_else_default lint
This will catch `unwrap_or_else(Default::default)` on Result and Option
and suggest `unwrap_or_default()` instead.
2021-08-10 14:40:26 -07:00
Jason Newcomb
ef9ad80617
Add examples to better explain walk_span_to_context 2021-04-22 09:36:46 -04:00
Jason Newcomb
22f8c13cf5
Improve implicit_return
Better suggestions when returning macro calls.
Suggest changeing all the break expressions in a loop, not just the final statement.
Don't lint divergent functions.
Don't suggest returning the result of any divergent fuction.
2021-04-22 09:13:06 -04:00
Jason Newcomb
ce5e927713
Improve map_entry lint
Fix false positives where the map is used before inserting into the map.
Fix false positives where two insertions happen.
Suggest using `if let Entry::Vacant(e) = _.entry(_)` when `or_insert` might be a semantic change
2021-04-15 08:19:40 -04:00
Cameron Steffen
6fc52a63d1 Move some utils to clippy_utils::source module 2021-03-15 15:34:15 -05:00