@@ -4,7 +4,7 @@ use syntax::{
4
4
algo:: non_trivia_sibling,
5
5
ast:: { self , LoopBodyOwner } ,
6
6
match_ast, AstNode , Direction , NodeOrToken , SyntaxElement ,
7
- SyntaxKind :: * ,
7
+ SyntaxKind :: { self , * } ,
8
8
SyntaxNode , SyntaxToken , T ,
9
9
} ;
10
10
@@ -71,7 +71,7 @@ fn test_has_block_expr_parent() {
71
71
}
72
72
73
73
pub ( crate ) fn has_bind_pat_parent ( element : SyntaxElement ) -> bool {
74
- element . ancestors ( ) . any ( |it| it. kind ( ) == IDENT_PAT )
74
+ not_same_range_ancestor ( element ) . filter ( |it| it. kind ( ) == IDENT_PAT ) . is_some ( )
75
75
}
76
76
#[ test]
77
77
fn test_has_bind_pat_parent ( ) {
@@ -133,20 +133,12 @@ fn test_for_is_prev2() {
133
133
check_pattern_is_applicable ( r"for i i$0" , for_is_prev2) ;
134
134
}
135
135
136
- pub ( crate ) fn has_trait_as_prev_sibling ( element : SyntaxElement ) -> bool {
137
- previous_sibling_or_ancestor_sibling ( element) . filter ( |it| it. kind ( ) == TRAIT ) . is_some ( )
138
- }
139
- #[ test]
140
- fn test_has_trait_as_prev_sibling ( ) {
141
- check_pattern_is_applicable ( r"trait A w$0 {}" , has_trait_as_prev_sibling) ;
142
- }
143
-
144
- pub ( crate ) fn has_impl_as_prev_sibling ( element : SyntaxElement ) -> bool {
145
- previous_sibling_or_ancestor_sibling ( element) . filter ( |it| it. kind ( ) == IMPL ) . is_some ( )
136
+ pub ( crate ) fn has_prev_sibling ( element : SyntaxElement , kind : SyntaxKind ) -> bool {
137
+ previous_sibling_or_ancestor_sibling ( element) . filter ( |it| it. kind ( ) == kind) . is_some ( )
146
138
}
147
139
#[ test]
148
140
fn test_has_impl_as_prev_sibling ( ) {
149
- check_pattern_is_applicable ( r"impl A w$0 {}" , has_impl_as_prev_sibling ) ;
141
+ check_pattern_is_applicable ( r"impl A w$0 {}" , |it| has_prev_sibling ( it , IMPL ) ) ;
150
142
}
151
143
152
144
pub ( crate ) fn is_in_loop_body ( element : SyntaxElement ) -> bool {
0 commit comments