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

"Use double quotes" suggestion turns overlong char literal into unterminated string literal #103323

Closed
jruderman opened this issue Oct 20, 2022 · 0 comments · Fixed by #103354
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jruderman
Copy link
Contributor

Given the following code (playground):

fn main() {
    let _s = '"""';
}

The current output is:

error: character literal may only contain one codepoint
 --> src/main.rs:2:14
  |
2 |     let _s = '"""';
  |              ^^^^^
  |
help: if you meant to write a `str` literal, use double quotes
  |
2 |     let _s = """"";
  |              ~~~~~

Ideally the suggestion should look like:

help: if you meant to write a `str` literal, use double quotes
  |
2 |     let _s = "\"\"\"";
  |              ~~~~~~~~
@jruderman jruderman added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 20, 2022
notriddle added a commit to notriddle/rust that referenced this issue Oct 22, 2022
…r=compiler-errors

Escape string literals when fixing overlong char literal

Fixes rust-lang#103323

`@rustbot` label +A-diagnostics +A-suggestion-diagnostics
notriddle added a commit to notriddle/rust that referenced this issue Oct 22, 2022
…r=compiler-errors

Escape string literals when fixing overlong char literal

Fixes rust-lang#103323

``@rustbot`` label +A-diagnostics +A-suggestion-diagnostics
JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 22, 2022
…r=compiler-errors

Escape string literals when fixing overlong char literal

Fixes rust-lang#103323

```@rustbot``` label +A-diagnostics +A-suggestion-diagnostics
@bors bors closed this as completed in b656f5e Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant