about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2020-03-22 12:43:19 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2020-03-22 12:43:19 +0100
commit263cbd1bbe2d89880c04b69a003f98ca12ba4970 (patch)
treedf9f187c92391eff28bfddf8b70bfe0e76b854cd
parent5574b1df577f737373b42cbf364b6cab2dfa5960 (diff)
downloadrust-263cbd1bbe2d89880c04b69a003f98ca12ba4970.tar.gz
rust-263cbd1bbe2d89880c04b69a003f98ca12ba4970.zip
remove redundant closures (clippy::redundant_closure)
-rw-r--r--src/liballoc/collections/btree/map.rs4
-rw-r--r--src/librustc/dep_graph/graph.rs2
-rw-r--r--src/librustc/mir/interpret/allocation.rs2
-rw-r--r--src/librustc_ast/ast.rs2
-rw-r--r--src/librustc_ast_lowering/path.rs2
-rw-r--r--src/librustc_builtin_macros/deriving/generic/ty.rs4
-rw-r--r--src/librustc_data_structures/sharded.rs2
-rw-r--r--src/librustc_errors/diagnostic_builder.rs2
-rw-r--r--src/librustc_feature/lib.rs2
-rw-r--r--src/librustc_interface/passes.rs2
-rw-r--r--src/librustc_metadata/locator.rs2
-rw-r--r--src/librustc_mir/dataflow/generic/graphviz.rs2
-rw-r--r--src/librustc_mir/monomorphize/collector.rs2
-rw-r--r--src/librustc_mir_build/hair/pattern/_match.rs2
-rw-r--r--src/librustc_save_analysis/dump_visitor.rs2
-rw-r--r--src/librustc_save_analysis/lib.rs17
-rw-r--r--src/librustc_session/config.rs2
-rw-r--r--src/librustc_trait_selection/traits/fulfill.rs4
-rw-r--r--src/librustc_trait_selection/traits/object_safety.rs2
-rw-r--r--src/librustc_trait_selection/traits/select.rs8
-rw-r--r--src/librustc_typeck/astconv.rs5
-rw-r--r--src/librustc_typeck/check/compare_method.rs2
22 files changed, 33 insertions, 41 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs
index 3ba7befc046..bde66c406af 100644
--- a/src/liballoc/collections/btree/map.rs
+++ b/src/liballoc/collections/btree/map.rs
@@ -196,7 +196,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
                                 (root, length)
                             };
 
-                            out_node.push(k, v, subroot.unwrap_or_else(|| node::Root::new_leaf()));
+                            out_node.push(k, v, subroot.unwrap_or_else(node::Root::new_leaf));
                             out_tree.length += 1 + sublength;
                         }
                     }
