-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add suggestion for captured and passed arg case in fmt macro #105635
Closed
+201
−3
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5af8f15
Add suggestion for captured and passed arg case
atamakahere-git 98407cb
Fixed suggestion
atamakahere-git 075e891
Update suggestion msgs
atamakahere-git 01a492c
Removed unused `name` from duplicate_explicit_arg
atamakahere-git 77a9673
Add better suggestion and more tests
atamakahere-git abe777b
Required changes and logic skeleton
atamakahere-git cd4f48c
Remove unwanted comments
atamakahere-git File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,16 @@ | ||
fn main() { | ||
let x = 10; | ||
println!("{x}", x); | ||
//~^ ERROR argument never used | ||
let y = 20; | ||
println!("{x} {y}", x, y); | ||
//~^ ERROR multiple unused formatting arguments | ||
println!("{x} {y}", y, x); | ||
//~^ ERROR multiple unused formatting arguments | ||
println!("{} {y}", x, y); | ||
//~^ ERROR argument never used | ||
println!("{} {} {y} {} {}", y, y, y, y, y); | ||
//~^ ERROR argument never used | ||
println!("{x} {x} {y} {x} {x}", x, y, x, y, y); | ||
//~^ ERROR argument never used | ||
} |
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,107 @@ | ||
error: argument never used | ||
--> $DIR/issue-105225.rs:3:21 | ||
| | ||
LL | println!("{x}", x); | ||
| ----- ^ argument never used | ||
| | | ||
| formatting specifier missing | ||
| | ||
help: the formatting string captures that binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:3:16 | ||
| | ||
LL | println!("{x}", x); | ||
| ^ - this can be removed | ||
| | | ||
| this formatting argument captures `x` directly | ||
|
||
error: multiple unused formatting arguments | ||
--> $DIR/issue-105225.rs:6:25 | ||
| | ||
LL | println!("{x} {y}", x, y); | ||
| --------- ^ ^ argument never used | ||
| | | | ||
| | argument never used | ||
| multiple missing formatting specifiers | ||
| | ||
help: the formatting string captures that binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:6:16 | ||
| | ||
LL | println!("{x} {y}", x, y); | ||
| ^ ^ - - this can be removed | ||
| | | | | ||
| | | this can be removed | ||
| | this formatting argument captures `y` directly | ||
| this formatting argument captures `x` directly | ||
|
||
error: multiple unused formatting arguments | ||
--> $DIR/issue-105225.rs:8:25 | ||
| | ||
LL | println!("{x} {y}", y, x); | ||
| --------- ^ ^ argument never used | ||
| | | | ||
| | argument never used | ||
| multiple missing formatting specifiers | ||
| | ||
help: the formatting string captures that binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:8:16 | ||
| | ||
LL | println!("{x} {y}", y, x); | ||
| ^ ^ - - this can be removed | ||
| | | | | ||
| | | this can be removed | ||
| | this formatting argument captures `y` directly | ||
| this formatting argument captures `x` directly | ||
|
||
error: argument never used | ||
--> $DIR/issue-105225.rs:10:27 | ||
| | ||
LL | println!("{} {y}", x, y); | ||
| -------- ^ argument never used | ||
| | | ||
| formatting specifier missing | ||
| | ||
help: the formatting string captures that binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:10:19 | ||
| | ||
LL | println!("{} {y}", x, y); | ||
| ^ - this can be removed | ||
| | | ||
| this formatting argument captures `y` directly | ||
|
||
error: argument never used | ||
--> $DIR/issue-105225.rs:12:45 | ||
| | ||
LL | println!("{} {} {y} {} {}", y, y, y, y, y); | ||
| ----------------- ^ argument never used | ||
| | | ||
| formatting specifier missing | ||
| | ||
help: the formatting string captures that binding directly, it doesn't need to be included in the argument list | ||
--> $DIR/issue-105225.rs:12:22 | ||
| | ||
LL | println!("{} {} {y} {} {}", y, y, y, y, y); | ||
| ^ - this can be removed | ||
| | | ||
| this formatting argument captures `y` directly | ||
|
||
error: multiple unused formatting arguments | ||
--> new.rs:14:37 | ||
| | ||
14 | println!("{x} {x} {y} {x} {x}", x, y, x, y, y); | ||
| --------------------- ^ ^ ^ ^ ^ argument never used | ||
| | | | | | | ||
| | | | | argument never used | ||
| | | | argument never used | ||
| | | argument never used | ||
| | argument never used | ||
| multiple missing formatting specifiers | ||
| | ||
help: the formatting string captures that binding directly, it doesn't need to be included in the argument list | ||
--> new.rs:14:16 | ||
| | ||
LL | println!("{x} {x} {y} {x} {x}", x, y, x, y, y); | ||
| ^ - this can be removed | ||
| | | ||
| this formatting argument captures `y` directly | ||
error: aborting due to 6 previous errors | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should customize the output depending on the number of bindings:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This request is still valid :)
You can choose to simplify it, but at least I'd like to specialize the output for a single binding as opposed to multiple.