Skip to content

Commit 7d18109

Browse files
bors[bot]matklad
andauthored
Merge #5615
5615: simplify r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents 43d8142 + 848f446 commit 7d18109

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

crates/ra_hir/src/source_analyzer.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,7 @@ fn scope_for_offset(
405405
)
406406
})
407407
.map(|(expr_range, scope)| {
408-
adjust(db, scopes, source_map, expr_range, offset.file_id, offset.value)
409-
.unwrap_or(*scope)
408+
adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
410409
})
411410
}
412411

@@ -417,24 +416,23 @@ fn adjust(
417416
scopes: &ExprScopes,
418417
source_map: &BodySourceMap,
419418
expr_range: TextRange,
420-
file_id: HirFileId,
421-
offset: TextSize,
419+
offset: InFile<TextSize>,
422420
) -> Option<ScopeId> {
423421
let child_scopes = scopes
424422
.scope_by_expr()
425423
.iter()
426424
.filter_map(|(id, scope)| {
427425
let source = source_map.expr_syntax(*id).ok()?;
428426
// FIXME: correctly handle macro expansion
429-
if source.file_id != file_id {
427+
if source.file_id != offset.file_id {
430428
return None;
431429
}
432430
let root = source.file_syntax(db.upcast());
433431
let node = source.value.to_node(&root);
434432
Some((node.syntax().text_range(), scope))
435433
})
436434
.filter(|&(range, _)| {
437-
range.start() <= offset && expr_range.contains_range(range) && range != expr_range
435+
range.start() <= offset.value && expr_range.contains_range(range) && range != expr_range
438436
});
439437

440438
child_scopes

0 commit comments

Comments
 (0)