Skip to content

Commit

Permalink
Merge pull request #1422 from dtolnay/trymacro
Browse files Browse the repository at this point in the history
Treat try keyword as 2015 ident in definition of try macro
  • Loading branch information
dtolnay committed Mar 23, 2023
2 parents b862eff + f3a4a4c commit 40aa291
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,11 @@ pub(crate) mod parsing {
let attrs = input.call(Attribute::parse_outer)?;
let path = input.call(Path::parse_mod_style)?;
let bang_token: Token![!] = input.parse()?;
let ident: Option<Ident> = input.parse()?;
let ident: Option<Ident> = if input.peek(Token![try]) {
input.call(Ident::parse_any).map(Some)
} else {
input.parse()
}?;
let (delimiter, tokens) = input.call(mac::parse_delimiter)?;
let semi_token: Option<Token![;]> = if !delimiter.is_brace() {
Some(input.parse()?)
Expand Down
2 changes: 1 addition & 1 deletion src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ pub(crate) mod parsing {
let mut is_item_macro = false;
if let Ok(path) = ahead.call(Path::parse_mod_style) {
if ahead.peek(Token![!]) {
if ahead.peek2(Ident) {
if ahead.peek2(Ident) || ahead.peek2(Token![try]) {
is_item_macro = true;
} else if ahead.peek2(token::Brace)
&& !(ahead.peek3(Token![.]) || ahead.peek3(Token![?]))
Expand Down

0 comments on commit 40aa291

Please sign in to comment.