about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2023-10-22 12:08:20 -0700
committerDavid Tolnay <dtolnay@gmail.com>2023-10-22 12:13:12 -0700
commit45363f11efce0e06a743d6e0dce25178462cfa1f (patch)
tree626ba2c371bdb47e9f83c8bb7abb93776f1b74d3 /compiler
parentbd2b53ba6dc0e41c82cce900dc7d6bcc329d9a60 (diff)
downloadrust-45363f11efce0e06a743d6e0dce25178462cfa1f.tar.gz
rust-45363f11efce0e06a743d6e0dce25178462cfa1f.zip
Directly collect into ty_param_names instead of peeking to see if empty
Diffstat (limited to 'compiler')
-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);