Skip to content

Commit 707c915

Browse files
committed
---
yaml --- r: 218592 b: refs/heads/auto c: 4d65ef4 h: refs/heads/master v: v3
1 parent 3fd5cbd commit 707c915

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
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: d22f189da13f8ffb3c9227a038615608e99a6211
11+
refs/heads/auto: 4d65ef45491b62fbecdb9a24822c216aa96bb34e
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/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/auto/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)