From 559fe9a8f97cb72ba84a2a7dcbf54dfee8cf9de2 Mon Sep 17 00:00:00 2001 From: Vincent Lafeychine <vincent.lafeychine@proton.me> Date: Thu, 25 Apr 2024 22:40:16 +0200 Subject: [PATCH] clippy: Fix map_clone --- rr_frontend/.cargo/config.toml | 1 - rr_frontend/attribute_parse/src/parse.rs | 2 +- rr_frontend/translation/src/environment/polonius_info.rs | 2 +- rr_frontend/translation/src/function_body.rs | 4 ++-- rr_frontend/translation/src/type_translator.rs | 3 +-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/rr_frontend/.cargo/config.toml b/rr_frontend/.cargo/config.toml index f139a0f3..a4f08575 100644 --- a/rr_frontend/.cargo/config.toml +++ b/rr_frontend/.cargo/config.toml @@ -80,7 +80,6 @@ rustflags = [ "-Aclippy::unwrap_in_result", # clippy::style - "-Aclippy::map_clone", "-Aclippy::match_like_matches_macro", "-Aclippy::needless_borrow", "-Aclippy::needless_late_init", diff --git a/rr_frontend/attribute_parse/src/parse.rs b/rr_frontend/attribute_parse/src/parse.rs index ba579e35..2f182e98 100644 --- a/rr_frontend/attribute_parse/src/parse.rs +++ b/rr_frontend/attribute_parse/src/parse.rs @@ -121,7 +121,7 @@ pub struct ParseBuffer { impl ParseBuffer { pub fn new(stream: &rustc_ast::tokenstream::TokenStream) -> Self { // TODO; maybe avoid the cloning - let trees: Vec<TokenTree> = stream.trees().map(|c| c.clone()).collect(); + let trees: Vec<TokenTree> = stream.trees().cloned().collect(); Self { trees, diff --git a/rr_frontend/translation/src/environment/polonius_info.rs b/rr_frontend/translation/src/environment/polonius_info.rs index 4aa0bed1..2d16fdaf 100644 --- a/rr_frontend/translation/src/environment/polonius_info.rs +++ b/rr_frontend/translation/src/environment/polonius_info.rs @@ -1080,7 +1080,7 @@ impl<'a, 'tcx: 'a> PoloniusInfo<'a, 'tcx> { /// Get the location at which a loan is created, if possible pub fn get_loan_location(&self, loan: &facts::Loan) -> Option<mir::Location> { - self.loan_position.get(loan).map(|r| *r) + self.loan_position.get(loan).copied() } /// Get the loan that gets created at a location. diff --git a/rr_frontend/translation/src/function_body.rs b/rr_frontend/translation/src/function_body.rs index 998c0278..006cce4b 100644 --- a/rr_frontend/translation/src/function_body.rs +++ b/rr_frontend/translation/src/function_body.rs @@ -3176,7 +3176,7 @@ impl<'a, 'def: 'a, 'tcx: 'def> BodyTranslator<'a, 'def, 'tcx> { } let struct_use = - self.ty_translator.generate_tuple_use(operand_types.iter().map(|r| *r))?; + self.ty_translator.generate_tuple_use(operand_types.iter().copied())?; let sl = struct_use.generate_raw_syn_type_term(); let initializers: Vec<_> = translated_ops.into_iter().enumerate().map(|(i, o)| (i.to_string(), o)).collect(); @@ -3264,7 +3264,7 @@ impl<'a, 'def: 'a, 'tcx: 'def> BodyTranslator<'a, 'def, 'tcx> { } let struct_use = - self.ty_translator.generate_tuple_use(operand_types.iter().map(|r| *r))?; + self.ty_translator.generate_tuple_use(operand_types.iter().copied())?; let sl = struct_use.generate_raw_syn_type_term(); let initializers: Vec<_> = diff --git a/rr_frontend/translation/src/type_translator.rs b/rr_frontend/translation/src/type_translator.rs index 3521954c..75abc297 100644 --- a/rr_frontend/translation/src/type_translator.rs +++ b/rr_frontend/translation/src/type_translator.rs @@ -284,8 +284,7 @@ impl<'def, 'tcx: 'def> TypeTranslator<'def, 'tcx> { /// Lookup a shim for an ADT. fn lookup_adt_shim(&self, did: DefId) -> Option<radium::LiteralTypeRef<'def>> { - let shims = self.adt_shims.borrow(); - shims.get(&did).map(|x| *x) + self.adt_shims.borrow().get(&did).copied() } /// Get all the struct definitions that clients have used (excluding the variants of enums). -- GitLab