mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Merge #9762
9762: fix: Fix ranged hover result range r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
29506b5a26
@ -93,7 +93,15 @@ pub(crate) fn hover(
|
||||
}
|
||||
}
|
||||
})?;
|
||||
return hover_type_info(&sema, config, expr).map(|it| RangeInfo::new(range, it));
|
||||
return hover_type_info(&sema, config, &expr).map(|it| {
|
||||
RangeInfo::new(
|
||||
match expr {
|
||||
Either::Left(it) => it.syntax().text_range(),
|
||||
Either::Right(it) => it.syntax().text_range(),
|
||||
},
|
||||
it,
|
||||
)
|
||||
});
|
||||
};
|
||||
|
||||
let token = pick_best_token(file.token_at_offset(offset), |kind| match kind {
|
||||
@ -207,7 +215,7 @@ pub(crate) fn hover(
|
||||
}
|
||||
};
|
||||
|
||||
let res = hover_type_info(&sema, config, expr_or_pat)?;
|
||||
let res = hover_type_info(&sema, config, &expr_or_pat)?;
|
||||
let range = sema.original_range(&node).range;
|
||||
Some(RangeInfo::new(range, res))
|
||||
}
|
||||
@ -215,16 +223,16 @@ pub(crate) fn hover(
|
||||
fn hover_type_info(
|
||||
sema: &Semantics<RootDatabase>,
|
||||
config: &HoverConfig,
|
||||
expr_or_pat: Either<ast::Expr, ast::Pat>,
|
||||
expr_or_pat: &Either<ast::Expr, ast::Pat>,
|
||||
) -> Option<HoverResult> {
|
||||
let (ty, coerced) = match &expr_or_pat {
|
||||
let (ty, coerced) = match expr_or_pat {
|
||||
Either::Left(expr) => sema.type_of_expr_with_coercion(expr)?,
|
||||
Either::Right(pat) => sema.type_of_pat_with_coercion(pat)?,
|
||||
};
|
||||
|
||||
let mut res = HoverResult::default();
|
||||
res.markup = if coerced {
|
||||
let uncoerced_ty = match &expr_or_pat {
|
||||
let uncoerced_ty = match expr_or_pat {
|
||||
Either::Left(expr) => sema.type_of_expr(expr)?,
|
||||
Either::Right(pat) => sema.type_of_pat(pat)?,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user