@@ -7,7 +7,6 @@ use syntax::SmolStr;
77
88use crate :: {
99 context:: { ParamContext , ParamKind , PathCompletionCtx , PatternContext } ,
10- item:: CompletionRelevanceTypeMatch ,
1110 render:: {
1211 variant:: { format_literal_label, format_literal_lookup, visible_fields} ,
1312 RenderContext ,
@@ -38,7 +37,9 @@ pub(crate) fn render_struct_pat(
3837 let lookup = format_literal_lookup ( name. as_str ( ) , kind) ;
3938 let pat = render_pat ( & ctx, pattern_ctx, & escaped_name, kind, & visible_fields, fields_omitted) ?;
4039
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) ) )
4243}
4344
4445pub ( crate ) fn render_variant_pat (
@@ -48,12 +49,12 @@ pub(crate) fn render_variant_pat(
4849 variant : hir:: Variant ,
4950 local_name : Option < Name > ,
5051 path : Option < & hir:: ModPath > ,
51- is_exact_type_match : bool ,
5252) -> Option < CompletionItem > {
5353 let _p = profile:: span ( "render_variant_pat" ) ;
5454
5555 let fields = variant. fields ( ctx. db ( ) ) ;
5656 let ( visible_fields, fields_omitted) = visible_fields ( ctx. completion , & fields, variant) ?;
57+ let enum_ty = variant. parent_enum ( ctx. db ( ) ) . ty ( ctx. db ( ) ) ;
5758
5859 let ( name, escaped_name) = match path {
5960 Some ( path) => ( path. unescaped ( ) . to_string ( ) . into ( ) , path. to_string ( ) . into ( ) ) ,
@@ -83,7 +84,7 @@ pub(crate) fn render_variant_pat(
8384 }
8485 } ;
8586
86- Some ( build_completion ( ctx, label, lookup, pat, variant, is_exact_type_match ) )
87+ Some ( build_completion ( ctx, label, lookup, pat, variant, enum_ty ) )
8788}
8889
8990fn build_completion (
@@ -92,13 +93,11 @@ fn build_completion(
9293 lookup : SmolStr ,
9394 pat : String ,
9495 def : impl HasAttrs + Copy ,
95- is_exact_type_match : bool ,
96+ adt_ty : hir :: Type ,
9697) -> CompletionItem {
9798 let mut relevance = ctx. completion_relevance ( ) ;
9899
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) ;
102101
103102 let mut item = CompletionItem :: new ( CompletionItemKind :: Binding , ctx. source_range ( ) , label) ;
104103 item. set_documentation ( ctx. docs ( def) )
0 commit comments