From e26e6749fb5638749ed8d73fcb595a11c12f7eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 23 Jul 2019 16:28:20 -0700 Subject: [PATCH] Always emit trailing slash error --- src/libsyntax/parse/unescape_error_reporting.rs | 2 +- src/test/ui/parser/issue-62913.rs | 3 +++ src/test/ui/parser/issue-62913.stderr | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/parser/issue-62913.rs create mode 100644 src/test/ui/parser/issue-62913.stderr diff --git a/src/libsyntax/parse/unescape_error_reporting.rs b/src/libsyntax/parse/unescape_error_reporting.rs index 71b41161ad8..34af3238fb0 100644 --- a/src/libsyntax/parse/unescape_error_reporting.rs +++ b/src/libsyntax/parse/unescape_error_reporting.rs @@ -191,7 +191,7 @@ pub(crate) fn emit_unescape_error( handler.span_err(span, "empty character literal") } EscapeError::LoneSlash => { - panic!("lexer accepted unterminated literal with trailing slash") + handler.span_err(span, "invalid trailing slash in literal") } } } diff --git a/src/test/ui/parser/issue-62913.rs b/src/test/ui/parser/issue-62913.rs new file mode 100644 index 00000000000..cfa19a2a310 --- /dev/null +++ b/src/test/ui/parser/issue-62913.rs @@ -0,0 +1,3 @@ +"\u\\" +//~^ ERROR incorrect unicode escape sequence +//~| ERROR invalid trailing slash in literal diff --git a/src/test/ui/parser/issue-62913.stderr b/src/test/ui/parser/issue-62913.stderr new file mode 100644 index 00000000000..05c5c4d000a --- /dev/null +++ b/src/test/ui/parser/issue-62913.stderr @@ -0,0 +1,16 @@ +error: incorrect unicode escape sequence + --> $DIR/issue-62913.rs:1:2 + | +LL | "\u\" + | ^^^ incorrect unicode escape sequence + | + = help: format of unicode escape sequences is `\u{...}` + +error: invalid trailing slash in literal + --> $DIR/issue-62913.rs:1:5 + | +LL | "\u\" + | ^ + +error: aborting due to 2 previous errors +