Skip to content

Commit

Permalink
remove padding from multiline format string label
Browse files Browse the repository at this point in the history
Fixes #53836.
  • Loading branch information
euclio committed Oct 3, 2018
1 parent 1c5e9c6 commit b14dc69
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libfmt_macros/lib.rs
Expand Up @@ -288,7 +288,7 @@ impl<'a> Parser<'a> {
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,
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/if/ifmt-bad-arg.rs
Expand Up @@ -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
}
8 changes: 7 additions & 1 deletion src/test/ui/if/ifmt-bad-arg.stderr
Expand Up @@ -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

0 comments on commit b14dc69

Please sign in to comment.