-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest removing redundant arguments in format!()
- Loading branch information
1 parent
c587fd4
commit 12ff6f2
Showing
3 changed files
with
180 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
fn main() { | ||
let x = 0; | ||
println!("{x}", x); | ||
//~^ ERROR: argument never used | ||
|
||
println!("{x} {}", x, x); | ||
//~^ ERROR: argument never used | ||
|
||
println!("{} {x}", x, x); | ||
//~^ ERROR: argument never used | ||
|
||
let y = 0; | ||
println!("{x} {y}", x, y); | ||
//~^ ERROR: multiple unused formatting arguments | ||
|
||
let y = 0; | ||
println!("{} {} {x} {y} {}", x, x, x, y, y); | ||
//~^ ERROR: multiple unused formatting arguments | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
error: argument never used | ||
--> $DIR/issue-105225.rs:3:21 | ||
| | ||
LL | println!("{x}", x); | ||
| ^ argument never used | ||
| | ||
help: the formatting string already captures the binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:3:21 | ||
| | ||
LL | println!("{x}", x); | ||
| - ^ this can be removed | ||
| | | ||
| this formatting specifier is referencing the `x` binding | ||
|
||
error: argument never used | ||
--> $DIR/issue-105225.rs:6:27 | ||
| | ||
LL | println!("{x} {}", x, x); | ||
| ^ argument never used | ||
| | ||
help: the formatting string already captures the binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:6:27 | ||
| | ||
LL | println!("{x} {}", x, x); | ||
| - ^ this can be removed | ||
| | | ||
| this formatting specifier is referencing the `x` binding | ||
|
||
error: argument never used | ||
--> $DIR/issue-105225.rs:9:27 | ||
| | ||
LL | println!("{} {x}", x, x); | ||
| ^ argument never used | ||
| | ||
help: the formatting string already captures the binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:9:27 | ||
| | ||
LL | println!("{} {x}", x, x); | ||
| - ^ this can be removed | ||
| | | ||
| this formatting specifier is referencing the `x` binding | ||
|
||
error: multiple unused formatting arguments | ||
--> $DIR/issue-105225.rs:13:25 | ||
| | ||
LL | println!("{x} {y}", x, y); | ||
| --------- ^ ^ argument never used | ||
| | | | ||
| | argument never used | ||
| multiple missing formatting specifiers | ||
| | ||
help: the formatting strings already captures the bindings directly, they don't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:13:25 | ||
| | ||
LL | println!("{x} {y}", x, y); | ||
| - - ^ ^ this can be removed | ||
| | | | | ||
| | | this can be removed | ||
| | this formatting specifier is referencing the `y` binding | ||
| this formatting specifier is referencing the `x` binding | ||
|
||
error: multiple unused formatting arguments | ||
--> $DIR/issue-105225.rs:17:43 | ||
| | ||
LL | println!("{} {} {x} {y} {}", x, x, x, y, y); | ||
| ------------------ ^ ^ argument never used | ||
| | | | ||
| | argument never used | ||
| multiple missing formatting specifiers | ||
| | ||
help: the formatting string already captures the binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:17:43 | ||
| | ||
LL | println!("{} {} {x} {y} {}", x, x, x, y, y); | ||
| - ^ ^ this can be removed | ||
| | | | ||
| | this can be removed | ||
| this formatting specifier is referencing the `y` binding | ||
|
||
error: aborting due to 5 previous errors | ||
|