From 336faf553e1ef8d21298a4f6e9835a22e29904ad Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Sun, 3 Jul 2022 12:51:09 +0100 Subject: [PATCH] clippy: Fix latest nightly lints Signed-off-by: Dave Tucker --- aya-gen/src/generate.rs | 2 +- aya/src/maps/map_lock.rs | 6 +++--- aya/src/obj/btf/types.rs | 4 ++-- aya/src/obj/mod.rs | 20 ++++++-------------- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/aya-gen/src/generate.rs b/aya-gen/src/generate.rs index 4bd4b8e7..5da33e81 100644 --- a/aya-gen/src/generate.rs +++ b/aya-gen/src/generate.rs @@ -150,7 +150,7 @@ mod test { use super::{combine_flags, extract_ctypes_prefix}; fn to_vec(s: &str) -> Vec { - s.split(" ").map(|x| x.into()).collect() + s.split(' ').map(|x| x.into()).collect() } #[test] diff --git a/aya/src/maps/map_lock.rs b/aya/src/maps/map_lock.rs index 7a693173..18f87acf 100644 --- a/aya/src/maps/map_lock.rs +++ b/aya/src/maps/map_lock.rs @@ -62,7 +62,7 @@ impl Deref for MapRef { type Target = Map; fn deref(&self) -> &Map { - &*self.guard + &self.guard } } @@ -70,12 +70,12 @@ impl Deref for MapRefMut { type Target = Map; fn deref(&self) -> &Map { - &*self.guard + &self.guard } } impl DerefMut for MapRefMut { fn deref_mut(&mut self) -> &mut Map { - &mut *self.guard + &mut self.guard } } diff --git a/aya/src/obj/btf/types.rs b/aya/src/obj/btf/types.rs index fc61c709..d5008858 100644 --- a/aya/src/obj/btf/types.rs +++ b/aya/src/obj/btf/types.rs @@ -602,8 +602,8 @@ pub(crate) fn fields_are_compatible( let flavorless_name = |name: &str| name.split_once("___").map_or(name, |x| x.0).to_string(); - let local_name = flavorless_name(&*local_btf.type_name(local_ty)?.unwrap()); - let target_name = flavorless_name(&*target_btf.type_name(target_ty)?.unwrap()); + let local_name = flavorless_name(&local_btf.type_name(local_ty)?.unwrap()); + let target_name = flavorless_name(&target_btf.type_name(target_ty)?.unwrap()); return Ok(local_name == target_name); } diff --git a/aya/src/obj/mod.rs b/aya/src/obj/mod.rs index c7852e45..9094986e 100644 --- a/aya/src/obj/mod.rs +++ b/aya/src/obj/mod.rs @@ -635,21 +635,13 @@ impl Object { let section_size_bytes = sym.size as u32 / INS_SIZE as u32; let mut func_info = btf_ext.func_info.get(section.name); - func_info.func_info = func_info - .func_info - .into_iter() - .filter(|f| f.insn_off == bytes_offset) - .collect(); + func_info.func_info.retain(|f| f.insn_off == bytes_offset); let mut line_info = btf_ext.line_info.get(section.name); - line_info.line_info = line_info - .line_info - .into_iter() - .filter(|l| { - l.insn_off >= bytes_offset - && l.insn_off < (bytes_offset + section_size_bytes) as u32 - }) - .collect(); + line_info.line_info.retain(|l| { + l.insn_off >= bytes_offset + && l.insn_off < (bytes_offset + section_size_bytes) as u32 + }); ( func_info, @@ -1401,7 +1393,7 @@ mod tests { assert!(obj.maps.get("foo").is_some()); assert!(obj.maps.get("bar").is_some()); assert!(obj.maps.get("baz").is_some()); - for (_, m) in &obj.maps { + for m in obj.maps.values() { assert_eq!(&m.def, def); } }