aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--crates/cfg/src/lib.rs2
-rw-r--r--crates/hir/Cargo.toml1
-rw-r--r--crates/hir/src/lib.rs5
4 files changed, 8 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f3a512a8a..0e1234b72 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -480,6 +480,7 @@ version = "0.0.0"
480dependencies = [ 480dependencies = [
481 "arrayvec", 481 "arrayvec",
482 "base_db", 482 "base_db",
483 "cfg",
483 "either", 484 "either",
484 "hir_def", 485 "hir_def",
485 "hir_expand", 486 "hir_expand",
diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs
index d88ecf8b0..59fd38880 100644
--- a/crates/cfg/src/lib.rs
+++ b/crates/cfg/src/lib.rs
@@ -13,7 +13,7 @@ use tt::SmolStr;
13pub use cfg_expr::{CfgAtom, CfgExpr}; 13pub use cfg_expr::{CfgAtom, CfgExpr};
14pub use dnf::DnfExpr; 14pub use dnf::DnfExpr;
15 15
16/// Configuration options used for conditional compilition on items with `cfg` attributes. 16/// Configuration options used for conditional compilation on items with `cfg` attributes.
17/// We have two kind of options in different namespaces: atomic options like `unix`, and 17/// We have two kind of options in different namespaces: atomic options like `unix`, and
18/// key-value options like `target_arch="x86"`. 18/// key-value options like `target_arch="x86"`.
19/// 19///
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" }
25hir_def = { path = "../hir_def", version = "0.0.0" } 25hir_def = { path = "../hir_def", version = "0.0.0" }
26hir_ty = { path = "../hir_ty", version = "0.0.0" } 26hir_ty = { path = "../hir_ty", version = "0.0.0" }
27tt = { path = "../tt", version = "0.0.0" } 27tt = { path = "../tt", version = "0.0.0" }
28cfg = { 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!
91pub use { 91pub 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)]