From 8d8697f2f16e3034539a01b063b6be54bb3143d8 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 22 Oct 2023 12:08:20 -0700 Subject: [PATCH] Directly collect into ty_param_names instead of peeking to see if empty --- .../rustc_builtin_macros/src/deriving/generic/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index b37418f1df6c9..aa1ce1b929d0f 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -695,15 +695,13 @@ impl<'a> TraitDef<'a> { } })); - let mut ty_params = params + let ty_param_names: Vec = params .iter() .filter(|param| matches!(param.kind, ast::GenericParamKind::Type { .. })) - .peekable(); - - if ty_params.peek().is_some() { - let ty_param_names: Vec = - 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);