diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-04 04:18:48 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-04 04:18:48 +0100 |
commit | d85528081834639c4580fc135f74eb23447b12c7 (patch) | |
tree | 31d6daed892fa22c09c11142c56d6fe9a83f05a9 /crates/ra_hir_def/src | |
parent | 57ec813294368a25e424672ad13bcee47f19f1d2 (diff) | |
parent | bed115d6e1a634d79e175e543a7936cd03200ebc (diff) |
Merge #4285
4285: add support of cfg attributes on enum variants r=edwin0cheng a=bnjjj
close #4279
Co-authored-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src')
-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 { |