diff options
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 687216dc3..443b057ab 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -162,8 +162,7 @@ impl ExprCollector<'_> { | |||
162 | 162 | ||
163 | fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { | 163 | fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { |
164 | let syntax_ptr = AstPtr::new(&expr); | 164 | let syntax_ptr = AstPtr::new(&expr); |
165 | let attrs = self.expander.parse_attrs(&expr); | 165 | if !self.expander.is_cfg_enabled(&expr) { |
166 | if !self.expander.is_cfg_enabled(&attrs) { | ||
167 | return self.missing_expr(); | 166 | return self.missing_expr(); |
168 | } | 167 | } |
169 | match expr { | 168 | match expr { |
@@ -329,8 +328,7 @@ impl ExprCollector<'_> { | |||
329 | .fields() | 328 | .fields() |
330 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) | 329 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) |
331 | .filter_map(|field| { | 330 | .filter_map(|field| { |
332 | let attrs = self.expander.parse_attrs(&field); | 331 | if !self.expander.is_cfg_enabled(&field) { |
333 | if !self.expander.is_cfg_enabled(&attrs) { | ||
334 | return None; | 332 | return None; |
335 | } | 333 | } |
336 | let name = field.field_name()?.as_name(); | 334 | let name = field.field_name()?.as_name(); |
@@ -575,9 +573,16 @@ impl ExprCollector<'_> { | |||
575 | self.body.item_scope.define_def(def); | 573 | self.body.item_scope.define_def(def); |
576 | if let Some(name) = name { | 574 | if let Some(name) = name { |
577 | let vis = crate::visibility::Visibility::Public; // FIXME determine correctly | 575 | let vis = crate::visibility::Visibility::Public; // FIXME determine correctly |
578 | self.body | 576 | let has_constructor = match def { |
579 | .item_scope | 577 | ModuleDefId::AdtId(AdtId::StructId(s)) => { |
580 | .push_res(name.as_name(), crate::per_ns::PerNs::from_def(def, vis)); | 578 | self.db.struct_data(s).variant_data.kind() != StructKind::Record |
579 | } | ||
580 | _ => true, | ||
581 | }; | ||
582 | self.body.item_scope.push_res( | ||
583 | name.as_name(), | ||
584 | crate::per_ns::PerNs::from_def(def, vis, has_constructor), | ||
585 | ); | ||
581 | } | 586 | } |
582 | } | 587 | } |
583 | } | 588 | } |