Skip to content

Commit

Permalink
Merge pull request #1148 from dtolnay/fnmutself
Browse files Browse the repository at this point in the history
Fix panic on comma after `mut self` in bare fn type
  • Loading branch information
dtolnay committed Mar 16, 2022
2 parents 9a66997 + 4a3a83d commit 6daa474
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ty.rs
Expand Up @@ -740,7 +740,10 @@ pub mod parsing {
break;
}

inputs.push_punct(args.parse()?);
let comma = args.parse()?;
if !has_mut_self {
inputs.push_punct(comma);
}
}

inputs
Expand Down
1 change: 1 addition & 0 deletions tests/test_ty.rs
Expand Up @@ -9,6 +9,7 @@ use syn::Type;
#[test]
fn test_mut_self() {
syn::parse_str::<Type>("fn(mut self)").unwrap();
syn::parse_str::<Type>("fn(mut self,)").unwrap();
syn::parse_str::<Type>("fn(mut self: ())").unwrap();
syn::parse_str::<Type>("fn(mut self: ...)").unwrap_err();
syn::parse_str::<Type>("fn(mut self: mut self)").unwrap_err();
Expand Down

0 comments on commit 6daa474

Please sign in to comment.