Skip to content

Commit

Permalink
Merge pull request #975 from dtolnay/emptybounds
Browse files Browse the repository at this point in the history
Permit empty trait bounds after colon on type item
  • Loading branch information
dtolnay authored Mar 9, 2021
2 parents 78f78ab + 79e357c commit 8ca66e5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,14 +1179,14 @@ pub mod parsing {
let mut bounds = Punctuated::new();
if colon_token.is_some() {
loop {
bounds.push_value(input.parse::<TypeParamBound>()?);
if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
break;
}
bounds.push_punct(input.parse::<Token![+]>()?);
bounds.push_value(input.parse::<TypeParamBound>()?);
if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
break;
}
bounds.push_punct(input.parse::<Token![+]>()?);
}
}
generics.where_clause = input.parse()?;
Expand Down
25 changes: 25 additions & 0 deletions tests/test_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,28 @@ fn test_supertraits() {
}
"###);
}

#[test]
fn test_type_empty_bounds() {
#[rustfmt::skip]
let tokens = quote! {
trait Foo {
type Bar: ;
}
};

snapshot!(tokens as ItemTrait, @r###"
ItemTrait {
vis: Inherited,
ident: "Foo",
generics: Generics,
items: [
TraitItem::Type {
ident: "Bar",
generics: Generics,
colon_token: Some,
},
],
}
"###);
}

0 comments on commit 8ca66e5

Please sign in to comment.