aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/attr.rs
diff options
context:
space:
mode:
authorBenjamin Coenen <[email protected]>2020-04-09 17:32:02 +0100
committerBenjamin Coenen <[email protected]>2020-04-09 17:32:02 +0100
commitfc70cf9458c5234decafdd52b9aced790ac43d7a (patch)
tree4e27e34d8fff2746731c4a1bce938c784b804661 /crates/ra_hir_def/src/attr.rs
parent85956932872481cf4813c5e7794d981a9edb4623 (diff)
feat: add support for feature attributes in struct literal
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/attr.rs')
-rw-r--r--crates/ra_hir_def/src/attr.rs5
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};
5use either::Either; 5use either::Either;
6use hir_expand::{hygiene::Hygiene, AstId, InFile}; 6use hir_expand::{hygiene::Hygiene, AstId, InFile};
7use mbe::ast_to_token_tree; 7use mbe::ast_to_token_tree;
8use ra_cfg::CfgOptions;
8use ra_syntax::{ 9use 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)]