Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/attrs.rs')
-rw-r--r--crates/hir-expand/src/attrs.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/hir-expand/src/attrs.rs b/crates/hir-expand/src/attrs.rs
index 3ff18e982e..0c369a18bb 100644
--- a/crates/hir-expand/src/attrs.rs
+++ b/crates/hir-expand/src/attrs.rs
@@ -309,6 +309,14 @@ impl Attr {
Some(paths)
}
+
+ pub fn cfg(&self) -> Option<CfgExpr> {
+ if *self.path.as_ident()? == crate::name![cfg] {
+ self.token_tree_value().map(CfgExpr::parse)
+ } else {
+ None
+ }
+ }
}
pub fn collect_attrs(