about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2020-02-29 13:14:52 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2020-02-29 15:23:13 +0100
commitc9a02c2e427fa22c8a86f7818dcde17e53151c30 (patch)
treefe98199cffe0ef210984db1d626b6280ce262553 /src
parent3f9bddc7fea3ca1d49f39f22bb937a84ed32f84e (diff)
downloadrust-c9a02c2e427fa22c8a86f7818dcde17e53151c30.tar.gz
rust-c9a02c2e427fa22c8a86f7818dcde17e53151c30.zip
use .copied() instead of .map(|x| *x) on iterators
Diffstat (limited to 'src')
-rw-r--r--src/librustc/ich/hcx.rs2
-rw-r--r--src/librustc/middle/region.rs2
-rw-r--r--src/librustc_ast_lowering/expr.rs2
-rw-r--r--src/librustc_builtin_macros/format.rs2
-rw-r--r--src/librustc_expand/mbe/macro_rules.rs2
-rw-r--r--src/librustc_metadata/rmeta/encoder.rs2
-rw-r--r--src/librustc_mir/interpret/terminator.rs2
-rw-r--r--src/librustc_mir_build/hair/cx/expr.rs23
-rw-r--r--src/librustc_mir_build/hair/pattern/_match.rs2
-rw-r--r--src/librustc_span/source_map.rs2
-rw-r--r--src/librustc_typeck/check/method/suggest.rs2
-rw-r--r--src/librustc_typeck/check/mod.rs2
-rw-r--r--src/librustc_typeck/collect.rs2
-rw-r--r--src/librustc_typeck/outlives/mod.rs2
-rw-r--r--src/librustc_typeck/variance/mod.rs2
-rw-r--r--src/libtest/test_result.rs2
16 files changed, 26 insertions, 27 deletions
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs
index 2cb8388aca6..d8be4194c9e 100644
--- a/src/librustc/ich/hcx.rs
+++ b/src/librustc/ich/hcx.rs
@@ -20,7 +20,7 @@ use std::cmp::Ord;
 
 fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
     debug_assert!(!ich::IGNORED_ATTRIBUTES.is_empty());
-    ich::IGNORED_ATTRIBUTES.iter().map(|&s| s).collect()
+    ich::IGNORED_ATTRIBUTES.iter().copied().collect()
 }
 
 /// This is the context state available during incr. comp. hashing. It contains
diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs
index 9e9c8bd8464..1d043f5dcde 100644
--- a/src/librustc/middle/region.rs
+++ b/src/librustc/middle/region.rs
@@ -635,7 +635,7 @@ impl<'tcx> ScopeTree {
     /// Used to sanity check visit_expr call count when
     /// calculating generator interiors.
     pub fn body_expr_count(&self, body_id: hir::BodyId) -> Option<usize> {
-        self.body_expr_count.get(&body_id).map(|r| *r)
+        self.body_expr_count.get(&body_id).copied()
     }
 }
 
diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs
index d781fbde59c..23ec924573c 100644
--- a/src/librustc_ast_lowering/expr.rs
+++ b/src/librustc_ast_lowering/expr.rs
@@ -1179,7 +1179,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
             let from_err_expr =
                 self.wrap_in_try_constructor(sym::from_error, unstable_span, from_expr, try_span);
             let thin_attrs = ThinVec::from(attrs);
