Skip to content

Commit c984a96

Browse files
authored
Rollup merge of #70269 - matthiaskrgr:clippy_closures, r=Dylan-DPC
remove redundant closures (clippy::redundant_closure)
2 parents 092c821 + 263cbd1 commit c984a96

File tree

22 files changed

+33
-41
lines changed

22 files changed

+33
-41
lines changed

src/liballoc/collections/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
196196
(root, length)
197197
};
198198

199-
out_node.push(k, v, subroot.unwrap_or_else(|| node::Root::new_leaf()));
199+
out_node.push(k, v, subroot.unwrap_or_else(node::Root::new_leaf));
200200
out_tree.length += 1 + sublength;
201201
}
202202
}
@@ -2147,7 +2147,7 @@ impl<K, V> BTreeMap<K, V> {
21472147
/// If the root node is the empty (non-allocated) root node, allocate our
21482148
/// own node.
21492149
fn ensure_root_is_owned(&mut self) -> &mut node::Root<K, V> {
2150-
self.root.get_or_insert_with(|| node::Root::new_leaf())
2150+
self.root.get_or_insert_with(node::Root::new_leaf)
21512151
}
21522152
}
21532153

src/librustc/dep_graph/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl DepGraph {
245245
C: DepGraphSafe + StableHashingContextProvider<'a>,
246246
{
247247
if let Some(ref data) = self.data {
248-
let task_deps = create_task(key).map(|deps| Lock::new(deps));
248+
let task_deps = create_task(key).map(Lock::new);
249249

250250
// In incremental mode, hash the result of the task. We don't
251251
// do anything with the hash yet, but we are computing it

src/librustc/mir/interpret/allocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl UndefMask {
796796
}
797797

798798
// FIXME(oli-obk): optimize this for allocations larger than a block.
799-
let idx = (start.bytes()..end.bytes()).map(|i| Size::from_bytes(i)).find(|&i| !self.get(i));
799+
let idx = (start.bytes()..end.bytes()).map(Size::from_bytes).find(|&i| !self.get(i));
800800

801801
match idx {
802802
Some(idx) => Err(idx),

src/librustc_ast/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl ParenthesizedArgs {
250250
pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs {
251251
AngleBracketedArgs {
252252
span: self.span,
253-
args: self.inputs.iter().cloned().map(|input| GenericArg::Type(input)).collect(),
253+
args: self.inputs.iter().cloned().map(GenericArg::Type).collect(),
254254
constraints: vec![],
255255
}
256256
}

src/librustc_ast_lowering/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
272272
if !generic_args.parenthesized && !has_lifetimes {
273273
generic_args.args = self
274274
.elided_path_lifetimes(path_span, expected_lifetimes)
275-
.map(|lt| GenericArg::Lifetime(lt))
275+
.map(GenericArg::Lifetime)
276276
.chain(generic_args.args.into_iter())
277277
.collect();
278278
if expected_lifetimes > 0 && param_mode == ParamMode::Explicit {

src/librustc_builtin_macros/deriving/generic/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ impl<'a> Path<'a> {
7676
self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics)).collect();
7777
let params = lt
7878
.into_iter()
79-
.map(|lt| GenericArg::Lifetime(lt))
80-
.chain(tys.into_iter().map(|ty| GenericArg::Type(ty)))
79+
.map(GenericArg::Lifetime)
80+
.chain(tys.into_iter().map(GenericArg::Type))
8181
.collect();
8282

8383
match self.kind {

src/librustc_data_structures/sharded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct Sharded<T> {
3030
impl<T: Default> Default for Sharded<T> {
3131
#[inline]
3232
fn default() -> Self {
33-
Self::new(|| T::default())
33+
Self::new(T::default)
3434
}
3535
}
3636

src/librustc_errors/diagnostic_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'a> DiagnosticBuilder<'a> {
162162
message: &str,
163163
span: Option<S>,
164164
) -> &mut Self {
165-
let span = span.map(|s| s.into()).unwrap_or_else(|| MultiSpan::new());
165+
let span = span.map(|s| s.into()).unwrap_or_else(MultiSpan::new);
166166
self.0.diagnostic.sub(level, message, span, None);
167167
self
168168
}

src/librustc_feature/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Feature {
5151

5252
impl Feature {
5353
fn issue(&self) -> Option<NonZeroU32> {
54-
self.issue.and_then(|i| NonZeroU32::new(i))
54+
self.issue.and_then(NonZeroU32::new)
5555
}
5656
}
5757

src/librustc_interface/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ impl<'tcx> QueryContext<'tcx> {
703703
where
704704
F: FnOnce(TyCtxt<'tcx>) -> R,
705705
{
706-
ty::tls::enter_global(self.0, |tcx| f(tcx))
706+
ty::tls::enter_global(self.0, f)
707707
}
708708

709709
pub fn print_stats(&mut self) {

0 commit comments

Comments
 (0)