diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-23 15:55:22 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-23 15:55:22 +0100 |
commit | 8df105b8b2061f33ed437a93ff72037a625f1a75 (patch) | |
tree | d7966981b7682eac07a24d57eb24b847323d0d25 /crates/ra_hir_def | |
parent | 7bada8a76dd6438cb6549d735d06e60fc50f6388 (diff) | |
parent | 38e38d9b290ff90973c25a06962b81dbbb5d3d9e (diff) |
Merge #5505
5505: Cleanup CFG API r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/attr.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index e228e2145..70ccd4305 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -5,7 +5,7 @@ use std::{ops, sync::Arc}; | |||
5 | use either::Either; | 5 | use either::Either; |
6 | use hir_expand::{hygiene::Hygiene, AstId, InFile}; | 6 | use hir_expand::{hygiene::Hygiene, AstId, InFile}; |
7 | use mbe::ast_to_token_tree; | 7 | use mbe::ast_to_token_tree; |
8 | use ra_cfg::CfgOptions; | 8 | use ra_cfg::{CfgExpr, CfgOptions}; |
9 | use ra_syntax::{ | 9 | use ra_syntax::{ |
10 | ast::{self, AstNode, AttrsOwner}, | 10 | ast::{self, AstNode, AttrsOwner}, |
11 | SmolStr, | 11 | SmolStr, |
@@ -125,9 +125,12 @@ impl Attrs { | |||
125 | AttrQuery { attrs: self, key } | 125 | AttrQuery { attrs: self, key } |
126 | } | 126 | } |
127 | 127 | ||
128 | pub(crate) fn is_cfg_enabled(&self, cfg_options: &CfgOptions) -> bool { | 128 | pub fn cfg(&self) -> impl Iterator<Item = CfgExpr> + '_ { |
129 | // FIXME: handle cfg_attr :-) | 129 | // FIXME: handle cfg_attr :-) |
130 | self.by_key("cfg").tt_values().all(|tt| cfg_options.is_cfg_enabled(tt) != Some(false)) | 130 | self.by_key("cfg").tt_values().map(CfgExpr::parse) |
131 | } | ||
132 | pub(crate) fn is_cfg_enabled(&self, cfg_options: &CfgOptions) -> bool { | ||
133 | self.cfg().all(|cfg| cfg_options.check(&cfg) != Some(false)) | ||
131 | } | 134 | } |
132 | } | 135 | } |
133 | 136 | ||