Accept underscores in unicode escapes

Fixes #43692.
This commit is contained in:
Malo Jaffré 2017-08-17 20:02:13 +02:00
parent dd39ecf368
commit d4e0e52281
8 changed files with 102 additions and 57 deletions

View file

@ -41,9 +41,8 @@ fn main() {
//~^^^ ERROR incorrect unicode escape sequence
//~^^^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
let _ = "\u{ffffff} \xf \u";
//~^ ERROR invalid unicode character escape
//~^^ ERROR invalid character in numeric character escape:
//~^^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f]
//~^^^^ ERROR incorrect unicode escape sequence
let _ = "\xf \u";
//~^ ERROR invalid character in numeric character escape:
//~^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f]
//~^^^ ERROR incorrect unicode escape sequence
}

View file

@ -0,0 +1,15 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -Z parse-only
fn main() {
'\u{_10FFFF}'; //~ ERROR invalid start of unicode escape
}

View file

@ -11,5 +11,5 @@
// compile-flags: -Z parse-only
pub fn main() {
let s = "\u{260311111111}"; //~ ERROR overlong unicode escape (can have at most 6 hex digits)
let s = "\u{260311111111}"; //~ ERROR overlong unicode escape (must have at most 6 hex digits)
}

View file

@ -11,5 +11,6 @@
// compile-flags: -Z parse-only
pub fn main() {
let s = "\u{d805}"; //~ ERROR invalid unicode character escape
let s1 = "\u{d805}"; //~ ERROR invalid unicode character escape
let s2 = "\u{ffffff}"; //~ ERROR invalid unicode character escape
}

View file

@ -13,6 +13,4 @@
pub fn main() {
let s = "\u{lol}";
//~^ ERROR invalid character in unicode escape: l
//~^^ ERROR invalid character in unicode escape: o
//~^^^ ERROR invalid character in unicode escape: l
}

View file

@ -0,0 +1,14 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
assert_eq!('\u{10__FFFF}', '\u{10FFFF}');
assert_eq!("\u{10_F0FF__}foo\u{1_0_0_0__}", "\u{10F0FF}foo\u{1000}");
}