Uh oh!
There was an error while loading. Please reload this page.
Suggest comma when writing println!("{}" a); - #52397
Conversation
println!("{}" a);println!("{}" a);rust-highfive
commented
Jul 15, 2018
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
println!("{}" a);println!("{}" a);There was a problem hiding this comment.
So this doesn't work for println!("{} {}" a, b); or println!("{} {}", a b);?
If it does work, please add tests, if it does not work, would it be a lot of effort to fix that?
There was a problem hiding this comment.
The further we go from the "{}" a case, the less likely we're to find a suitable fix by just checking against comma separated list. Having said that, making sure that every element is separated by commas should be easy to add.
oli-obk
commented
Jul 16, 2018
r? @oli-obk Advanced mode: Can we ask the macro matcher how far each arm got and suggest the next possible matches in the spirit of "expected one of |
estebank
commented
Jul 16, 2018
@oli-obk that sounds interesting to do... I'll look into it this week. |
emilyalbini
commented
Jul 30, 2018
Ping from triage @estebank! It's been a while since we heard from you, will you have time to work on this again? |
estebank
commented
Jul 30, 2018
@pietroalbini will do soonish. @oli-obk I tried to get this for arbitrary sequences (finding a missing comma that is not the first one) and it was a bit more involved than I anticipated. I need to regroup and write a generalized version, but I feel like we could land this very specific one in the meantime, after I fix the typo. |
oli-obk
commented
Jul 31, 2018
Sgtm |
estebank
commented
Jul 31, 2018
Fixed the typo. |
oli-obk
commented
Jul 31, 2018
@bors r+ |
bors
commented
Jul 31, 2018
📌 Commit c4b7b1eec4ea0b354bce8c1fb417598b63710966 has been approved by |
This comment has been minimized.
This comment has been minimized.
estebank
commented
Jul 31, 2018
@bors r- gonna rebase against master, it's probably stale |
This comment has been minimized.
This comment has been minimized.
bors
commented
Aug 7, 2018
💔 Test failed - status-travis |
This comment has been minimized.
This comment has been minimized.
oli-obk
commented
Aug 7, 2018
@bors retry |
bors
commented
Aug 7, 2018
⌛ Testing commit daa5bd3 with merge 80be6b8e7f9b40181807bb6ea7afb5e856f7a1d0... |
bors
commented
Aug 7, 2018
💔 Test failed - status-travis |
This comment has been minimized.
This comment has been minimized.
oli-obk
commented
Aug 7, 2018
@bors retry |
bors
commented
Aug 7, 2018
Suggest comma when writing `println!("{}" a);`
Fix#49370.bors
commented
Aug 8, 2018
☀️ Test successful - status-appveyor, status-travis |
sunjay
commented
Aug 8, 2018
This is awesome! Thank you for doing this! I'm the one who filed the original issue about it and I really appreciate that it was fixed. 😁 |
Suggest comma when missing in macro call When missing a comma in a macro call, suggest it, regardless of position. When a macro call doesn't match any of the patterns, check if the call's token stream could be missing a comma between two idents, and if so, create a new token stream containing the comma and try to match against the macro patterns. If successful, emit the suggestion. This works on arbitrary macros, with no need of special support from the macro writers. ``` error: no rules expected the token `d` --> $DIR/missing-comma.rs:26:18 | LL | foo!(a, b, c d, e); | -^ | | | help: missing comma here ``` Follow up to rust-lang#52397.
Suggest comma when missing in macro call When missing a comma in a macro call, suggest it, regardless of position. When a macro call doesn't match any of the patterns, check if the call's token stream could be missing a comma between two idents, and if so, create a new token stream containing the comma and try to match against the macro patterns. If successful, emit the suggestion. This works on arbitrary macros, with no need of special support from the macro writers. ``` error: no rules expected the token `d` --> $DIR/missing-comma.rs:26:18 | LL | foo!(a, b, c d, e); | -^ | | | help: missing comma here ``` Follow up to rust-lang#52397.
Suggest comma when missing in macro call When missing a comma in a macro call, suggest it, regardless of position. When a macro call doesn't match any of the patterns, check if the call's token stream could be missing a comma between two idents, and if so, create a new token stream containing the comma and try to match against the macro patterns. If successful, emit the suggestion. This works on arbitrary macros, with no need of special support from the macro writers. ``` error: no rules expected the token `d` --> $DIR/missing-comma.rs:26:18 | LL | foo!(a, b, c d, e); | -^ | | | help: missing comma here ``` Follow up to rust-lang#52397.
Suggest comma when missing in macro call When missing a comma in a macro call, suggest it, regardless of position. When a macro call doesn't match any of the patterns, check if the call's token stream could be missing a comma between two idents, and if so, create a new token stream containing the comma and try to match against the macro patterns. If successful, emit the suggestion. This works on arbitrary macros, with no need of special support from the macro writers. ``` error: no rules expected the token `d` --> $DIR/missing-comma.rs:26:18 | LL | foo!(a, b, c d, e); | -^ | | | help: missing comma here ``` Follow up to rust-lang#52397.
Fix#49370.