@@ -8,8 +8,10 @@ use itertools::Itertools;
8
8
use syntax:: { AstNode , SyntaxNode , T } ;
9
9
10
10
use crate :: {
11
- context:: { CompletionContext , NameRefContext , PathCompletionCtx , PathKind , PatternContext } ,
12
- patterns:: ImmediateLocation ,
11
+ context:: {
12
+ CompletionContext , NameRefContext , NameRefKind , PathCompletionCtx , PathKind ,
13
+ PatternContext , TypeLocation ,
14
+ } ,
13
15
render:: { render_resolution_with_import, RenderContext } ,
14
16
} ;
15
17
@@ -111,19 +113,20 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext)
111
113
return None ;
112
114
}
113
115
let path_kind = match ctx. nameref_ctx ( ) {
114
- Some ( NameRefContext { path_ctx : Some ( PathCompletionCtx { kind, .. } ) , .. } )
115
- if matches ! (
116
- kind,
117
- PathKind :: Expr { .. }
118
- | PathKind :: Type { .. }
119
- | PathKind :: Attr { .. }
120
- | PathKind :: Derive
121
- | PathKind :: Pat
122
- ) =>
123
- {
124
- Some ( kind)
125
- }
126
- Some ( NameRefContext { dot_access : Some ( _) , .. } ) => None ,
116
+ Some ( NameRefContext {
117
+ kind :
118
+ Some ( NameRefKind :: Path ( PathCompletionCtx {
119
+ kind :
120
+ kind @ ( PathKind :: Expr { .. }
121
+ | PathKind :: Type { .. }
122
+ | PathKind :: Attr { .. }
123
+ | PathKind :: Derive
124
+ | PathKind :: Pat ) ,
125
+ ..
126
+ } ) ) ,
127
+ ..
128
+ } ) => Some ( kind) ,
129
+ Some ( NameRefContext { kind : Some ( NameRefKind :: DotAccess ( _) ) , .. } ) => None ,
127
130
None if matches ! ( ctx. pattern_ctx, Some ( PatternContext { record_pat: None , .. } ) ) => {
128
131
Some ( & PathKind :: Pat )
129
132
}
@@ -173,8 +176,8 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext)
173
176
( PathKind :: Pat , ItemInNs :: Types ( _) ) => true ,
174
177
( PathKind :: Pat , ItemInNs :: Values ( def) ) => matches ! ( def, hir:: ModuleDef :: Const ( _) ) ,
175
178
176
- ( PathKind :: Type { .. } , ItemInNs :: Types ( ty) ) => {
177
- if matches ! ( ctx . completion_location , Some ( ImmediateLocation :: TypeBound ) ) {
179
+ ( PathKind :: Type { location } , ItemInNs :: Types ( ty) ) => {
180
+ if matches ! ( location , TypeLocation :: TypeBound ) {
178
181
matches ! ( ty, ModuleDef :: Trait ( _) )
179
182
} else {
180
183
true
0 commit comments