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".
This commit is contained in:
parent
6c2c29c432
commit
5418e15a50
1 changed files with 7 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue