Skip to content

Commit adddae6

Browse files
committed
stop returning errors when format foreign has trailing dollar
1 parent f5703d5 commit adddae6

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

compiler/rustc_builtin_macros/src/format_foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ pub(crate) mod printf {
416416
// Yes, this *is* the parameter.
417417
Some(('$', end2)) => {
418418
state = Flags;
419-
parameter = Some(at.slice_between(end).unwrap().parse().unwrap());
419+
parameter = at.slice_between(end).unwrap().parse().ok();
420420
move_to!(end2);
421421
}
422422
// Wait, no, actually, it's the width.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
println!("%65536$", 1);
3+
//~^ ERROR never used
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: argument never used
2+
--> $DIR/format-foreign-dollar-without-spec.rs:2:25
3+
|
4+
LL | println!("%65536$", 1);
5+
| ^ argument never used
6+
|
7+
note: format specifiers use curly braces, and the conversion specifier `
8+
` is unknown or unsupported
9+
--> $DIR/format-foreign-dollar-without-spec.rs:2:15
10+
|
11+
LL | println!("%65536$", 1);
12+
| ^^^^^^^^
13+
= note: printf formatting is not supported; see the documentation for `std::fmt`
14+
15+
error: aborting due to 1 previous error
16+

0 commit comments

Comments
 (0)