about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml1
-rw-r--r--crates/base-db/src/input.rs2
-rw-r--r--crates/hir-def/src/path/lower.rs2
-rw-r--r--crates/hir-ty/src/display.rs6
-rw-r--r--crates/hir-ty/src/infer/expr.rs2
-rw-r--r--crates/hir-ty/src/lower.rs2
-rw-r--r--crates/hir-ty/src/mir/eval.rs2
-rw-r--r--crates/hir/src/source_analyzer.rs4
-rw-r--r--crates/ide-assists/src/handlers/auto_import.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_impl.rs4
-rw-r--r--crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs2
-rw-r--r--crates/ide-assists/src/handlers/unnecessary_async.rs6
-rw-r--r--crates/ide-completion/src/completions/item_list.rs2
-rwxr-xr-xcrates/ide/src/folding_ranges.rs12
-rw-r--r--crates/ide/src/inlay_hints/fn_lifetime_fn.rs16
-rw-r--r--crates/ide/src/inlay_hints/param_name.rs2
-rw-r--r--crates/rust-analyzer/src/reload.rs18
17 files changed, 39 insertions, 46 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 73a0881e4a3..32e9fb28b20 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_pattern_matching = "allow"
 search_is_some = "allow"
 self_named_constructors = "allow"
 single_match = "allow"
diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs
index 1fa5f33575e..852f36ea712 100644
--- a/crates/base-db/src/input.rs
+++ b/crates/base-db/src/input.rs
@@ -331,7 +331,7 @@ impl CrateData {
                 return false;
             }
 
-            if let Some(_) = opts.next() {
+            if opts.next().is_some() {
                 return false;
             }
         }
diff --git a/crates/hir-def/src/path/lower.rs b/crates/hir-def/src/path/lower.rs
index 39f1b6f1c06..b3c41a073c6 100644
--- a/crates/hir-def/src/path/lower.rs
+++ b/crates/hir-def/src/path/lower.rs
@@ -53,7 +53,7 @@ pub(super) fn lower_path(ctx: &LowerCtx<'_>, mut path: ast::Path) -> Option<Path
                         )
                     })
                     .map(Interned::new);
