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

Suggest {var:?} when finding {?:var} in inline format strings #106805

Merged
merged 1 commit into from
Feb 3, 2023
Merged

Suggest {var:?} when finding {?:var} in inline format strings #106805

merged 1 commit into from
Feb 3, 2023

Conversation

madsravn
Copy link
Contributor

@madsravn madsravn commented Jan 13, 2023

Fixes #106572

This is my first PR to this project, so hopefully I can get some good pointers with me from the first PR.

Currently my idea was to test out whether or not this is the correct solution to this issue and then hopefully expand upon the idea to not only work for Debug formatting but for all of them. If this is a valid solution, I will create a new issue to give a better error message to a broader range of wrong-order formatting.

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @TaKO8Ki (or someone else) soon.

Please see the contribution instructions for more information.

@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 Jan 13, 2023
@Noratrieb Noratrieb changed the title Pull request to fix issue #106572 - suggesting {var:?} when finding {:?var} in inline format strings Suggest {var:?} when finding {:?var} in inline format strings Jan 13, 2023
@Noratrieb
Copy link
Member

Thanks! Yes, something like this is the correct approach. If you intend to make more changes with more suggestions then feel free, but you can also land just this change first if you prefer.

@mejrs
Copy link
Contributor

mejrs commented Jan 13, 2023

We moved the tests from src/test to tests, so you must rebase and move your tests to the correct location.

@madsravn
Copy link
Contributor Author

Thanks! Yes, something like this is the correct approach. If you intend to make more changes with more suggestions then feel free, but you can also land just this change first if you prefer.

If it is OK, then let's just land this one first. Then I can use some time to tinker with the full idea while maybe grabbing one or two other issues to really learn the ropes.

@madsravn
Copy link
Contributor Author

We moved the tests from src/test to tests, so you must rebase and move your tests to the correct location.

That's a roger. Will do later today - just on my way out the door. Thanks :)

@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic labels Jan 13, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2023

Some changes occurred in need_type_info.rs

cc @lcnr

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@estebank
Copy link
Contributor

There seems to have been an issue with rebasing on top of master. You'll have to rebase interactively on top of master while discarding any commits that you didn't intend to include in the PR. Let us know if you need assistance doing so.

@madsravn
Copy link
Contributor Author

There seems to have been an issue with rebasing on top of master. You'll have to rebase interactively on top of master while discarding any commits that you didn't intend to include in the PR. Let us know if you need assistance doing so.

I would love some assistance with this. For some reason, me and git rebase never became close friends. From the current state, how would you suggest me to unclutter the mess I made and then do it correctly?

@mejrs
Copy link
Contributor

mejrs commented Jan 13, 2023

@mejrs
Copy link
Contributor

mejrs commented Jan 13, 2023

Ah, looks like you managed to figure it out :)

@madsravn
Copy link
Contributor Author

Ah, looks like you managed to figure it out :)

Thanks for the link.

I think I sort of stumbled over the way to solve it. I hope that did the trick and I will be more careful in the future :)

@estebank estebank changed the title Suggest {var:?} when finding {:?var} in inline format strings Suggest {var:?} when finding {?:var} in inline format strings Jan 15, 2023
@madsravn
Copy link
Contributor Author

@TaKO8Ki Hi, I have been told it would be OK to ping you after a few weeks.

Do you know when you will get time to review this? No need to jump on it now if you don't have the time.

@compiler-errors
Copy link
Member

r? @compiler-errors

@rustbot rustbot assigned compiler-errors and unassigned TaKO8Ki Feb 1, 2023
@compiler-errors
Copy link
Member

@madsravn, can you add the tests requested in #106805 (comment) ?

Also, do you mind rebasing and squashing the commit history into one or two PRs -- all those "Adding" and tweaking commits just clutters up the git history 😄

Afterwards, I think this can be approved, as Esteban had noted above.

@@ -0,0 +1,5 @@
fn main() {
let bar = 3;
format!("{?:}", bar); //~ ERROR invalid format string: expected format parameter to occur after `:`
Copy link
Member

@compiler-errors compiler-errors Feb 1, 2023

Choose a reason for hiding this comment

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

tiny nitpick, take it or leave it -- it's easier to read, in my opinion, when the error follows the line in question, using ~^ like:

Suggested change
format!("{?:}", bar); //~ ERROR invalid format string: expected format parameter to occur after `:`
format!("{?:}", bar);
//~^ ERROR invalid format string: expected format parameter to occur after `:`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have squashed the commits - hadn't tried that before. Was surprisingly easy.

And nitpicks are awesome. Those are what changes "good" to "great".

Done

Adding

Adding

Fixing small issues for PR

Adding tests

Removing unused binding

Changing the wording on note

Fixing PR comment
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 3, 2023

📌 Commit f922c83 has been approved by compiler-errors

It is now in the queue for this repository.

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

Rollup of 6 pull requests

Successful merges:

 - rust-lang#106575 (Suggest `move` in nested closure when appropriate)
 - rust-lang#106805 (Suggest `{var:?}` when finding `{?:var}` in inline format strings)
 - rust-lang#107500 (Add tests to assert current behavior of large future sizes)
 - rust-lang#107598 (Fix benchmarks in library/core with black_box)
 - rust-lang#107602 (Parse and recover from type ascription in patterns)
 - rust-lang#107608 (Use triple rather than arch for fuchsia test-runner)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2fdb355 into rust-lang:master Feb 3, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 3, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2024
Adding alignment to the cases to test for specific error messages.

Adding alignment to the list of cases to test for specific error message. Covers `>`, `^` and `<`.

Pinging people who chimed in last time ( rust-lang#106805 ): `@estebank` , `@compiler-errors` and `@Nilstrieb`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 9, 2024
Adding alignment to the cases to test for specific error messages.

Adding alignment to the list of cases to test for specific error message. Covers `>`, `^` and `<`.

Pinging people who chimed in last time ( rust-lang#106805 ): ``@estebank`` , ``@compiler-errors`` and ``@Nilstrieb``
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 9, 2024
Rollup merge of rust-lang#119712 - madsravn:parsing-errors, r=estebank

Adding alignment to the cases to test for specific error messages.

Adding alignment to the list of cases to test for specific error message. Covers `>`, `^` and `<`.

Pinging people who chimed in last time ( rust-lang#106805 ): ``@estebank`` , ``@compiler-errors`` and ``@Nilstrieb``
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 10, 2024
Adding alignment to the cases to test for specific error messages.

Adding alignment to the list of cases to test for specific error message. Covers `>`, `^` and `<`.

Pinging people who chimed in last time ( rust-lang/rust#106805 ): ``@estebank`` , ``@compiler-errors`` and ``@Nilstrieb``
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Apr 7, 2024
Adding alignment to the cases to test for specific error messages.

Adding alignment to the list of cases to test for specific error message. Covers `>`, `^` and `<`.

Pinging people who chimed in last time ( rust-lang/rust#106805 ): ``@estebank`` , ``@compiler-errors`` and ``@Nilstrieb``
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 27, 2024
Adding alignment to the cases to test for specific error messages.

Adding alignment to the list of cases to test for specific error message. Covers `>`, `^` and `<`.

Pinging people who chimed in last time ( rust-lang/rust#106805 ): ``@estebank`` , ``@compiler-errors`` and ``@Nilstrieb``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic 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.

suggest {var:?} when finding {:?var} in inline format strings
8 participants