@@ -6,10 +6,6 @@ use ra_syntax::{
6
6
SyntaxNode , SyntaxToken ,
7
7
} ;
8
8
9
- pub ( crate ) fn inside_impl ( element : SyntaxElement ) -> bool {
10
- element. ancestors ( ) . find ( |it| it. kind ( ) == IMPL_DEF ) . is_some ( )
11
- }
12
-
13
9
pub ( crate ) fn inside_trait ( element : SyntaxElement ) -> bool {
14
10
element. ancestors ( ) . find ( |it| it. kind ( ) == TRAIT_DEF ) . is_some ( )
15
11
}
@@ -42,10 +38,6 @@ pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool {
42
38
not_same_range_ancestor ( element) . filter ( |it| it. kind ( ) == BLOCK_EXPR ) . is_some ( )
43
39
}
44
40
45
- pub ( crate ) fn has_item_list_parent ( element : SyntaxElement ) -> bool {
46
- not_same_range_ancestor ( element) . filter ( |it| it. kind ( ) == ITEM_LIST ) . is_some ( )
47
- }
48
-
49
41
pub ( crate ) fn has_trait_as_prev_sibling ( element : SyntaxElement ) -> bool {
50
42
previous_sibling_or_ancestor_sibling ( element) . filter ( |it| it. kind ( ) == TRAIT_DEF ) . is_some ( )
51
43
}
@@ -122,8 +114,8 @@ fn previous_sibling_or_ancestor_sibling(element: SyntaxElement) -> Option<Syntax
122
114
#[ cfg( test) ]
123
115
mod tests {
124
116
use super :: {
125
- has_block_expr_parent, has_impl_as_prev_sibling, has_trait_as_prev_sibling , if_is_prev ,
126
- inside_trait, unsafe_is_prev,
117
+ has_bind_pat_parent , has_block_expr_parent, has_impl_as_prev_sibling, has_ref_pat_parent ,
118
+ has_trait_as_prev_sibling , if_is_prev , inside_trait, unsafe_is_prev,
127
119
} ;
128
120
use crate :: completion:: test_utils:: check_pattern_is_applicable;
129
121
@@ -193,4 +185,51 @@ mod tests {
193
185
has_block_expr_parent,
194
186
) ;
195
187
}
188
+
189
+ #[ test]
190
+ fn test_has_ref_pat_parent_in_func_parameters ( ) {
191
+ check_pattern_is_applicable (
192
+ r"
193
+ fn my_fn(&<|>) {
194
+ let a = 2;
195
+ }
196
+ " ,
197
+ has_ref_pat_parent,
198
+ ) ;
199
+ }
200
+
201
+ #[ test]
202
+ fn test_has_ref_pat_parent_in_let_statement ( ) {
203
+ check_pattern_is_applicable (
204
+ r"
205
+ fn my_fn() {
206
+ let &<|>
207
+ }
208
+ " ,
209
+ has_ref_pat_parent,
210
+ ) ;
211
+ }
212
+
213
+ #[ test]
214
+ fn test_has_bind_pat_parent_in_func_parameters ( ) {
215
+ check_pattern_is_applicable (
216
+ r"
217
+ fn my_fn(m<|>) {
218
+ }
219
+ " ,
220
+ has_bind_pat_parent,
221
+ ) ;
222
+ }
223
+
224
+ #[ test]
225
+ fn test_has_bind_pat_parent_in_let_statement ( ) {
226
+ check_pattern_is_applicable (
227
+ r"
228
+ fn my_fn() {
229
+ let m<|>
230
+ }
231
+ " ,
232
+ has_bind_pat_parent,
233
+ ) ;
234
+ }
196
235
}
0 commit comments