From bed115d6e1a634d79e175e543a7936cd03200ebc Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Sun, 3 May 2020 17:56:45 +0200 Subject: add support of cfg attributes on enum variants #4279 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_hir_def/src/adt.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 8eef51828..d0912ddaa 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -117,7 +117,13 @@ fn lower_enum( ast: &InFile, module_id: ModuleId, ) { - for var in ast.value.variant_list().into_iter().flat_map(|it| it.variants()) { + let expander = CfgExpander::new(db, ast.file_id, module_id.krate); + let variants = + ast.value.variant_list().into_iter().flat_map(|it| it.variants()).filter(|var| { + let attrs = expander.parse_attrs(var); + expander.is_cfg_enabled(&attrs) + }); + for var in variants { trace.alloc( || var.clone(), || EnumVariantData { -- cgit v1.2.3