diff options
author | Benjamin Coenen <[email protected]> | 2020-04-09 17:32:02 +0100 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-04-09 17:32:02 +0100 |
commit | fc70cf9458c5234decafdd52b9aced790ac43d7a (patch) | |
tree | 4e27e34d8fff2746731c4a1bce938c784b804661 /crates/ra_hir_def/src/attr.rs | |
parent | 85956932872481cf4813c5e7794d981a9edb4623 (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.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)] |