Skip to content

Commit 5a0078c

Browse files
committed
more clippy fixes:
clippy::search_is_some clippy::redundant_static_lifetimes clippy::match_single_binding clippy::match_ref_pats clippy::map_entry clippy::manual_map clippy::iter_overeager_cloned clippy::into_iter_on_ref clippy::extra_unused_lifetimes
1 parent 56e4ea5 commit 5a0078c

File tree

6 files changed

+15
-24
lines changed

6 files changed

+15
-24
lines changed

crates/hir_ty/src/consteval.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ pub fn eval_const(expr: &Expr, ctx: &mut ConstEvalCtx<'_>) -> Result<ComputedExp
241241
Expr::Block { statements, tail, .. } => {
242242
let mut prev_values = HashMap::<Name, Option<ComputedExpr>>::default();
243243
for statement in &**statements {
244-
match statement {
245-
&hir_def::expr::Statement::Let { pat, initializer, .. } => {
244+
match *statement {
245+
hir_def::expr::Statement::Let { pat, initializer, .. } => {
246246
let pat = &ctx.pats[pat];
247247
let name = match pat {
248248
Pat::Bind { name, subpat, .. } if subpat.is_none() => name.clone(),
@@ -261,7 +261,7 @@ pub fn eval_const(expr: &Expr, ctx: &mut ConstEvalCtx<'_>) -> Result<ComputedExp
261261
ctx.local_data.insert(name, value);
262262
}
263263
}
264-
&hir_def::expr::Statement::Expr { .. } => {
264+
hir_def::expr::Statement::Expr { .. } => {
265265
return Err(ConstEvalError::NotSupported("this kind of statement"))
266266
}
267267
}

crates/hir_ty/src/method_resolution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ pub(crate) fn inherent_impl_substs(
11051105
// Unknown, and in that case we want the result to contain Unknown in those
11061106
// places again.
11071107
let suffix =
1108-
Substitution::from_iter(Interner, substs.iter(Interner).cloned().skip(self_ty_vars));
1108+
Substitution::from_iter(Interner, substs.iter(Interner).skip(self_ty_vars).cloned());
11091109
Some(fallback_bound_vars(suffix, self_ty_vars))
11101110
}
11111111

crates/ide/src/syntax_highlighting/inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub(super) fn ra_fixture(
7878
Some(())
7979
}
8080

81-
const RUSTDOC_FENCE: &'static str = "```";
81+
const RUSTDOC_FENCE: &str = "```";
8282

8383
/// Injection of syntax highlighting of doctests.
8484
pub(super) fn doc_comment(

crates/ide_assists/src/handlers/extract_module.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
195195
// Remove complete impl block if it has only one child (as such it will be empty
196196
// after deleting that child)
197197
if impl_child_count == 1 {
198-
node_to_be_removed = impl_.syntax()
198+
node_to_be_removed = impl_.syntax();
199199
} else {
200200
//Remove selected node
201201
node_to_be_removed = &node;
202-
}
202+
};
203203

204204
builder.delete(node_to_be_removed.text_range());
205205
// Remove preceding indentation from node
@@ -418,11 +418,8 @@ impl Module {
418418

419419
record_field_parents.into_iter().for_each(|x| {
420420
x.1.descendants().filter_map(ast::RecordField::cast).for_each(|desc| {
421-
let is_record_field_present = record_fields
422-
.clone()
423-
.into_iter()
424-
.find(|x| x.to_string() == desc.to_string())
425-
.is_some();
421+
let is_record_field_present =
422+
record_fields.clone().into_iter().any(|x| x.to_string() == desc.to_string());
426423
if is_record_field_present {
427424
replacements.push((desc.visibility(), desc.syntax().clone()));
428425
}
@@ -520,7 +517,7 @@ impl Module {
520517
let mut exists_inside_sel = false;
521518
let mut exists_outside_sel = false;
522519
usage_res.clone().into_iter().for_each(|x| {
523-
let mut non_use_nodes_itr = (&x.1).into_iter().filter_map(|x| {
520+
let mut non_use_nodes_itr = (&x.1).iter().filter_map(|x| {
524521
if find_node_at_range::<ast::Use>(file.syntax(), x.range).is_none() {
525522
let path_opt = find_node_at_range::<ast::Path>(file.syntax(), x.range);
526523
return path_opt;
@@ -531,15 +528,11 @@ impl Module {
531528

532529
if non_use_nodes_itr
533530
.clone()
534-
.find(|x| !selection_range.contains_range(x.syntax().text_range()))
535-
.is_some()
531+
.any(|x| !selection_range.contains_range(x.syntax().text_range()))
536532
{
537533
exists_outside_sel = true;
538534
}
539-
if non_use_nodes_itr
540-
.find(|x| selection_range.contains_range(x.syntax().text_range()))
541-
.is_some()
542-
{
535+
if non_use_nodes_itr.any(|x| selection_range.contains_range(x.syntax().text_range())) {
543536
exists_inside_sel = true;
544537
}
545538
});
@@ -556,7 +549,7 @@ impl Module {
556549
let file_id = x.0;
557550
let mut use_opt: Option<ast::Use> = None;
558551
if file_id == curr_file_id {
559-
(&x.1).into_iter().for_each(|x| {
552+
(&x.1).iter().for_each(|x| {
560553
let node_opt: Option<ast::Use> = find_node_at_range(file.syntax(), x.range);
561554
if let Some(node) = node_opt {
562555
use_opt = Some(node);

crates/ide_assists/src/handlers/inline_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ fn inline(
374374
// inline direct local arguments
375375
[_, ..] if expr_as_name_ref(expr).is_some() => {
376376
cov_mark::hit!(inline_call_inline_locals);
377-
usages.into_iter().for_each(|usage| inline_direct(usage, expr));
377+
usages.iter().for_each(|usage| inline_direct(usage, expr));
378378
}
379379
// can't inline, emit a let statement
380380
_ => {

crates/syntax/src/ast/expr_ext.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,8 @@ impl AstNode for CallableExpr {
392392
{
393393
if let Some(it) = ast::CallExpr::cast(syntax.clone()) {
394394
Some(Self::Call(it))
395-
} else if let Some(it) = ast::MethodCallExpr::cast(syntax) {
396-
Some(Self::MethodCall(it))
397395
} else {
398-
None
396+
ast::MethodCallExpr::cast(syntax).map(Self::MethodCall)
399397
}
400398
}
401399

0 commit comments

Comments
 (0)