-                if let Some(_) = args {
+                if args.is_some() {
                     generic_args.resize(segments.len(), None);
                     generic_args.push(args);
                 }
diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs
index a630db05de2..96c7949e3d6 100644
--- a/crates/hir-ty/src/display.rs
+++ b/crates/hir-ty/src/display.rs
@@ -1043,7 +1043,7 @@ impl HirDisplay for Ty {
                             f.start_location_link(t.into());
                         }
                         write!(f, "Future")?;
-                        if let Some(_) = future_trait {
+                        if future_trait.is_some() {
                             f.end_location_link();
                         }
                         write!(f, "<")?;
@@ -1051,7 +1051,7 @@ impl HirDisplay for Ty {
                             f.start_location_link(t.into());
                         }
                         write!(f, "Output")?;
-                        if let Some(_) = output {
+                        if output.is_some() {
                             f.end_location_link();
                         }
                         write!(f, " = ")?;
@@ -1520,7 +1520,7 @@ fn write_bounds_like_dyn_trait(
             }
             write!(f, "Sized")?;
         }
-        if let Some(_) = sized_trait {
+        if sized_trait.is_some() {
             f.end_location_link();
         }
     }
diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs
index b1cf0b11059..842f7bdafe7 100644
--- a/crates/hir-ty/src/infer/expr.rs
+++ b/crates/hir-ty/src/infer/expr.rs
@@ -439,7 +439,7 @@ impl InferenceContext<'_> {
                 ty
             }
             &Expr::Continue { label } => {
-                if let None = find_continuable(&mut self.breakables, label) {
+                if find_continuable(&mut self.breakables, label).is_none() {
                     self.push_diagnostic(InferenceDiagnostic::BreakOutsideOfLoop {
                         expr: tgt_expr,
                         is_break: false,
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index 46f5830ef7d..386a03d93f3 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -1335,7 +1335,7 @@ fn named_associated_type_shorthand_candidates<R>(
                 ),
                 _ => None,
             });
-            if let Some(_) = res {
+            if res.is_some() {
                 return res;
             }
             // Handle `Self::Type` referring to own associated type in trait definitions
diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs
index 85caf0f58ce..8143dc05c38 100644
--- a/crates/hir-ty/src/mir/eval.rs
+++ b/crates/hir-ty/src/mir/eval.rs
@@ -2217,7 +2217,7 @@ impl Evaluator<'_> {
         let generic_args = generic_args.clone();
         match def {
             CallableDefId::FunctionId(def) => {
-                if let Some(_) = self.detect_fn_trait(def) {
+                if self.detect_fn_trait(def).is_some() {
                     return self.exec_fn_trait(
                         def,
                         args,
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 811e724747f..fd0a1178421 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -614,7 +614,7 @@ impl SourceAnalyzer {
             }
             None
         })();
-        if let Some(_) = resolved {
+        if resolved.is_some() {
             return resolved;
         }
 
@@ -659,7 +659,7 @@ impl SourceAnalyzer {
             if let Some(name_ref) = path.as_single_name_ref() {
                 let builtin =
                     BuiltinAttr::by_name(db, self.resolver.krate().into(), &name_ref.text());
-                if let Some(_) = builtin {
+                if builtin.is_some() {
                     return builtin.map(PathResolution::BuiltinAttr);
                 }
 
diff --git a/crates/ide-assists/src/handlers/auto_import.rs b/crates/ide-assists/src/handlers/auto_import.rs
index 45ac03fbf31..62696d1a9a8 100644
--- a/crates/ide-assists/src/handlers/auto_import.rs
+++ b/crates/ide-assists/src/handlers/auto_import.rs
@@ -198,7 +198,7 @@ pub(super) fn find_importable_node(
     {
         ImportAssets::for_method_call(&method_under_caret, &ctx.sema)
             .zip(Some(method_under_caret.syntax().clone().into()))
-    } else if let Some(_) = ctx.find_node_at_offset_with_descend::<ast::Param>() {
+    } else if ctx.find_node_at_offset_with_descend::<ast::Param>().is_some() {
         None
     } else if let Some(pat) = ctx
         .find_node_at_offset_with_descend::<ast::IdentPat>()
diff --git a/crates/ide-assists/src/handlers/generate_impl.rs b/crates/ide-assists/src/handlers/generate_impl.rs
index 9ad14a819d9..d52d778d344 100644
--- a/crates/ide-assists/src/handlers/generate_impl.rs
+++ b/crates/ide-assists/src/handlers/generate_impl.rs
@@ -29,7 +29,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Optio
     let name = nominal.name()?;
     let target = nominal.syntax().text_range();
 
-    if let Some(_) = ctx.find_node_at_offset::<ast::RecordFieldList>() {
+    if ctx.find_node_at_offset::<ast::RecordFieldList>().is_some() {
         return None;
     }
 
@@ -77,7 +77,7 @@ pub(crate) fn generate_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_>) ->
     let name = nominal.name()?;
     let target = nominal.syntax().text_range();
 
-    if let Some(_) = ctx.find_node_at_offset::<ast::RecordFieldList>() {
+    if ctx.find_node_at_offset::<ast::RecordFieldList>().is_some() {
         return None;
     }
 
diff --git a/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs b/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs
index 5cc95fd9c0b..1794c887439 100644
--- a/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs
+++ b/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs
@@ -69,7 +69,7 @@ pub(crate) fn replace_turbofish_with_explicit_type(
         return None;
     }
 
-    if let None = let_stmt.colon_token() {
+    if let_stmt.colon_token().is_none() {
         // If there's no colon in a let statement, then there is no explicit type.
         // let x = fn::<...>();
         let ident_range = let_stmt.pat()?.syntax().text_range();
diff --git a/crates/ide-assists/src/handlers/unnecessary_async.rs b/crates/ide-assists/src/handlers/unnecessary_async.rs
index 1cfa291a29d..b2e8c4cf9fd 100644
--- a/crates/ide-assists/src/handlers/unnecessary_async.rs
+++ b/crates/ide-assists/src/handlers/unnecessary_async.rs
@@ -37,16 +37,14 @@ pub(crate) fn unnecessary_async(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
         return None;
     }
     // Do nothing if the function isn't async.
-    if let None = function.async_token() {
-        return None;
-    }
+    function.async_token()?;
     // Do nothing if the function has an `await` expression in its body.
     if function.body()?.syntax().descendants().find_map(ast::AwaitExpr::cast).is_some() {
         return None;
     }
     // Do nothing if the method is a member of trait.
     if let Some(impl_) = function.syntax().ancestors().nth(2).and_then(ast::Impl::cast) {
-        if let Some(_) = impl_.trait_() {
+        if impl_.trait_().is_some() {
             return None;
         }
     }
diff --git a/crates/ide-completion/src/completions/item_list.rs b/crates/ide-completion/src/completions/item_list.rs
index 5ea6a49b1ae..4de15ab7596 100644
--- a/crates/ide-completion/src/completions/item_list.rs
+++ b/crates/ide-completion/src/completions/item_list.rs
@@ -80,7 +80,7 @@ fn add_keywords(acc: &mut Completions, ctx: &CompletionContext<'_>, kind: Option
     let in_trait_impl = matches!(kind, Some(ItemListKind::TraitImpl(_)));
     let in_inherent_impl = matches!(kind, Some(ItemListKind::Impl));
     let no_qualifiers = ctx.qualifier_ctx.vis_node.is_none();
-    let in_block = matches!(kind, None);
+    let in_block = kind.is_none();
 
     if !in_trait_impl {
         if ctx.qualifier_ctx.unsafe_tok.is_some() {
diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs
index c694d95d537..b863e144f0a 100755
--- a/crates/ide/src/folding_ranges.rs
+++ b/crates/ide/src/folding_ranges.rs
@@ -271,13 +271,13 @@ fn fold_range_for_where_clause(where_clause: ast::WhereClause) -> Option<TextRan
 }
 
 fn fold_range_for_multiline_match_arm(match_arm: ast::MatchArm) -> Option<TextRange> {
-    if let Some(_) = fold_kind(match_arm.expr()?.syntax().kind()) {
-        return None;
-    }
-    if match_arm.expr()?.syntax().text().contains_char('\n') {
-        return Some(match_arm.expr()?.syntax().text_range());
+    if fold_kind(match_arm.expr()?.syntax().kind()).is_some() {
+        None
+    } else if match_arm.expr()?.syntax().text().contains_char('\n') {
+        Some(match_arm.expr()?.syntax().text_range())
+    } else {
+        None
     }
-    None
 }
 
 #[cfg(test)]
diff --git a/crates/ide/src/inlay_hints/fn_lifetime_fn.rs b/crates/ide/src/inlay_hints/fn_lifetime_fn.rs
index eb97f2fb819..6e5f23bed09 100644
--- a/crates/ide/src/inlay_hints/fn_lifetime_fn.rs
+++ b/crates/ide/src/inlay_hints/fn_lifetime_fn.rs
@@ -98,15 +98,13 @@ pub(super) fn hints(
         };
     {
         let mut potential_lt_refs = potential_lt_refs.iter().filter(|&&(.., is_elided)| is_elided);
-        if let Some(_) = &self_param {
-            if let Some(_) = potential_lt_refs.next() {
-                allocated_lifetimes.push(if config.param_names_for_lifetime_elision_hints {
-                    // self can't be used as a lifetime, so no need to check for collisions
-                    "'self".into()
-                } else {
-                    gen_idx_name()
-                });
-            }
+        if self_param.is_some() && potential_lt_refs.next().is_some() {
+            allocated_lifetimes.push(if config.param_names_for_lifetime_elision_hints {
+                // self can't be used as a lifetime, so no need to check for collisions
+                "'self".into()
+            } else {
+                gen_idx_name()
+            });
         }
         potential_lt_refs.for_each(|(name, ..)| {
             let name = match name {
diff --git a/crates/ide/src/inlay_hints/param_name.rs b/crates/ide/src/inlay_hints/param_name.rs
index b4260d82506..418fc002a8b 100644
--- a/crates/ide/src/inlay_hints/param_name.rs
+++ b/crates/ide/src/inlay_hints/param_name.rs
@@ -47,7 +47,7 @@ pub(super) fn hints(
             if let Some(name) = param {
                 if let hir::CallableKind::Function(f) = callable.kind() {
                     // assert the file is cached so we can map out of macros
-                    if let Some(_) = sema.source(f) {
+                    if sema.source(f).is_some() {
                         linked_location = sema.original_range_opt(name.syntax());
                     }
                 }
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index b64936e799f..82712c9ae01 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -109,7 +109,7 @@ impl GlobalState {
             status.health = lsp_ext::Health::Warning;
             message.push_str("Proc-macros have changed and need to be rebuilt.\n\n");
         }
-        if let Err(_) = self.fetch_build_data_error() {
+        if self.fetch_build_data_error().is_err() {
             status.health = lsp_ext::Health::Warning;
             message.push_str("Failed to run build scripts of some packages.\n\n");
         }
@@ -173,7 +173,7 @@ impl GlobalState {
             }
         }
 
-        if let Err(_) = self.fetch_workspace_error() {
+        if self.fetch_workspace_error().is_err() {
             status.health = lsp_ext::Health::Error;
             message.push_str("Failed to load workspaces.");
 
@@ -364,15 +364,13 @@ impl GlobalState {
             return;
         };
 
-        if let Err(_) = self.fetch_workspace_error() {
-            if !self.workspaces.is_empty() {
-                if *force_reload_crate_graph {
-                    self.recreate_crate_graph(cause);
-                }
-                // It only makes sense to switch to a partially broken workspace
-                // if we don't have any workspace at all yet.
-                return;
+        if self.fetch_workspace_error().is_err() && !self.workspaces.is_empty() {
+            if *force_reload_crate_graph {
+                self.recreate_crate_graph(cause);
             }
+            // It only makes sense to switch to a partially broken workspace
+            // if we don't have any workspace at all yet.
+            return;
         }
 
         let workspaces =