diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-26 17:55:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-26 17:55:15 +0200 |
| commit | 95ea4a1a8a0c8786fdb0d6c63669ece927820ad3 (patch) | |
| tree | d65d373ce0b6b6f59811d74261374c0e494df878 /src/libsyntax | |
| parent | 01303936f37ef494bfe11012645ff7ca37606fdf (diff) | |
| parent | a048447ff42c0e7c793aa33c92aa8daf61576b71 (diff) | |
| download | rust-95ea4a1a8a0c8786fdb0d6c63669ece927820ad3.tar.gz rust-95ea4a1a8a0c8786fdb0d6c63669ece927820ad3.zip | |
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.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/unescape_error_reporting.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsyntax/parse/unescape_error_reporting.rs b/src/libsyntax/parse/unescape_error_reporting.rs index 7eee07e61a9..5565015179c 100644 --- a/src/libsyntax/parse/unescape_error_reporting.rs +++ b/src/libsyntax/parse/unescape_error_reporting.rs @@ -47,6 +47,12 @@ pub(crate) fn emit_unescape_error( .emit(); } EscapeError::MoreThanOneChar => { + let msg = if mode.is_bytes() { + "if you meant to write a byte string literal, use double quotes" + } else { + "if you meant to write a `str` literal, use double quotes" + }; + handler .struct_span_err( span_with_quotes, @@ -54,7 +60,7 @@ pub(crate) fn emit_unescape_error( ) .span_suggestion( span_with_quotes, - "if you meant to write a `str` literal, use double quotes", + msg, format!("\"{}\"", lit), Applicability::MachineApplicable, ).emit() |
