Skip to content

Conversation

lukas-code
Copy link
Member

Format strings don't support raw identifiers (e.g. format!("{r#type}")), but they do support keywords in the format string directly (e.g. format!("{type}")). This PR improves the error output when attempting to use a raw identifier in a format string and adds a machine-applicable suggestion to remove the r#.

fixes #115466

@rustbot
Copy link
Collaborator

rustbot commented Sep 6, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@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 Sep 6, 2023
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 16, 2023

📌 Commit d990eee has been approved by compiler-errors

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 Sep 16, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 17, 2023
Rollup of 6 pull requests

Successful merges:

 - rust-lang#114965 (Remove Drop impl of mpsc Receiver and (Sync)Sender)
 - rust-lang#115434 (make `Debug` impl for `ascii::Char` match that of `char`)
 - rust-lang#115477 (Stabilize the `Saturating` type)
 - rust-lang#115611 (add diagnostic for raw identifiers in format string)
 - rust-lang#115654 (improve PassMode docs)
 - rust-lang#115862 (Migrate `compiler/rustc_hir_typeck/src/callee.rs` to translatable diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0900712 into rust-lang:master Sep 17, 2023
@rustbot rustbot added this to the 1.74.0 milestone Sep 17, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 17, 2023
Rollup merge of rust-lang#115611 - lukas-code:format!("{r#ident}"), r=compiler-errors

add diagnostic for raw identifiers in format string

Format strings don't support raw identifiers (e.g. `format!("{r#type}")`), but they do support keywords in the format string directly (e.g. `format!("{type}")`). This PR improves the error output when attempting to use a raw identifier in a format string and adds a machine-applicable suggestion to remove the `r#`.

fixes rust-lang#115466
@lukas-code lukas-code deleted the format!("{r#ident}") branch September 17, 2023 15:21
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.

Raw identifiers don't work in formatting strings
4 participants