Directly collect into ty_param_names instead of peeking to see if empty

This commit is contained in:
David Tolnay 2023-10-22 12:08:20 -07:00
parent bd2b53ba6d
commit 45363f11ef
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -695,15 +695,13 @@ impl<'a> TraitDef<'a> {
}
}));
let mut ty_params = params
let ty_param_names: Vec<Symbol> = params
.iter()
.filter(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }))
.peekable();
if ty_params.peek().is_some() {
let ty_param_names: Vec<Symbol> =
ty_params.map(|ty_param| ty_param.ident.name).collect();
.map(|ty_param| ty_param.ident.name)
.collect();
if !ty_param_names.is_empty() {
for field_ty in field_tys {
let field_ty_params = find_type_parameters(&field_ty, &ty_param_names, cx);