1- use hir:: TypeInfo ;
1+ use hir:: Type ;
22use std:: { collections:: HashMap , iter:: successors} ;
33use syntax:: {
44 algo:: neighbor,
@@ -95,15 +95,15 @@ fn contains_placeholder(a: &ast::MatchArm) -> bool {
9595}
9696
9797fn are_same_types (
98- current_arm_types : & HashMap < String , Option < TypeInfo > > ,
98+ current_arm_types : & HashMap < String , Option < Type > > ,
9999 arm : & ast:: MatchArm ,
100100 ctx : & AssistContext < ' _ > ,
101101) -> bool {
102102 let arm_types = get_arm_types ( ctx, arm) ;
103103 for ( other_arm_type_name, other_arm_type) in arm_types {
104104 match ( current_arm_types. get ( & other_arm_type_name) , other_arm_type) {
105105 ( Some ( Some ( current_arm_type) ) , Some ( other_arm_type) )
106- if other_arm_type. original == current_arm_type. original => { }
106+ if other_arm_type == * current_arm_type => { }
107107 _ => return false ,
108108 }
109109 }
@@ -114,44 +114,44 @@ fn are_same_types(
114114fn get_arm_types (
115115 context : & AssistContext < ' _ > ,
116116 arm : & ast:: MatchArm ,
117- ) -> HashMap < String , Option < TypeInfo > > {
118- let mut mapping: HashMap < String , Option < TypeInfo > > = HashMap :: new ( ) ;
117+ ) -> HashMap < String , Option < Type > > {
118+ let mut mapping: HashMap < String , Option < Type > > = HashMap :: new ( ) ;
119119
120120 fn recurse (
121- map : & mut HashMap < String , Option < TypeInfo > > ,
121+ map : & mut HashMap < String , Option < Type > > ,
122122 ctx : & AssistContext < ' _ > ,
123123 pat : & Option < ast:: Pat > ,
124124 ) {
125125 if let Some ( local_pat) = pat {
126- match pat {
127- Some ( ast:: Pat :: TupleStructPat ( tuple) ) => {
126+ match local_pat {
127+ ast:: Pat :: TupleStructPat ( tuple) => {
128128 for field in tuple. fields ( ) {
129129 recurse ( map, ctx, & Some ( field) ) ;
130130 }
131131 }
132- Some ( ast:: Pat :: TuplePat ( tuple) ) => {
132+ ast:: Pat :: TuplePat ( tuple) => {
133133 for field in tuple. fields ( ) {
134134 recurse ( map, ctx, & Some ( field) ) ;
135135 }
136136 }
137- Some ( ast:: Pat :: RecordPat ( record) ) => {
137+ ast:: Pat :: RecordPat ( record) => {
138138 if let Some ( field_list) = record. record_pat_field_list ( ) {
139139 for field in field_list. fields ( ) {
140140 recurse ( map, ctx, & field. pat ( ) ) ;
141141 }
142142 }
143143 }
144- Some ( ast:: Pat :: ParenPat ( parentheses) ) => {
144+ ast:: Pat :: ParenPat ( parentheses) => {
145145 recurse ( map, ctx, & parentheses. pat ( ) ) ;
146146 }
147- Some ( ast:: Pat :: SlicePat ( slice) ) => {
147+ ast:: Pat :: SlicePat ( slice) => {
148148 for slice_pat in slice. pats ( ) {
149149 recurse ( map, ctx, & Some ( slice_pat) ) ;
150150 }
151151 }
152- Some ( ast:: Pat :: IdentPat ( ident_pat) ) => {
152+ ast:: Pat :: IdentPat ( ident_pat) => {
153153 if let Some ( name) = ident_pat. name ( ) {
154- let pat_type = ctx. sema . type_of_pat ( local_pat ) ;
154+ let pat_type = ctx. sema . type_of_binding_in_pat ( ident_pat ) ;
155155 map. insert ( name. text ( ) . to_string ( ) , pat_type) ;
156156 }
157157 }
0 commit comments