Skip to content
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 explicit_write suggestions for write!s with format args #8365

Merged
merged 2 commits into from
Feb 5, 2022

Conversation

Alexendoo
Copy link
Member

changelog: Add [explicit_write] suggestions for write!s with format args

Fixes #4542

writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();

Now suggests:

error: use of `writeln!(stderr(), ...).unwrap()`
  --> $DIR/explicit_write.rs:36:9
   |
LL |         writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("macro arg {}", one!())`

r? @camsteffen (again, sorry 😛) for the FormatArgsExpn change

Before this change inputs_span returned a span pointing to just 1 in

macro_rules! one {
    () => { 1 };
}

`writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();`

And the source_callsite of that span didn't include the format string, it was just one!()

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 28, 2022
@Alexendoo Alexendoo force-pushed the explicit-write-suggestion branch from d253263 to 8f2df87 Compare January 28, 2022 16:42
@camsteffen camsteffen assigned camsteffen and unassigned Manishearth Jan 28, 2022
@camsteffen camsteffen added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 28, 2022
@Alexendoo Alexendoo force-pushed the explicit-write-suggestion branch from 8f2df87 to 28b192c Compare January 29, 2022 12:09
@Alexendoo Alexendoo force-pushed the explicit-write-suggestion branch from 28b192c to 144b4a5 Compare February 5, 2022 13:34
@Alexendoo
Copy link
Member Author

Alexendoo commented Feb 5, 2022

@rustbot ready

Forgot to do that 👀

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Feb 5, 2022
@camsteffen
Copy link
Contributor

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Feb 5, 2022

📌 Commit 144b4a5 has been approved by camsteffen

@bors
Copy link
Contributor

bors commented Feb 5, 2022

⌛ Testing commit 144b4a5 with merge 68b4498...

@bors
Copy link
Contributor

bors commented Feb 5, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: camsteffen
Pushing 68b4498 to master...

@bors bors merged commit 68b4498 into rust-lang:master Feb 5, 2022
@Alexendoo Alexendoo deleted the explicit-write-suggestion branch February 6, 2022 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revive suggestion on explicit_write
6 participants