diff options
Diffstat (limited to 'crates/ra_hir_def/src/attr.rs')
-rw-r--r-- | crates/ra_hir_def/src/attr.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 71a18f5e1..7b0c506b1 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -5,6 +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_syntax::{ | 9 | use ra_syntax::{ |
9 | ast::{self, AstNode, AttrsOwner}, | 10 | ast::{self, AstNode, AttrsOwner}, |
10 | SmolStr, | 11 | SmolStr, |
@@ -90,6 +91,10 @@ impl Attrs { | |||
90 | pub fn by_key(&self, key: &'static str) -> AttrQuery<'_> { | 91 | pub fn by_key(&self, key: &'static str) -> AttrQuery<'_> { |
91 | AttrQuery { attrs: self, key } | 92 | AttrQuery { attrs: self, key } |
92 | } | 93 | } |
94 | |||
95 | pub(crate) fn is_cfg_enabled(&self, cfg_options: &CfgOptions) -> bool { | ||
96 | self.by_key("cfg").tt_values().all(|tt| cfg_options.is_cfg_enabled(tt) != Some(false)) | ||
97 | } | ||
93 | } | 98 | } |
94 | 99 | ||
95 | #[derive(Debug, Clone, PartialEq, Eq)] | 100 | #[derive(Debug, Clone, PartialEq, Eq)] |