mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Merge #8753
8753: internal: expose cfg attrs from hir::Crate r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
6860b647a5
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -480,6 +480,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"base_db",
|
"base_db",
|
||||||
|
"cfg",
|
||||||
"either",
|
"either",
|
||||||
"hir_def",
|
"hir_def",
|
||||||
"hir_expand",
|
"hir_expand",
|
||||||
|
@ -13,7 +13,7 @@ use tt::SmolStr;
|
|||||||
pub use cfg_expr::{CfgAtom, CfgExpr};
|
pub use cfg_expr::{CfgAtom, CfgExpr};
|
||||||
pub use dnf::DnfExpr;
|
pub use dnf::DnfExpr;
|
||||||
|
|
||||||
/// Configuration options used for conditional compilition on items with `cfg` attributes.
|
/// Configuration options used for conditional compilation on items with `cfg` attributes.
|
||||||
/// We have two kind of options in different namespaces: atomic options like `unix`, and
|
/// We have two kind of options in different namespaces: atomic options like `unix`, and
|
||||||
/// key-value options like `target_arch="x86"`.
|
/// key-value options like `target_arch="x86"`.
|
||||||
///
|
///
|
||||||
|
@ -25,3 +25,4 @@ hir_expand = { path = "../hir_expand", version = "0.0.0" }
|
|||||||
hir_def = { path = "../hir_def", version = "0.0.0" }
|
hir_def = { path = "../hir_def", version = "0.0.0" }
|
||||||
hir_ty = { path = "../hir_ty", version = "0.0.0" }
|
hir_ty = { path = "../hir_ty", version = "0.0.0" }
|
||||||
tt = { path = "../tt", version = "0.0.0" }
|
tt = { path = "../tt", version = "0.0.0" }
|
||||||
|
cfg = { path = "../cfg", version = "0.0.0" }
|
||||||
|
@ -89,6 +89,7 @@ pub use crate::{
|
|||||||
// Generally, a refactoring which *removes* a name from this list is a good
|
// Generally, a refactoring which *removes* a name from this list is a good
|
||||||
// idea!
|
// idea!
|
||||||
pub use {
|
pub use {
|
||||||
|
cfg::{CfgAtom, CfgExpr, CfgOptions},
|
||||||
hir_def::{
|
hir_def::{
|
||||||
adt::StructKind,
|
adt::StructKind,
|
||||||
attr::{Attr, Attrs, AttrsWithOwner, Documentation},
|
attr::{Attr, Attrs, AttrsWithOwner, Documentation},
|
||||||
@ -215,6 +216,10 @@ impl Crate {
|
|||||||
|
|
||||||
doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/")
|
doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cfg(&self, db: &dyn HirDatabase) -> CfgOptions {
|
||||||
|
db.crate_graph()[self.id].cfg_options.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user