mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Use the fact that Either
: AstNode
This commit is contained in:
parent
c78b9f0068
commit
a7787533af
5 changed files with 8 additions and 34 deletions
|
@ -230,15 +230,8 @@ fn hover_ranged(
|
|||
config: &HoverConfig,
|
||||
) -> Option<RangeInfo<HoverResult>> {
|
||||
// FIXME: make this work in attributes
|
||||
let expr_or_pat = file.covering_element(range).ancestors().find_map(|it| {
|
||||
match_ast! {
|
||||
match it {
|
||||
ast::Expr(expr) => Some(Either::Left(expr)),
|
||||
ast::Pat(pat) => Some(Either::Right(pat)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
})?;
|
||||
let expr_or_pat =
|
||||
file.covering_element(range).ancestors().find_map(Either::<ast::Expr, ast::Pat>::cast)?;
|
||||
let res = match &expr_or_pat {
|
||||
Either::Left(ast::Expr::TryExpr(try_expr)) => render::try_expr(sema, config, try_expr),
|
||||
Either::Left(ast::Expr::PrefixExpr(prefix_expr))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue