about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-30 20:58:20 +0000
committerGitHub <noreply@github.com>2020-07-30 20:58:20 +0000
commit7d18109af47dfe993bcb1122c051ef96da63561b (patch)
treeb6ad2d8a30309bf2bf1be92456e311c2ecb61ec1
parent43d81422149cabf7e61c0db67e298103c86bfb0d (diff)
parent848f446a5abdc1c5512782267427f72c217b1556 (diff)
downloadrust-7d18109af47dfe993bcb1122c051ef96da63561b.tar.gz
rust-7d18109af47dfe993bcb1122c051ef96da63561b.zip
Merge #5615
5615: simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
-rw-r--r--crates/ra_hir/src/source_analyzer.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs
index 8f438bba0e4..f2e630ef1ab 100644
--- a/crates/ra_hir/src/source_analyzer.rs
+++ b/crates/ra_hir/src/source_analyzer.rs
@@ -405,8 +405,7 @@ fn scope_for_offset(
             )
         })
         .map(|(expr_range, scope)| {
-            adjust(db, scopes, source_map, expr_range, offset.file_id, offset.value)
-                .unwrap_or(*scope)
+            adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
         })
 }
 
@@ -417,8 +416,7 @@ fn adjust(
     scopes: &ExprScopes,
     source_map: &BodySourceMap,
     expr_range: TextRange,
-    file_id: HirFileId,
-    offset: TextSize,
+    offset: InFile<TextSize>,
 ) -> Option<ScopeId> {
     let child_scopes = scopes
         .scope_by_expr()
@@ -426,7 +424,7 @@ fn adjust(
         .filter_map(|(id, scope)| {
             let source = source_map.expr_syntax(*id).ok()?;
             // FIXME: correctly handle macro expansion
-            if source.file_id != file_id {
+            if source.file_id != offset.file_id {
                 return None;
             }
             let root = source.file_syntax(db.upcast());
@@ -434,7 +432,7 @@ fn adjust(
             Some((node.syntax().text_range(), scope))
         })
         .filter(|&(range, _)| {
-            range.start() <= offset && expr_range.contains_range(range) && range != expr_range
+            range.start() <= offset.value && expr_range.contains_range(range) && range != expr_range
         });
 
     child_scopes