Merge pull request #2395 from dtolnay/parsewhere

Simplify parsing of where-predicates in bound attribute
This commit is contained in:
David Tolnay 2023-03-09 00:38:57 -08:00 committed by GitHub
commit 7e9b98401d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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))
}