Skip to content

Comments

Improve write! and writeln! error when called without destination#152508

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
arferreira:improve-write-macro-diagnostic
Feb 15, 2026
Merged

Improve write! and writeln! error when called without destination#152508
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
arferreira:improve-write-macro-diagnostic

Conversation

@arferreira
Copy link
Contributor

@arferreira arferreira commented Feb 12, 2026

Fixes #152493

Adds catch-all arms to write! and writeln! macros so that calling them without a destination (e.g., write!("S") instead of write!(f, "S")) gives a clear error instead of the cryptic "unexpected end of macro invocation" pointing at macro internals.

r? @estebank

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 12, 2026
@Kivooeo
Copy link
Member

Kivooeo commented Feb 12, 2026

as far as I can see this requires someone from libs team, since this is library/ change, so...

r? libs

@rustbot rustbot assigned Mark-Simulacrum and unassigned estebank Feb 12, 2026
@Kivooeo Kivooeo removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 12, 2026
@theemathas
Copy link
Contributor

Does this fix the case where someone writes write!("{}", x) ?

@arferreira
Copy link
Contributor Author

No, write!("{}", x) still matches the existing ($dst:expr, $($arg:tt)*) arm

@Mark-Simulacrum
Copy link
Member

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 14, 2026

📌 Commit 0bcec37 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Feb 14, 2026
rust-bors bot pushed a commit that referenced this pull request Feb 15, 2026
Rollup of 9 pull requests

Successful merges:

 - #150424 (diagnostics: add note when param-env shadows global impl)
 - #152132 (implement `carryless_mul`)
 - #152508 (Improve write! and writeln! error when called without destination)
 - #152534 (Test(lib/win/net): Skip UDS tests when under Win7)
 - #152578 (ci: Lock cross toolchain version and update docs)
 - #152188 (Include `library/stdarch` for `CURRENT_RUSTC_VERSION` updates)
 - #152402 (Add regression test for #141738)
 - #152472 (unwind/wasm: fix compile error by wrapping wasm_throw in unsafe block)
 - #152610 (Exchange js_lint message between bless and non-bless)
@rust-bors rust-bors bot merged commit 8075b89 into rust-lang:main Feb 15, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 15, 2026
rust-timer added a commit that referenced this pull request Feb 15, 2026
Rollup merge of #152508 - arferreira:improve-write-macro-diagnostic, r=Mark-Simulacrum

Improve write! and writeln! error when called without destination

Fixes #152493

Adds catch-all arms to `write!` and `writeln!` macros so that calling them without a destination (e.g., `write!("S")` instead of `write!(f, "S")`) gives a clear error instead of the cryptic "unexpected end of macro invocation" pointing at macro internals.

r? @estebank
github-actions bot pushed a commit to rust-lang/stdarch that referenced this pull request Feb 16, 2026
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#150424 (diagnostics: add note when param-env shadows global impl)
 - rust-lang/rust#152132 (implement `carryless_mul`)
 - rust-lang/rust#152508 (Improve write! and writeln! error when called without destination)
 - rust-lang/rust#152534 (Test(lib/win/net): Skip UDS tests when under Win7)
 - rust-lang/rust#152578 (ci: Lock cross toolchain version and update docs)
 - rust-lang/rust#152188 (Include `library/stdarch` for `CURRENT_RUSTC_VERSION` updates)
 - rust-lang/rust#152402 (Add regression test for rust-lang/rust#141738)
 - rust-lang/rust#152472 (unwind/wasm: fix compile error by wrapping wasm_throw in unsafe block)
 - rust-lang/rust#152610 (Exchange js_lint message between bless and non-bless)
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-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error on incomplete macro call could provide more context, specially for built-in macros like write! not receiving the Formatter

6 participants