mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Simplify
This commit is contained in:
parent
8907533536
commit
5a97a326a9
2 changed files with 7 additions and 14 deletions
|
@ -115,7 +115,7 @@ impl InferenceContext<'_> {
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub(crate) struct HirPlace {
|
pub(crate) struct HirPlace {
|
||||||
pub local: BindingId,
|
pub(crate) local: BindingId,
|
||||||
pub(crate) projections: Vec<ProjectionElem<Infallible, Ty>>,
|
pub(crate) projections: Vec<ProjectionElem<Infallible, Ty>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,16 +72,8 @@ pub(crate) fn highlight_related(
|
||||||
T![break] | T![loop] | T![while] | T![continue] if config.break_points => {
|
T![break] | T![loop] | T![while] | T![continue] if config.break_points => {
|
||||||
highlight_break_points(token)
|
highlight_break_points(token)
|
||||||
}
|
}
|
||||||
T![|] if config.closure_captures => highlight_closure_captures(
|
T![|] if config.closure_captures => highlight_closure_captures(sema, token, file_id),
|
||||||
sema,
|
T![move] if config.closure_captures => highlight_closure_captures(sema, token, file_id),
|
||||||
token.parent_ancestors().nth(1).and_then(ast::ClosureExpr::cast)?,
|
|
||||||
file_id,
|
|
||||||
),
|
|
||||||
T![move] if config.closure_captures => highlight_closure_captures(
|
|
||||||
sema,
|
|
||||||
token.parent().and_then(ast::ClosureExpr::cast)?,
|
|
||||||
file_id,
|
|
||||||
),
|
|
||||||
_ if config.references => highlight_references(sema, &syntax, token, file_id),
|
_ if config.references => highlight_references(sema, &syntax, token, file_id),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -89,11 +81,12 @@ pub(crate) fn highlight_related(
|
||||||
|
|
||||||
fn highlight_closure_captures(
|
fn highlight_closure_captures(
|
||||||
sema: &Semantics<'_, RootDatabase>,
|
sema: &Semantics<'_, RootDatabase>,
|
||||||
node: ast::ClosureExpr,
|
token: SyntaxToken,
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
) -> Option<Vec<HighlightedRange>> {
|
) -> Option<Vec<HighlightedRange>> {
|
||||||
let search_range = node.body()?.syntax().text_range();
|
let closure = token.parent_ancestors().take(2).find_map(ast::ClosureExpr::cast)?;
|
||||||
let ty = &sema.type_of_expr(&node.into())?.original;
|
let search_range = closure.body()?.syntax().text_range();
|
||||||
|
let ty = &sema.type_of_expr(&closure.into())?.original;
|
||||||
let c = ty.as_closure()?;
|
let c = ty.as_closure()?;
|
||||||
Some(
|
Some(
|
||||||
c.captured_items(sema.db)
|
c.captured_items(sema.db)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue