@@ -7,6 +7,7 @@ use syntax::SmolStr;
77
88use crate :: {
99 context:: { ParamContext , ParamKind , PathCompletionCtx , PatternContext } ,
10+ item:: CompletionRelevanceTypeMatch ,
1011 render:: {
1112 variant:: { format_literal_label, format_literal_lookup, visible_fields} ,
1213 RenderContext ,
@@ -37,7 +38,7 @@ pub(crate) fn render_struct_pat(
3738 let lookup = format_literal_lookup ( name. as_str ( ) , kind) ;
3839 let pat = render_pat ( & ctx, pattern_ctx, & escaped_name, kind, & visible_fields, fields_omitted) ?;
3940
40- Some ( build_completion ( ctx, label, lookup, pat, strukt) )
41+ Some ( build_completion ( ctx, label, lookup, pat, strukt, false ) )
4142}
4243
4344pub ( crate ) fn render_variant_pat (
@@ -47,6 +48,7 @@ pub(crate) fn render_variant_pat(
4748 variant : hir:: Variant ,
4849 local_name : Option < Name > ,
4950 path : Option < & hir:: ModPath > ,
51+ is_exact_type_match : bool ,
5052) -> Option < CompletionItem > {
5153 let _p = profile:: span ( "render_variant_pat" ) ;
5254
@@ -81,7 +83,7 @@ pub(crate) fn render_variant_pat(
8183 }
8284 } ;
8385
84- Some ( build_completion ( ctx, label, lookup, pat, variant) )
86+ Some ( build_completion ( ctx, label, lookup, pat, variant, is_exact_type_match ) )
8587}
8688
8789fn build_completion (
@@ -90,13 +92,20 @@ fn build_completion(
9092 lookup : SmolStr ,
9193 pat : String ,
9294 def : impl HasAttrs + Copy ,
95+ is_exact_type_match : bool ,
9396) -> CompletionItem {
97+ let mut relevance = ctx. completion_relevance ( ) ;
98+
99+ if is_exact_type_match {
100+ relevance. type_match = Some ( CompletionRelevanceTypeMatch :: Exact ) ;
101+ }
102+
94103 let mut item = CompletionItem :: new ( CompletionItemKind :: Binding , ctx. source_range ( ) , label) ;
95104 item. set_documentation ( ctx. docs ( def) )
96105 . set_deprecated ( ctx. is_deprecated ( def) )
97106 . detail ( & pat)
98107 . lookup_by ( lookup)
99- . set_relevance ( ctx . completion_relevance ( ) ) ;
108+ . set_relevance ( relevance ) ;
100109 match ctx. snippet_cap ( ) {
101110 Some ( snippet_cap) => item. insert_snippet ( snippet_cap, pat) ,
102111 None => item. insert_text ( pat) ,
0 commit comments