-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #64783 - onehr:onehrxn, r=varkor
Fix issue #64732 Based on issue #64732, when creating a byte literal with single quotes, the suggestion message would indicate that you meant to write a `str` literal, but we actually meant to write a byte string literal. So I changed the unescape_error_reporting.rs to decide whether to print out "if you meant to write a `str` literal, use double quotes", or "if you meant to write a byte string literal, use double quotes". Fixes #64732.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![allow(unused)] | ||
fn main() { | ||
let _foo = b'hello\0'; | ||
//~^ ERROR character literal may only contain one codepoint | ||
//~| HELP if you meant to write a byte string literal, use double quotes | ||
let _bar = 'hello'; | ||
//~^ ERROR character literal may only contain one codepoint | ||
//~| HELP if you meant to write a `str` literal, use double quotes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error: character literal may only contain one codepoint | ||
--> $DIR/issue-64732.rs:3:17 | ||
| | ||
LL | let _foo = b'hello\0'; | ||
| ^^^^^^^^^ | ||
help: if you meant to write a byte string literal, use double quotes | ||
| | ||
LL | let _foo = b"hello\0"; | ||
| ^^^^^^^^^ | ||
|
||
error: character literal may only contain one codepoint | ||
--> $DIR/issue-64732.rs:6:16 | ||
| | ||
LL | let _bar = 'hello'; | ||
| ^^^^^^^ | ||
help: if you meant to write a `str` literal, use double quotes | ||
| | ||
LL | let _bar = "hello"; | ||
| ^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|