@@ -7,6 +7,7 @@ use syntax::SmolStr;
7
7
8
8
use crate :: {
9
9
context:: { ParamContext , ParamKind , PathCompletionCtx , PatternContext } ,
10
+ item:: CompletionRelevanceTypeMatch ,
10
11
render:: {
11
12
variant:: { format_literal_label, format_literal_lookup, visible_fields} ,
12
13
RenderContext ,
@@ -37,7 +38,7 @@ pub(crate) fn render_struct_pat(
37
38
let lookup = format_literal_lookup ( name. as_str ( ) , kind) ;
38
39
let pat = render_pat ( & ctx, pattern_ctx, & escaped_name, kind, & visible_fields, fields_omitted) ?;
39
40
40
- Some ( build_completion ( ctx, label, lookup, pat, strukt) )
41
+ Some ( build_completion ( ctx, label, lookup, pat, strukt, false ) )
41
42
}
42
43
43
44
pub ( crate ) fn render_variant_pat (
@@ -47,6 +48,7 @@ pub(crate) fn render_variant_pat(
47
48
variant : hir:: Variant ,
48
49
local_name : Option < Name > ,
49
50
path : Option < & hir:: ModPath > ,
51
+ is_exact_type_match : bool ,
50
52
) -> Option < CompletionItem > {
51
53
let _p = profile:: span ( "render_variant_pat" ) ;
52
54
@@ -81,7 +83,7 @@ pub(crate) fn render_variant_pat(
81
83
}
82
84
} ;
83
85
84
- Some ( build_completion ( ctx, label, lookup, pat, variant) )
86
+ Some ( build_completion ( ctx, label, lookup, pat, variant, is_exact_type_match ) )
85
87
}
86
88
87
89
fn build_completion (
@@ -90,13 +92,20 @@ fn build_completion(
90
92
lookup : SmolStr ,
91
93
pat : String ,
92
94
def : impl HasAttrs + Copy ,
95
+ is_exact_type_match : bool ,
93
96
) -> CompletionItem {
97
+ let mut relevance = ctx. completion_relevance ( ) ;
98
+
99
+ if is_exact_type_match {
100
+ relevance. type_match = Some ( CompletionRelevanceTypeMatch :: Exact ) ;
101
+ }
102
+
94
103
let mut item = CompletionItem :: new ( CompletionItemKind :: Binding , ctx. source_range ( ) , label) ;
95
104
item. set_documentation ( ctx. docs ( def) )
96
105
. set_deprecated ( ctx. is_deprecated ( def) )
97
106
. detail ( & pat)
98
107
. lookup_by ( lookup)
99
- . set_relevance ( ctx . completion_relevance ( ) ) ;
108
+ . set_relevance ( relevance ) ;
100
109
match ctx. snippet_cap ( ) {
101
110
Some ( snippet_cap) => item. insert_snippet ( snippet_cap, pat) ,
102
111
None => item. insert_text ( pat) ,
0 commit comments