Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5a97a32

Browse files
committed
Simplify
1 parent 8907533 commit 5a97a32

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

crates/hir-ty/src/infer/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl InferenceContext<'_> {
115115

116116
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
117117
pub(crate) struct HirPlace {
118-
pub local: BindingId,
118+
pub(crate) local: BindingId,
119119
pub(crate) projections: Vec<ProjectionElem<Infallible, Ty>>,
120120
}
121121

crates/ide/src/highlight_related.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,21 @@ pub(crate) fn highlight_related(
7272
T![break] | T![loop] | T![while] | T![continue] if config.break_points => {
7373
highlight_break_points(token)
7474
}
75-
T![|] if config.closure_captures => highlight_closure_captures(
76-
sema,
77-
token.parent_ancestors().nth(1).and_then(ast::ClosureExpr::cast)?,
78-
file_id,
79-
),
80-
T![move] if config.closure_captures => highlight_closure_captures(
81-
sema,
82-
token.parent().and_then(ast::ClosureExpr::cast)?,
83-
file_id,
84-
),
75+
T![|] if config.closure_captures => highlight_closure_captures(sema, token, file_id),
76+
T![move] if config.closure_captures => highlight_closure_captures(sema, token, file_id),
8577
_ if config.references => highlight_references(sema, &syntax, token, file_id),
8678
_ => None,
8779
}
8880
}
8981

9082
fn highlight_closure_captures(
9183
sema: &Semantics<'_, RootDatabase>,
92-
node: ast::ClosureExpr,
84+
token: SyntaxToken,
9385
file_id: FileId,
9486
) -> Option<Vec<HighlightedRange>> {
95-
let search_range = node.body()?.syntax().text_range();
96-
let ty = &sema.type_of_expr(&node.into())?.original;
87+
let closure = token.parent_ancestors().take(2).find_map(ast::ClosureExpr::cast)?;
88+
let search_range = closure.body()?.syntax().text_range();
89+
let ty = &sema.type_of_expr(&closure.into())?.original;
9790
let c = ty.as_closure()?;
9891
Some(
9992
c.captured_items(sema.db)

0 commit comments

Comments
 (0)