about summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving/generic
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-07-26 17:11:10 +0200
committerljedrz <ljedrz@gmail.com>2018-07-29 18:53:22 +0200
commit59c8a279daf6912b99ba089ff6dafbfc3469831e (patch)
treeab821f37fca36aa9730bed95c0cad5fbf3e9eaa4 /src/libsyntax_ext/deriving/generic
parenta5c2d0fffaaf0b764c01bc4066e51ffd475ceae9 (diff)
downloadrust-59c8a279daf6912b99ba089ff6dafbfc3469831e.tar.gz
rust-59c8a279daf6912b99ba089ff6dafbfc3469831e.zip
Replace push loops with collect() and extend() where possible
Diffstat (limited to 'src/libsyntax_ext/deriving/generic')
-rw-r--r--src/libsyntax_ext/deriving/generic/mod.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs
index a9f60fd053c..e0f985c26c7 100644
--- a/src/libsyntax_ext/deriving/generic/mod.rs
+++ b/src/libsyntax_ext/deriving/generic/mod.rs
@@ -188,6 +188,7 @@ pub use self::StaticFields::*;
 pub use self::SubstructureFields::*;
 
 use std::cell::RefCell;
+use std::iter;
 use std::vec;
 
 use rustc_target::spec::abi::Abi;
@@ -558,15 +559,13 @@ impl<'a> TraitDef<'a> {
                     // type being derived upon
                     self.additional_bounds.iter().map(|p| {
                         cx.trait_bound(p.to_path(cx, self.span, type_ident, generics))
-                    }).collect();
-
-                // require the current trait
-                bounds.push(cx.trait_bound(trait_path.clone()));
-
-                // also add in any bounds from the declaration
-                for declared_bound in &param.bounds {
-                    bounds.push((*declared_bound).clone());
-                }
+                    }).chain(
+                        // require the current trait
+                        iter::once(cx.trait_bound(trait_path.clone()))
+                    ).chain(
+                        // also add in any bounds from the declaration
+                        param.bounds.iter().cloned()
+                    ).collect();
 
                 cx.typaram(self.span, param.ident, vec![], bounds, None)
             }