about summary refs log tree commit diff
path: root/src/test/ui/parser/macro
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2019-04-25 11:48:25 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2019-05-02 15:31:57 +0300
commitbfa5f278472d0bad4e7db4a4259b2f1fa97ca0ab (patch)
treebb27691d38cfe85ef181ea8d2cb7609da12cbe91 /src/test/ui/parser/macro
parent9b67bd42b7cbf97f72d039afcba02f5177d0d68c (diff)
downloadrust-bfa5f278472d0bad4e7db4a4259b2f1fa97ca0ab.tar.gz
rust-bfa5f278472d0bad4e7db4a4259b2f1fa97ca0ab.zip
introduce unescape module
Currently, we deal with escape sequences twice: once when we lex a
string, and a second time when we unescape literals. This PR aims to
remove this duplication, by introducing a new `unescape` mode as a
single source of truth for character escaping rules
Diffstat (limited to 'src/test/ui/parser/macro')
-rw-r--r--src/test/ui/parser/macro/literals-are-validated-before-expansion.rs10
-rw-r--r--src/test/ui/parser/macro/literals-are-validated-before-expansion.stderr18
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/parser/macro/literals-are-validated-before-expansion.rs b/src/test/ui/parser/macro/literals-are-validated-before-expansion.rs
new file mode 100644
index 00000000000..c3fc754b556
--- /dev/null
+++ b/src/test/ui/parser/macro/literals-are-validated-before-expansion.rs
@@ -0,0 +1,10 @@
+macro_rules! black_hole {
+    ($($tt:tt)*) => {}
+}
+
+fn main() {
+    black_hole! { '\u{FFFFFF}' }
+    //~^ ERROR: invalid unicode character escape
+    black_hole! { "this is surrogate: \u{DAAA}" }
+    //~^ ERROR: invalid unicode character escape
+}
diff --git a/src/test/ui/parser/macro/literals-are-validated-before-expansion.stderr b/src/test/ui/parser/macro/literals-are-validated-before-expansion.stderr
new file mode 100644
index 00000000000..d20eb0fb30a
--- /dev/null
+++ b/src/test/ui/parser/macro/literals-are-validated-before-expansion.stderr
@@ -0,0 +1,18 @@
+error: invalid unicode character escape
+  --> $DIR/literals-are-validated-before-expansion.rs:6:20
+   |
+LL |     black_hole! { '\u{FFFFFF}' }
+   |                    ^^^^^^^^^^
+   |
+   = help: unicode escape must be at most 10FFFF
+
+error: invalid unicode character escape
+  --> $DIR/literals-are-validated-before-expansion.rs:8:39
+   |
+LL |     black_hole! { "this is surrogate: \u{DAAA}" }
+   |                                       ^^^^^^^^
+   |
+   = help: unicode escape must not be a surrogate
+
+error: aborting due to 2 previous errors
+