Skip to content

Commit

Permalink
Merge pull request #1074 from dtolnay/impltraitplus
Browse files Browse the repository at this point in the history
Support trailing plus on impl trait type
  • Loading branch information
dtolnay committed Oct 3, 2021
2 parents a1096c2 + caea567 commit c480344
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ty.rs
Expand Up @@ -919,6 +919,14 @@ pub mod parsing {
break;
}
bounds.push_punct(input.parse()?);
if !(input.peek(Ident::peek_any)
|| input.peek(Token![::])
|| input.peek(Token![?])
|| input.peek(Lifetime)
|| input.peek(token::Paren))
{
break;
}
}
bounds
},
Expand Down
35 changes: 35 additions & 0 deletions tests/test_item.rs
Expand Up @@ -299,3 +299,38 @@ fn test_impl_type_parameter_defaults() {
self_ty: Type::Tuple,
}"###);
}

#[test]
fn test_impl_trait_trailing_plus() {
let tokens = quote! {
fn f() -> impl Sized + {}
};

snapshot!(tokens as Item, @r###"
Item::Fn {
vis: Inherited,
sig: Signature {
ident: "f",
generics: Generics,
output: Type(
Type::ImplTrait {
bounds: [
Trait(TraitBound {
modifier: None,
path: Path {
segments: [
PathSegment {
ident: "Sized",
arguments: None,
},
],
},
}),
],
},
),
},
block: Block,
}
"###);
}

0 comments on commit c480344

Please sign in to comment.