@@ -93,7 +93,15 @@ pub(crate) fn hover(
93
93
}
94
94
}
95
95
} ) ?;
96
- return hover_type_info ( & sema, config, expr) . map ( |it| RangeInfo :: new ( range, it) ) ;
96
+ return hover_type_info ( & sema, config, & expr) . map ( |it| {
97
+ RangeInfo :: new (
98
+ match expr {
99
+ Either :: Left ( it) => it. syntax ( ) . text_range ( ) ,
100
+ Either :: Right ( it) => it. syntax ( ) . text_range ( ) ,
101
+ } ,
102
+ it,
103
+ )
104
+ } ) ;
97
105
} ;
98
106
99
107
let token = pick_best_token ( file. token_at_offset ( offset) , |kind| match kind {
@@ -204,24 +212,24 @@ pub(crate) fn hover(
204
212
}
205
213
} ;
206
214
207
- let res = hover_type_info ( & sema, config, expr_or_pat) ?;
215
+ let res = hover_type_info ( & sema, config, & expr_or_pat) ?;
208
216
let range = sema. original_range ( & node) . range ;
209
217
Some ( RangeInfo :: new ( range, res) )
210
218
}
211
219
212
220
fn hover_type_info (
213
221
sema : & Semantics < RootDatabase > ,
214
222
config : & HoverConfig ,
215
- expr_or_pat : Either < ast:: Expr , ast:: Pat > ,
223
+ expr_or_pat : & Either < ast:: Expr , ast:: Pat > ,
216
224
) -> Option < HoverResult > {
217
- let ( ty, coerced) = match & expr_or_pat {
225
+ let ( ty, coerced) = match expr_or_pat {
218
226
Either :: Left ( expr) => sema. type_of_expr_with_coercion ( expr) ?,
219
227
Either :: Right ( pat) => sema. type_of_pat_with_coercion ( pat) ?,
220
228
} ;
221
229
222
230
let mut res = HoverResult :: default ( ) ;
223
231
res. markup = if coerced {
224
- let uncoerced_ty = match & expr_or_pat {
232
+ let uncoerced_ty = match expr_or_pat {
225
233
Either :: Left ( expr) => sema. type_of_expr ( expr) ?,
226
234
Either :: Right ( pat) => sema. type_of_pat ( pat) ?,
227
235
} ;
0 commit comments