aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl
diff options
context:
space:
mode:
authorMarcus Klaas de Vries <[email protected]>2019-01-10 01:07:42 +0000
committerMarcus Klaas de Vries <[email protected]>2019-01-10 13:43:01 +0000
commite78286c8e88d31045d354320a1d29bbd75405027 (patch)
treeed4c6f986b6ede2bbafa19a66dd81f5be2d0371c /crates/ra_hir/src/code_model_impl
parent978de5cf8bfd2ff82696fc8d5369b41e147431c3 (diff)
Save variant names in EnumData to reduce needless queries
We already have their names when anyway, and when in all (current) situations where we're interested in an Enum's variants, we want their names.
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r--crates/ra_hir/src/code_model_impl/module.rs18
1 files changed, 4 insertions, 14 deletions
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs
index d7d62e863..878dc37c8 100644
--- a/crates/ra_hir/src/code_model_impl/module.rs
+++ b/crates/ra_hir/src/code_model_impl/module.rs
@@ -142,20 +142,10 @@ impl Module {
142 Def::Enum(e) => { 142 Def::Enum(e) => {
143 if segments.len() == idx + 1 { 143 if segments.len() == idx + 1 {
144 // enum variant 144 // enum variant
145 let matching_variant = e.variants(db)?.map(|variants| { 145 let matching_variant =
146 variants 146 e.variants(db)?.into_iter().find(|(n, _variant)| n == name);
147 .into_iter() 147
148 // FIXME: replace by match lol 148 if let Some((_n, variant)) = matching_variant {
149 .find(|variant| {
150 variant
151 .name(db)
152 .map(|o| o.map(|ref n| n == name))
153 .unwrap_or(Some(false))
154 .unwrap_or(false)
155 })
156 });
157
158 if let Some(Some(variant)) = matching_variant {
159 return Ok(PerNs::both(variant.def_id(), e.def_id())); 149 return Ok(PerNs::both(variant.def_id(), e.def_id()));
160 } else { 150 } else {
161 return Ok(PerNs::none()); 151 return Ok(PerNs::none());