Improve some of the string escape diagnostic spans
This commit is contained in:
@@ -742,7 +742,7 @@ impl<'a> StringReader<'a> {
|
|||||||
let valid = self.scan_unicode_escape(delim);
|
let valid = self.scan_unicode_escape(delim);
|
||||||
if valid && ascii_only {
|
if valid && ascii_only {
|
||||||
self.err_span_(
|
self.err_span_(
|
||||||
escaped_pos,
|
start,
|
||||||
self.last_pos,
|
self.last_pos,
|
||||||
"unicode escape sequences cannot be used as a byte or in \
|
"unicode escape sequences cannot be used as a byte or in \
|
||||||
a byte string"
|
a byte string"
|
||||||
@@ -753,9 +753,9 @@ impl<'a> StringReader<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
'u' if !ascii_only => {
|
'u' if !ascii_only => {
|
||||||
self.err_span_(escaped_pos, self.last_pos,
|
self.err_span_(start, self.last_pos,
|
||||||
"incomplete unicode escape sequence");
|
"incomplete unicode escape sequence");
|
||||||
self.help_span_(escaped_pos, self.last_pos,
|
self.help_span_(start, self.last_pos,
|
||||||
"format of unicode escape sequences is `\\u{…}`");
|
"format of unicode escape sequences is `\\u{…}`");
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -862,14 +862,12 @@ impl<'a> StringReader<'a> {
|
|||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bump(); // past the ending }
|
|
||||||
|
|
||||||
if valid && (char::from_u32(accum_int).is_none() || count == 0) {
|
if valid && (char::from_u32(accum_int).is_none() || count == 0) {
|
||||||
self.err_span_(start_bpos, self.last_pos, "illegal unicode character escape");
|
self.err_span_(start_bpos, self.last_pos, "illegal unicode character escape");
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.bump(); // past the ending }
|
||||||
valid
|
valid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user