aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ide_assists/src/handlers/expand_glob_import.rs4
-rw-r--r--crates/ide_db/src/search.rs34
2 files changed, 14 insertions, 24 deletions
diff --git a/crates/ide_assists/src/handlers/expand_glob_import.rs b/crates/ide_assists/src/handlers/expand_glob_import.rs
index 5b540df5c..83aa11d52 100644
--- a/crates/ide_assists/src/handlers/expand_glob_import.rs
+++ b/crates/ide_assists/src/handlers/expand_glob_import.rs
@@ -73,8 +73,8 @@ fn find_parent_and_path(
73) -> Option<(Either<ast::UseTree, ast::UseTreeList>, ast::Path)> { 73) -> Option<(Either<ast::UseTree, ast::UseTreeList>, ast::Path)> {
74 return star.ancestors().find_map(|n| { 74 return star.ancestors().find_map(|n| {
75 find_use_tree_list(n.clone()) 75 find_use_tree_list(n.clone())
76 .and_then(|(u, p)| Some((Either::Right(u), p))) 76 .map(|(u, p)| (Either::Right(u), p))
77 .or_else(|| find_use_tree(n).and_then(|(u, p)| Some((Either::Left(u), p)))) 77 .or_else(|| find_use_tree(n).map(|(u, p)| (Either::Left(u), p)))
78 }); 78 });
79 79
80 fn find_use_tree_list(n: SyntaxNode) -> Option<(ast::UseTreeList, ast::Path)> { 80 fn find_use_tree_list(n: SyntaxNode) -> Option<(ast::UseTreeList, ast::Path)> {
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs
index f56221a6c..324817cd0 100644
--- a/crates/ide_db/src/search.rs
+++ b/crates/ide_db/src/search.rs
@@ -161,15 +161,9 @@ impl Definition {
161 161
162 if let Definition::Local(var) = self { 162 if let Definition::Local(var) = self {
163 let range = match var.parent(db) { 163 let range = match var.parent(db) {
164 DefWithBody::Function(f) => { 164 DefWithBody::Function(f) => f.source(db).map(|src| src.value.syntax().text_range()),
165 f.source(db).and_then(|src| Some(src.value.syntax().text_range())) 165 DefWithBody::Const(c) => c.source(db).map(|src| src.value.syntax().text_range()),
166 } 166 DefWithBody::Static(s) => s.source(db).map(|src| src.value.syntax().text_range()),
167 DefWithBody::Const(c) => {
168 c.source(db).and_then(|src| Some(src.value.syntax().text_range()))
169 }
170 DefWithBody::Static(s) => {
171 s.source(db).and_then(|src| Some(src.value.syntax().text_range()))
172 }
173 }; 167 };
174 let mut res = FxHashMap::default(); 168 let mut res = FxHashMap::default();
175 res.insert(file_id, range); 169 res.insert(file_id, range);
@@ -179,33 +173,29 @@ impl Definition {
179 if let Definition::GenericParam(hir::GenericParam::LifetimeParam(param)) = self { 173 if let Definition::GenericParam(hir::GenericParam::LifetimeParam(param)) = self {
180 let range = match param.parent(db) { 174 let range = match param.parent(db) {
181 hir::GenericDef::Function(it) => { 175 hir::GenericDef::Function(it) => {
182 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 176 it.source(db).map(|src| src.value.syntax().text_range())
183 } 177 }
184 hir::GenericDef::Adt(it) => match it { 178 hir::GenericDef::Adt(it) => match it {
185 hir::Adt::Struct(it) => { 179 hir::Adt::Struct(it) => {
186 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 180 it.source(db).map(|src| src.value.syntax().text_range())
187 }
188 hir::Adt::Union(it) => {
189 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
190 }
191 hir::Adt::Enum(it) => {
192 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
193 } 181 }
182 hir::Adt::Union(it) => it.source(db).map(|src| src.value.syntax().text_range()),
183 hir::Adt::Enum(it) => it.source(db).map(|src| src.value.syntax().text_range()),
194 }, 184 },
195 hir::GenericDef::Trait(it) => { 185 hir::GenericDef::Trait(it) => {
196 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 186 it.source(db).map(|src| src.value.syntax().text_range())
197 } 187 }
198 hir::GenericDef::TypeAlias(it) => { 188 hir::GenericDef::TypeAlias(it) => {
199 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 189 it.source(db).map(|src| src.value.syntax().text_range())
200 } 190 }
201 hir::GenericDef::Impl(it) => { 191 hir::GenericDef::Impl(it) => {
202 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 192 it.source(db).map(|src| src.value.syntax().text_range())
203 } 193 }
204 hir::GenericDef::Variant(it) => { 194 hir::GenericDef::Variant(it) => {
205 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 195 it.source(db).map(|src| src.value.syntax().text_range())
206 } 196 }
207 hir::GenericDef::Const(it) => { 197 hir::GenericDef::Const(it) => {
208 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 198 it.source(db).map(|src| src.value.syntax().text_range())
209 } 199 }
210 }; 200 };
211 let mut res = FxHashMap::default(); 201 let mut res = FxHashMap::default();