@@ -7,7 +7,6 @@ use syntax::SmolStr;
7
7
8
8
use crate :: {
9
9
context:: { ParamContext , ParamKind , PathCompletionCtx , PatternContext } ,
10
- item:: CompletionRelevanceTypeMatch ,
11
10
render:: {
12
11
variant:: { format_literal_label, format_literal_lookup, visible_fields} ,
13
12
RenderContext ,
@@ -38,7 +37,9 @@ pub(crate) fn render_struct_pat(
38
37
let lookup = format_literal_lookup ( name. as_str ( ) , kind) ;
39
38
let pat = render_pat ( & ctx, pattern_ctx, & escaped_name, kind, & visible_fields, fields_omitted) ?;
40
39
41
- Some ( build_completion ( ctx, label, lookup, pat, strukt, true ) )
40
+ let db = ctx. db ( ) ;
41
+
42
+ Some ( build_completion ( ctx, label, lookup, pat, strukt, strukt. ty ( db) ) )
42
43
}
43
44
44
45
pub ( crate ) fn render_variant_pat (
@@ -48,12 +49,12 @@ pub(crate) fn render_variant_pat(
48
49
variant : hir:: Variant ,
49
50
local_name : Option < Name > ,
50
51
path : Option < & hir:: ModPath > ,
51
- is_exact_type_match : bool ,
52
52
) -> Option < CompletionItem > {
53
53
let _p = profile:: span ( "render_variant_pat" ) ;
54
54
55
55
let fields = variant. fields ( ctx. db ( ) ) ;
56
56
let ( visible_fields, fields_omitted) = visible_fields ( ctx. completion , & fields, variant) ?;
57
+ let enum_ty = variant. parent_enum ( ctx. db ( ) ) . ty ( ctx. db ( ) ) ;
57
58
58
59
let ( name, escaped_name) = match path {
59
60
Some ( path) => ( path. unescaped ( ) . to_string ( ) . into ( ) , path. to_string ( ) . into ( ) ) ,
@@ -83,7 +84,7 @@ pub(crate) fn render_variant_pat(
83
84
}
84
85
} ;
85
86
86
- Some ( build_completion ( ctx, label, lookup, pat, variant, is_exact_type_match ) )
87
+ Some ( build_completion ( ctx, label, lookup, pat, variant, enum_ty ) )
87
88
}
88
89
89
90
fn build_completion (
@@ -92,13 +93,11 @@ fn build_completion(
92
93
lookup : SmolStr ,
93
94
pat : String ,
94
95
def : impl HasAttrs + Copy ,
95
- is_exact_type_match : bool ,
96
+ adt_ty : hir :: Type ,
96
97
) -> CompletionItem {
97
98
let mut relevance = ctx. completion_relevance ( ) ;
98
99
99
- if is_exact_type_match {
100
- relevance. type_match = Some ( CompletionRelevanceTypeMatch :: Exact ) ;
101
- }
100
+ relevance. type_match = super :: compute_type_match ( ctx. completion , & adt_ty) ;
102
101
103
102
let mut item = CompletionItem :: new ( CompletionItemKind :: Binding , ctx. source_range ( ) , label) ;
104
103
item. set_documentation ( ctx. docs ( def) )
0 commit comments