diff options
author | Benjamin Coenen <[email protected]> | 2020-05-03 16:56:45 +0100 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-05-03 16:56:45 +0100 |
commit | bed115d6e1a634d79e175e543a7936cd03200ebc (patch) | |
tree | 10548a96ae07d24b8cb276da02fbf84fb6b46032 /crates/ra_hir_def | |
parent | 682c079043656a55775eff33d806da517542f9eb (diff) |
add support of cfg attributes on enum variants #4279
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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( | |||
117 | ast: &InFile<ast::EnumDef>, | 117 | ast: &InFile<ast::EnumDef>, |
118 | module_id: ModuleId, | 118 | module_id: ModuleId, |
119 | ) { | 119 | ) { |
120 | for var in ast.value.variant_list().into_iter().flat_map(|it| it.variants()) { | 120 | let expander = CfgExpander::new(db, ast.file_id, module_id.krate); |
121 | let variants = | ||
122 | ast.value.variant_list().into_iter().flat_map(|it| it.variants()).filter(|var| { | ||
123 | let attrs = expander.parse_attrs(var); | ||
124 | expander.is_cfg_enabled(&attrs) | ||
125 | }); | ||
126 | for var in variants { | ||
121 | trace.alloc( | 127 | trace.alloc( |
122 | || var.clone(), | 128 | || var.clone(), |
123 | || EnumVariantData { | 129 | || EnumVariantData { |