mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
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
This commit is contained in:
parent
56e4ea59d9
commit
5a0078c9d1
6 changed files with 15 additions and 24 deletions
|
@ -241,8 +241,8 @@ pub fn eval_const(expr: &Expr, ctx: &mut ConstEvalCtx<'_>) -> Result<ComputedExp
|
|||
Expr::Block { statements, tail, .. } => {
|
||||
let mut prev_values = HashMap::<Name, Option<ComputedExpr>>::default();
|
||||
for statement in &**statements {
|
||||
match statement {
|
||||
&hir_def::expr::Statement::Let { pat, initializer, .. } => {
|
||||
match *statement {
|
||||
hir_def::expr::Statement::Let { pat, initializer, .. } => {
|
||||
let pat = &ctx.pats[pat];
|
||||
let name = match pat {
|
||||
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
|
|||
ctx.local_data.insert(name, value);
|
||||
}
|
||||
}
|
||||
&hir_def::expr::Statement::Expr { .. } => {
|
||||
hir_def::expr::Statement::Expr { .. } => {
|
||||
return Err(ConstEvalError::NotSupported("this kind of statement"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1105,7 +1105,7 @@ pub(crate) fn inherent_impl_substs(
|
|||
// Unknown, and in that case we want the result to contain Unknown in those
|
||||
// places again.
|
||||
let suffix =
|
||||
Substitution::from_iter(Interner, substs.iter(Interner).cloned().skip(self_ty_vars));
|
||||
Substitution::from_iter(Interner, substs.iter(Interner).skip(self_ty_vars).cloned());
|
||||
Some(fallback_bound_vars(suffix, self_ty_vars))
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ pub(super) fn ra_fixture(
|
|||
Some(())
|
||||
}
|
||||
|
||||
const RUSTDOC_FENCE: &'static str = "```";
|
||||
const RUSTDOC_FENCE: &str = "```";
|
||||
|
||||
/// Injection of syntax highlighting of doctests.
|
||||
pub(super) fn doc_comment(
|
||||
|
|
|
@ -195,11 +195,11 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
|
|||
// Remove complete impl block if it has only one child (as such it will be empty
|
||||
// after deleting that child)
|
||||
if impl_child_count == 1 {
|
||||
node_to_be_removed = impl_.syntax()
|
||||
node_to_be_removed = impl_.syntax();
|
||||
} else {
|
||||
//Remove selected node
|
||||
node_to_be_removed = &node;
|
||||
}
|
||||
};
|
||||
|
||||
builder.delete(node_to_be_removed.text_range());
|
||||
// Remove preceding indentation from node
|
||||
|
@ -418,11 +418,8 @@ impl Module {
|
|||
|
||||
record_field_parents.into_iter().for_each(|x| {
|
||||
x.1.descendants().filter_map(ast::RecordField::cast).for_each(|desc| {
|
||||
let is_record_field_present = record_fields
|
||||
.clone()
|
||||
.into_iter()
|
||||
.find(|x| x.to_string() == desc.to_string())
|
||||
.is_some();
|
||||
let is_record_field_present =
|
||||
record_fields.clone().into_iter().any(|x| x.to_string() == desc.to_string());
|
||||
if is_record_field_present {
|
||||
replacements.push((desc.visibility(), desc.syntax().clone()));
|
||||
}
|
||||
|
@ -520,7 +517,7 @@ impl Module {
|
|||
let mut exists_inside_sel = false;
|
||||
let mut exists_outside_sel = false;
|
||||
usage_res.clone().into_iter().for_each(|x| {
|
||||
let mut non_use_nodes_itr = (&x.1).into_iter().filter_map(|x| {
|
||||
let mut non_use_nodes_itr = (&x.1).iter().filter_map(|x| {
|
||||
if find_node_at_range::<ast::Use>(file.syntax(), x.range).is_none() {
|
||||
let path_opt = find_node_at_range::<ast::Path>(file.syntax(), x.range);
|
||||
return path_opt;
|
||||
|
@ -531,15 +528,11 @@ impl Module {
|
|||
|
||||
if non_use_nodes_itr
|
||||
.clone()
|
||||
.find(|x| !selection_range.contains_range(x.syntax().text_range()))
|
||||
.is_some()
|
||||
.any(|x| !selection_range.contains_range(x.syntax().text_range()))
|
||||
{
|
||||
exists_outside_sel = true;
|
||||
}
|
||||
if non_use_nodes_itr
|
||||
.find(|x| selection_range.contains_range(x.syntax().text_range()))
|
||||
.is_some()
|
||||
{
|
||||
if non_use_nodes_itr.any(|x| selection_range.contains_range(x.syntax().text_range())) {
|
||||
exists_inside_sel = true;
|
||||
}
|
||||
});
|
||||
|
@ -556,7 +549,7 @@ impl Module {
|
|||
let file_id = x.0;
|
||||
let mut use_opt: Option<ast::Use> = None;
|
||||
if file_id == curr_file_id {
|
||||
(&x.1).into_iter().for_each(|x| {
|
||||
(&x.1).iter().for_each(|x| {
|
||||
let node_opt: Option<ast::Use> = find_node_at_range(file.syntax(), x.range);
|
||||
if let Some(node) = node_opt {
|
||||
use_opt = Some(node);
|
||||
|
|
|
@ -374,7 +374,7 @@ fn inline(
|
|||
// inline direct local arguments
|
||||
[_, ..] if expr_as_name_ref(expr).is_some() => {
|
||||
cov_mark::hit!(inline_call_inline_locals);
|
||||
usages.into_iter().for_each(|usage| inline_direct(usage, expr));
|
||||
usages.iter().for_each(|usage| inline_direct(usage, expr));
|
||||
}
|
||||
// can't inline, emit a let statement
|
||||
_ => {
|
||||
|
|
|
@ -392,10 +392,8 @@ impl AstNode for CallableExpr {
|
|||
{
|
||||
if let Some(it) = ast::CallExpr::cast(syntax.clone()) {
|
||||
Some(Self::Call(it))
|
||||
} else if let Some(it) = ast::MethodCallExpr::cast(syntax) {
|
||||
Some(Self::MethodCall(it))
|
||||
} else {
|
||||
None
|
||||
ast::MethodCallExpr::cast(syntax).map(Self::MethodCall)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue