aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src/search.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db/src/search.rs')
-rw-r--r--crates/ra_ide_db/src/search.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs
index 1bf014149..596f957b8 100644
--- a/crates/ra_ide_db/src/search.rs
+++ b/crates/ra_ide_db/src/search.rs
@@ -4,13 +4,13 @@
4//! get a super-set of matches. Then, we we confirm each match using precise 4//! get a super-set of matches. Then, we we confirm each match using precise
5//! name resolution. 5//! name resolution.
6 6
7use std::mem; 7use std::{convert::TryInto, mem};
8 8
9use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility}; 9use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility};
10use once_cell::unsync::Lazy; 10use once_cell::unsync::Lazy;
11use ra_db::{FileId, FileRange, SourceDatabaseExt}; 11use ra_db::{FileId, FileRange, SourceDatabaseExt};
12use ra_prof::profile; 12use ra_prof::profile;
13use ra_syntax::{ast, match_ast, AstNode, TextRange, TextUnit}; 13use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize};
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
15use test_utils::tested_by; 15use test_utils::tested_by;
16 16
@@ -85,7 +85,7 @@ impl SearchScope {
85 match (r1, r2) { 85 match (r1, r2) {
86 (None, r) | (r, None) => Some(r), 86 (None, r) | (r, None) => Some(r),
87 (Some(r1), Some(r2)) => { 87 (Some(r1), Some(r2)) => {
88 let r = r1.intersection(&r2)?; 88 let r = r1.intersect(r2)?;
89 Some(Some(r)) 89 Some(Some(r))
90 } 90 }
91 } 91 }
@@ -201,13 +201,13 @@ impl Definition {
201 for (file_id, search_range) in search_scope { 201 for (file_id, search_range) in search_scope {
202 let text = db.file_text(file_id); 202 let text = db.file_text(file_id);
203 let search_range = 203 let search_range =
204 search_range.unwrap_or(TextRange::offset_len(0.into(), TextUnit::of_str(&text))); 204 search_range.unwrap_or(TextRange::up_to(TextSize::of(text.as_str())));
205 205
206 let sema = Semantics::new(db); 206 let sema = Semantics::new(db);
207 let tree = Lazy::new(|| sema.parse(file_id).syntax().clone()); 207 let tree = Lazy::new(|| sema.parse(file_id).syntax().clone());
208 208
209 for (idx, _) in text.match_indices(pat) { 209 for (idx, _) in text.match_indices(pat) {
210 let offset = TextUnit::from_usize(idx); 210 let offset: TextSize = idx.try_into().unwrap();
211 if !search_range.contains_inclusive(offset) { 211 if !search_range.contains_inclusive(offset) {
212 tested_by!(search_filters_by_range; force); 212 tested_by!(search_filters_by_range; force);
213 continue; 213 continue;