]> git.lizzy.rs Git - rust.git/commitdiff
remove padding from multiline format string label
authorAndy Russell <arussell123@gmail.com>
Wed, 3 Oct 2018 18:29:02 +0000 (14:29 -0400)
committerAndy Russell <arussell123@gmail.com>
Wed, 3 Oct 2018 18:29:39 +0000 (14:29 -0400)
Fixes #53836.

src/libfmt_macros/lib.rs
src/test/ui/if/ifmt-bad-arg.rs
src/test/ui/if/ifmt-bad-arg.stderr

index 2a38464d7c1ee3ca742888d52669641cd5b567b3..7d87c1839d78c7059e9fe49d8dacb404964d2efe 100644 (file)
@@ -288,7 +288,7 @@ fn must_consume(&mut self, c: char) -> Option<usize> {
                 self.cur.next();
                 Some(pos)
             } else {
-                let pos = pos + padding + 1;
+                let pos = pos + raw + 1;
                 self.err(format!("expected `{:?}`, found `{:?}`", c, maybe),
                          format!("expected `{}`", c),
                          pos,
index bbd75f30d6cb13ca69a05af3d2319dafc4133c03..6f051b40e8b65eaf2959e41f0ada2fc7625860b4 100644 (file)
@@ -71,4 +71,18 @@ fn main() {
 
     "##);
     //~^^^ ERROR: there is no argument named `foo`
+
+    // bad syntax in format string with multiple newlines, #53836
+    format!("first number: {}
+second number: {}
+third number: {}
+fourth number: {}
+fifth number: {}
+sixth number: {}
+seventh number: {}
+eighth number: {}
+ninth number: {
+tenth number: {}",
+        1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+    //~^^ ERROR: invalid format string
 }
index c8fd8bad19ba54402f1f3176ef4280ab4004288a..7e71707c22b16705c74bdd174d1e0f12fed88a9c 100644 (file)
@@ -204,5 +204,11 @@ error: there is no argument named `foo`
 LL |         {foo}
    |         ^^^^^
 
-error: aborting due to 27 previous errors
+error: invalid format string: expected `'}'`, found `'t'`
+  --> $DIR/ifmt-bad-arg.rs:85:1
+   |
+LL | tenth number: {}",
+   | ^ expected `}` in format string
+
+error: aborting due to 28 previous errors