}
}
- fn old_escape_warning(&mut self, sp: Span) {
- self.span_diagnostic
- .span_warn(sp, "\\U00ABCD12 and \\uABCD escapes are deprecated");
- self.span_diagnostic
- .fileline_help(sp, "use \\u{ABCD12} escapes instead");
- }
-
/// Scan for a single (possibly escaped) byte or char
/// in a byte, (non-raw) byte string, char, or (non-raw) string literal.
/// `start` is the position of `first_source_char`, which is already consumed.
return match e {
'n' | 'r' | 't' | '\\' | '\'' | '"' | '0' => true,
'x' => self.scan_byte_escape(delim, !ascii_only),
- 'u' if !ascii_only => {
- if self.curr == Some('{') {
- self.scan_unicode_escape(delim)
- } else {
- let res = self.scan_hex_digits(4, delim, false);
- let sp = codemap::mk_sp(escaped_pos, self.last_pos);
- self.old_escape_warning(sp);
- res
- }
- }
- 'U' if !ascii_only => {
- let res = self.scan_hex_digits(8, delim, false);
- let sp = codemap::mk_sp(escaped_pos, self.last_pos);
- self.old_escape_warning(sp);
- res
+ 'u' if self.curr_is('{') => {
+ self.scan_unicode_escape(delim)
}
'\n' if delim == '"' => {
self.consume_whitespace();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-static c: char =
- '\u539_' //~ ERROR: illegal character in numeric character escape
- //~^ WARNING: \uABCD escapes are deprecated
-;
-
-static c2: char =
- '\Uffffffff' //~ ERROR: illegal numeric character escape
- //~^ WARNING: \uABCD escapes are deprecated
-;
-
static c3: char =
'\x1' //~ ERROR: numeric character escape is too short
;
-static c4: char =
- '\u23q' //~ ERROR: illegal character in numeric character escape
- //~^ WARNING: \uABCD escapes are deprecated
-;
-//~^^^ ERROR: numeric character escape is too short
-
static s: &'static str =
"\x1" //~ ERROR: numeric character escape is too short
;
-static s2: &'static str =
- "\u23q" //~ ERROR: illegal character in numeric character escape
- //~^ ERROR: numeric character escape is too short
- //~^^ WARNING: \uABCD escapes are deprecated
-;
-
static c: char =
'\●' //~ ERROR: unknown character escape
;
fn main() {
// Taken from http://www.unicode.org/Public/UNIDATA/PropList.txt
let chars =
- ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u0085', '\u00A0', '\u1680',
- '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006',
- '\u2007', '\u2008', '\u2009', '\u200A', '\u2028', '\u2029', '\u202F',
- '\u205F', '\u3000'];
+ ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u{85}', '\u{A0}',
+ '\u{1680}', '\u{2000}', '\u{2001}', '\u{2002}', '\u{2003}',
+ '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}',
+ '\u{2009}', '\u{200A}', '\u{2028}', '\u{2029}', '\u{202F}',
+ '\u{205F}', '\u{3000}'];
for c in &chars {
let ws = c.is_whitespace();
println!("{} {}" , c , ws);
fn main() {
// Taken from http://www.unicode.org/Public/UNIDATA/PropList.txt
let chars =
- ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u0085', '\u00A0', '\u1680',
- '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006',
- '\u2007', '\u2008', '\u2009', '\u200A', '\u2028', '\u2029', '\u202F',
- '\u205F', '\u3000'];
+ ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u{85}', '\u{A0}',
+ '\u{1680}', '\u{2000}', '\u{2001}', '\u{2002}', '\u{2003}',
+ '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}',
+ '\u{2009}', '\u{200A}', '\u{2028}', '\u{2029}', '\u{202F}',
+ '\u{205F}', '\u{3000}'];
for c in &chars {
let ws = c.is_whitespace();
println!("{} {}", c , ws);
pub fn main()
{
- let all_nuls1 = "\0\x00\u0000\U00000000";
- let all_nuls2 = "\U00000000\u0000\x00\0";
- let all_nuls3 = "\u0000\U00000000\x00\0";
- let all_nuls4 = "\x00\u0000\0\U00000000";
+ let all_nuls1 = "\0\x00\u{0}\u{0}";
+ let all_nuls2 = "\u{0}\u{0}\x00\0";
+ let all_nuls3 = "\u{0}\u{0}\x00\0";
+ let all_nuls4 = "\x00\u{0}\0\u{0}";
// sizes for two should suffice
assert_eq!(all_nuls1.len(), 4);
// testing equality between explicit character literals
assert_eq!('\0', '\x00');
- assert_eq!('\u0000', '\x00');
- assert_eq!('\u0000', '\U00000000');
+ assert_eq!('\u{0}', '\x00');
+ assert_eq!('\u{0}', '\u{0}');
// NUL characters should make a difference
assert!("Hello World" != "Hello \0World");
assert_eq!(y_diaeresis as int, 0xff);
assert_eq!(pi as int, 0x3a0);
- assert_eq!(pi as int, '\u03a0' as int);
+ assert_eq!(pi as int, '\u{3a0}' as int);
assert_eq!('\x0a' as int, '\n' as int);
let bhutan: String = "འབྲུག་ཡུལ།".to_string();
let austria: String = "Österreich".to_string();
let bhutan_e: String =
- "\u0f60\u0f56\u0fb2\u0f74\u0f42\u0f0b\u0f61\u0f74\u0f63\u0f0d".to_string();
- let japan_e: String = "\u65e5\u672c".to_string();
+ "\u{f60}\u{f56}\u{fb2}\u{f74}\u{f42}\u{f0b}\u{f61}\u{f74}\u{f63}\u{f0d}".to_string();
+ let japan_e: String = "\u{65e5}\u{672c}".to_string();
let uzbekistan_e: String =
- "\u040e\u0437\u0431\u0435\u043a\u0438\u0441\u0442\u043e\u043d".to_string();
- let austria_e: String = "\u00d6sterreich".to_string();
+ "\u{40e}\u{437}\u{431}\u{435}\u{43a}\u{438}\u{441}\u{442}\u{43e}\u{43d}".to_string();
+ let austria_e: String = "\u{d6}sterreich".to_string();
let oo: char = 'Ö';
assert_eq!(oo as int, 0xd6);
pub fn main() {
// Chars of 1, 2, 3, and 4 bytes
- let chs: Vec<char> = vec!('e', 'é', '€', '\U00010000');
+ let chs: Vec<char> = vec!('e', 'é', '€', '\u{10000}');
let s: String = chs.iter().cloned().collect();
let schs: Vec<char> = s.chars().collect();