Skip to content

Commit 71aded8

Browse files
authored
Rollup merge of #54795 - euclio:ifmt-bad-arg, r=estebank
remove padding from multiline format string label Fixes #53836.
2 parents 2503db8 + b14dc69 commit 71aded8

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/libfmt_macros/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl<'a> Parser<'a> {
288288
self.cur.next();
289289
Some(pos)
290290
} else {
291-
let pos = pos + padding + 1;
291+
let pos = pos + raw + 1;
292292
self.err(format!("expected `{:?}`, found `{:?}`", c, maybe),
293293
format!("expected `{}`", c),
294294
pos,

src/test/ui/if/ifmt-bad-arg.rs

+14
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,18 @@ fn main() {
7171
7272
"##);
7373
//~^^^ ERROR: there is no argument named `foo`
74+
75+
// bad syntax in format string with multiple newlines, #53836
76+
format!("first number: {}
77+
second number: {}
78+
third number: {}
79+
fourth number: {}
80+
fifth number: {}
81+
sixth number: {}
82+
seventh number: {}
83+
eighth number: {}
84+
ninth number: {
85+
tenth number: {}",
86+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
87+
//~^^ ERROR: invalid format string
7488
}

src/test/ui/if/ifmt-bad-arg.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,11 @@ error: there is no argument named `foo`
204204
LL | {foo}
205205
| ^^^^^
206206

207-
error: aborting due to 27 previous errors
207+
error: invalid format string: expected `'}'`, found `'t'`
208+
--> $DIR/ifmt-bad-arg.rs:85:1
209+
|
210+
LL | tenth number: {}",
211+
| ^ expected `}` in format string
212+
213+
error: aborting due to 28 previous errors
208214

0 commit comments

Comments
 (0)