aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/handlers/change_visibility.rs11
-rw-r--r--crates/ra_assists/src/handlers/fix_visibility.rs6
-rw-r--r--crates/ra_assists/src/handlers/merge_match_arms.rs5
3 files changed, 5 insertions, 17 deletions
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs
index c21d75be0..18e92e393 100644
--- a/crates/ra_assists/src/handlers/change_visibility.rs
+++ b/crates/ra_assists/src/handlers/change_visibility.rs
@@ -30,9 +30,8 @@ pub(crate) fn change_visibility(acc: &mut Assists, ctx: &AssistContext) -> Optio
30} 30}
31 31
32fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 32fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
33 let item_keyword = ctx.token_at_offset().find(|leaf| match leaf.kind() { 33 let item_keyword = ctx.token_at_offset().find(|leaf| {
34 T![const] | T![fn] | T![mod] | T![struct] | T![enum] | T![trait] => true, 34 matches!(leaf.kind(), T![const] | T![fn] | T![mod] | T![struct] | T![enum] | T![trait])
35 _ => false,
36 }); 35 });
37 36
38 let (offset, target) = if let Some(keyword) = item_keyword { 37 let (offset, target) = if let Some(keyword) = item_keyword {
@@ -73,11 +72,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
73 72
74fn vis_offset(node: &SyntaxNode) -> TextSize { 73fn vis_offset(node: &SyntaxNode) -> TextSize {
75 node.children_with_tokens() 74 node.children_with_tokens()
76 .skip_while(|it| match it.kind() { 75 .find(|it| !matches!(it.kind(), WHITESPACE | COMMENT | ATTR))
77 WHITESPACE | COMMENT | ATTR => true,
78 _ => false,
79 })
80 .next()
81 .map(|it| it.text_range().start()) 76 .map(|it| it.text_range().start())
82 .unwrap_or_else(|| node.text_range().start()) 77 .unwrap_or_else(|| node.text_range().start())
83} 78}
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs
index 54601d1f3..02763c5b9 100644
--- a/crates/ra_assists/src/handlers/fix_visibility.rs
+++ b/crates/ra_assists/src/handlers/fix_visibility.rs
@@ -179,11 +179,7 @@ fn target_data_for_def(
179 179
180fn vis_offset(node: &SyntaxNode) -> TextSize { 180fn vis_offset(node: &SyntaxNode) -> TextSize {
181 node.children_with_tokens() 181 node.children_with_tokens()
182 .skip_while(|it| match it.kind() { 182 .find(|it| !matches!(it.kind(), WHITESPACE | COMMENT | ATTR))
183 WHITESPACE | COMMENT | ATTR => true,
184 _ => false,
185 })
186 .next()
187 .map(|it| it.text_range().start()) 183 .map(|it| it.text_range().start())
188 .unwrap_or_else(|| node.text_range().start()) 184 .unwrap_or_else(|| node.text_range().start())
189} 185}
diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs
index ca04ec671..53c2c130f 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
83fn contains_placeholder(a: &ast::MatchArm) -> bool { 83fn contains_placeholder(a: &ast::MatchArm) -> bool {
84 match a.pat() { 84 matches!(a.pat(), Some(ra_syntax::ast::Pat::PlaceholderPat(..)))
85 Some(ra_syntax::ast::Pat::PlaceholderPat(..)) => true,
86 _ => false,
87 }
88} 85}
89 86
90#[cfg(test)] 87#[cfg(test)]