diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/handlers/change_visibility.rs | 25 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/fix_visibility.rs | 19 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/merge_match_arms.rs | 5 | ||||
-rw-r--r-- | crates/ra_assists/src/utils.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide/src/join_lines.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide_db/src/symbol_index.rs | 5 | ||||
-rw-r--r-- | crates/ra_mbe/src/parser.rs | 5 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 5 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/paths.rs | 5 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/type_params.rs | 5 | ||||
-rw-r--r-- | crates/ra_parser/src/syntax_kind.rs | 5 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 5 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 16 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing/reparsing.rs | 5 | ||||
-rw-r--r-- | crates/ra_tt/src/buffer.rs | 5 | ||||
-rw-r--r-- | crates/rust-analyzer/src/cli.rs | 10 | ||||
-rw-r--r-- | crates/rust-analyzer/src/cli/analysis_bench.rs | 5 |
20 files changed, 44 insertions, 119 deletions
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index c21d75be0..157c7b665 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs | |||
@@ -1,15 +1,12 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, NameOwner, VisibilityOwner}, | 2 | ast::{self, NameOwner, VisibilityOwner}, |
3 | AstNode, | 3 | AstNode, |
4 | SyntaxKind::{ | 4 | SyntaxKind::{CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STRUCT_DEF, TRAIT_DEF, VISIBILITY}, |
5 | ATTR, COMMENT, CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STRUCT_DEF, TRAIT_DEF, VISIBILITY, | 5 | T, |
6 | WHITESPACE, | ||
7 | }, | ||
8 | SyntaxNode, TextSize, T, | ||
9 | }; | 6 | }; |
10 | use test_utils::mark; | 7 | use test_utils::mark; |
11 | 8 | ||
12 | use crate::{AssistContext, AssistId, Assists}; | 9 | use crate::{utils::vis_offset, AssistContext, AssistId, Assists}; |
13 | 10 | ||
14 | // Assist: change_visibility | 11 | // Assist: change_visibility |
15 | // | 12 | // |
@@ -30,9 +27,8 @@ pub(crate) fn change_visibility(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
30 | } | 27 | } |
31 | 28 | ||
32 | fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 29 | fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
33 | let item_keyword = ctx.token_at_offset().find(|leaf| match leaf.kind() { | 30 | let item_keyword = ctx.token_at_offset().find(|leaf| { |
34 | T![const] | T![fn] | T![mod] | T![struct] | T![enum] | T![trait] => true, | 31 | matches!(leaf.kind(), T![const] | T![fn] | T![mod] | T![struct] | T![enum] | T![trait]) |
35 | _ => false, | ||
36 | }); | 32 | }); |
37 | 33 | ||
38 | let (offset, target) = if let Some(keyword) = item_keyword { | 34 | let (offset, target) = if let Some(keyword) = item_keyword { |
@@ -71,17 +67,6 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
71 | }) | 67 | }) |
72 | } | 68 | } |
73 | 69 | ||
74 | fn vis_offset(node: &SyntaxNode) -> TextSize { | ||
75 | node.children_with_tokens() | ||
76 | .skip_while(|it| match it.kind() { | ||
77 | WHITESPACE | COMMENT | ATTR => true, | ||
78 | _ => false, | ||
79 | }) | ||
80 | .next() | ||
81 | .map(|it| it.text_range().start()) | ||
82 | .unwrap_or_else(|| node.text_range().start()) | ||
83 | } | ||
84 | |||
85 | fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> { | 70 | fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> { |
86 | if vis.syntax().text() == "pub" { | 71 | if vis.syntax().text() == "pub" { |
87 | let target = vis.syntax().text_range(); | 72 | let target = vis.syntax().text_range(); |
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index 54601d1f3..19d4dac5e 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs | |||
@@ -1,12 +1,8 @@ | |||
1 | use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; | 1 | use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; |
2 | use ra_db::FileId; | 2 | use ra_db::FileId; |
3 | use ra_syntax::{ | 3 | use ra_syntax::{ast, AstNode, TextRange, TextSize}; |
4 | ast, AstNode, | ||
5 | SyntaxKind::{ATTR, COMMENT, WHITESPACE}, | ||
6 | SyntaxNode, TextRange, TextSize, | ||
7 | }; | ||
8 | 4 | ||
9 | use crate::{AssistContext, AssistId, Assists}; | 5 | use crate::{utils::vis_offset, AssistContext, AssistId, Assists}; |
10 | 6 | ||
11 | // FIXME: this really should be a fix for diagnostic, rather than an assist. | 7 | // FIXME: this really should be a fix for diagnostic, rather than an assist. |
12 | 8 | ||
@@ -177,17 +173,6 @@ fn target_data_for_def( | |||
177 | Some((offset, target, target_file, target_name)) | 173 | Some((offset, target, target_file, target_name)) |
178 | } | 174 | } |
179 | 175 | ||
180 | fn vis_offset(node: &SyntaxNode) -> TextSize { | ||
181 | node.children_with_tokens() | ||
182 | .skip_while(|it| match it.kind() { | ||
183 | WHITESPACE | COMMENT | ATTR => true, | ||
184 | _ => false, | ||
185 | }) | ||
186 | .next() | ||
187 | .map(|it| it.text_range().start()) | ||
188 | .unwrap_or_else(|| node.text_range().start()) | ||
189 | } | ||
190 | |||
191 | #[cfg(test)] | 176 | #[cfg(test)] |
192 | mod tests { | 177 | mod tests { |
193 | use crate::tests::{check_assist, check_assist_not_applicable}; | 178 | use crate::tests::{check_assist, check_assist_not_applicable}; |
diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs index ca04ec671..90ce66378 100644 --- a/crates/ra_assists/src/handlers/merge_match_arms.rs +++ b/crates/ra_assists/src/handlers/merge_match_arms.rs | |||
@@ -81,10 +81,7 @@ pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
81 | } | 81 | } |
82 | 82 | ||
83 | fn contains_placeholder(a: &ast::MatchArm) -> bool { | 83 | fn contains_placeholder(a: &ast::MatchArm) -> bool { |
84 | match a.pat() { | 84 | matches!(a.pat(), Some(ast::Pat::PlaceholderPat(..))) |
85 | Some(ra_syntax::ast::Pat::PlaceholderPat(..)) => true, | ||
86 | _ => false, | ||
87 | } | ||
88 | } | 85 | } |
89 | 86 | ||
90 | #[cfg(test)] | 87 | #[cfg(test)] |
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index b7c45a619..02de902d6 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs | |||
@@ -7,7 +7,9 @@ use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type}; | |||
7 | use ra_ide_db::RootDatabase; | 7 | use ra_ide_db::RootDatabase; |
8 | use ra_syntax::{ | 8 | use ra_syntax::{ |
9 | ast::{self, make, NameOwner}, | 9 | ast::{self, make, NameOwner}, |
10 | AstNode, SyntaxNode, T, | 10 | AstNode, |
11 | SyntaxKind::*, | ||
12 | SyntaxNode, TextSize, T, | ||
11 | }; | 13 | }; |
12 | use rustc_hash::FxHashSet; | 14 | use rustc_hash::FxHashSet; |
13 | 15 | ||
@@ -120,6 +122,13 @@ pub(crate) fn resolve_target_trait( | |||
120 | } | 122 | } |
121 | } | 123 | } |
122 | 124 | ||
125 | pub(crate) fn vis_offset(node: &SyntaxNode) -> TextSize { | ||
126 | node.children_with_tokens() | ||
127 | .find(|it| !matches!(it.kind(), WHITESPACE | COMMENT | ATTR)) | ||
128 | .map(|it| it.text_range().start()) | ||
129 | .unwrap_or_else(|| node.text_range().start()) | ||
130 | } | ||
131 | |||
123 | pub(crate) fn invert_boolean_expression(expr: ast::Expr) -> ast::Expr { | 132 | pub(crate) fn invert_boolean_expression(expr: ast::Expr) -> ast::Expr { |
124 | if let Some(expr) = invert_special_case(&expr) { | 133 | if let Some(expr) = invert_special_case(&expr) { |
125 | return expr; | 134 | return expr; |
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 61af5f064..22884522a 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -785,11 +785,7 @@ impl<'a> InferenceContext<'a> { | |||
785 | for &check_closures in &[false, true] { | 785 | for &check_closures in &[false, true] { |
786 | let param_iter = param_tys.iter().cloned().chain(repeat(Ty::Unknown)); | 786 | let param_iter = param_tys.iter().cloned().chain(repeat(Ty::Unknown)); |
787 | for (&arg, param_ty) in args.iter().zip(param_iter) { | 787 | for (&arg, param_ty) in args.iter().zip(param_iter) { |
788 | let is_closure = match &self.body[arg] { | 788 | let is_closure = matches!(&self.body[arg], Expr::Lambda { .. }); |
789 | Expr::Lambda { .. } => true, | ||
790 | _ => false, | ||
791 | }; | ||
792 | |||
793 | if is_closure != check_closures { | 789 | if is_closure != check_closures { |
794 | continue; | 790 | continue; |
795 | } | 791 | } |
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 414158139..c9513b752 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -620,17 +620,11 @@ pub enum GenericPredicate { | |||
620 | 620 | ||
621 | impl GenericPredicate { | 621 | impl GenericPredicate { |
622 | pub fn is_error(&self) -> bool { | 622 | pub fn is_error(&self) -> bool { |
623 | match self { | 623 | matches!(self, GenericPredicate::Error) |
624 | GenericPredicate::Error => true, | ||
625 | _ => false, | ||
626 | } | ||
627 | } | 624 | } |
628 | 625 | ||
629 | pub fn is_implemented(&self) -> bool { | 626 | pub fn is_implemented(&self) -> bool { |
630 | match self { | 627 | matches!(self, GenericPredicate::Implemented(_)) |
631 | GenericPredicate::Implemented(_) => true, | ||
632 | _ => false, | ||
633 | } | ||
634 | } | 628 | } |
635 | 629 | ||
636 | pub fn trait_ref(&self, db: &dyn HirDatabase) -> Option<TraitRef> { | 630 | pub fn trait_ref(&self, db: &dyn HirDatabase) -> Option<TraitRef> { |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 98fb34486..c87652555 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -313,10 +313,8 @@ fn get_string_representation(expr: &ast::Expr) -> Option<String> { | |||
313 | } | 313 | } |
314 | 314 | ||
315 | fn is_obvious_param(param_name: &str) -> bool { | 315 | fn is_obvious_param(param_name: &str) -> bool { |
316 | let is_obvious_param_name = match param_name { | 316 | let is_obvious_param_name = |
317 | "predicate" | "value" | "pat" | "rhs" | "other" => true, | 317 | matches!(param_name, "predicate" | "value" | "pat" | "rhs" | "other"); |
318 | _ => false, | ||
319 | }; | ||
320 | param_name.len() == 1 || is_obvious_param_name | 318 | param_name.len() == 1 || is_obvious_param_name |
321 | } | 319 | } |
322 | 320 | ||
diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs index 5036c1fb0..6907c09e8 100644 --- a/crates/ra_ide/src/join_lines.rs +++ b/crates/ra_ide/src/join_lines.rs | |||
@@ -165,10 +165,7 @@ fn join_single_use_tree(edit: &mut TextEditBuilder, token: &SyntaxToken) -> Opti | |||
165 | } | 165 | } |
166 | 166 | ||
167 | fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool { | 167 | fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool { |
168 | match (left, right) { | 168 | matches!((left, right), (T![,], T![')']) | (T![,], T![']'])) |
169 | (T![,], T![')']) | (T![,], T![']']) => true, | ||
170 | _ => false, | ||
171 | } | ||
172 | } | 169 | } |
173 | 170 | ||
174 | #[cfg(test)] | 171 | #[cfg(test)] |
diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 6929055b2..5a09e7d1d 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs | |||
@@ -346,10 +346,7 @@ impl Query { | |||
346 | } | 346 | } |
347 | 347 | ||
348 | fn is_type(kind: SyntaxKind) -> bool { | 348 | fn is_type(kind: SyntaxKind) -> bool { |
349 | match kind { | 349 | matches!(kind, STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF) |
350 | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => true, | ||
351 | _ => false, | ||
352 | } | ||
353 | } | 350 | } |
354 | 351 | ||
355 | /// The actual data that is stored in the index. It should be as compact as | 352 | /// The actual data that is stored in the index. It should be as compact as |
diff --git a/crates/ra_mbe/src/parser.rs b/crates/ra_mbe/src/parser.rs index 034150432..1e5dafbdf 100644 --- a/crates/ra_mbe/src/parser.rs +++ b/crates/ra_mbe/src/parser.rs | |||
@@ -137,10 +137,7 @@ fn eat_fragment_kind<'a>( | |||
137 | } | 137 | } |
138 | 138 | ||
139 | fn is_boolean_literal(lit: &tt::Literal) -> bool { | 139 | fn is_boolean_literal(lit: &tt::Literal) -> bool { |
140 | match lit.text.as_str() { | 140 | matches!(lit.text.as_str(), "true" | "false") |
141 | "true" | "false" => true, | ||
142 | _ => false, | ||
143 | } | ||
144 | } | 141 | } |
145 | 142 | ||
146 | fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), ExpandError> { | 143 | fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), ExpandError> { |
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index 293baecf6..caedeead0 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -73,10 +73,7 @@ pub(crate) mod fragments { | |||
73 | // Parse a meta item , which excluded [], e.g : #[ MetaItem ] | 73 | // Parse a meta item , which excluded [], e.g : #[ MetaItem ] |
74 | pub(crate) fn meta_item(p: &mut Parser) { | 74 | pub(crate) fn meta_item(p: &mut Parser) { |
75 | fn is_delimiter(p: &mut Parser) -> bool { | 75 | fn is_delimiter(p: &mut Parser) -> bool { |
76 | match p.current() { | 76 | matches!(p.current(), T!['{'] | T!['('] | T!['[']) |
77 | T!['{'] | T!['('] | T!['['] => true, | ||
78 | _ => false, | ||
79 | } | ||
80 | } | 77 | } |
81 | 78 | ||
82 | if is_delimiter(p) { | 79 | if is_delimiter(p) { |
diff --git a/crates/ra_parser/src/grammar/paths.rs b/crates/ra_parser/src/grammar/paths.rs index fd51189d5..b503af1dc 100644 --- a/crates/ra_parser/src/grammar/paths.rs +++ b/crates/ra_parser/src/grammar/paths.rs | |||
@@ -41,10 +41,7 @@ fn path(p: &mut Parser, mode: Mode) { | |||
41 | path_segment(p, mode, true); | 41 | path_segment(p, mode, true); |
42 | let mut qual = path.complete(p, PATH); | 42 | let mut qual = path.complete(p, PATH); |
43 | loop { | 43 | loop { |
44 | let use_tree = match p.nth(2) { | 44 | let use_tree = matches!(p.nth(2), T![*] | T!['{']); |
45 | T![*] | T!['{'] => true, | ||
46 | _ => false, | ||
47 | }; | ||
48 | if p.at(T![::]) && !use_tree { | 45 | if p.at(T![::]) && !use_tree { |
49 | let path = qual.precede(p); | 46 | let path = qual.precede(p); |
50 | p.bump(T![::]); | 47 | p.bump(T![::]); |
diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs index 325d566ad..d1330d4b9 100644 --- a/crates/ra_parser/src/grammar/type_params.rs +++ b/crates/ra_parser/src/grammar/type_params.rs | |||
@@ -169,10 +169,7 @@ fn is_where_predicate(p: &mut Parser) -> bool { | |||
169 | } | 169 | } |
170 | 170 | ||
171 | fn is_where_clause_end(p: &mut Parser) -> bool { | 171 | fn is_where_clause_end(p: &mut Parser) -> bool { |
172 | match p.current() { | 172 | matches!(p.current(), T!['{'] | T![;] | T![=]) |
173 | T!['{'] | T![;] | T![=] => true, | ||
174 | _ => false, | ||
175 | } | ||
176 | } | 173 | } |
177 | 174 | ||
178 | fn where_predicate(p: &mut Parser) { | 175 | fn where_predicate(p: &mut Parser) { |
diff --git a/crates/ra_parser/src/syntax_kind.rs b/crates/ra_parser/src/syntax_kind.rs index 8d6bd057b..63204436c 100644 --- a/crates/ra_parser/src/syntax_kind.rs +++ b/crates/ra_parser/src/syntax_kind.rs | |||
@@ -20,9 +20,6 @@ impl From<SyntaxKind> for u16 { | |||
20 | 20 | ||
21 | impl SyntaxKind { | 21 | impl SyntaxKind { |
22 | pub fn is_trivia(self) -> bool { | 22 | pub fn is_trivia(self) -> bool { |
23 | match self { | 23 | matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT) |
24 | SyntaxKind::WHITESPACE | SyntaxKind::COMMENT => true, | ||
25 | _ => false, | ||
26 | } | ||
27 | } | 24 | } |
28 | } | 25 | } |
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 7771d6759..db5438d68 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -399,10 +399,7 @@ impl ast::BlockExpr { | |||
399 | Some(it) => it, | 399 | Some(it) => it, |
400 | None => return true, | 400 | None => return true, |
401 | }; | 401 | }; |
402 | match parent.kind() { | 402 | !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) |
403 | FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR => false, | ||
404 | _ => true, | ||
405 | } | ||
406 | } | 403 | } |
407 | } | 404 | } |
408 | 405 | ||
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 98c38d009..662c6f73e 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -459,16 +459,16 @@ impl ast::RangePat { | |||
459 | 459 | ||
460 | impl ast::TokenTree { | 460 | impl ast::TokenTree { |
461 | pub fn left_delimiter_token(&self) -> Option<SyntaxToken> { | 461 | pub fn left_delimiter_token(&self) -> Option<SyntaxToken> { |
462 | self.syntax().first_child_or_token()?.into_token().filter(|it| match it.kind() { | 462 | self.syntax() |
463 | T!['{'] | T!['('] | T!['['] => true, | 463 | .first_child_or_token()? |
464 | _ => false, | 464 | .into_token() |
465 | }) | 465 | .filter(|it| matches!(it.kind(), T!['{'] | T!['('] | T!['['])) |
466 | } | 466 | } |
467 | 467 | ||
468 | pub fn right_delimiter_token(&self) -> Option<SyntaxToken> { | 468 | pub fn right_delimiter_token(&self) -> Option<SyntaxToken> { |
469 | self.syntax().last_child_or_token()?.into_token().filter(|it| match it.kind() { | 469 | self.syntax() |
470 | T!['}'] | T![')'] | T![']'] => true, | 470 | .last_child_or_token()? |
471 | _ => false, | 471 | .into_token() |
472 | }) | 472 | .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']'])) |
473 | } | 473 | } |
474 | } | 474 | } |
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index edbc190f8..ed5a42ea3 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs | |||
@@ -120,10 +120,7 @@ fn get_text_after_edit(element: SyntaxElement, edit: &Indel) -> String { | |||
120 | } | 120 | } |
121 | 121 | ||
122 | fn is_contextual_kw(text: &str) -> bool { | 122 | fn is_contextual_kw(text: &str) -> bool { |
123 | match text { | 123 | matches!(text, "auto" | "default" | "union") |
124 | "auto" | "default" | "union" => true, | ||
125 | _ => false, | ||
126 | } | ||
127 | } | 124 | } |
128 | 125 | ||
129 | fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(SyntaxNode, Reparser)> { | 126 | fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(SyntaxNode, Reparser)> { |
diff --git a/crates/ra_tt/src/buffer.rs b/crates/ra_tt/src/buffer.rs index 5967f44cd..02c771f70 100644 --- a/crates/ra_tt/src/buffer.rs +++ b/crates/ra_tt/src/buffer.rs | |||
@@ -105,10 +105,7 @@ impl<'a> Eq for Cursor<'a> {} | |||
105 | impl<'a> Cursor<'a> { | 105 | impl<'a> Cursor<'a> { |
106 | /// Check whether it is eof | 106 | /// Check whether it is eof |
107 | pub fn eof(self) -> bool { | 107 | pub fn eof(self) -> bool { |
108 | match self.buffer.entry(&self.ptr) { | 108 | matches!(self.buffer.entry(&self.ptr), None | Some(Entry::End(None))) |
109 | None | Some(Entry::End(None)) => true, | ||
110 | _ => false, | ||
111 | } | ||
112 | } | 109 | } |
113 | 110 | ||
114 | /// If the cursor is pointing at the end of a subtree, returns | 111 | /// If the cursor is pointing at the end of a subtree, returns |
diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs index 39ce77900..c5faec83a 100644 --- a/crates/rust-analyzer/src/cli.rs +++ b/crates/rust-analyzer/src/cli.rs | |||
@@ -28,16 +28,10 @@ pub enum Verbosity { | |||
28 | 28 | ||
29 | impl Verbosity { | 29 | impl Verbosity { |
30 | pub fn is_verbose(self) -> bool { | 30 | pub fn is_verbose(self) -> bool { |
31 | match self { | 31 | matches!(self, Verbosity::Verbose | Verbosity::Spammy) |
32 | Verbosity::Verbose | Verbosity::Spammy => true, | ||
33 | _ => false, | ||
34 | } | ||
35 | } | 32 | } |
36 | pub fn is_spammy(self) -> bool { | 33 | pub fn is_spammy(self) -> bool { |
37 | match self { | 34 | matches!(self, Verbosity::Spammy) |
38 | Verbosity::Spammy => true, | ||
39 | _ => false, | ||
40 | } | ||
41 | } | 35 | } |
42 | } | 36 | } |
43 | 37 | ||
diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs index 4fe99ff68..930375d3e 100644 --- a/crates/rust-analyzer/src/cli/analysis_bench.rs +++ b/crates/rust-analyzer/src/cli/analysis_bench.rs | |||
@@ -78,10 +78,7 @@ pub fn analysis_bench( | |||
78 | } | 78 | } |
79 | } | 79 | } |
80 | BenchWhat::Complete(pos) | BenchWhat::GotoDef(pos) => { | 80 | BenchWhat::Complete(pos) | BenchWhat::GotoDef(pos) => { |
81 | let is_completion = match what { | 81 | let is_completion = matches!(what, BenchWhat::Complete(..)); |
82 | BenchWhat::Complete(..) => true, | ||
83 | _ => false, | ||
84 | }; | ||
85 | 82 | ||
86 | let offset = host | 83 | let offset = host |
87 | .analysis() | 84 | .analysis() |