1
Fork 0
rust/compiler/rustc_parse/src
Josh Stone 7ea4de9632
Rollup merge of #114913 - beetrees:escape-double-quote, r=davidtwco
Fix suggestion for attempting to define a string with single quotes

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.
2023-08-17 15:40:09 -07:00
..
lexer Fix suggestion for attempting to define a string with single quotes 2023-08-16 21:51:57 +01:00
parser Fix bad suggestion when wrong parentheses around a dyn trait 2023-08-16 00:26:10 +08:00
errors.rs Fix bad suggestion when wrong parentheses around a dyn trait 2023-08-16 00:26:10 +08:00
lib.rs Add internal_features lint 2023-08-03 14:50:50 +02:00
validate_attr.rs Remove MacDelimiter. 2023-08-03 09:03:30 +10:00