From 95c8c65139c10e4de44367fead8dff88511e6d46 Mon Sep 17 00:00:00 2001
From: Lukas Wirth <lukastw97@gmail.com>
Date: Thu, 17 Jun 2021 17:37:14 +0200
Subject: Nest all the or-patterns!

---
 crates/hir/src/semantics.rs                        | 17 ++++----
 crates/hir_def/src/item_tree/pretty.rs             |  4 +-
 crates/hir_def/src/nameres/collector.rs            |  2 +-
 crates/hir_def/src/resolver.rs                     |  3 +-
 crates/hir_def/src/visibility.rs                   |  5 +--
 crates/hir_expand/src/hygiene.rs                   |  9 ++--
 crates/hir_expand/src/lib.rs                       |  9 ++--
 crates/hir_ty/src/consteval.rs                     |  3 +-
 .../src/diagnostics/match_check/deconstruct_pat.rs |  9 ++--
 crates/hir_ty/src/infer/coerce.rs                  |  8 +---
 crates/hir_ty/src/infer/expr.rs                    | 16 ++++---
 crates/hir_ty/src/infer/pat.rs                     |  9 ++--
 crates/hir_ty/src/op.rs                            | 38 +++++++----------
 crates/ide/src/join_lines.rs                       |  2 +-
 crates/ide/src/references.rs                       |  3 +-
 crates/ide/src/syntax_highlighting.rs              |  4 +-
 .../ide_assists/src/handlers/extract_function.rs   |  2 +-
 .../src/handlers/inline_local_variable.rs          | 49 ++++++++++++----------
 crates/ide_assists/src/tests.rs                    |  7 ++--
 .../src/completions/qualified_path.rs              | 18 +++++---
 .../src/completions/unqualified_path.rs            |  8 ++--
 crates/ide_completion/src/context.rs               | 31 +++++++-------
 crates/ide_completion/src/render/builder_ext.rs    |  2 +-
 crates/mbe/src/expander/matcher.rs                 | 22 ++--------
 crates/vfs/src/vfs_path.rs                         |  2 +-
 25 files changed, 132 insertions(+), 150 deletions(-)

(limited to 'crates')

diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 613266e07..43162797e 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -51,12 +51,14 @@ impl PathResolution {
             PathResolution::Def(ModuleDef::BuiltinType(builtin)) => {
                 Some(TypeNs::BuiltinType((*builtin).into()))
             }
-            PathResolution::Def(ModuleDef::Const(_))
-            | PathResolution::Def(ModuleDef::Variant(_))
-            | PathResolution::Def(ModuleDef::Function(_))
-            | PathResolution::Def(ModuleDef::Module(_))
-            | PathResolution::Def(ModuleDef::Static(_))
-            | PathResolution::Def(ModuleDef::Trait(_)) => None,
+            PathResolution::Def(
+                ModuleDef::Const(_)
+                | ModuleDef::Variant(_)
+                | ModuleDef::Function(_)
+                | ModuleDef::Module(_)
+                | ModuleDef::Static(_)
+                | ModuleDef::Trait(_),
+            ) => None,
             PathResolution::Def(ModuleDef::TypeAlias(alias)) => {
                 Some(TypeNs::TypeAliasId((*alias).into()))
             }
@@ -65,8 +67,7 @@ impl PathResolution {
             }
             PathResolution::TypeParam(param) => Some(TypeNs::GenericParam((*param).into())),
             PathResolution::SelfType(impl_def) => Some(TypeNs::SelfType((*impl_def).into())),
-            PathResolution::AssocItem(AssocItem::Const(_))
-            | PathResolution::AssocItem(AssocItem::Function(_)) => None,
+            PathResolution::AssocItem(AssocItem::Const(_) | AssocItem::Function(_)) => None,
             PathResolution::AssocItem(AssocItem::TypeAlias(alias)) => {
                 Some(TypeNs::TypeAliasId((*alias).into()))
             }
diff --git a/crates/hir_def/src/item_tree/pretty.rs b/crates/hir_def/src/item_tree/pretty.rs
index b1e1b70d0..e63bc8232 100644
--- a/crates/hir_def/src/item_tree/pretty.rs
+++ b/crates/hir_def/src/item_tree/pretty.rs
@@ -63,7 +63,7 @@ impl<'a> Printer<'a> {
     fn blank(&mut self) {
         let mut iter = self.buf.chars().rev().fuse();
         match (iter.next(), iter.next()) {
-            (Some('\n'), Some('\n')) | (Some('\n'), None) | (None, None) => {}
+            (Some('\n'), Some('\n') | None) | (None, None) => {}
             (Some('\n'), Some(_)) => {
                 self.buf.push('\n');
             }
@@ -77,7 +77,7 @@ impl<'a> Printer<'a> {
 
     fn whitespace(&mut self) {
         match self.buf.chars().next_back() {
-            None | Some('\n') | Some(' ') => {}
+            None | Some('\n' | ' ') => {}
             _ => self.buf.push(' '),
         }
     }
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index fc2c50fb8..927a7b6e8 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -1260,7 +1260,7 @@ impl DefCollector<'_> {
         for directive in &self.unresolved_imports {
             if let ImportSource::Import { id: import, use_tree } = &directive.import.source {
                 match (directive.import.path.segments().first(), &directive.import.path.kind) {
-                    (Some(krate), PathKind::Plain) | (Some(krate), PathKind::Abs) => {
+                    (Some(krate), PathKind::Plain | PathKind::Abs) => {
                         if diagnosed_extern_crates.contains(krate) {
                             continue;
                         }
diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs
index d4681fa3e..47e56259f 100644
--- a/crates/hir_def/src/resolver.rs
+++ b/crates/hir_def/src/resolver.rs
@@ -605,8 +605,7 @@ fn to_value_ns(per_ns: PerNs) -> Option<ValueNs> {
         ModuleDefId::ConstId(it) => ValueNs::ConstId(it),
         ModuleDefId::StaticId(it) => ValueNs::StaticId(it),
 
-        ModuleDefId::AdtId(AdtId::EnumId(_))
-        | ModuleDefId::AdtId(AdtId::UnionId(_))
+        ModuleDefId::AdtId(AdtId::EnumId(_) | AdtId::UnionId(_))
         | ModuleDefId::TraitId(_)
         | ModuleDefId::TypeAliasId(_)
         | ModuleDefId::BuiltinType(_)
diff --git a/crates/hir_def/src/visibility.rs b/crates/hir_def/src/visibility.rs
index 83500f54e..aeb1e7726 100644
--- a/crates/hir_def/src/visibility.rs
+++ b/crates/hir_def/src/visibility.rs
@@ -172,9 +172,8 @@ impl Visibility {
     /// visible in unrelated modules).
     pub(crate) fn max(self, other: Visibility, def_map: &DefMap) -> Option<Visibility> {
         match (self, other) {
-            (Visibility::Module(_), Visibility::Public)
-            | (Visibility::Public, Visibility::Module(_))
-            | (Visibility::Public, Visibility::Public) => Some(Visibility::Public),
+            (Visibility::Module(_) | Visibility::Public, Visibility::Public)
+            | (Visibility::Public, Visibility::Module(_)) => Some(Visibility::Public),
             (Visibility::Module(mod_a), Visibility::Module(mod_b)) => {
                 if mod_a.krate != mod_b.krate {
                     return None;
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs
index 05c6c3fb1..848522411 100644
--- a/crates/hir_expand/src/hygiene.rs
+++ b/crates/hir_expand/src/hygiene.rs
@@ -146,10 +146,11 @@ impl HygieneInfo {
                 (&self.macro_arg.1, InFile::new(loc.kind.file_id(), arg_start))
             }
             mbe::Origin::Def => match (&*self.macro_def, self.def_start) {
-                (TokenExpander::MacroDef { def_site_token_map, .. }, Some(tt))
-                | (TokenExpander::MacroRules { def_site_token_map, .. }, Some(tt)) => {
-                    (def_site_token_map, tt)
-                }
+                (
+                    TokenExpander::MacroDef { def_site_token_map, .. }
+                    | TokenExpander::MacroRules { def_site_token_map, .. },
+                    Some(tt),
+                ) => (def_site_token_map, tt),
                 _ => panic!("`Origin::Def` used with non-`macro_rules!` macro"),
             },
         };
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs
index 33107aa24..c31426d7c 100644
--- a/crates/hir_expand/src/lib.rs
+++ b/crates/hir_expand/src/lib.rs
@@ -368,10 +368,11 @@ impl ExpansionInfo {
         let (token_map, tt) = match origin {
             mbe::Origin::Call => (&self.macro_arg.1, self.arg.clone()),
             mbe::Origin::Def => match (&*self.macro_def, self.def.as_ref()) {
-                (db::TokenExpander::MacroRules { def_site_token_map, .. }, Some(tt))
-                | (db::TokenExpander::MacroDef { def_site_token_map, .. }, Some(tt)) => {
-                    (def_site_token_map, tt.as_ref().map(|tt| tt.syntax().clone()))
-                }
+                (
+                    db::TokenExpander::MacroRules { def_site_token_map, .. }
+                    | db::TokenExpander::MacroDef { def_site_token_map, .. },
+                    Some(tt),
+                ) => (def_site_token_map, tt.as_ref().map(|tt| tt.syntax().clone())),
                 _ => panic!("`Origin::Def` used with non-`macro_rules!` macro"),
             },
         };
diff --git a/crates/hir_ty/src/consteval.rs b/crates/hir_ty/src/consteval.rs
index 6f0bf8f8c..ab1afce08 100644
--- a/crates/hir_ty/src/consteval.rs
+++ b/crates/hir_ty/src/consteval.rs
@@ -38,8 +38,7 @@ impl ConstExt for Const {
 // FIXME: support more than just evaluating literals
 pub fn eval_usize(expr: &Expr) -> Option<u64> {
     match expr {
-        Expr::Literal(Literal::Uint(v, None))
-        | Expr::Literal(Literal::Uint(v, Some(BuiltinUint::Usize))) => (*v).try_into().ok(),
+        Expr::Literal(Literal::Uint(v, None | Some(BuiltinUint::Usize))) => (*v).try_into().ok(),
         _ => None,
     }
 }
diff --git a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs
index 471cd4921..e3d640a79 100644
--- a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs
+++ b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs
@@ -84,10 +84,7 @@ impl IntRange {
     #[inline]
     fn is_integral(ty: &Ty) -> bool {
         match ty.kind(&Interner) {
-            TyKind::Scalar(Scalar::Char)
-            | TyKind::Scalar(Scalar::Int(_))
-            | TyKind::Scalar(Scalar::Uint(_))
-            | TyKind::Scalar(Scalar::Bool) => true,
+            TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool) => true,
             _ => false,
         }
     }
@@ -381,7 +378,7 @@ impl Constructor {
             // Wildcards cover anything
             (_, Wildcard) => true,
             // The missing ctors are not covered by anything in the matrix except wildcards.
-            (Missing, _) | (Wildcard, _) => false,
+            (Missing | Wildcard, _) => false,
 
             (Single, Single) => true,
             (Variant(self_id), Variant(other_id)) => self_id == other_id,
@@ -523,7 +520,7 @@ impl SplitWildcard {
                 }
             }
             TyKind::Scalar(Scalar::Char) => unhandled(),
-            TyKind::Scalar(Scalar::Int(..)) | TyKind::Scalar(Scalar::Uint(..)) => unhandled(),
+            TyKind::Scalar(Scalar::Int(..) | Scalar::Uint(..)) => unhandled(),
             TyKind::Never if !cx.feature_exhaustive_patterns() && !pcx.is_top_level => {
                 smallvec![NonExhaustive]
             }
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs
index 4b7f31521..7be914451 100644
--- a/crates/hir_ty/src/infer/coerce.rs
+++ b/crates/hir_ty/src/infer/coerce.rs
@@ -47,10 +47,7 @@ impl<'a> InferenceContext<'a> {
         // pointers to have a chance at getting a match. See
         // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916
         let sig = match (ty1.kind(&Interner), ty2.kind(&Interner)) {
-            (TyKind::FnDef(..), TyKind::FnDef(..))
-            | (TyKind::Closure(..), TyKind::FnDef(..))
-            | (TyKind::FnDef(..), TyKind::Closure(..))
-            | (TyKind::Closure(..), TyKind::Closure(..)) => {
+            (TyKind::FnDef(..) | TyKind::Closure(..), TyKind::FnDef(..) | TyKind::Closure(..)) => {
                 // FIXME: we're ignoring safety here. To be more correct, if we have one FnDef and one Closure,
                 // we should be coercing the closure to a fn pointer of the safety of the FnDef
                 cov_mark::hit!(coerce_fn_reification);
@@ -448,8 +445,7 @@ fn safe_to_unsafe_fn_ty(fn_ty: FnPointer) -> FnPointer {
 
 fn coerce_mutabilities(from: Mutability, to: Mutability) -> Result<(), TypeError> {
     match (from, to) {
-        (Mutability::Mut, Mutability::Mut)
-        | (Mutability::Mut, Mutability::Not)
+        (Mutability::Mut, Mutability::Mut | Mutability::Not)
         | (Mutability::Not, Mutability::Not) => Ok(()),
         (Mutability::Not, Mutability::Mut) => Err(TypeError),
     }
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index 5ea2e5934..4e4f6e5a4 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -593,11 +593,11 @@ impl<'a> InferenceContext<'a> {
                     UnaryOp::Neg => {
                         match inner_ty.kind(&Interner) {
                             // Fast path for builtins
-                            TyKind::Scalar(Scalar::Int(_))
-                            | TyKind::Scalar(Scalar::Uint(_))
-                            | TyKind::Scalar(Scalar::Float(_))
-                            | TyKind::InferenceVar(_, TyVariableKind::Integer)
-                            | TyKind::InferenceVar(_, TyVariableKind::Float) => inner_ty,
+                            TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_) | Scalar::Float(_))
+                            | TyKind::InferenceVar(
+                                _,
+                                TyVariableKind::Integer | TyVariableKind::Float,
+                            ) => inner_ty,
                             // Otherwise we resolve via the std::ops::Neg trait
                             _ => self
                                 .resolve_associated_type(inner_ty, self.resolve_ops_neg_output()),
@@ -606,9 +606,7 @@ impl<'a> InferenceContext<'a> {
                     UnaryOp::Not => {
                         match inner_ty.kind(&Interner) {
                             // Fast path for builtins
-                            TyKind::Scalar(Scalar::Bool)
-                            | TyKind::Scalar(Scalar::Int(_))
-                            | TyKind::Scalar(Scalar::Uint(_))
+                            TyKind::Scalar(Scalar::Bool | Scalar::Int(_) | Scalar::Uint(_))
                             | TyKind::InferenceVar(_, TyVariableKind::Integer) => inner_ty,
                             // Otherwise we resolve via the std::ops::Not trait
                             _ => self
@@ -735,7 +733,7 @@ impl<'a> InferenceContext<'a> {
             Expr::Array(array) => {
                 let elem_ty =
                     match expected.to_option(&mut self.table).as_ref().map(|t| t.kind(&Interner)) {
-                        Some(TyKind::Array(st, _)) | Some(TyKind::Slice(st)) => st.clone(),
+                        Some(TyKind::Array(st, _) | TyKind::Slice(st)) => st.clone(),
                         _ => self.table.new_type_var(),
                     };
 
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs
index 035f4ded6..58cb23e9d 100644
--- a/crates/hir_ty/src/infer/pat.rs
+++ b/crates/hir_ty/src/infer/pat.rs
@@ -297,10 +297,11 @@ fn is_non_ref_pat(body: &hir_def::body::Body, pat: PatId) -> bool {
             Expr::Literal(Literal::String(..)) => false,
             _ => true,
         },
-        Pat::Bind { mode: BindingAnnotation::Mutable, subpat: Some(subpat), .. }
-        | Pat::Bind { mode: BindingAnnotation::Unannotated, subpat: Some(subpat), .. } => {
-            is_non_ref_pat(body, *subpat)
-        }
+        Pat::Bind {
+            mode: BindingAnnotation::Mutable | BindingAnnotation::Unannotated,
+            subpat: Some(subpat),
+            ..
+        } => is_non_ref_pat(body, *subpat),
         Pat::Wild | Pat::Bind { .. } | Pat::Ref { .. } | Pat::Box { .. } | Pat::Missing => false,
     }
 }
diff --git a/crates/hir_ty/src/op.rs b/crates/hir_ty/src/op.rs
index 0222de2bc..5ef6342d5 100644
--- a/crates/hir_ty/src/op.rs
+++ b/crates/hir_ty/src/op.rs
@@ -8,17 +8,15 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty {
     match op {
         BinaryOp::LogicOp(_) | BinaryOp::CmpOp(_) => TyKind::Scalar(Scalar::Bool).intern(&Interner),
         BinaryOp::Assignment { .. } => TyBuilder::unit(),
-        BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => {
+        BinaryOp::ArithOp(ArithOp::Shl | ArithOp::Shr) => {
             // all integer combinations are valid here
             if matches!(
                 lhs_ty.kind(&Interner),
-                TyKind::Scalar(Scalar::Int(_))
-                    | TyKind::Scalar(Scalar::Uint(_))
+                TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_))
                     | TyKind::InferenceVar(_, TyVariableKind::Integer)
             ) && matches!(
                 rhs_ty.kind(&Interner),
-                TyKind::Scalar(Scalar::Int(_))
-                    | TyKind::Scalar(Scalar::Uint(_))
+                TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_))
                     | TyKind::InferenceVar(_, TyVariableKind::Integer)
             ) {
                 lhs_ty
@@ -32,15 +30,15 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty {
             | (TyKind::Scalar(Scalar::Uint(_)), TyKind::Scalar(Scalar::Uint(_)))
             | (TyKind::Scalar(Scalar::Float(_)), TyKind::Scalar(Scalar::Float(_))) => rhs_ty,
             // ({int}, int) | ({int}, uint)
-            (TyKind::InferenceVar(_, TyVariableKind::Integer), TyKind::Scalar(Scalar::Int(_)))
-            | (TyKind::InferenceVar(_, TyVariableKind::Integer), TyKind::Scalar(Scalar::Uint(_))) => {
-                rhs_ty
-            }
+            (
+                TyKind::InferenceVar(_, TyVariableKind::Integer),
+                TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)),
+            ) => rhs_ty,
             // (int, {int}) | (uint, {int})
-            (TyKind::Scalar(Scalar::Int(_)), TyKind::InferenceVar(_, TyVariableKind::Integer))
-            | (TyKind::Scalar(Scalar::Uint(_)), TyKind::InferenceVar(_, TyVariableKind::Integer)) => {
-                lhs_ty
-            }
+            (
+                TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)),
+                TyKind::InferenceVar(_, TyVariableKind::Integer),
+            ) => lhs_ty,
             // ({float} | float)
             (TyKind::InferenceVar(_, TyVariableKind::Float), TyKind::Scalar(Scalar::Float(_))) => {
                 rhs_ty
@@ -69,21 +67,15 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty {
         BinaryOp::Assignment { op: None } => lhs_ty,
         BinaryOp::CmpOp(CmpOp::Eq { .. }) => match lhs_ty.kind(&Interner) {
             TyKind::Scalar(_) | TyKind::Str => lhs_ty,
-            TyKind::InferenceVar(_, TyVariableKind::Integer)
-            | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty,
+            TyKind::InferenceVar(_, TyVariableKind::Integer | TyVariableKind::Float) => lhs_ty,
             _ => TyKind::Error.intern(&Interner),
         },
-        BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => {
-            TyKind::Error.intern(&Interner)
-        }
+        BinaryOp::ArithOp(ArithOp::Shl | ArithOp::Shr) => TyKind::Error.intern(&Interner),
         BinaryOp::CmpOp(CmpOp::Ord { .. })
         | BinaryOp::Assignment { op: Some(_) }
         | BinaryOp::ArithOp(_) => match lhs_ty.kind(&Interner) {
-            TyKind::Scalar(Scalar::Int(_))
-            | TyKind::Scalar(Scalar::Uint(_))
-            | TyKind::Scalar(Scalar::Float(_)) => lhs_ty,
-            TyKind::InferenceVar(_, TyVariableKind::Integer)
-            | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty,
+            TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_) | Scalar::Float(_)) => lhs_ty,
+            TyKind::InferenceVar(_, TyVariableKind::Integer | TyVariableKind::Float) => lhs_ty,
             _ => TyKind::Error.intern(&Interner),
         },
     }
diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs
index 93d3760bf..ffa8bd182 100644
--- a/crates/ide/src/join_lines.rs
+++ b/crates/ide/src/join_lines.rs
@@ -197,7 +197,7 @@ fn join_single_use_tree(edit: &mut TextEditBuilder, token: &SyntaxToken) -> Opti
 }
 
 fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool {
-    matches!((left, right), (T![,], T![')']) | (T![,], T![']']))
+    matches!((left, right), (T![,], T![')'] | T![']']))
 }
 
 fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str {
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index 945c9b9e1..5808562a7 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -79,8 +79,7 @@ pub(crate) fn find_all_refs(
                 });
                 usages.references.retain(|_, it| !it.is_empty());
             }
-            Definition::ModuleDef(hir::ModuleDef::Adt(_))
-            | Definition::ModuleDef(hir::ModuleDef::Variant(_)) => {
+            Definition::ModuleDef(hir::ModuleDef::Adt(_) | hir::ModuleDef::Variant(_)) => {
                 refs.for_each(|it| {
                     it.retain(|reference| {
                         reference.name.as_name_ref().map_or(false, is_lit_name_ref)
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index e186b82b7..d44a1b45f 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -294,7 +294,7 @@ fn traverse(
                 Some(parent) => {
                     // We only care Name and Name_ref
                     match (token.kind(), parent.kind()) {
-                        (IDENT, NAME) | (IDENT, NAME_REF) => parent.into(),
+                        (IDENT, NAME | NAME_REF) => parent.into(),
                         _ => token.into(),
                     }
                 }
@@ -310,7 +310,7 @@ fn traverse(
                 Some(parent) => {
                     // We only care Name and Name_ref
                     match (token.kind(), parent.kind()) {
-                        (IDENT, NAME) | (IDENT, NAME_REF) => parent.into(),
+                        (IDENT, NAME | NAME_REF) => parent.into(),
                         _ => token.into(),
                     }
                 }
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index f2be091f4..7085a0c48 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -1384,7 +1384,7 @@ fn fix_param_usages(ctx: &AssistContext, params: &[Param], syntax: &SyntaxNode)
     for (param, usages) in usages_for_param {
         for usage in usages {
             match usage.syntax().ancestors().skip(1).find_map(ast::Expr::cast) {
-                Some(ast::Expr::MethodCallExpr(_)) | Some(ast::Expr::FieldExpr(_)) => {
+                Some(ast::Expr::MethodCallExpr(_) | ast::Expr::FieldExpr(_)) => {
                     // do nothing
                 }
                 Some(ast::Expr::RefExpr(node))
diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs
index 2441dbb8b..bf4ba16f0 100644
--- a/crates/ide_assists/src/handlers/inline_local_variable.rs
+++ b/crates/ide_assists/src/handlers/inline_local_variable.rs
@@ -68,28 +68,33 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
 
                     Some(!matches!(
                         (&initializer_expr, usage_parent),
-                        (ast::Expr::CallExpr(_), _)
-                            | (ast::Expr::IndexExpr(_), _)
-                            | (ast::Expr::MethodCallExpr(_), _)
-                            | (ast::Expr::FieldExpr(_), _)
-                            | (ast::Expr::TryExpr(_), _)
-                            | (ast::Expr::RefExpr(_), _)
-                            | (ast::Expr::Literal(_), _)
-                            | (ast::Expr::TupleExpr(_), _)
-                            | (ast::Expr::ArrayExpr(_), _)
-                            | (ast::Expr::ParenExpr(_), _)
-                            | (ast::Expr::PathExpr(_), _)
-                            | (ast::Expr::BlockExpr(_), _)
-                            | (ast::Expr::EffectExpr(_), _)
-                            | (_, ast::Expr::CallExpr(_))
-                            | (_, ast::Expr::TupleExpr(_))
-                            | (_, ast::Expr::ArrayExpr(_))
-                            | (_, ast::Expr::ParenExpr(_))
-                            | (_, ast::Expr::ForExpr(_))
-                            | (_, ast::Expr::WhileExpr(_))
-                            | (_, ast::Expr::BreakExpr(_))
-                            | (_, ast::Expr::ReturnExpr(_))
-                            | (_, ast::Expr::MatchExpr(_))
+                        (
+                            ast::Expr::CallExpr(_)
+                                | ast::Expr::IndexExpr(_)
+                                | ast::Expr::MethodCallExpr(_)
+                                | ast::Expr::FieldExpr(_)
+                                | ast::Expr::TryExpr(_)
+                                | ast::Expr::RefExpr(_)
+                                | ast::Expr::Literal(_)
+                                | ast::Expr::TupleExpr(_)
+                                | ast::Expr::ArrayExpr(_)
+                                | ast::Expr::ParenExpr(_)
+                                | ast::Expr::PathExpr(_)
+                                | ast::Expr::BlockExpr(_)
+                                | ast::Expr::EffectExpr(_),
+                            _
+                        ) | (
+                            _,
+                            ast::Expr::CallExpr(_)
+                                | ast::Expr::TupleExpr(_)
+                                | ast::Expr::ArrayExpr(_)
+                                | ast::Expr::ParenExpr(_)
+                                | ast::Expr::ForExpr(_)
+                                | ast::Expr::WhileExpr(_)
+                                | ast::Expr::BreakExpr(_)
+                                | ast::Expr::ReturnExpr(_)
+                                | ast::Expr::MatchExpr(_)
+                        )
                     ))
                 })
                 .collect::<Option<_>>()
diff --git a/crates/ide_assists/src/tests.rs b/crates/ide_assists/src/tests.rs
index 60cecd94c..29bd4a563 100644
--- a/crates/ide_assists/src/tests.rs
+++ b/crates/ide_assists/src/tests.rs
@@ -179,9 +179,10 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label:
             "unresolved assist should not contain source changes"
         ),
         (Some(_), ExpectedResult::NotApplicable) => panic!("assist should not be applicable!"),
-        (None, ExpectedResult::After(_))
-        | (None, ExpectedResult::Target(_))
-        | (None, ExpectedResult::Unresolved) => {
+        (
+            None,
+            ExpectedResult::After(_) | ExpectedResult::Target(_) | ExpectedResult::Unresolved,
+        ) => {
             panic!("code action is not applicable")
         }
         (None, ExpectedResult::NotApplicable) => (),
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs
index 0597879ac..da3385bdc 100644
--- a/crates/ide_completion/src/completions/qualified_path.rs
+++ b/crates/ide_completion/src/completions/qualified_path.rs
@@ -65,9 +65,11 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
                     // Don't suggest attribute macros and derives.
                     hir::ScopeDef::MacroDef(mac) => mac.is_fn_like(),
                     // no values in type places
-                    hir::ScopeDef::ModuleDef(hir::ModuleDef::Function(_))
-                    | hir::ScopeDef::ModuleDef(hir::ModuleDef::Variant(_))
-                    | hir::ScopeDef::ModuleDef(hir::ModuleDef::Static(_))
+                    hir::ScopeDef::ModuleDef(
+                        hir::ModuleDef::Function(_)
+                        | hir::ModuleDef::Variant(_)
+                        | hir::ModuleDef::Static(_),
+                    )
                     | hir::ScopeDef::Local(_) => !ctx.expects_type(),
                     // unless its a constant in a generic arg list position
                     hir::ScopeDef::ModuleDef(hir::ModuleDef::Const(_)) => {
@@ -81,9 +83,13 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
                 }
             }
         }
-        hir::PathResolution::Def(def @ hir::ModuleDef::Adt(_))
-        | hir::PathResolution::Def(def @ hir::ModuleDef::TypeAlias(_))
-        | hir::PathResolution::Def(def @ hir::ModuleDef::BuiltinType(_)) => {
+        hir::PathResolution::Def(
+            def
+            @
+            (hir::ModuleDef::Adt(_)
+            | hir::ModuleDef::TypeAlias(_)
+            | hir::ModuleDef::BuiltinType(_)),
+        ) => {
             if let hir::ModuleDef::Adt(hir::Adt::Enum(e)) = def {
                 add_enum_variants(acc, ctx, e);
             }
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs
index 6f96eceb9..77c6d706f 100644
--- a/crates/ide_completion/src/completions/unqualified_path.rs
+++ b/crates/ide_completion/src/completions/unqualified_path.rs
@@ -71,9 +71,11 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
             // Don't suggest attribute macros and derives.
             ScopeDef::MacroDef(mac) => mac.is_fn_like(),
             // no values in type places
-            ScopeDef::ModuleDef(hir::ModuleDef::Function(_))
-            | ScopeDef::ModuleDef(hir::ModuleDef::Variant(_))
-            | ScopeDef::ModuleDef(hir::ModuleDef::Static(_))
+            ScopeDef::ModuleDef(
+                hir::ModuleDef::Function(_)
+                | hir::ModuleDef::Variant(_)
+                | hir::ModuleDef::Static(_),
+            )
             | ScopeDef::Local(_) => !ctx.expects_type(),
             // unless its a constant in a generic arg list position
             ScopeDef::ModuleDef(hir::ModuleDef::Const(_))
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index 240cac1de..84b2bcf9f 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -242,24 +242,23 @@ impl<'a> CompletionContext<'a> {
     }
 
     pub(crate) fn expects_assoc_item(&self) -> bool {
-        matches!(
-            self.completion_location,
-            Some(ImmediateLocation::Trait) | Some(ImmediateLocation::Impl)
-        )
+        matches!(self.completion_location, Some(ImmediateLocation::Trait | ImmediateLocation::Impl))
     }
 
     pub(crate) fn has_dot_receiver(&self) -> bool {
         matches!(
             &self.completion_location,
-            Some(ImmediateLocation::FieldAccess { receiver, .. }) | Some(ImmediateLocation::MethodCall { receiver,.. })
+            Some(ImmediateLocation::FieldAccess { receiver, .. } | ImmediateLocation::MethodCall { receiver,.. })
                 if receiver.is_some()
         )
     }
 
     pub(crate) fn dot_receiver(&self) -> Option<&ast::Expr> {
         match &self.completion_location {
-            Some(ImmediateLocation::MethodCall { receiver, .. })
-            | Some(ImmediateLocation::FieldAccess { receiver, .. }) => receiver.as_ref(),
+            Some(
+                ImmediateLocation::MethodCall { receiver, .. }
+                | ImmediateLocation::FieldAccess { receiver, .. },
+            ) => receiver.as_ref(),
             _ => None,
         }
     }
@@ -283,7 +282,7 @@ impl<'a> CompletionContext<'a> {
     pub(crate) fn expects_ident_pat_or_ref_expr(&self) -> bool {
         matches!(
             self.completion_location,
-            Some(ImmediateLocation::IdentPat) | Some(ImmediateLocation::RefExpr)
+            Some(ImmediateLocation::IdentPat | ImmediateLocation::RefExpr)
         )
     }
 
@@ -294,14 +293,14 @@ impl<'a> CompletionContext<'a> {
     pub(crate) fn in_use_tree(&self) -> bool {
         matches!(
             self.completion_location,
-            Some(ImmediateLocation::Use) | Some(ImmediateLocation::UseTree)
+            Some(ImmediateLocation::Use | ImmediateLocation::UseTree)
         )
     }
 
     pub(crate) fn has_impl_or_trait_prev_sibling(&self) -> bool {
         matches!(
             self.prev_sibling,
-            Some(ImmediatePrevSibling::ImplDefType) | Some(ImmediatePrevSibling::TraitDefName)
+            Some(ImmediatePrevSibling::ImplDefType | ImmediatePrevSibling::TraitDefName)
         )
     }
 
@@ -318,14 +317,16 @@ impl<'a> CompletionContext<'a> {
             || self.previous_token_is(T![unsafe])
             || matches!(
                 self.prev_sibling,
-                Some(ImmediatePrevSibling::Attribute) | Some(ImmediatePrevSibling::Visibility)
+                Some(ImmediatePrevSibling::Attribute | ImmediatePrevSibling::Visibility)
             )
             || matches!(
                 self.completion_location,
-                Some(ImmediateLocation::Attribute(_))
-                    | Some(ImmediateLocation::ModDeclaration(_))
-                    | Some(ImmediateLocation::RecordPat(_))
-                    | Some(ImmediateLocation::RecordExpr(_))
+                Some(
+                    ImmediateLocation::Attribute(_)
+                        | ImmediateLocation::ModDeclaration(_)
+                        | ImmediateLocation::RecordPat(_)
+                        | ImmediateLocation::RecordExpr(_)
+                )
             )
     }
 
diff --git a/crates/ide_completion/src/render/builder_ext.rs b/crates/ide_completion/src/render/builder_ext.rs
index 749dfc665..33d3a5ee1 100644
--- a/crates/ide_completion/src/render/builder_ext.rs
+++ b/crates/ide_completion/src/render/builder_ext.rs
@@ -32,7 +32,7 @@ impl Builder {
             cov_mark::hit!(no_parens_in_use_item);
             return false;
         }
-        if matches!(ctx.path_call_kind(), Some(CallKind::Expr) | Some(CallKind::Pat))
+        if matches!(ctx.path_call_kind(), Some(CallKind::Expr | CallKind::Pat))
             | matches!(
                 ctx.completion_location,
                 Some(ImmediateLocation::MethodCall { has_parens: true, .. })
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index c2a9a38c9..b4f2fe9a4 100644
--- a/crates/mbe/src/expander/matcher.rs
+++ b/crates/mbe/src/expander/matcher.rs
@@ -804,33 +804,17 @@ impl<'a> TtIter<'a> {
         };
 
         match (punct.char, second, third) {
-            ('.', '.', Some('.'))
-            | ('.', '.', Some('='))
-            | ('<', '<', Some('='))
-            | ('>', '>', Some('=')) => {
+            ('.', '.', Some('.' | '=')) | ('<', '<', Some('=')) | ('>', '>', Some('=')) => {
                 let tt2 = self.next().unwrap().clone();
                 let tt3 = self.next().unwrap().clone();
                 Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2, tt3] }.into())
             }
-            ('-', '=', _)
-            | ('-', '>', _)
+            ('-' | '!' | '*' | '/' | '&' | '%' | '^' | '+' | '<' | '=' | '>' | '|', '=', _)
+            | ('-' | '=' | '>', '>', _)
             | (':', ':', _)
-            | ('!', '=', _)
             | ('.', '.', _)
-            | ('*', '=', _)
-            | ('/', '=', _)
             | ('&', '&', _)
-            | ('&', '=', _)
-            | ('%', '=', _)
-            | ('^', '=', _)
-            | ('+', '=', _)
             | ('<', '<', _)
-            | ('<', '=', _)
-            | ('=', '=', _)
-            | ('=', '>', _)
-            | ('>', '=', _)
-            | ('>', '>', _)
-            | ('|', '=', _)
             | ('|', '|', _) => {
                 let tt2 = self.next().unwrap().clone();
                 Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into())
diff --git a/crates/vfs/src/vfs_path.rs b/crates/vfs/src/vfs_path.rs
index 2b3d7fd84..ef2d7657a 100644
--- a/crates/vfs/src/vfs_path.rs
+++ b/crates/vfs/src/vfs_path.rs
@@ -389,7 +389,7 @@ impl VirtualPath {
 
             match (file_stem, extension) {
                 (None, None) => None,
-                (None, Some(_)) | (Some(""), Some(_)) => Some((file_name, None)),
+                (None | Some(""), Some(_)) => Some((file_name, None)),
                 (Some(file_stem), extension) => Some((file_stem, extension)),
             }
         }
-- 
cgit v1.2.3