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

Improve position named arguments lint underline and formatting names #99958

Merged
merged 2 commits into from
Aug 3, 2022

Conversation

PrestonFrom
Copy link
Contributor

For named arguments used as implicit position arguments, underline both
the opening curly brace and either:

  • if there is formatting, the next character (which will either be the
    closing curl brace or the : denoting the start of formatting args)
  • if there is no formatting, the entire arg span (important if there is
    whitespace like { })

This should make it more obvious where the named argument should be.

Additionally, in the lint message, emit the formatting argument names
without a dollar sign to avoid potentially confusion.

Fixes #99907

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 30, 2022
@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 30, 2022
@PrestonFrom
Copy link
Contributor Author

@lqd This addresses your comment here: #99660 (comment)

Not sure if you want to be the reviewer here or not though?

@compiler-errors
Copy link
Member

r? @compiler-errors since i reviewed the other two PRs touching this code

@@ -190,7 +190,7 @@ LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
| - this formatting argument uses named argument `f` by position
...
LL | f = 0.02f32,
| ^ this named argument is only referred to by position in formatting string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to drop "only" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the previous PR, the lint will trigger for every case a named argument is used positionally even if it's used by name elsewhere, so I think "only" is now incorrect. (I missed this in the last change.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok.

For named arguments used as implicit position arguments, underline both
the opening curly brace and either:
* if there is formatting, the next character (which will either be the
  closing curl brace or the `:` denoting the start of formatting args)
* if there is no formatting, the entire arg span (important if there is
  whitespace like `{  }`)

This should make it more obvious where the named argument should be.

Additionally, in the lint message, emit the formatting argument names
without a dollar sign to avoid potentially confusion.

Fixes rust-lang#99907
@PrestonFrom
Copy link
Contributor Author

@compiler-errors Thank you for the review!

It looks like #99987 is still in the queue but at the moment I don't think it should have any merge conflicts.

@compiler-errors
Copy link
Member

Alright, seems like it didn't conflict.

@bors r+

@bors
Copy link
Contributor

bors commented Aug 2, 2022

📌 Commit 298acef has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 2, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 3, 2022
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#99933 (parallelize HTML checking tool)
 - rust-lang#99958 (Improve position named arguments lint underline and formatting names)
 - rust-lang#100008 (Update all pre-cloned submodules on startup)
 - rust-lang#100049 (:arrow_up: rust-analyzer)
 - rust-lang#100070 (Clarify Cargo.toml comments)
 - rust-lang#100074 (rustc-docs: Be less specific about the representation of `+bundle`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 82feb49 into rust-lang:master Aug 3, 2022
@rustbot rustbot added this to the 1.64.0 milestone Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
6 participants