Skip to content

Commit

Permalink
Directly collect into ty_param_names instead of peeking to see if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 22, 2023
1 parent bd2b53b commit 45363f1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 45363f1

Please sign in to comment.