Simplify parsing of where-predicates in bound attribute

This commit is contained in:
David Tolnay 2023-03-09 00:20:51 -08:00
parent b80e722f81
commit f301e09e02
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -1627,11 +1627,9 @@ fn parse_lit_into_where(
) -> Result<Vec<syn::WherePredicate>, ()> {
let string = get_lit_str2(cx, attr_name, meta_item_name, lit)?;
let where_string = syn::LitStr::new(&format!("where {}", string.value()), string.span());
where_string
.parse::<syn::WhereClause>()
.map(|wh| wh.predicates.into_iter().collect())
string
.parse_with(Punctuated::<syn::WherePredicate, Token![,]>::parse_terminated)
.map(|predicates| predicates.into_iter().collect())
.map_err(|err| cx.error_spanned_by(lit, err))
}