aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/defs.rs2
-rw-r--r--crates/ide_db/src/helpers/insert_use.rs2
-rw-r--r--crates/ide_db/src/search.rs34
3 files changed, 14 insertions, 24 deletions
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs
index f86e5ce93..75167ff39 100644
--- a/crates/ide_db/src/defs.rs
+++ b/crates/ide_db/src/defs.rs
@@ -181,7 +181,7 @@ impl NameClass {
181 }, 181 },
182 ast::SelfParam(it) => { 182 ast::SelfParam(it) => {
183 let def = sema.to_def(&it)?; 183 let def = sema.to_def(&it)?;
184 Some(NameClass::Definition(Definition::Local(def.into()))) 184 Some(NameClass::Definition(Definition::Local(def)))
185 }, 185 },
186 ast::RecordField(it) => { 186 ast::RecordField(it) => {
187 let field: hir::Field = sema.to_def(&it)?; 187 let field: hir::Field = sema.to_def(&it)?;
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs
index df66d8ea0..9e0cb91c3 100644
--- a/crates/ide_db/src/helpers/insert_use.rs
+++ b/crates/ide_db/src/helpers/insert_use.rs
@@ -80,7 +80,7 @@ impl ImportScope {
80 }) 80 })
81 .last() 81 .last()
82 .map(|last_inner_element| { 82 .map(|last_inner_element| {
83 (InsertPosition::After(last_inner_element.into()), AddBlankLine::BeforeTwice) 83 (InsertPosition::After(last_inner_element), AddBlankLine::BeforeTwice)
84 }) 84 })
85 .unwrap_or_else(|| self.first_insert_pos()) 85 .unwrap_or_else(|| self.first_insert_pos())
86 } 86 }
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();