diff options
author | Matthias Krüger <[email protected]> | 2021-03-17 01:34:46 +0000 |
---|---|---|
committer | Matthias Krüger <[email protected]> | 2021-03-17 01:36:29 +0000 |
commit | ff5f90d8ae2da8e4856d5c78f55e5cd02b178325 (patch) | |
tree | 68a4b706477487e466d9d33e577f7cb6dbf2bf50 /crates/ide_db/src | |
parent | 64b91393b85eb2b5d41ccbd3048dcc61eb8061c7 (diff) |
use simpler .map(|x| y) instead of .and_then(|x| Some(y)) for Options. (clippy::bind_instead_of_map)
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/search.rs | 34 |
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(); |