Skip to content

Commit

Permalink
Improve error message when parsing Ident encounters keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 20, 2023
1 parent 25def51 commit 18cac49
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,16 @@ mod parsing {
input.step(|cursor| {
if let Some((ident, rest)) = cursor.ident() {
if accept_as_ident(&ident) {
return Ok((ident, rest));
Ok((ident, rest))
} else {
Err(cursor.error(format_args!(
"expected identifier, found keyword `{}`",
ident,
)))
}
} else {
Err(cursor.error("expected identifier"))
}
Err(cursor.error("expected identifier"))
})
}
}
Expand Down

0 comments on commit 18cac49

Please sign in to comment.