Skip to content

Commit 1c7cb8b

Browse files
committed
Relpace map(|x| x.clone()) with cloned().
1 parent c6a647a commit 1c7cb8b

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

src/libcollections/dlist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ impl<A: Ord> Ord for DList<A> {
895895
#[stable(feature = "rust1", since = "1.0.0")]
896896
impl<A: Clone> Clone for DList<A> {
897897
fn clone(&self) -> DList<A> {
898-
self.iter().map(|x| x.clone()).collect()
898+
self.iter().cloned().collect()
899899
}
900900
}
901901

src/librustc/middle/infer/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
924924

925925
fn rebuild(&self)
926926
-> (ast::FnDecl, Option<ast::ExplicitSelf_>, ast::Generics) {
927-
let mut expl_self_opt = self.expl_self_opt.map(|x| x.clone());
927+
let mut expl_self_opt = self.expl_self_opt.cloned();
928928
let mut inputs = self.fn_decl.inputs.clone();
929929
let mut output = self.fn_decl.output.clone();
930930
let mut ty_params = self.generics.ty_params.clone();

src/librustc_back/rpath.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn get_rpath_flags<F, G>(config: RPathConfig<F, G>) -> Vec<String> where
4141

4242
let libs = config.used_crates.clone();
4343
let libs = libs.into_iter().filter_map(|(_, l)| {
44-
l.map(|p| p.clone())
44+
l.cloned()
4545
}).collect::<Vec<_>>();
4646

4747
let rpaths = get_rpaths(config, &libs[]);

src/librustc_trans/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3228,7 +3228,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
32283228
reachable.push("rust_eh_personality_catch".to_string());
32293229

32303230
if codegen_units > 1 {
3231-
internalize_symbols(&shared_ccx, &reachable.iter().map(|x| x.clone()).collect());
3231+
internalize_symbols(&shared_ccx, &reachable.iter().cloned().collect());
32323232
}
32333233

32343234
let metadata_module = ModuleTranslation {

src/librustdoc/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
293293
let mut a: Vec<clean::Attribute> = i.attrs.iter().filter(|&a| match a {
294294
&clean::NameValue(ref x, _) if "doc" == *x => false,
295295
_ => true
296-
}).map(|x| x.clone()).collect();
296+
}).cloned().collect();
297297
if docstr.len() > 0 {
298298
a.push(clean::NameValue("doc".to_string(), docstr));
299299
}

src/libsyntax/ext/deriving/generic/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ impl<'a> TraitDef<'a> {
367367
"allow" | "warn" | "deny" | "forbid" => true,
368368
_ => false,
369369
}
370-
}).map(|a| a.clone()));
370+
}).cloned());
371371
push(P(ast::Item {
372372
attrs: attrs,
373373
..(*newitem).clone()
@@ -445,14 +445,14 @@ impl<'a> TraitDef<'a> {
445445
span: self.span,
446446
bound_lifetimes: wb.bound_lifetimes.clone(),
447447
bounded_ty: wb.bounded_ty.clone(),
448-
bounds: OwnedSlice::from_vec(wb.bounds.iter().map(|b| b.clone()).collect())
448+
bounds: OwnedSlice::from_vec(wb.bounds.iter().cloned().collect())
449449
})
450450
}
451451
ast::WherePredicate::RegionPredicate(ref rb) => {
452452
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
453453
span: self.span,
454454
lifetime: rb.lifetime,
455-
bounds: rb.bounds.iter().map(|b| b.clone()).collect()
455+
bounds: rb.bounds.iter().cloned().collect()
456456
})
457457
}
458458
ast::WherePredicate::EqPredicate(ref we) => {
@@ -500,7 +500,7 @@ impl<'a> TraitDef<'a> {
500500
let opt_trait_ref = Some(trait_ref);
501501
let ident = ast_util::impl_pretty_name(&opt_trait_ref, &*self_type);
502502
let mut a = vec![attr];
503-
a.extend(self.attributes.iter().map(|a| a.clone()));
503+
a.extend(self.attributes.iter().cloned());
504504
cx.item(
505505
self.span,
506506
ident,

src/libsyntax/parse/parser.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ macro_rules! maybe_whole {
241241
fn maybe_append(mut lhs: Vec<Attribute>, rhs: Option<Vec<Attribute>>)
242242
-> Vec<Attribute> {
243243
match rhs {
244-
Some(ref attrs) => lhs.extend(attrs.iter().map(|a| a.clone())),
244+
Some(ref attrs) => lhs.extend(attrs.iter().cloned()),
245245
None => {}
246246
}
247247
lhs
@@ -467,7 +467,7 @@ impl<'a> Parser<'a> {
467467
debug!("commit_expr {:?}", e);
468468
if let ExprPath(..) = e.node {
469469
// might be unit-struct construction; check for recoverableinput error.
470-
let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>();
470+
let mut expected = edible.iter().cloned().collect::<Vec<_>>();
471471
expected.push_all(inedible);
472472
self.check_for_erroneous_unit_struct_expecting(&expected[]);
473473
}
@@ -485,7 +485,7 @@ impl<'a> Parser<'a> {
485485
if self.last_token
486486
.as_ref()
487487
.map_or(false, |t| t.is_ident() || t.is_path()) {
488-
let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>();
488+
let mut expected = edible.iter().cloned().collect::<Vec<_>>();
489489
expected.push_all(&inedible[]);
490490
self.check_for_erroneous_unit_struct_expecting(
491491
&expected[]);

src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ impl<'a> State<'a> {
983983
try!(self.word_nbsp("trait"));
984984
try!(self.print_ident(item.ident));
985985
try!(self.print_generics(generics));
986-
let bounds: Vec<_> = bounds.iter().map(|b| b.clone()).collect();
986+
let bounds: Vec<_> = bounds.iter().cloned().collect();
987987
let mut real_bounds = Vec::with_capacity(bounds.len());
988988
for b in bounds {
989989
if let TraitTyParamBound(ref ptr, ast::TraitBoundModifier::Maybe) = b {

0 commit comments

Comments
 (0)