Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bd90013

Browse files
Rollup merge of #145905 - TaKO8Ki:fix-137580, r=nnethercote
Stop calling unwrap when format foreign has trailing dollar Fixes #137580
2 parents ecb377f + 2c361f8 commit bd90013

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
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.

‎tests/crashes/137580.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// https://github.com/rust-lang/rust/issues/137580
2+
fn main() {
3+
println!("%65536$", 1);
4+
//~^ ERROR never used
5+
}
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:3: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:3: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)

AltStyle によって変換されたページ (->オリジナル) /