diff options
author | Benjamin Coenen <[email protected]> | 2020-05-06 08:57:00 +0100 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-05-06 08:57:00 +0100 |
commit | c4d128e454448191c4b21d8e151c673e4c42376e (patch) | |
tree | 17cf5bbf429642c52708cd0d3c1d8885b63543f0 /crates/ra_hir_def/src/adt.rs | |
parent | 0bf02f5ccac99c91f10ef46bb06ff2ea316c382c (diff) | |
parent | 30eb458b4fa8adcecd8cbf731bd1cfa9a7a8b88b (diff) |
Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into fix_4311
Diffstat (limited to 'crates/ra_hir_def/src/adt.rs')
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index d0912ddaa..2bc34d449 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -118,11 +118,12 @@ fn lower_enum( | |||
118 | module_id: ModuleId, | 118 | module_id: ModuleId, |
119 | ) { | 119 | ) { |
120 | let expander = CfgExpander::new(db, ast.file_id, module_id.krate); | 120 | let expander = CfgExpander::new(db, ast.file_id, module_id.krate); |
121 | let variants = | 121 | let variants = ast |
122 | ast.value.variant_list().into_iter().flat_map(|it| it.variants()).filter(|var| { | 122 | .value |
123 | let attrs = expander.parse_attrs(var); | 123 | .variant_list() |
124 | expander.is_cfg_enabled(&attrs) | 124 | .into_iter() |
125 | }); | 125 | .flat_map(|it| it.variants()) |
126 | .filter(|var| expander.is_cfg_enabled(var)); | ||
126 | for var in variants { | 127 | for var in variants { |
127 | trace.alloc( | 128 | trace.alloc( |
128 | || var.clone(), | 129 | || var.clone(), |
@@ -215,8 +216,7 @@ fn lower_struct( | |||
215 | match &ast.value { | 216 | match &ast.value { |
216 | ast::StructKind::Tuple(fl) => { | 217 | ast::StructKind::Tuple(fl) => { |
217 | for (i, fd) in fl.fields().enumerate() { | 218 | for (i, fd) in fl.fields().enumerate() { |
218 | let attrs = expander.parse_attrs(&fd); | 219 | if !expander.is_cfg_enabled(&fd) { |
219 | if !expander.is_cfg_enabled(&attrs) { | ||
220 | continue; | 220 | continue; |
221 | } | 221 | } |
222 | 222 | ||
@@ -233,8 +233,7 @@ fn lower_struct( | |||
233 | } | 233 | } |
234 | ast::StructKind::Record(fl) => { | 234 | ast::StructKind::Record(fl) => { |
235 | for fd in fl.fields() { | 235 | for fd in fl.fields() { |
236 | let attrs = expander.parse_attrs(&fd); | 236 | if !expander.is_cfg_enabled(&fd) { |
237 | if !expander.is_cfg_enabled(&attrs) { | ||
238 | continue; | 237 | continue; |
239 | } | 238 | } |
240 | 239 | ||