about summary refs log tree commit diff
path: root/src/test/ui/fmt
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/fmt
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/fmt')
-rw-r--r--src/test/ui/fmt/format-string-error-2.rs3
-rw-r--r--src/test/ui/fmt/format-string-error-2.stderr52
2 files changed, 29 insertions, 26 deletions
diff --git a/src/test/ui/fmt/format-string-error-2.rs b/src/test/ui/fmt/format-string-error-2.rs
index 5c25ae502ff..e9169d338f7 100644
--- a/src/test/ui/fmt/format-string-error-2.rs
+++ b/src/test/ui/fmt/format-string-error-2.rs
@@ -1,3 +1,4 @@
+// compile-flags: -Z continue-parse-after-error
 // ignore-tidy-tab
 
 fn main() {
@@ -76,7 +77,7 @@ raw  { \n
 
     println!("\x7B}\u8 {", 1);
     //~^ ERROR incorrect unicode escape sequence
-    //~| ERROR argument never used
+    //~| ERROR invalid format string: expected `'}'` but string was terminated
 
     // note: raw strings don't escape `\xFF` and `\u{FF}` sequences
     println!(r#"\x7B}\u{8} {"#, 1);
diff --git a/src/test/ui/fmt/format-string-error-2.stderr b/src/test/ui/fmt/format-string-error-2.stderr
index 66d35a1b854..6656cc82369 100644
--- a/src/test/ui/fmt/format-string-error-2.stderr
+++ b/src/test/ui/fmt/format-string-error-2.stderr
@@ -1,13 +1,13 @@
 error: incorrect unicode escape sequence
-  --> $DIR/format-string-error-2.rs:77:20
+  --> $DIR/format-string-error-2.rs:78:20
    |
 LL |     println!("\x7B}\u8 {", 1);
    |                    ^^-
-   |                    |
-   |                    help: format of unicode escape sequences uses braces: `\u{8}`
+   |                      |
+   |                      help: format of unicode escape sequences uses braces: `\u{8}`
 
 error: invalid format string: expected `'}'`, found `'a'`
-  --> $DIR/format-string-error-2.rs:5:5
+  --> $DIR/format-string-error-2.rs:6:5
    |
 LL |     format!("{
    |              - because of this opening brace
@@ -17,7 +17,7 @@ LL |     a");
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'b'`
-  --> $DIR/format-string-error-2.rs:9:5
+  --> $DIR/format-string-error-2.rs:10:5
    |
 LL |     format!("{ \
    |              - because of this opening brace
@@ -28,7 +28,7 @@ LL |     b");
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'\'`
-  --> $DIR/format-string-error-2.rs:11:18
+  --> $DIR/format-string-error-2.rs:12:18
    |
 LL |     format!(r#"{ \
    |                - ^ expected `}` in format string
@@ -38,7 +38,7 @@ LL |     format!(r#"{ \
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'\'`
-  --> $DIR/format-string-error-2.rs:15:18
+  --> $DIR/format-string-error-2.rs:16:18
    |
 LL |     format!(r#"{ \n
    |                - ^ expected `}` in format string
@@ -48,7 +48,7 @@ LL |     format!(r#"{ \n
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'e'`
-  --> $DIR/format-string-error-2.rs:21:5
+  --> $DIR/format-string-error-2.rs:22:5
    |
 LL |     format!("{ \n
    |              - because of this opening brace
@@ -59,7 +59,7 @@ LL |     e");
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'a'`
-  --> $DIR/format-string-error-2.rs:25:5
+  --> $DIR/format-string-error-2.rs:26:5
    |
 LL |     {
    |     - because of this opening brace
@@ -69,7 +69,7 @@ LL |     a");
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'a'`
-  --> $DIR/format-string-error-2.rs:29:5
+  --> $DIR/format-string-error-2.rs:30:5
    |
 LL |     {
    |     - because of this opening brace
@@ -79,7 +79,7 @@ LL |     a
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'b'`
-  --> $DIR/format-string-error-2.rs:35:5
+  --> $DIR/format-string-error-2.rs:36:5
    |
 LL |     { \
    |     - because of this opening brace
@@ -90,7 +90,7 @@ LL |     b");
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'b'`
-  --> $DIR/format-string-error-2.rs:40:5
+  --> $DIR/format-string-error-2.rs:41:5
    |
 LL |     { \
    |     - because of this opening brace
@@ -101,7 +101,7 @@ LL |     b \
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'\'`
-  --> $DIR/format-string-error-2.rs:45:8
+  --> $DIR/format-string-error-2.rs:46:8
    |
 LL | raw  { \
    |      - ^ expected `}` in format string
@@ -111,7 +111,7 @@ LL | raw  { \
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'\'`
-  --> $DIR/format-string-error-2.rs:50:8
+  --> $DIR/format-string-error-2.rs:51:8
    |
 LL | raw  { \n
    |      - ^ expected `}` in format string
@@ -121,7 +121,7 @@ LL | raw  { \n
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'e'`
-  --> $DIR/format-string-error-2.rs:57:5
+  --> $DIR/format-string-error-2.rs:58:5
    |
 LL |   { \n
    |   - because of this opening brace
@@ -132,7 +132,7 @@ LL |     e");
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: expected `'}'`, found `'a'`
-  --> $DIR/format-string-error-2.rs:67:5
+  --> $DIR/format-string-error-2.rs:68:5
    |
 LL |     {
    |     - because of this opening brace
@@ -142,13 +142,13 @@ LL |     asdf}
    = note: if you intended to print `{`, you can escape it using `{{`
 
 error: 1 positional argument in format string, but no arguments were given
-  --> $DIR/format-string-error-2.rs:70:17
+  --> $DIR/format-string-error-2.rs:71:17
    |
 LL |     println!("\t{}");
    |                 ^^
 
 error: invalid format string: expected `'}'` but string was terminated
-  --> $DIR/format-string-error-2.rs:74:27
+  --> $DIR/format-string-error-2.rs:75:27
    |
 LL |     println!("\x7B}\u{8} {", 1);
    |                          -^ expected `'}'` in format string
@@ -157,16 +157,18 @@ LL |     println!("\x7B}\u{8} {", 1);
    |
    = note: if you intended to print `{`, you can escape it using `{{`
 
-error: argument never used
-  --> $DIR/format-string-error-2.rs:77:28
+error: invalid format string: expected `'}'` but string was terminated
+  --> $DIR/format-string-error-2.rs:78:27
    |
 LL |     println!("\x7B}\u8 {", 1);
-   |              ------------  ^ argument never used
-   |              |
-   |              formatting specifier missing
+   |                          -^ expected `'}'` in format string
+   |                          |
+   |                          because of this opening brace
+   |
+   = note: if you intended to print `{`, you can escape it using `{{`
 
 error: invalid format string: unmatched `}` found
-  --> $DIR/format-string-error-2.rs:82:21
+  --> $DIR/format-string-error-2.rs:83:21
    |
 LL |     println!(r#"\x7B}\u{8} {"#, 1);
    |                     ^ unmatched `}` in format string
@@ -174,7 +176,7 @@ LL |     println!(r#"\x7B}\u{8} {"#, 1);
    = note: if you intended to print `}`, you can escape it using `}}`
 
 error: invalid format string: unmatched `}` found
-  --> $DIR/format-string-error-2.rs:85:21
+  --> $DIR/format-string-error-2.rs:86:21
    |
 LL |     println!(r#"\x7B}\u8 {"#, 1);
    |                     ^ unmatched `}` in format string