Skip to content

Commit

Permalink
Merge pull request #382 from dtolnay/hang
Browse files Browse the repository at this point in the history
Fix fallback fmt expression parser hang
  • Loading branch information
dtolnay authored Nov 10, 2024
2 parents 8d06fb5 + 591a44d commit 9d6506e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions impl/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ fn fallback_explicit_named_args(input: ParseStream) -> Result<FmtArguments> {
let ident = input.call(Ident::parse_any)?;
input.parse::<Token![=]>()?;
args.named.insert(ident);
} else {
input.parse::<TokenTree>()?;
}
}

Expand Down
7 changes: 7 additions & 0 deletions tests/ui/expression-fallback.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use thiserror::Error;

#[derive(Error, Debug)]
#[error("".yellow)]
pub struct ArgError;

fn main() {}
19 changes: 19 additions & 0 deletions tests/ui/expression-fallback.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: expected `,`, found `.`
--> tests/ui/expression-fallback.rs:4:11
|
4 | #[error("".yellow)]
| ^ expected `,`

error: argument never used
--> tests/ui/expression-fallback.rs:4:12
|
4 | #[error("".yellow)]
| -- ^^^^^^ argument never used
| |
| formatting specifier missing

error[E0425]: cannot find value `yellow` in this scope
--> tests/ui/expression-fallback.rs:4:12
|
4 | #[error("".yellow)]
| ^^^^^^ not found in this scope

0 comments on commit 9d6506e

Please sign in to comment.