Skip to content

Commit 66e4b32

Browse files
committed
---
yaml --- r: 235386 b: refs/heads/stable c: 4d65ef4 h: refs/heads/master v: v3
1 parent c726c70 commit 66e4b32

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: d22f189da13f8ffb3c9227a038615608e99a6211
32+
refs/heads/stable: 4d65ef45491b62fbecdb9a24822c216aa96bb34e
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/libsyntax/parse/lexer/mod.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -738,26 +738,24 @@ impl<'a> StringReader<'a> {
738738
return match e {
739739
'n' | 'r' | 't' | '\\' | '\'' | '"' | '0' => true,
740740
'x' => self.scan_byte_escape(delim, !ascii_only),
741-
'u' if self.curr_is('{') => {
742-
let valid = self.scan_unicode_escape(delim);
743-
if valid && ascii_only {
744-
self.err_span_(
745-
start,
746-
self.last_pos,
741+
'u' => {
742+
let valid = if self.curr_is('{') {
743+
self.scan_unicode_escape(delim) && !ascii_only
744+
} else {
745+
self.err_span_(start, self.last_pos,
746+
"incorrect unicode escape sequence");
747+
self.help_span_(start, self.last_pos,
748+
"format of unicode escape sequences is `\\u{…}`");
749+
false
750+
};
751+
if ascii_only {
752+
self.err_span_(start, self.last_pos,
747753
"unicode escape sequences cannot be used as a byte or in \
748754
a byte string"
749755
);
750-
false
751-
} else {
752-
valid
753756
}
754-
}
755-
'u' if !ascii_only => {
756-
self.err_span_(start, self.last_pos,
757-
"incomplete unicode escape sequence");
758-
self.help_span_(start, self.last_pos,
759-
"format of unicode escape sequences is `\\u{…}`");
760-
false
757+
valid
758+
761759
}
762760
'\n' if delim == '"' => {
763761
self.consume_whitespace();

branches/stable/src/test/parse-fail/issue-23620-invalid-escapes.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ fn main() {
1616
//~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
1717

1818
let _ = b'\u';
19-
//~^ ERROR unknown byte escape: u
19+
//~^ ERROR incorrect unicode escape sequence
20+
//~^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
2021

2122
let _ = b'\x5';
2223
//~^ ERROR numeric character escape is too short
@@ -35,11 +36,12 @@ fn main() {
3536
let _ = b"\u{a4a4} \xf \u";
3637
//~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
3738
//~^^ ERROR illegal character in numeric character escape:
38-
//~^^^ ERROR unknown byte escape: u
39+
//~^^^ ERROR incorrect unicode escape sequence
40+
//~^^^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
3941

4042
let _ = "\u{ffffff} \xf \u";
4143
//~^ ERROR illegal unicode character escape
4244
//~^^ ERROR illegal character in numeric character escape:
4345
//~^^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f]
44-
//~^^^^ ERROR incomplete unicode escape sequence
46+
//~^^^^ ERROR incorrect unicode escape sequence
4547
}

0 commit comments

Comments
 (0)