-            let catch_scope = self.catch_scopes.last().map(|x| *x);
+            let catch_scope = self.catch_scopes.last().copied();
             let ret_expr = if let Some(catch_node) = catch_scope {
                 let target_id = Ok(self.lower_node_id(catch_node));
                 self.arena.alloc(self.expr(
diff --git a/src/librustc_builtin_macros/format.rs b/src/librustc_builtin_macros/format.rs
index 0684662b2bf..9092caef60a 100644
--- a/src/librustc_builtin_macros/format.rs
+++ b/src/librustc_builtin_macros/format.rs
@@ -359,7 +359,7 @@ impl<'a, 'b> Context<'a, 'b> {
             refs.sort();
             refs.dedup();
             let (arg_list, mut sp) = if refs.len() == 1 {
-                let spans: Vec<_> = spans.into_iter().filter_map(|sp| sp.map(|sp| *sp)).collect();
+                let spans: Vec<_> = spans.into_iter().filter_map(|sp| sp.copied()).collect();
                 (
                     format!("argument {}", refs[0]),
                     if spans.is_empty() {
diff --git a/src/librustc_expand/mbe/macro_rules.rs b/src/librustc_expand/mbe/macro_rules.rs
index 52e581e30f5..3607e59a52c 100644
--- a/src/librustc_expand/mbe/macro_rules.rs
+++ b/src/librustc_expand/mbe/macro_rules.rs
@@ -970,7 +970,7 @@ fn check_matcher_core(
                                         msg,
                                         ts[..ts.len() - 1]
                                             .iter()
-                                            .map(|s| *s)
+                                            .copied()
                                             .collect::<Vec<_>>()
                                             .join(", "),
                                         ts[ts.len() - 1],
diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs
index ee54f40ece5..79dc4364a61 100644
--- a/src/librustc_metadata/rmeta/encoder.rs
+++ b/src/librustc_metadata/rmeta/encoder.rs
@@ -503,7 +503,7 @@ impl<'tcx> EncodeContext<'tcx> {
             },
             proc_macro_data,
             proc_macro_stability: if is_proc_macro {
-                tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| *stab)
+                tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).copied()
             } else {
                 None
             },
diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs
index a02a6898c1d..53e10f86a2c 100644
--- a/src/librustc_mir/interpret/terminator.rs
+++ b/src/librustc_mir/interpret/terminator.rs
@@ -305,7 +305,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                         let mut caller_iter = caller_args
                             .iter()
                             .filter(|op| !rust_abi || !op.layout.is_zst())
-                            .map(|op| *op);
+                            .copied();
 
                         // Now we have to spread them out across the callee's locals,
                         // taking into account the `spread_arg`.  If we could write
diff --git a/src/librustc_mir_build/hair/cx/expr.rs b/src/librustc_mir_build/hair/cx/expr.rs
index 74006c88371..46d49b6b493 100644
--- a/src/librustc_mir_build/hair/cx/expr.rs
+++ b/src/librustc_mir_build/hair/cx/expr.rs
@@ -187,13 +187,12 @@ fn make_mirror_unadjusted<'a, 'tcx>(
                 if let Some((adt_def, index)) = adt_data {
                     let substs = cx.tables().node_substs(fun.hir_id);
                     let user_provided_types = cx.tables().user_provided_types();
-                    let user_ty =
-                        user_provided_types.get(fun.hir_id).map(|u_ty| *u_ty).map(|mut u_ty| {
-                            if let UserType::TypeOf(ref mut did, _) = &mut u_ty.value {
-                                *did = adt_def.did;
-                            }
-                            u_ty
-                        });
+                    let user_ty = user_provided_types.get(fun.hir_id).copied().map(|mut u_ty| {
+                        if let UserType::TypeOf(ref mut did, _) = &mut u_ty.value {
+                            *did = adt_def.did;
+                        }
+                        u_ty
+                    });
                     debug!("make_mirror_unadjusted: (call) user_ty={:?}", user_ty);
 
                     let field_refs = args
@@ -329,7 +328,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
             ty::Adt(adt, substs) => match adt.adt_kind() {
                 AdtKind::Struct | AdtKind::Union => {
                     let user_provided_types = cx.tables().user_provided_types();
-                    let user_ty = user_provided_types.get(expr.hir_id).map(|u_ty| *u_ty);
+                    let user_ty = user_provided_types.get(expr.hir_id).copied();
                     debug!("make_mirror_unadjusted: (struct/union) user_ty={:?}", user_ty);
                     ExprKind::Adt {
                         adt_def: adt,
@@ -351,7 +350,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
 
                             let index = adt.variant_index_with_id(variant_id);
                             let user_provided_types = cx.tables().user_provided_types();
-                            let user_ty = user_provided_types.get(expr.hir_id).map(|u_ty| *u_ty);
+                            let user_ty = user_provided_types.get(expr.hir_id).copied();
                             debug!("make_mirror_unadjusted: (variant) user_ty={:?}", user_ty);
                             ExprKind::Adt {
                                 adt_def: adt,
@@ -570,7 +569,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
         }
         hir::ExprKind::Type(ref source, ref ty) => {
             let user_provided_types = cx.tables.user_provided_types();
-            let user_ty = user_provided_types.get(ty.hir_id).map(|u_ty| *u_ty);
+            let user_ty = user_provided_types.get(ty.hir_id).copied();
             debug!("make_mirror_unadjusted: (type) user_ty={:?}", user_ty);
             if source.is_syntactic_place_expr() {
                 ExprKind::PlaceTypeAscription { source: source.to_ref(), user_ty }
@@ -605,7 +604,7 @@ fn user_substs_applied_to_res<'tcx>(
         | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
         | Res::Def(DefKind::Const, _)
         | Res::Def(DefKind::AssocConst, _) => {
-            cx.tables().user_provided_types().get(hir_id).map(|u_ty| *u_ty)
+            cx.tables().user_provided_types().get(hir_id).copied()
         }
 
         // A unit struct/variant which is used as a value (e.g.,
@@ -744,7 +743,7 @@ fn convert_path_expr<'a, 'tcx>(
 
         Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id) => {
             let user_provided_types = cx.tables.user_provided_types();
-            let user_provided_type = user_provided_types.get(expr.hir_id).map(|u_ty| *u_ty);
+            let user_provided_type = user_provided_types.get(expr.hir_id).copied();
             debug!("convert_path_expr: user_provided_type={:?}", user_provided_type);
             let ty = cx.tables().node_type(expr.hir_id);
             match ty.kind {
diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs
index 85f03629b64..90e4f536478 100644
--- a/src/librustc_mir_build/hair/pattern/_match.rs
+++ b/src/librustc_mir_build/hair/pattern/_match.rs
@@ -411,7 +411,7 @@ impl<'p, 'tcx> PatStack<'p, 'tcx> {
     }
 
     fn iter(&self) -> impl Iterator<Item = &Pat<'tcx>> {
-        self.0.iter().map(|p| *p)
+        self.0.iter().copied()
     }
 
     // If the first pattern is an or-pattern, expand this pattern. Otherwise, return `None`.
diff --git a/src/librustc_span/source_map.rs b/src/librustc_span/source_map.rs
index 31d397f040c..3b665e1d6dc 100644
--- a/src/librustc_span/source_map.rs
+++ b/src/librustc_span/source_map.rs
@@ -206,7 +206,7 @@ impl SourceMap {
         &self,
         stable_id: StableSourceFileId,
     ) -> Option<Lrc<SourceFile>> {
-        self.files.borrow().stable_id_to_source_file.get(&stable_id).map(|sf| sf.clone())
+        self.files.borrow().stable_id_to_source_file.get(&stable_id).cloned()
     }
 
     fn allocate_address_space(&self, size: usize) -> Result<usize, OffsetOverflowError> {
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs
index 44f87319ebf..97ed50b3500 100644
--- a/src/librustc_typeck/check/method/suggest.rs
+++ b/src/librustc_typeck/check/method/suggest.rs
@@ -167,7 +167,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                                     .skip_binder()
                                     .get(0)
                                     .filter(|ty| ty.is_region_ptr() && !rcvr_ty.is_region_ptr())
-                                    .map(|ty| *ty)
+                                    .copied()
                                     .unwrap_or(rcvr_ty),
                             };
                             print_disambiguation_help(
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index ce2af9b96e5..d025f81153f 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -1315,7 +1315,7 @@ fn check_fn<'a, 'tcx>(
         fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType);
 
         // Resume type defaults to `()` if the generator has no argument.
-        let resume_ty = fn_sig.inputs().get(0).map(|ty| *ty).unwrap_or_else(|| tcx.mk_unit());
+        let resume_ty = fn_sig.inputs().get(0).copied().unwrap_or_else(|| tcx.mk_unit());
 
         fcx.resume_yield_tys = Some((resume_ty, yield_ty));
     }
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 252abaee747..7ec3686c013 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -2236,7 +2236,7 @@ fn from_target_feature(
             };
 
             // Only allow features whose feature gates have been enabled.
-            let allowed = match feature_gate.as_ref().map(|s| *s) {
+            let allowed = match feature_gate.as_ref().copied() {
                 Some(sym::arm_target_feature) => rust_features.arm_target_feature,
                 Some(sym::aarch64_target_feature) => rust_features.aarch64_target_feature,
                 Some(sym::hexagon_target_feature) => rust_features.hexagon_target_feature,
diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs
index 51987391097..f7b6e0fce5a 100644
--- a/src/librustc_typeck/outlives/mod.rs
+++ b/src/librustc_typeck/outlives/mod.rs
@@ -25,7 +25,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
             hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => {
                 let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE);
 
-                let predicates = crate_map.predicates.get(&item_def_id).map(|p| *p).unwrap_or(&[]);
+                let predicates = crate_map.predicates.get(&item_def_id).copied().unwrap_or(&[]);
 
                 if tcx.has_attr(item_def_id, sym::rustc_outlives) {
                     let mut pred: Vec<String> = predicates
diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs
index 32bd7e4c4c1..ddde11b3844 100644
--- a/src/librustc_typeck/variance/mod.rs
+++ b/src/librustc_typeck/variance/mod.rs
@@ -79,5 +79,5 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] {
     // Everything else must be inferred.
 
     let crate_map = tcx.crate_variances(LOCAL_CRATE);
-    crate_map.variances.get(&item_def_id).map(|p| *p).unwrap_or(&[])
+    crate_map.variances.get(&item_def_id).copied().unwrap_or(&[])
 }
diff --git a/src/libtest/test_result.rs b/src/libtest/test_result.rs
index bfa572c887a..5c975c6272b 100644
--- a/src/libtest/test_result.rs
+++ b/src/libtest/test_result.rs
@@ -40,7 +40,7 @@ pub fn calc_result<'a>(
             let maybe_panic_str = err
                 .downcast_ref::<String>()
                 .map(|e| &**e)
-                .or_else(|| err.downcast_ref::<&'static str>().map(|e| *e));
+                .or_else(|| err.downcast_ref::<&'static str>().copied());
 
             if maybe_panic_str.map(|e| e.contains(msg)).unwrap_or(false) {
                 TestResult::TrOk