Rollup merge of #77587 - ehuss:unicode-escape-span, r=ecstatic-morse
Fix span for unicode escape suggestion. If a unicode escape is missing the curly braces, the suggested fix is to add the curly braces, but the span for the fix was incorrect. It was not covering the `\u`, but the suggested text includes the `\u`, causing the resulting fix to be `"\u\u{1234}"`. This changes it so that the span includes the `\u`. An alternate fix would be to remove `\u` from the suggested fix, but I think the error message reads better if the entire escape is included.
This commit is contained in:
commit
cc908f3b70
3 changed files with 6 additions and 9 deletions
|
@ -181,10 +181,9 @@ pub(crate) fn emit_unescape_error(
|
|||
|
||||
if suggestion_len > 0 {
|
||||
suggestion.push('}');
|
||||
let lo = char_span.lo();
|
||||
let hi = lo + BytePos(suggestion_len as u32);
|
||||
let hi = char_span.lo() + BytePos(suggestion_len as u32);
|
||||
diag.span_suggestion(
|
||||
span.with_lo(lo).with_hi(hi),
|
||||
span.with_hi(hi),
|
||||
"format of unicode escape sequences uses braces",
|
||||
suggestion,
|
||||
Applicability::MaybeIncorrect,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue