Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/utils.rs')
-rw-r--r--crates/ide-assists/src/utils.rs48
1 files changed, 23 insertions, 25 deletions
diff --git a/crates/ide-assists/src/utils.rs b/crates/ide-assists/src/utils.rs
index 15c7a6a3fc..77d471e5a7 100644
--- a/crates/ide-assists/src/utils.rs
+++ b/crates/ide-assists/src/utils.rs
@@ -131,10 +131,10 @@ pub fn filter_assoc_items(
if ignore_items == IgnoreAssocItems::DocHiddenAttrPresent
&& assoc_item.attrs(sema.db).has_doc_hidden()
{
- if let hir::AssocItem::Function(f) = assoc_item {
- if !f.has_body(sema.db) {
- return true;
- }
+ if let hir::AssocItem::Function(f) = assoc_item
+ && !f.has_body(sema.db)
+ {
+ return true;
}
return false;
}
@@ -514,10 +514,10 @@ pub(crate) fn find_struct_impl(
if !(same_ty && not_trait_impl) { None } else { Some(impl_blk) }
});
- if let Some(ref impl_blk) = block {
- if has_any_fn(impl_blk, names) {
- return None;
- }
+ if let Some(ref impl_blk) = block
+ && has_any_fn(impl_blk, names)
+ {
+ return None;
}
Some(block)
@@ -526,12 +526,11 @@ pub(crate) fn find_struct_impl(
fn has_any_fn(imp: &ast::Impl, names: &[String]) -> bool {
if let Some(il) = imp.assoc_item_list() {
for item in il.assoc_items() {
- if let ast::AssocItem::Fn(f) = item {
- if let Some(name) = f.name() {
- if names.iter().any(|n| n.eq_ignore_ascii_case(&name.text())) {
- return true;
- }
- }
+ if let ast::AssocItem::Fn(f) = item
+ && let Some(name) = f.name()
+ && names.iter().any(|n| n.eq_ignore_ascii_case(&name.text()))
+ {
+ return true;
}
}
}
@@ -1021,12 +1020,12 @@ pub(crate) fn trimmed_text_range(source_file: &SourceFile, initial_range: TextRa
pub(crate) fn convert_param_list_to_arg_list(list: ast::ParamList) -> ast::ArgList {
let mut args = vec![];
for param in list.params() {
- if let Some(ast::Pat::IdentPat(pat)) = param.pat() {
- if let Some(name) = pat.name() {
- let name = name.to_string();
- let expr = make::expr_path(make::ext::ident_path(&name));
- args.push(expr);
- }
+ if let Some(ast::Pat::IdentPat(pat)) = param.pat()
+ && let Some(name) = pat.name()
+ {
+ let name = name.to_string();
+ let expr = make::expr_path(make::ext::ident_path(&name));
+ args.push(expr);
}
}
make::arg_list(args)
@@ -1138,12 +1137,11 @@ pub fn is_body_const(sema: &Semantics<'_, RootDatabase>, expr: &ast::Expr) -> bo
};
match expr {
ast::Expr::CallExpr(call) => {
- if let Some(ast::Expr::PathExpr(path_expr)) = call.expr() {
- if let Some(PathResolution::Def(ModuleDef::Function(func))) =
+ if let Some(ast::Expr::PathExpr(path_expr)) = call.expr()
+ && let Some(PathResolution::Def(ModuleDef::Function(func))) =
path_expr.path().and_then(|path| sema.resolve_path(&path))
- {
- is_const &= func.is_const(sema.db);
- }
+ {
+ is_const &= func.is_const(sema.db);
}
}
ast::Expr::MethodCallExpr(call) => {