about summary refs log tree commit diff
path: root/src/test/parse-fail
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2015-03-26 09:38:25 +0100
committerFlorian Hahn <flo@fhahn.com>2015-03-27 17:47:16 +0100
commitafaa3b6a2066e4dacd4e7dafb5fd911bf35bdd6c (patch)
tree386bfb345beaa7eba3e37cd6771433eb13ef30c3 /src/test/parse-fail
parent242ed0b7c0f6a21096f2cc3e1ad1bdb176d02545 (diff)
downloadrust-afaa3b6a2066e4dacd4e7dafb5fd911bf35bdd6c.tar.gz
rust-afaa3b6a2066e4dacd4e7dafb5fd911bf35bdd6c.zip
Prevent ICEs when parsing invalid escapes, closes #23620
Diffstat (limited to 'src/test/parse-fail')
-rw-r--r--src/test/parse-fail/issue-23620-invalid-escapes.rs45
-rw-r--r--src/test/parse-fail/new-unicode-escapes-4.rs5
2 files changed, 49 insertions, 1 deletions
diff --git a/src/test/parse-fail/issue-23620-invalid-escapes.rs b/src/test/parse-fail/issue-23620-invalid-escapes.rs
new file mode 100644
index 00000000000..7930ea75bf5
--- /dev/null
+++ b/src/test/parse-fail/issue-23620-invalid-escapes.rs
@@ -0,0 +1,45 @@
+// Copyright 2015 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() {
+    let _ = b"\u{a66e}";
+    //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
+
+    let _ = b'\u{a66e}';
+    //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
+
+    let _ = b'\u';
+    //~^ ERROR unknown byte escape: u
+
+    let _ = b'\x5';
+    //~^ ERROR numeric character escape is too short
+
+    let _ = b'\xxy';
+    //~^ ERROR illegal character in numeric character escape: x
+    //~^^ ERROR illegal character in numeric character escape: y
+
+    let _ = '\x5';
+    //~^ ERROR numeric character escape is too short
+
+    let _ = '\xxy';
+    //~^ ERROR illegal character in numeric character escape: x
+    //~^^ ERROR illegal character in numeric character escape: y
+
+    let _ = b"\u{a4a4} \xf \u";
+    //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
+    //~^^ ERROR illegal character in numeric character escape:
+    //~^^^ ERROR unknown byte escape: u
+
+    let _ = "\u{ffffff} \xf \u";
+    //~^ ERROR illegal unicode character escape
+    //~^^ ERROR illegal character in numeric character escape:
+    //~^^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f]
+    //~^^^^ ERROR unknown character escape: u
+}
diff --git a/src/test/parse-fail/new-unicode-escapes-4.rs b/src/test/parse-fail/new-unicode-escapes-4.rs
index ffc2b11e0c1..96b86f1f563 100644
--- a/src/test/parse-fail/new-unicode-escapes-4.rs
+++ b/src/test/parse-fail/new-unicode-escapes-4.rs
@@ -9,5 +9,8 @@
 // except according to those terms.
 
 pub fn main() {
-    let s = "\u{lol}"; //~ ERROR illegal character in unicode escape
+    let s = "\u{lol}";
+     //~^ ERROR illegal character in unicode escape: l
+     //~^^ ERROR illegal character in unicode escape: o
+     //~^^^ ERROR illegal character in unicode escape: l
 }