about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorHaoran Wang <waharaxn@gmail.com>2019-09-25 17:22:46 -0400
committerHaoran Wang <waharaxn@gmail.com>2019-09-25 20:42:59 -0400
commit5418e15a50d033474ef8868468ba0604b63ca471 (patch)
tree7688c1f8d425de6dda9d47deee1e2d765b57889c /src/libsyntax/parse
parent6c2c29c43206d6e2f1091fa278d2792ea10e3659 (diff)
downloadrust-5418e15a50d033474ef8868468ba0604b63ca471.tar.gz
rust-5418e15a50d033474ef8868468ba0604b63ca471.zip
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".
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/unescape_error_reporting.rs8
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()