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 suggestion for wrongly ordered format parameters #134877

Merged
merged 1 commit into from
Jan 1, 2025

Conversation

DavisRayM
Copy link
Contributor

@DavisRayM DavisRayM commented Dec 29, 2024

Add suggestion for wrongly ordered format parameters like ?#.

Supersedes #131004
Fix #129966

@rustbot
Copy link
Collaborator

rustbot commented Dec 29, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 29, 2024
Comment on lines +19 to +20
//~^ ERROR invalid format string: expected `}`, found `x`
//~| HELP did you mean `x?`?
Copy link
Contributor Author

@DavisRayM DavisRayM Dec 29, 2024

Choose a reason for hiding this comment

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

I thought it made sense to return the same error description, expected '}'..., rather than introducing a new one, as it's the actual underlying error. I added a suggestion to reorder the format parameter if a #/x/X character is spotted afterward. However, I completely understand if the preference is to add a new error message similar to the approach taken in the previous PR this one replaces.

@DavisRayM DavisRayM force-pushed the 129966-format-string-help-message branch from e35719c to 62c3c9a Compare December 30, 2024 14:15
@@ -197,6 +197,8 @@ builtin_macros_format_redundant_args = redundant {$n ->

builtin_macros_format_remove_raw_ident = remove the `r#`

builtin_macros_format_reorder_format_parameter = did you mean `{$replacement}`?
Copy link
Contributor

Choose a reason for hiding this comment

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

For future reference, we prefer not to ask questions of the user anymore. If I were writing this message, I'd say something like "you might have meant to write #?".

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 31, 2024

📌 Commit 62c3c9a has been approved by estebank

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 Dec 31, 2024
Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 1, 2025
…p-message, r=estebank

add suggestion for wrongly ordered format parameters

Add suggestion for wrongly ordered format parameters like `?#`.

Supersedes rust-lang#131004
Fix rust-lang#129966
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 1, 2025
Rollup of 7 pull requests

Successful merges:

 - rust-lang#131439 (Remove allowing static_mut_refs lint)
 - rust-lang#133292 (E0277: suggest dereferencing function arguments in more cases)
 - rust-lang#134080 (Avoid use of LFS64 symbols on Emscripten)
 - rust-lang#134877 (add suggestion for wrongly ordered format parameters)
 - rust-lang#134926 (Update books)
 - rust-lang#134945 (Some small nits to the borrowck suggestions for mutating a map through index)
 - rust-lang#134979 (Provide structured suggestion for `impl Default` of type where all fields have defaults)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 1, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang#131439 (Remove allowing static_mut_refs lint)
 - rust-lang#133292 (E0277: suggest dereferencing function arguments in more cases)
 - rust-lang#134877 (add suggestion for wrongly ordered format parameters)
 - rust-lang#134945 (Some small nits to the borrowck suggestions for mutating a map through index)
 - rust-lang#134950 (bootstrap: Overhaul and simplify the `tool_check_step!` macro)
 - rust-lang#134979 (Provide structured suggestion for `impl Default` of type where all fields have defaults)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1ea1db5 into rust-lang:master Jan 1, 2025
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Jan 1, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 1, 2025
Rollup merge of rust-lang#134877 - DavisRayM:129966-format-string-help-message, r=estebank

add suggestion for wrongly ordered format parameters

Add suggestion for wrongly ordered format parameters like `?#`.

Supersedes rust-lang#131004
Fix rust-lang#129966
@DavisRayM DavisRayM deleted the 129966-format-string-help-message branch January 2, 2025 11:19
@DavisRayM DavisRayM restored the 129966-format-string-help-message branch January 2, 2025 11:20
@DavisRayM DavisRayM deleted the 129966-format-string-help-message branch January 2, 2025 11:20
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
Development

Successfully merging this pull request may close these issues.

Reversed order of ?# in format string gives unhelpful error message
4 participants