diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-05 09:24:27 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-05 09:24:27 +0100 |
commit | 87af7c9bd71892028ac91c4e514c548a66e4e8a8 (patch) | |
tree | 433165dceea40f9b530a343dd4cf3725ec6406c5 /crates/ra_hir_def/src/body.rs | |
parent | 15de338703fd9c789c4cf8041a59d8730f12bc78 (diff) | |
parent | 831bb1cf91d69e7e325ecbdab11e6fc80bcae4a4 (diff) |
Merge #4313
4313: refactor: use attrsOwner directly in is_cfg_enabled r=edwin0cheng a=bnjjj
As promised @edwin0cheng here is the PR to resolve the comment [here](https://github.com/rust-analyzer/rust-analyzer/pull/4285#discussion_r419200375).
Co-authored-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/body.rs')
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 4edaad960..f5a7305dc 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs | |||
@@ -60,7 +60,8 @@ impl CfgExpander { | |||
60 | Attrs::new(owner, &self.hygiene) | 60 | Attrs::new(owner, &self.hygiene) |
61 | } | 61 | } |
62 | 62 | ||
63 | pub(crate) fn is_cfg_enabled(&self, attrs: &Attrs) -> bool { | 63 | pub(crate) fn is_cfg_enabled(&self, owner: &dyn ast::AttrsOwner) -> bool { |
64 | let attrs = self.parse_attrs(owner); | ||
64 | attrs.is_cfg_enabled(&self.cfg_options) | 65 | attrs.is_cfg_enabled(&self.cfg_options) |
65 | } | 66 | } |
66 | } | 67 | } |
@@ -141,12 +142,8 @@ impl Expander { | |||
141 | InFile { file_id: self.current_file_id, value } | 142 | InFile { file_id: self.current_file_id, value } |
142 | } | 143 | } |
143 | 144 | ||
144 | pub(crate) fn parse_attrs(&self, owner: &dyn ast::AttrsOwner) -> Attrs { | 145 | pub(crate) fn is_cfg_enabled(&self, owner: &dyn ast::AttrsOwner) -> bool { |
145 | self.cfg_expander.parse_attrs(owner) | 146 | self.cfg_expander.is_cfg_enabled(owner) |
146 | } | ||
147 | |||
148 | pub(crate) fn is_cfg_enabled(&self, attrs: &Attrs) -> bool { | ||
149 | self.cfg_expander.is_cfg_enabled(attrs) | ||
150 | } | 147 | } |
151 | 148 | ||
152 | fn parse_path(&mut self, path: ast::Path) -> Option<Path> { | 149 | fn parse_path(&mut self, path: ast::Path) -> Option<Path> { |