aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r--crates/ide_db/src/search.rs34
1 files changed, 12 insertions, 22 deletions
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();