forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#87662 - FabianWolff:rb-string, r=estebank
Suggest `br` if the unknown string prefix `rb` is found Currently, for the following code: ```rust fn main() { rb"abc"; } ``` we issue the following suggestion: ``` help: consider inserting whitespace here | 2 | rb "abc"; | -- ``` With my changes (only in edition 2021, where unknown prefixes became an error), I get: ``` help: use `br` for a raw byte string | 2 | br"abc"; | ^^ ```
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 deletions.
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,10 @@ | ||
// `br` and `rb` are easy to confuse; check that we issue a suggestion to help. | ||
|
||
// edition:2021 | ||
|
||
fn main() { | ||
rb"abc"; | ||
//~^ ERROR: prefix `rb` is unknown | ||
//~| HELP: use `br` for a raw byte string | ||
//~| ERROR: expected one of | ||
} |
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,20 @@ | ||
error: prefix `rb` is unknown | ||
--> $DIR/raw-byte-string-prefix.rs:6:5 | ||
| | ||
LL | rb"abc"; | ||
| ^^ unknown prefix | ||
| | ||
= note: prefixed identifiers and literals are reserved since Rust 2021 | ||
help: use `br` for a raw byte string | ||
| | ||
LL | br"abc"; | ||
| ^^ | ||
|
||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"abc"` | ||
--> $DIR/raw-byte-string-prefix.rs:6:7 | ||
| | ||
LL | rb"abc"; | ||
| ^^^^^ expected one of 8 possible tokens | ||
|
||
error: aborting due to 2 previous errors | ||
|