@@ -2147,7 +2147,7 @@ impl<K, V> BTreeMap<K, V> {
     /// If the root node is the empty (non-allocated) root node, allocate our
     /// own node.
     fn ensure_root_is_owned(&mut self) -> &mut node::Root<K, V> {
-        self.root.get_or_insert_with(|| node::Root::new_leaf())
+        self.root.get_or_insert_with(node::Root::new_leaf)
     }
 }
 
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs
index 40192d072eb..f3ae2b3d57a 100644
--- a/src/librustc/dep_graph/graph.rs
+++ b/src/librustc/dep_graph/graph.rs
@@ -245,7 +245,7 @@ impl DepGraph {
         C: DepGraphSafe + StableHashingContextProvider<'a>,
     {
         if let Some(ref data) = self.data {
-            let task_deps = create_task(key).map(|deps| Lock::new(deps));
+            let task_deps = create_task(key).map(Lock::new);
 
             // In incremental mode, hash the result of the task. We don't
             // do anything with the hash yet, but we are computing it
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs
index 9474f05b55d..dd2a3f6c29a 100644
--- a/src/librustc/mir/interpret/allocation.rs
+++ b/src/librustc/mir/interpret/allocation.rs
@@ -796,7 +796,7 @@ impl UndefMask {
         }
 
         // FIXME(oli-obk): optimize this for allocations larger than a block.
-        let idx = (start.bytes()..end.bytes()).map(|i| Size::from_bytes(i)).find(|&i| !self.get(i));
+        let idx = (start.bytes()..end.bytes()).map(Size::from_bytes).find(|&i| !self.get(i));
 
         match idx {
             Some(idx) => Err(idx),
diff --git a/src/librustc_ast/ast.rs b/src/librustc_ast/ast.rs
index b7b50617eaa..9d00cbe1951 100644
--- a/src/librustc_ast/ast.rs
+++ b/src/librustc_ast/ast.rs
@@ -250,7 +250,7 @@ impl ParenthesizedArgs {
     pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs {
         AngleBracketedArgs {
             span: self.span,
-            args: self.inputs.iter().cloned().map(|input| GenericArg::Type(input)).collect(),
+            args: self.inputs.iter().cloned().map(GenericArg::Type).collect(),
             constraints: vec![],
         }
     }
diff --git a/src/librustc_ast_lowering/path.rs b/src/librustc_ast_lowering/path.rs
index b5b0a3089ce..91b61ebbce6 100644
--- a/src/librustc_ast_lowering/path.rs
+++ b/src/librustc_ast_lowering/path.rs
@@ -272,7 +272,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         if !generic_args.parenthesized && !has_lifetimes {
             generic_args.args = self
                 .elided_path_lifetimes(path_span, expected_lifetimes)
-                .map(|lt| GenericArg::Lifetime(lt))
+                .map(GenericArg::Lifetime)
                 .chain(generic_args.args.into_iter())
                 .collect();
             if expected_lifetimes > 0 && param_mode == ParamMode::Explicit {
diff --git a/src/librustc_builtin_macros/deriving/generic/ty.rs b/src/librustc_builtin_macros/deriving/generic/ty.rs
index bd54a735311..d83c98572a2 100644
--- a/src/librustc_builtin_macros/deriving/generic/ty.rs
+++ b/src/librustc_builtin_macros/deriving/generic/ty.rs
@@ -76,8 +76,8 @@ impl<'a> Path<'a> {
             self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics)).collect();
         let params = lt
             .into_iter()
-            .map(|lt| GenericArg::Lifetime(lt))
-            .chain(tys.into_iter().map(|ty| GenericArg::Type(ty)))
+            .map(GenericArg::Lifetime)
+            .chain(tys.into_iter().map(GenericArg::Type))
             .collect();
 
         match self.kind {
diff --git a/src/librustc_data_structures/sharded.rs b/src/librustc_data_structures/sharded.rs
index d08d46a7414..485719c5175 100644
--- a/src/librustc_data_structures/sharded.rs
+++ b/src/librustc_data_structures/sharded.rs
@@ -30,7 +30,7 @@ pub struct Sharded<T> {
 impl<T: Default> Default for Sharded<T> {
     #[inline]
     fn default() -> Self {
-        Self::new(|| T::default())
+        Self::new(T::default)
     }
 }
 
diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs
index 008d2e92418..fffae0bfd24 100644
--- a/src/librustc_errors/diagnostic_builder.rs
+++ b/src/librustc_errors/diagnostic_builder.rs
@@ -162,7 +162,7 @@ impl<'a> DiagnosticBuilder<'a> {
         message: &str,
         span: Option<S>,
     ) -> &mut Self {
-        let span = span.map(|s| s.into()).unwrap_or_else(|| MultiSpan::new());
+        let span = span.map(|s| s.into()).unwrap_or_else(MultiSpan::new);
         self.0.diagnostic.sub(level, message, span, None);
         self
     }
diff --git a/src/librustc_feature/lib.rs b/src/librustc_feature/lib.rs
index 01546f78257..f8bf0315d0c 100644
--- a/src/librustc_feature/lib.rs
+++ b/src/librustc_feature/lib.rs
@@ -51,7 +51,7 @@ pub struct Feature {
 
 impl Feature {
     fn issue(&self) -> Option<NonZeroU32> {
-        self.issue.and_then(|i| NonZeroU32::new(i))
+        self.issue.and_then(NonZeroU32::new)
     }
 }
 
diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs
index 8d9e287cdc9..cb1ed87b02f 100644
--- a/src/librustc_interface/passes.rs
+++ b/src/librustc_interface/passes.rs
@@ -703,7 +703,7 @@ impl<'tcx> QueryContext<'tcx> {
     where
         F: FnOnce(TyCtxt<'tcx>) -> R,
     {
-        ty::tls::enter_global(self.0, |tcx| f(tcx))
+        ty::tls::enter_global(self.0, f)
     }
 
     pub fn print_stats(&mut self) {
diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs
index 2f9be599ba9..c1a95c094b1 100644
--- a/src/librustc_metadata/locator.rs
+++ b/src/librustc_metadata/locator.rs
@@ -327,7 +327,7 @@ impl<'a> CrateLocator<'a> {
                     .into_iter()
                     .filter_map(|entry| entry.files())
                     .flatten()
-                    .map(|location| PathBuf::from(location))
+                    .map(PathBuf::from)
                     .collect()
             } else {
                 // SVH being specified means this is a transitive dependency,
diff --git a/src/librustc_mir/dataflow/generic/graphviz.rs b/src/librustc_mir/dataflow/generic/graphviz.rs
index 36decf7f5a9..c15f2a726ee 100644
--- a/src/librustc_mir/dataflow/generic/graphviz.rs
+++ b/src/librustc_mir/dataflow/generic/graphviz.rs
@@ -577,7 +577,7 @@ fn write_diff<A: Analysis<'tcx>>(
     let mut clear = HybridBitSet::new_empty(len);
 
     // FIXME: Implement a lazy iterator over the symmetric difference of two bitsets.
-    for i in (0..len).map(|i| A::Idx::new(i)) {
+    for i in (0..len).map(A::Idx::new) {
         match (from.contains(i), to.contains(i)) {
             (false, true) => set.insert(i),
             (true, false) => clear.insert(i),
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs
index a592e8d9c05..cbd19f080eb 100644
--- a/src/librustc_mir/monomorphize/collector.rs
+++ b/src/librustc_mir/monomorphize/collector.rs
@@ -895,7 +895,7 @@ fn create_mono_items_for_vtable_methods<'tcx>(
                     .unwrap()
                 })
                 .filter(|&instance| should_monomorphize_locally(tcx, &instance))
-                .map(|instance| create_fn_mono_item(instance));
+                .map(create_fn_mono_item);
             output.extend(methods);
         }
 
diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs
index 82810f35675..89063a4227f 100644
--- a/src/librustc_mir_build/hair/pattern/_match.rs
+++ b/src/librustc_mir_build/hair/pattern/_match.rs
@@ -2066,7 +2066,7 @@ fn split_grouped_constructors<'p, 'tcx>(
                         }
                         intersection
                     })
-                    .flat_map(|range| range_borders(range));
+                    .flat_map(range_borders);
                 let ctor_borders = range_borders(ctor_range.clone());
                 let mut borders: Vec<_> = row_borders.chain(ctor_borders).collect();
                 borders.sort_unstable();
diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs
index 8d1a39eab89..a80c3b72044 100644
--- a/src/librustc_save_analysis/dump_visitor.rs
+++ b/src/librustc_save_analysis/dump_visitor.rs
@@ -1148,7 +1148,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
 
                 let sub_span = path.segments.last().unwrap().ident.span;
                 if !self.span.filter_generated(sub_span) {
-                    let ref_id = self.lookup_def_id(id).map(|id| id_from_def_id(id));
+                    let ref_id = self.lookup_def_id(id).map(id_from_def_id);
                     let alias_span = alias.map(|i| self.span_from_span(i.span));
                     let span = self.span_from_span(sub_span);
                     self.dumper.import(
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index bb717981a3b..024633c3b3d 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -326,7 +326,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
                                     .as_ref()
                                     .and_then(|t| self.lookup_def_id(t.ref_id))
                                     .map(id_from_def_id)
-                                    .unwrap_or_else(|| null_id()),
+                                    .unwrap_or_else(null_id),
                             },
                             Impl {
                                 id: impl_id,
@@ -487,9 +487,9 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
             qualname,
             // FIXME you get better data here by using the visitor.
             value: String::new(),
-            parent: parent_scope.map(|id| id_from_def_id(id)),
+            parent: parent_scope.map(id_from_def_id),
             children: vec![],
-            decl_id: decl_id.map(|id| id_from_def_id(id)),
+            decl_id: decl_id.map(id_from_def_id),
             docs,
             sig: None,
             attributes: lower_attributes(attributes, self),
@@ -541,7 +541,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
                                 .tcx
                                 .find_field_index(ident, variant)
                                 .map(|index| id_from_def_id(variant.fields[index].did))
-                                .unwrap_or_else(|| null_id()),
+                                .unwrap_or_else(null_id),
                         }))
                     }
                     ty::Tuple(..) => None,
@@ -590,14 +590,11 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
                 Some(Data::RefData(Ref {
                     kind: RefKind::Function,
                     span,
-                    ref_id: def_id
-                        .or(decl_id)
-                        .map(|id| id_from_def_id(id))
-                        .unwrap_or_else(|| null_id()),
+                    ref_id: def_id.or(decl_id).map(id_from_def_id).unwrap_or_else(|| null_id()),
                 }))
             }
             ast::ExprKind::Path(_, ref path) => {
-                self.get_path_data(expr.id, path).map(|d| Data::RefData(d))
+                self.get_path_data(expr.id, path).map(Data::RefData)
             }
             _ => {
                 // FIXME
@@ -1075,7 +1072,7 @@ fn id_from_def_id(id: DefId) -> rls_data::Id {
 
 fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id {
     let def_id = scx.tcx.hir().opt_local_def_id_from_node_id(id);
-    def_id.map(|id| id_from_def_id(id)).unwrap_or_else(|| {
+    def_id.map(id_from_def_id).unwrap_or_else(|| {
         // Create a *fake* `DefId` out of a `NodeId` by subtracting the `NodeId`
         // out of the maximum u32 value. This will work unless you have *billions*
         // of definitions in a single crate (very unlikely to actually happen).
diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs
index f16e4ca93d8..6c4d70c09a3 100644
--- a/src/librustc_session/config.rs
+++ b/src/librustc_session/config.rs
@@ -1310,7 +1310,7 @@ fn select_incremental_path(
         (None, Some(path)) => Some(path),
         (None, None) => None,
     }
-    .map(|m| PathBuf::from(m))
+    .map(PathBuf::from)
 }
 
 fn collect_print_requests(
diff --git a/src/librustc_trait_selection/traits/fulfill.rs b/src/librustc_trait_selection/traits/fulfill.rs
index 5def77ce732..260363a5d1f 100644
--- a/src/librustc_trait_selection/traits/fulfill.rs
+++ b/src/librustc_trait_selection/traits/fulfill.rs
@@ -131,7 +131,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
             // FIXME: if we kept the original cache key, we could mark projection
             // obligations as complete for the projection cache here.
 
-            errors.extend(outcome.errors.into_iter().map(|e| to_fulfillment_error(e)));
+            errors.extend(outcome.errors.into_iter().map(to_fulfillment_error));
 
             // If nothing new was added, no need to keep looping.
             if outcome.stalled {
@@ -214,7 +214,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
             .predicates
             .to_errors(CodeAmbiguity)
             .into_iter()
-            .map(|e| to_fulfillment_error(e))
+            .map(to_fulfillment_error)
             .collect();
         if errors.is_empty() { Ok(()) } else { Err(errors) }
     }
diff --git a/src/librustc_trait_selection/traits/object_safety.rs b/src/librustc_trait_selection/traits/object_safety.rs
index 452f965014b..5cc1da045fc 100644
--- a/src/librustc_trait_selection/traits/object_safety.rs
+++ b/src/librustc_trait_selection/traits/object_safety.rs
@@ -39,7 +39,7 @@ pub fn astconv_object_safety_violations(
     let violations = traits::supertrait_def_ids(tcx, trait_def_id)
         .map(|def_id| predicates_reference_self(tcx, def_id, true))
         .filter(|spans| !spans.is_empty())
-        .map(|spans| ObjectSafetyViolation::SupertraitSelf(spans))
+        .map(ObjectSafetyViolation::SupertraitSelf)
         .collect();
 
     debug!("astconv_object_safety_violations(trait_def_id={:?}) = {:?}", trait_def_id, violations);
diff --git a/src/librustc_trait_selection/traits/select.rs b/src/librustc_trait_selection/traits/select.rs
index 660d4d14bc7..2f59620be93 100644
--- a/src/librustc_trait_selection/traits/select.rs
+++ b/src/librustc_trait_selection/traits/select.rs
@@ -2947,13 +2947,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
                 let existential_predicates = data_a.map_bound(|data_a| {
                     let iter = data_a
                         .principal()
-                        .map(|x| ty::ExistentialPredicate::Trait(x))
+                        .map(ty::ExistentialPredicate::Trait)
                         .into_iter()
-                        .chain(
-                            data_a
-                                .projection_bounds()
-                                .map(|x| ty::ExistentialPredicate::Projection(x)),
-                        )
+                        .chain(data_a.projection_bounds().map(ty::ExistentialPredicate::Projection))
                         .chain(data_b.auto_traits().map(ty::ExistentialPredicate::AutoTrait));
                     tcx.mk_existential_predicates(iter)
                 });
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 3ee6d5df735..408e5c2d2f2 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -1693,9 +1693,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
         };
 
         // Erase the `dummy_self` (`trait_object_dummy_self`) used above.
-        let existential_trait_refs = regular_traits
-            .iter()
-            .map(|i| i.trait_ref().map_bound(|trait_ref| trait_ref_to_existential(trait_ref)));
+        let existential_trait_refs =
+            regular_traits.iter().map(|i| i.trait_ref().map_bound(trait_ref_to_existential));
         let existential_projections = bounds.projection_bounds.iter().map(|(bound, _)| {
             bound.map_bound(|b| {
                 let trait_ref = trait_ref_to_existential(b.projection_ty.trait_ref(tcx));
diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs
index 6178158e4e5..f666ef72d52 100644
--- a/src/librustc_typeck/check/compare_method.rs
+++ b/src/librustc_typeck/check/compare_method.rs
@@ -677,7 +677,7 @@ fn compare_number_of_generics<'tcx>(
                         impl_count,
                         kind,
                         pluralize!(impl_count),
-                        suffix.unwrap_or_else(|| String::new()),
+                        suffix.unwrap_or_else(String::new),
                     ),
                 );
             }