forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#115324 - francorbacho:master, r=davidtwco
Suggest removing redundant arguments in format!() Closes rust-lang#105225. This is also a follow-up to rust-lang#105635, which seems to have become stale. r? `@estebank`
- Loading branch information
Showing
8 changed files
with
291 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
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,10 @@ | ||
fn main() { | ||
let x = "x"; | ||
let y = "y"; | ||
|
||
println!("{x}", x, x = y); | ||
//~^ ERROR: redundant argument | ||
|
||
println!("{x}", x = y, x = y); | ||
//~^ ERROR: duplicate argument named `x` | ||
} |
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,22 @@ | ||
error: redundant argument | ||
--> $DIR/issue-105225-named-args.rs:5:21 | ||
| | ||
LL | println!("{x}", x, x = y); | ||
| ^ | ||
| | ||
note: the formatting specifier is referencing the binding already | ||
--> $DIR/issue-105225-named-args.rs:5:16 | ||
| | ||
LL | println!("{x}", x, x = y); | ||
| ^ | ||
|
||
error: duplicate argument named `x` | ||
--> $DIR/issue-105225-named-args.rs:8:28 | ||
| | ||
LL | println!("{x}", x = y, x = y); | ||
| - ^ duplicate argument | ||
| | | ||
| previously here | ||
|
||
error: aborting due to 2 previous errors | ||
|
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,21 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
let x = "x"; | ||
let y = "y"; | ||
|
||
println!("{x}", ); | ||
//~^ ERROR: redundant argument | ||
|
||
println!("{x} {}", x, ); | ||
//~^ ERROR: redundant argument | ||
|
||
println!("{} {x}", x, ); | ||
//~^ ERROR: redundant argument | ||
|
||
println!("{x} {y}", ); | ||
//~^ ERROR: redundant arguments | ||
|
||
println!("{} {} {x} {y} {}", x, x, x, ); | ||
//~^ ERROR: redundant 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,21 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
let x = "x"; | ||
let y = "y"; | ||
|
||
println!("{x}", x); | ||
//~^ ERROR: redundant argument | ||
|
||
println!("{x} {}", x, x); | ||
//~^ ERROR: redundant argument | ||
|
||
println!("{} {x}", x, x); | ||
//~^ ERROR: redundant argument | ||
|
||
println!("{x} {y}", x, y); | ||
//~^ ERROR: redundant arguments | ||
|
||
println!("{} {} {x} {y} {}", x, x, x, y, y); | ||
//~^ ERROR: redundant 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,72 @@ | ||
error: redundant argument | ||
--> $DIR/issue-105225.rs:7:21 | ||
| | ||
LL | println!("{x}", x); | ||
| ^ help: this can be removed | ||
| | ||
note: the formatting specifier is referencing the binding already | ||
--> $DIR/issue-105225.rs:7:16 | ||
| | ||
LL | println!("{x}", x); | ||
| ^ | ||
|
||
error: redundant argument | ||
--> $DIR/issue-105225.rs:10:27 | ||
| | ||
LL | println!("{x} {}", x, x); | ||
| ^ help: this can be removed | ||
| | ||
note: the formatting specifier is referencing the binding already | ||
--> $DIR/issue-105225.rs:10:16 | ||
| | ||
LL | println!("{x} {}", x, x); | ||
| ^ | ||
|
||
error: redundant argument | ||
--> $DIR/issue-105225.rs:13:27 | ||
| | ||
LL | println!("{} {x}", x, x); | ||
| ^ help: this can be removed | ||
| | ||
note: the formatting specifier is referencing the binding already | ||
--> $DIR/issue-105225.rs:13:19 | ||
| | ||
LL | println!("{} {x}", x, x); | ||
| ^ | ||
|
||
error: redundant arguments | ||
--> $DIR/issue-105225.rs:16:25 | ||
| | ||
LL | println!("{x} {y}", x, y); | ||
| ^ ^ | ||
| | ||
note: the formatting specifiers are referencing the bindings already | ||
--> $DIR/issue-105225.rs:16:16 | ||
| | ||
LL | println!("{x} {y}", x, y); | ||
| ^ ^ | ||
help: this can be removed | ||
| | ||
LL - println!("{x} {y}", x, y); | ||
LL + println!("{x} {y}", ); | ||
| | ||
|
||
error: redundant arguments | ||
--> $DIR/issue-105225.rs:19:43 | ||
| | ||
LL | println!("{} {} {x} {y} {}", x, x, x, y, y); | ||
| ^ ^ | ||
| | ||
note: the formatting specifiers are referencing the bindings already | ||
--> $DIR/issue-105225.rs:19:26 | ||
| | ||
LL | println!("{} {} {x} {y} {}", x, x, x, y, y); | ||
| ^ | ||
help: this can be removed | ||
| | ||
LL - println!("{} {} {x} {y} {}", x, x, x, y, y); | ||
LL + println!("{} {} {x} {y} {}", x, x, x, ); | ||
| | ||
|
||
error: aborting due to 5 previous errors | ||
|