diff options
author | Aleksey Kladov <[email protected]> | 2021-05-07 21:35:43 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-05-07 21:50:24 +0100 |
commit | 53f7149d4510137111ed810803e9529157537288 (patch) | |
tree | ab508ae06c161225c9f70452c6c54decd02d0e54 /crates/hir | |
parent | ba8620398713d6f116dd1cce1a7e1cd6e3f97461 (diff) |
internal: expose cfg attrs from hir::Crate
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/crates/hir/Cargo.toml b/crates/hir/Cargo.toml index 9e329656f..560b15238 100644 --- a/crates/hir/Cargo.toml +++ b/crates/hir/Cargo.toml | |||
@@ -25,3 +25,4 @@ hir_expand = { path = "../hir_expand", version = "0.0.0" } | |||
25 | hir_def = { path = "../hir_def", version = "0.0.0" } | 25 | hir_def = { path = "../hir_def", version = "0.0.0" } |
26 | hir_ty = { path = "../hir_ty", version = "0.0.0" } | 26 | hir_ty = { path = "../hir_ty", version = "0.0.0" } |
27 | tt = { path = "../tt", version = "0.0.0" } | 27 | tt = { path = "../tt", version = "0.0.0" } |
28 | cfg = { path = "../cfg", version = "0.0.0" } | ||
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index f876339de..ac23e385e 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -89,6 +89,7 @@ pub use crate::{ | |||
89 | // Generally, a refactoring which *removes* a name from this list is a good | 89 | // Generally, a refactoring which *removes* a name from this list is a good |
90 | // idea! | 90 | // idea! |
91 | pub use { | 91 | pub use { |
92 | cfg::{CfgAtom, CfgExpr, CfgOptions}, | ||
92 | hir_def::{ | 93 | hir_def::{ |
93 | adt::StructKind, | 94 | adt::StructKind, |
94 | attr::{Attr, Attrs, AttrsWithOwner, Documentation}, | 95 | attr::{Attr, Attrs, AttrsWithOwner, Documentation}, |
@@ -215,6 +216,10 @@ impl Crate { | |||
215 | 216 | ||
216 | doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/") | 217 | doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/") |
217 | } | 218 | } |
219 | |||
220 | pub fn cfg(&self, db: &dyn HirDatabase) -> CfgOptions { | ||
221 | db.crate_graph()[self.id].cfg_options.clone() | ||
222 | } | ||
218 | } | 223 | } |
219 | 224 | ||
220 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 225 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |