about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/generic/mod.rs10
1 files 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 b37418f1df6..aa1ce1b929d 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<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);