Skip to content

Fix suggestion for attempting to define a string with single quotes #114913

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

beetrees
Copy link
Contributor

Currently attempting to compile fn main() { let _ = '\\"'; } will result in the following error message:

error: character literal may only contain one codepoint
 --> src/main.rs:1:21
  |
1 | fn main() { let _ = '\\"'; }
  |                     ^^^^^
  |
help: if you meant to write a `str` literal, use double quotes
  |
1 | fn main() { let _ = "\\""; }
  |                     ~~~~~

The suggestion is invalid as it fails to escape the ". This PR fixes the suggestion so that it now reads:

help: if you meant to write a `str` literal, use double quotes
  |
1 | fn main() { let _ = "\\\""; }
  |                     ~~~~~~

The relevant test is also updated to ensure that this does not regress in future.

@rustbot
Copy link
Collaborator

rustbot commented Aug 16, 2023

r? @davidtwco

(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 Aug 16, 2023
@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 17, 2023

📌 Commit 072d8c8 has been approved by davidtwco

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

Successful merges:

 - rust-lang#113715 (Unstable Book: update `lang_items` page and split it)
 - rust-lang#114897 (Partially revert rust-lang#107200)
 - rust-lang#114913 (Fix suggestion for attempting to define a string with single quotes)
 - rust-lang#114931 (Revert PR rust-lang#114052 to fix invalid suggestion)
 - rust-lang#114944 (update `thiserror` to version >= 1.0.46)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7ea4de9 into rust-lang:master Aug 18, 2023
@rustbot rustbot added this to the 1.73.0 milestone Aug 18, 2023
@beetrees beetrees deleted the escape-double-quote branch August 18, 2023 13:57
# for free to join this conversation on GitHub. Already have an account? # 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.

5 participants