Skip to content

Fixed issue by changing error label and note #144693

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

OneProgGit
Copy link

@OneProgGit OneProgGit commented Jul 30, 2025

Fixed issue #144023.
Now, the text of the error that occurs when the order of formatting arguments is incorrect is clearer and runned cargo fmt.
Before:
6 | println!("Next u64: {0:#X>18} = {0:>20}", rng.next_u64());
| ^ expected > to occur after : in format string

After:
|
2 | println!("Next u64: {0:#X>18} = {0:>20}", rand::rng().next_u64());
| ^ expected > to occur in its correct place in format string
|
= note: See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details

@rustbot
Copy link
Collaborator

rustbot commented Jul 30, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 30, 2025

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot

This comment has been minimized.

@OneProgGit OneProgGit changed the title Fixed issue #144023 by changing error label and note Fixed issue by changing error label and note Jul 30, 2025
@samueltardieu
Copy link
Member

It looks like a lot of unrelated files have been (badly?) reformatted in the process.

@compiler-errors
Copy link
Member

@OneProgGit: This PR contains a bunch of unnecessary formatting changes. It also doesn't really seem to fix #144693, since I think it makes the error message a bit more vague, since "to occur in its correct place" isn't really self-evident.

Could you please improve the error message to actually explain what is happening here, and remove the unnecessary formatting changes?

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 30, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like formatting only changes in Clippy. Please revert those. It's a minor inconvenience during the sync (This extra newline removal isn't but the other file is).

Copy link
Author

Choose a reason for hiding this comment

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

Reverted this

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/fmt/format-string-wrong-order/format-string-wrong-order.stderr`
diff of stderr:

50    |
51    = note: `?` comes after `:`, try `:?` instead
52 
- error: invalid format string: expected format parameter to occur after `:`
+ error: invalid format string: expected format parameter to occur in its right place
54   --> $DIR/format-string-wrong-order.rs:15:21
55    |
56 LL |     format!("Hello {<5:}!", "x");

-    |                     ^ expected `<` to occur after `:` in format string
+    |                     ^ expected `<` to occur in its right place in format string
+    |
+    = note: See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details
58 
- error: invalid format string: expected format parameter to occur after `:`
+ error: invalid format string: expected format parameter to occur in its right place
60   --> $DIR/format-string-wrong-order.rs:17:21
61    |
62 LL |     format!("Hello {^5:}!", "x");

-    |                     ^ expected `^` to occur after `:` in format string
+    |                     ^ expected `^` to occur in its right place in format string
+    |
+    = note: See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details
64 
- error: invalid format string: expected format parameter to occur after `:`
+ error: invalid format string: expected format parameter to occur in its right place
66   --> $DIR/format-string-wrong-order.rs:19:21
67    |
68 LL |     format!("Hello {>5:}!", "x");

-    |                     ^ expected `>` to occur after `:` in format string
+    |                     ^ expected `>` to occur in its right place in format string
+    |
+    = note: See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details
70 
71 error: aborting due to 9 previous errors
72 
---
To only update this specific test, also pass `--test-args fmt/format-string-wrong-order.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/fmt/format-string-wrong-order.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/fmt/format-string-wrong-order" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: invalid format string: expected format parameter to occur after `:`
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:3:15
   |
LL |     format!("{?:}", bar);
   |               ^ expected `?` to occur after `:` in format string
   |
   = note: `?` comes after `:`, try `:?` instead

error: invalid format string: expected format parameter to occur after `:`
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:5:15
   |
LL |     format!("{?:bar}");
   |               ^ expected `?` to occur after `:` in format string
   |
   = note: `?` comes after `:`, try `bar:?` instead

error: invalid format string: expected format parameter to occur after `:`
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:7:15
   |
LL |     format!("{?:?}", bar);
   |               ^ expected `?` to occur after `:` in format string
   |
   = note: `?` comes after `:`, try `:?` instead

error: invalid format string: expected `}`, found `?`
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:9:15
   |
LL |     format!("{??}", bar);
   |              -^ expected `}` in format string
   |              |
   |              because of this opening brace
   |
   = note: if you intended to print `{`, you can escape it using `{{`

error: invalid format string: expected `}`, found `?`
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:11:15
   |
LL |     format!("{?;bar}");
   |              -^ expected `}` in format string
   |              |
   |              because of this opening brace
   |
   = note: if you intended to print `{`, you can escape it using `{{`

error: invalid format string: expected format parameter to occur after `:`
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:13:15
   |
LL |     format!("{?:#?}", bar);
   |               ^ expected `?` to occur after `:` in format string
   |
   = note: `?` comes after `:`, try `:?` instead

error: invalid format string: expected format parameter to occur in its right place
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:15:21
   |
LL |     format!("Hello {<5:}!", "x");
   |                     ^ expected `<` to occur in its right place in format string
   |
   = note: See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details

error: invalid format string: expected format parameter to occur in its right place
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:17:21
   |
LL |     format!("Hello {^5:}!", "x");
   |                     ^ expected `^` to occur in its right place in format string
   |
   = note: See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details

error: invalid format string: expected format parameter to occur in its right place
##[error]  --> /checkout/tests/ui/fmt/format-string-wrong-order.rs:19:21
   |
LL |     format!("Hello {>5:}!", "x");
   |                     ^ expected `>` to occur in its right place in format string
   |
   = note: See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details

error: aborting due to 9 previous errors
------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. 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.

7 participants