Skip to content

Commit

Permalink
Merge pull request #109 from dtolnay/keyword
Browse files Browse the repository at this point in the history
Fix keyword as fmt argument
  • Loading branch information
dtolnay authored Nov 4, 2020
2 parents 7a9066f + aafcf0a commit 53bb2fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions impl/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn explicit_named_args(input: ParseStream) -> Result<Set<Ident>> {
while !input.is_empty() {
if input.peek(Token![,]) && input.peek2(Ident::peek_any) && input.peek3(Token![=]) {
input.parse::<Token![,]>()?;
let ident: Ident = input.parse()?;
let ident = input.call(Ident::parse_any)?;
input.parse::<Token![=]>()?;
named_args.insert(ident);
} else {
Expand Down Expand Up @@ -143,5 +143,5 @@ fn take_ident(read: &mut &str) -> Ident {
}
}
}
syn::parse_str(&ident).unwrap()
Ident::parse_any.parse_str(&ident).unwrap()
}
9 changes: 9 additions & 0 deletions tests/test_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,12 @@ fn test_raw_conflict() {

assert("braced raw error: T, U", Error::Braced { r#func: "T" });
}

#[test]
fn test_keyword() {
#[derive(Error, Debug)]
#[error("error: {type}", type = 1)]
struct Error;

assert("error: 1", Error);
}

0 comments on commit 53bb2fb

Please sign in to comment.