@@ -18,8 +18,9 @@ use crate::{
18
18
patterns:: {
19
19
fn_is_prev, for_is_prev2, has_bind_pat_parent, has_block_expr_parent,
20
20
has_field_list_parent, has_impl_as_prev_sibling, has_impl_parent,
21
- has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling,
22
- has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev,
21
+ has_impl_trait_parent, has_item_list_or_source_file_parent, has_ref_parent,
22
+ has_trait_as_prev_sibling, has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm,
23
+ unsafe_is_prev,
23
24
} ,
24
25
CompletionConfig ,
25
26
} ,
@@ -86,6 +87,7 @@ pub(crate) struct CompletionContext<'a> {
86
87
pub ( super ) in_loop_body : bool ,
87
88
pub ( super ) has_trait_parent : bool ,
88
89
pub ( super ) has_impl_parent : bool ,
90
+ pub ( super ) has_impl_trait_parent : bool ,
89
91
pub ( super ) has_field_list_parent : bool ,
90
92
pub ( super ) trait_as_prev_sibling : bool ,
91
93
pub ( super ) impl_as_prev_sibling : bool ,
@@ -170,6 +172,7 @@ impl<'a> CompletionContext<'a> {
170
172
block_expr_parent : false ,
171
173
has_trait_parent : false ,
172
174
has_impl_parent : false ,
175
+ has_impl_trait_parent : false ,
173
176
has_field_list_parent : false ,
174
177
trait_as_prev_sibling : false ,
175
178
impl_as_prev_sibling : false ,
@@ -228,9 +231,10 @@ impl<'a> CompletionContext<'a> {
228
231
/// Checks whether completions in that particular case don't make much sense.
229
232
/// Examples:
230
233
/// - `fn <|>` -- we expect function name, it's unlikely that "hint" will be helpful.
234
+ /// Exception for this case is `impl Trait for Foo`, where we would like to hint trait method names.
231
235
/// - `for _ i<|>` -- obviously, it'll be "in" keyword.
232
236
pub ( crate ) fn no_completion_required ( & self ) -> bool {
233
- self . fn_is_prev || self . for_is_prev2
237
+ ( self . fn_is_prev && ! self . has_impl_trait_parent ) || self . for_is_prev2
234
238
}
235
239
236
240
/// The range of the identifier that is being completed.
@@ -256,6 +260,7 @@ impl<'a> CompletionContext<'a> {
256
260
self . in_loop_body = is_in_loop_body ( syntax_element. clone ( ) ) ;
257
261
self . has_trait_parent = has_trait_parent ( syntax_element. clone ( ) ) ;
258
262
self . has_impl_parent = has_impl_parent ( syntax_element. clone ( ) ) ;
263
+ self . has_impl_trait_parent = has_impl_trait_parent ( syntax_element. clone ( ) ) ;
259
264
self . has_field_list_parent = has_field_list_parent ( syntax_element. clone ( ) ) ;
260
265
self . impl_as_prev_sibling = has_impl_as_prev_sibling ( syntax_element. clone ( ) ) ;
261
266
self . trait_as_prev_sibling = has_trait_as_prev_sibling ( syntax_element. clone ( ) ) ;
0 commit comments