From b87b335e6859ead3baa7fde20e3ea2ac69f63d85 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Sat, 25 Apr 2020 15:48:04 +0200 Subject: add support for cfg feature attributes on expression #4063 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_hir_def/src/body/lower.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 0caedd8d8..571603854 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -141,6 +141,10 @@ impl ExprCollector<'_> { fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { let syntax_ptr = AstPtr::new(&expr); + let attrs = self.expander.parse_attrs(&expr); + if !self.expander.is_cfg_enabled(&attrs) { + return self.missing_expr(); + } match expr { ast::Expr::IfExpr(e) => { let then_branch = self.collect_block_opt(e.then_branch()); -- cgit v1.2.3 From f52e2f6840280ef1302604d90cd3b338a2e488cc Mon Sep 17 00:00:00 2001 From: veetaha Date: Sat, 25 Apr 2020 20:49:51 +0300 Subject: Fix typo --- crates/ra_hir_def/src/body.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 3b169440a..890cefcaf 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -27,7 +27,7 @@ use crate::{ AsMacroCall, DefWithBodyId, HasModule, Lookup, ModuleId, }; -/// A subser of Exander that only deals with cfg attributes. We only need it to +/// A subset of Exander that only deals with cfg attributes. We only need it to /// avoid cyclic queries in crate def map during enum processing. pub(crate) struct CfgExpander { cfg_options: CfgOptions, -- cgit v1.2.3