Unnamed repository; edit this file 'description' to name the repository.
redundant_closure
Johann Hemmann 2024-01-19
parent 3cf1358 · commit 5a62a0d
-rw-r--r--Cargo.toml1
-rw-r--r--crates/hir-def/src/body.rs4
-rw-r--r--crates/hir/src/lib.rs4
-rw-r--r--crates/hir/src/semantics/source_to_def.rs7
4 files changed, 6 insertions, 10 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 11b3369469..73a0881e4a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -177,7 +177,6 @@ needless_doctest_main = "allow"
new_without_default = "allow"
non_canonical_clone_impl = "allow"
non_canonical_partial_ord_impl = "allow"
-redundant_closure = "allow"
redundant_pattern_matching = "allow"
search_is_some = "allow"
self_named_constructors = "allow"
diff --git a/crates/hir-def/src/body.rs b/crates/hir-def/src/body.rs
index adc5b4520b..81132d7385 100644
--- a/crates/hir-def/src/body.rs
+++ b/crates/hir-def/src/body.rs
@@ -258,12 +258,12 @@ impl Body {
}
}
Pat::Or(args) | Pat::Tuple { args, .. } | Pat::TupleStruct { args, .. } => {
- args.iter().copied().for_each(|p| f(p));
+ args.iter().copied().for_each(f);
}
Pat::Ref { pat, .. } => f(*pat),
Pat::Slice { prefix, slice, suffix } => {
let total_iter = prefix.iter().chain(slice.iter()).chain(suffix.iter());
- total_iter.copied().for_each(|p| f(p));
+ total_iter.copied().for_each(f);
}
Pat::Record { args, .. } => {
args.iter().for_each(|RecordFieldPat { pat, .. }| f(*pat));
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index b75c4bb36d..c50be5f114 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -3152,7 +3152,7 @@ impl DeriveHelper {
.and_then(|it| it.get(self.idx as usize))
.cloned(),
}
- .unwrap_or_else(|| Name::missing())
+ .unwrap_or_else(Name::missing)
}
}
@@ -4421,7 +4421,7 @@ impl Type {
traits_in_scope,
with_local_impls.and_then(|b| b.id.containing_block()).into(),
name,
- &mut |id| callback(id),
+ callback,
);
}
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index e581c84b79..f60b3749b0 100644
--- a/crates/hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
@@ -308,7 +308,7 @@ impl SourceToDefCtx<'_, '_> {
pub(super) fn type_param_to_def(&mut self, src: InFile<ast::TypeParam>) -> Option<TypeParamId> {
let container: ChildContainer = self.find_generic_param_container(src.syntax())?.into();
let dyn_map = self.cache_for(container, src.file_id);
- dyn_map[keys::TYPE_PARAM].get(&src.value).copied().map(|it| TypeParamId::from_unchecked(it))
+ dyn_map[keys::TYPE_PARAM].get(&src.value).copied().map(TypeParamId::from_unchecked)
}
pub(super) fn lifetime_param_to_def(
@@ -326,10 +326,7 @@ impl SourceToDefCtx<'_, '_> {
) -> Option<ConstParamId> {
let container: ChildContainer = self.find_generic_param_container(src.syntax())?.into();
let dyn_map = self.cache_for(container, src.file_id);
- dyn_map[keys::CONST_PARAM]
- .get(&src.value)
- .copied()
- .map(|it| ConstParamId::from_unchecked(it))
+ dyn_map[keys::CONST_PARAM].get(&src.value).copied().map(ConstParamId::from_unchecked)
}
pub(super) fn generic_param_to_def(