Commit Graph

11 Commits

Author SHA1 Message Date
Oli Scherer
5bd97ac17a Update tests 2023-06-26 14:13:07 +00:00
Pavan Kumar Sunkara
bfd5abad4b Fix all the other tests 2023-06-12 16:21:06 +01:00
Oli Scherer
def1705a27 Update to a compiletest-rs version that requires //@ for commands 2023-04-20 14:44:03 +00:00
Yuri Astrakhan
783879e6fe Partial no-op refactoring of #9948
This contains preparatory work for #9948 to keep that change to the
minimum, and make it easier to review it.
2023-03-28 21:08:06 -04:00
Jason Newcomb
1c7048d785 Add utility macros to help with writing tests. 2023-03-12 17:24:36 -04:00
Samuel Tardieu
75aa2b9ec8 uninlined_format_args: do not inline argument with generic parameters 2023-02-15 08:49:43 +01:00
Alex Macleod
461e219d1d Allow using clippy::msrv as an outer attribute 2022-11-27 12:43:17 +00:00
Yuri Astrakhan
74ba7e1b99 Handle panic! inline_format-arg before ed2021 2022-10-11 21:27:41 -04:00
Alex Macleod
9226066bcb FormatArgsExpn: Find comma spans and ignore weird proc macro spans 2022-10-05 16:10:52 +00:00
Yuri Astrakhan
eb3970285b fallout: fix tests to allow uninlined_format_args
In order to switch `clippy::uninlined_format_args` from pedantic to
style, all existing tests must not raise a warning. I did not want to
change the actual tests, so this is a relatively minor change that:

* add `#![allow(clippy::uninlined_format_args)]` where needed
* normalizes all allow/deny/warn attributes
   * all allow attributes are grouped together
   * sorted alphabetically
   * the `clippy::*` attributes are listed separate from the other ones.
   * deny and warn attributes are listed before the allowed ones

changelog: none
2022-10-02 15:13:22 -04:00
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