@@ -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 {
@@ -207,24 +215,24 @@ pub(crate) fn hover(
207
215
}
208
216
} ;
209
217
210
- let res = hover_type_info ( & sema, config, expr_or_pat) ?;
218
+ let res = hover_type_info ( & sema, config, & expr_or_pat) ?;
211
219
let range = sema. original_range ( & node) . range ;
212
220
Some ( RangeInfo :: new ( range, res) )
213
221
}
214
222
215
223
fn hover_type_info (
216
224
sema : & Semantics < RootDatabase > ,
217
225
config : & HoverConfig ,
218
- expr_or_pat : Either < ast:: Expr , ast:: Pat > ,
226
+ expr_or_pat : & Either < ast:: Expr , ast:: Pat > ,
219
227
) -> Option < HoverResult > {
220
- let ( ty, coerced) = match & expr_or_pat {
228
+ let ( ty, coerced) = match expr_or_pat {
221
229
Either :: Left ( expr) => sema. type_of_expr_with_coercion ( expr) ?,
222
230
Either :: Right ( pat) => sema. type_of_pat_with_coercion ( pat) ?,
223
231
} ;
224
232
225
233
let mut res = HoverResult :: default ( ) ;
226
234
res. markup = if coerced {
227
- let uncoerced_ty = match & expr_or_pat {
235
+ let uncoerced_ty = match expr_or_pat {
228
236
Either :: Left ( expr) => sema. type_of_expr ( expr) ?,
229
237
Either :: Right ( pat) => sema. type_of_pat ( pat) ?,
230
238
} ;
0 commit comments