-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
@lqd This addresses your comment here: #99660 (comment) Not sure if you want to be the reviewer here or not though? |
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 |
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.
Did you mean to drop "only" here?
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.
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.)
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.
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
d0ebef7
to
298acef
Compare
@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. |
Alright, seems like it didn't conflict. @bors r+ |
…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
For named arguments used as implicit position arguments, underline both
the opening curly brace and either:
closing curl brace or the
:
denoting the start of formatting args)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