Skip to content

Commit d786170

Browse files
committed
---
yaml --- r: 228315 b: refs/heads/try c: 4d65ef4 h: refs/heads/master i: 228313: cbc84a1 228311: 280292d v: v3
1 parent ece6c37 commit d786170

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: d22f189da13f8ffb3c9227a038615608e99a6211
4+
refs/heads/try: 4d65ef45491b62fbecdb9a24822c216aa96bb34e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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