]> git.lizzy.rs Git - rust.git/commitdiff
syntax: Remove deprecated unicode escapes
authorAlex Crichton <alex@alexcrichton.com>
Fri, 6 Mar 2015 21:57:44 +0000 (13:57 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 6 Mar 2015 22:11:09 +0000 (14:11 -0800)
These have been deprecated for quite some time, so we should be good to remove
them now.

src/libsyntax/parse/lexer/mod.rs
src/test/parse-fail/lex-bad-char-literals.rs
src/test/pretty/block-comment-wchar.pp
src/test/pretty/block-comment-wchar.rs
src/test/run-pass/nul-characters.rs
src/test/run-pass/raw-str.rs
src/test/run-pass/utf8.rs
src/test/run-pass/utf8_chars.rs

index 72ff501c6481eb2c2627dcca68e26c97d59dd227..f5781e0587d245f7d5c6a404a9d634e97a414c3f 100644 (file)
@@ -777,13 +777,6 @@ fn scan_hex_digits(&mut self,
         }
     }
 
-    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.
@@ -803,21 +796,8 @@ fn scan_char_or_byte(&mut self, start: BytePos, first_source_char: char,
                         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();
index fbe03e355eed6e5cba7b267c5e044072aff74b11..4aa01bcde69897b3423fc5b32ff32c269575039b 100644 (file)
@@ -8,36 +8,14 @@
 // 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
 ;
index 5a55cb4e561309b2781f8b28c7767f5c42e3d3d1..a5d82277d2f94aaa66de840350b9d03503b57efd 100644 (file)
@@ -105,10 +105,11 @@ fn f() {
 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);
index c82bdcd8dcb9388efc2fa79409a8be1557686fbe..eb6d2a4a0a17392851e3808808b65721053ac897 100644 (file)
@@ -99,10 +99,11 @@ fn nested() {
 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);
index 22786c0abc89b9bd6487882d021967e18abb377f..4a14969209f027dbeb5d8128d7b549851ee57c9e 100644 (file)
 
 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);
@@ -35,8 +35,8 @@ pub fn main()
 
     // 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");
index 35e863d05a177dd06262b4d4302b5f40886ed0aa..298ac8f77eb11dd6f5a4a63ea68920e34a5e7d61 100644 (file)
Binary files a/src/test/run-pass/raw-str.rs and b/src/test/run-pass/raw-str.rs differ
index 96bba01068f2b3ecb722497931c7f9ba70c93688..4be54bd7080d2eab3aa7d837d6768fd2e6f9ff28 100644 (file)
@@ -24,7 +24,7 @@ pub fn main() {
     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();
@@ -33,11 +33,11 @@ pub fn main() {
     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);
index 88369f2e500b19dd0b1fe321d864d6082a4bb3e3..c54b3b69c688053d8a22cbb1b52b9ca29f35ae69 100644 (file)
@@ -14,7 +14,7 @@
 
 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();