diff options
author | Edwin Cheng <[email protected]> | 2020-05-04 18:15:27 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-05-04 18:15:27 +0100 |
commit | e921195d93c443b20a6fcb3cb1c5b8117fe2fa1b (patch) | |
tree | 2023a2b1f5b2fc037a42c2cf850d6e1b41b65446 /crates/ra_hir_def | |
parent | 5ae18f4f814501ccd96a277c320e919159c91fac (diff) |
Change favor_types to has_constructor
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_scope.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index ea0ddeebc..4671b72e9 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -575,15 +575,15 @@ impl ExprCollector<'_> { | |||
575 | self.body.item_scope.define_def(def); | 575 | self.body.item_scope.define_def(def); |
576 | if let Some(name) = name { | 576 | if let Some(name) = name { |
577 | let vis = crate::visibility::Visibility::Public; // FIXME determine correctly | 577 | let vis = crate::visibility::Visibility::Public; // FIXME determine correctly |
578 | let favor_types = match def { | 578 | let has_constructor = match def { |
579 | ModuleDefId::AdtId(AdtId::StructId(s)) => { | 579 | ModuleDefId::AdtId(AdtId::StructId(s)) => { |
580 | self.db.struct_data(s).variant_data.kind() == StructKind::Record | 580 | self.db.struct_data(s).variant_data.kind() != StructKind::Record |
581 | } | 581 | } |
582 | _ => false, | 582 | _ => true, |
583 | }; | 583 | }; |
584 | self.body.item_scope.push_res( | 584 | self.body.item_scope.push_res( |
585 | name.as_name(), | 585 | name.as_name(), |
586 | crate::per_ns::PerNs::from_def(def, vis, favor_types), | 586 | crate::per_ns::PerNs::from_def(def, vis, has_constructor), |
587 | ); | 587 | ); |
588 | } | 588 | } |
589 | } | 589 | } |
diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index 6d8d1f8a3..954f2542a 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs | |||
@@ -151,7 +151,7 @@ impl ItemScope { | |||
151 | } | 151 | } |
152 | 152 | ||
153 | impl PerNs { | 153 | impl PerNs { |
154 | pub(crate) fn from_def(def: ModuleDefId, v: Visibility, favor_types: bool) -> PerNs { | 154 | pub(crate) fn from_def(def: ModuleDefId, v: Visibility, has_constructor: bool) -> PerNs { |
155 | match def { | 155 | match def { |
156 | ModuleDefId::ModuleId(_) => PerNs::types(def, v), | 156 | ModuleDefId::ModuleId(_) => PerNs::types(def, v), |
157 | ModuleDefId::FunctionId(_) => PerNs::values(def, v), | 157 | ModuleDefId::FunctionId(_) => PerNs::values(def, v), |
@@ -159,7 +159,7 @@ impl PerNs { | |||
159 | AdtId::UnionId(_) => PerNs::both(def, def, v), | 159 | AdtId::UnionId(_) => PerNs::both(def, def, v), |
160 | AdtId::EnumId(_) => PerNs::types(def, v), | 160 | AdtId::EnumId(_) => PerNs::types(def, v), |
161 | AdtId::StructId(_) => { | 161 | AdtId::StructId(_) => { |
162 | if favor_types { | 162 | if !has_constructor { |
163 | PerNs::types(def, v) | 163 | PerNs::types(def, v) |
164 | } else { | 164 | } else { |
165 | PerNs::both(def, def, v) | 165 | PerNs::both(def, def, v) |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 49b33ca94..db994122a 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -844,7 +844,7 @@ impl ModCollector<'_, '_> { | |||
844 | let name = def.name.clone(); | 844 | let name = def.name.clone(); |
845 | let container = ContainerId::ModuleId(module); | 845 | let container = ContainerId::ModuleId(module); |
846 | let vis = &def.visibility; | 846 | let vis = &def.visibility; |
847 | let mut favor_types = false; | 847 | let mut has_constructor = false; |
848 | 848 | ||
849 | let def: ModuleDefId = match def.kind { | 849 | let def: ModuleDefId = match def.kind { |
850 | raw::DefKind::Function(ast_id) => FunctionLoc { | 850 | raw::DefKind::Function(ast_id) => FunctionLoc { |
@@ -854,7 +854,7 @@ impl ModCollector<'_, '_> { | |||
854 | .intern(self.def_collector.db) | 854 | .intern(self.def_collector.db) |
855 | .into(), | 855 | .into(), |
856 | raw::DefKind::Struct(ast_id, mode) => { | 856 | raw::DefKind::Struct(ast_id, mode) => { |
857 | favor_types = mode == raw::StructDefKind::Record; | 857 | has_constructor = mode != raw::StructDefKind::Record; |
858 | StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } | 858 | StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
859 | .intern(self.def_collector.db) | 859 | .intern(self.def_collector.db) |
860 | .into() | 860 | .into() |
@@ -899,7 +899,7 @@ impl ModCollector<'_, '_> { | |||
899 | .unwrap_or(Visibility::Public); | 899 | .unwrap_or(Visibility::Public); |
900 | self.def_collector.update( | 900 | self.def_collector.update( |
901 | self.module_id, | 901 | self.module_id, |
902 | &[(name, PerNs::from_def(def, vis, favor_types))], | 902 | &[(name, PerNs::from_def(def, vis, has_constructor))], |
903 | vis, | 903 | vis, |
904 | ) | 904 | ) |
905 | } | 905 | } |