Skip to content

Commit

Permalink
Allow where-clause to end at end of input
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 2, 2018
1 parent 800df6e commit 38012de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ pub mod parsing {
predicates: {
let mut predicates = Punctuated::new();
loop {
if input.peek(token::Brace)
if input.is_empty()
|| input.peek(token::Brace)
|| input.peek(Token![,])
|| input.peek(Token![;])
|| input.peek(Token![:]) && !input.peek(Token![::])
Expand Down
9 changes: 9 additions & 0 deletions tests/test_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,12 @@ fn test_fn_precedence_in_where_clause() {
let second_bound = &predicate.bounds[1];
assert_eq!(quote!(#second_bound).to_string(), "Send");
}

#[test]
fn test_where_clause_at_end_of_input() {
let tokens = quote! {
where
};
let where_clause = syn::parse2::<WhereClause>(tokens).unwrap();
assert_eq!(where_clause.predicates.len(), 0);
}

0 comments on commit 38012de

Please sign in to comment.