Skip to content

Commit 2736430

Browse files
committed
compiler: use copied instead of manual map
1 parent e6779d9 commit 2736430

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
4141
}
4242
// Merge attributes into the inner expression.
4343
if !e.attrs.is_empty() {
44-
let old_attrs =
45-
self.attrs.get(&ex.hir_id.local_id).map(|la| *la).unwrap_or(&[]);
44+
let old_attrs = self.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
4645
self.attrs.insert(
4746
ex.hir_id.local_id,
4847
&*self.arena.alloc_from_iter(

compiler/rustc_ast_lowering/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
505505
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
506506
/// resolver (if any).
507507
fn orig_opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
508-
self.resolver.node_id_to_def_id.get(&node).map(|local_def_id| *local_def_id)
508+
self.resolver.node_id_to_def_id.get(&node).copied()
509509
}
510510

511511
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
@@ -548,7 +548,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
548548
self.generics_def_id_map
549549
.iter()
550550
.rev()
551-
.find_map(|map| map.get(&local_def_id).map(|local_def_id| *local_def_id))
551+
.find_map(|map| map.get(&local_def_id).copied())
552552
.unwrap_or(local_def_id)
553553
}
554554

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
860860
self.suggest_boxing_for_return_impl_trait(
861861
err,
862862
ret_sp,
863-
prior_arms.iter().chain(std::iter::once(&arm_span)).map(|s| *s),
863+
prior_arms.iter().chain(std::iter::once(&arm_span)).copied(),
864864
);
865865
}
866866
}

compiler/rustc_lint/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ pub trait LintContext: Sized {
715715
db.note("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information");
716716
},
717717
BuiltinLintDiagnostics::UnexpectedCfgName((name, name_span), value) => {
718-
let possibilities: Vec<Symbol> = sess.parse_sess.check_config.expecteds.keys().map(|s| *s).collect();
718+
let possibilities: Vec<Symbol> = sess.parse_sess.check_config.expecteds.keys().copied().collect();
719719

720720
// Suggest the most probable if we found one
721721
if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) {

compiler/rustc_middle/src/mir/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ pub fn write_allocations<'tcx>(
13371337
fn alloc_ids_from_alloc(
13381338
alloc: ConstAllocation<'_>,
13391339
) -> impl DoubleEndedIterator<Item = AllocId> + '_ {
1340-
alloc.inner().provenance().ptrs().values().map(|id| *id)
1340+
alloc.inner().provenance().ptrs().values().copied()
13411341
}
13421342

13431343
fn alloc_ids_from_const_val(val: ConstValue<'_>) -> impl Iterator<Item = AllocId> + '_ {

compiler/rustc_ty_utils/src/assoc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &[DefId] {
4343
trait_fn_def_id,
4444
)
4545
})
46-
.map(|def_id| *def_id),
46+
.copied(),
4747
),
4848
)
4949
}
@@ -69,7 +69,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &[DefId] {
6969
impl_fn_def_id,
7070
)
7171
})
72-
.map(|def_id| *def_id)
72+
.copied()
7373
})),
7474
)
7575
}

0 commit comments

Comments
 (0)