diff options
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 18 |
2 files changed, 18 insertions, 1 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..d443b124c 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -52,7 +52,9 @@ use hir_def::{ | |||
52 | }; | 52 | }; |
53 | use hir_expand::{diagnostics::DiagnosticSink, name::name, MacroDefKind}; | 53 | use hir_expand::{diagnostics::DiagnosticSink, name::name, MacroDefKind}; |
54 | use hir_ty::{ | 54 | use hir_ty::{ |
55 | autoderef, could_unify, | 55 | autoderef, |
56 | consteval::ConstExt, | ||
57 | could_unify, | ||
56 | method_resolution::{self, def_crates, TyFingerprint}, | 58 | method_resolution::{self, def_crates, TyFingerprint}, |
57 | primitive::UintTy, | 59 | primitive::UintTy, |
58 | subst_prefix, | 60 | subst_prefix, |
@@ -89,6 +91,7 @@ pub use crate::{ | |||
89 | // Generally, a refactoring which *removes* a name from this list is a good | 91 | // Generally, a refactoring which *removes* a name from this list is a good |
90 | // idea! | 92 | // idea! |
91 | pub use { | 93 | pub use { |
94 | cfg::{CfgAtom, CfgExpr, CfgOptions}, | ||
92 | hir_def::{ | 95 | hir_def::{ |
93 | adt::StructKind, | 96 | adt::StructKind, |
94 | attr::{Attr, Attrs, AttrsWithOwner, Documentation}, | 97 | attr::{Attr, Attrs, AttrsWithOwner, Documentation}, |
@@ -215,6 +218,10 @@ impl Crate { | |||
215 | 218 | ||
216 | doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/") | 219 | doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/") |
217 | } | 220 | } |
221 | |||
222 | pub fn cfg(&self, db: &dyn HirDatabase) -> CfgOptions { | ||
223 | db.crate_graph()[self.id].cfg_options.clone() | ||
224 | } | ||
218 | } | 225 | } |
219 | 226 | ||
220 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 227 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
@@ -868,6 +875,10 @@ impl Function { | |||
868 | db.function_data(self.id).is_unsafe() | 875 | db.function_data(self.id).is_unsafe() |
869 | } | 876 | } |
870 | 877 | ||
878 | pub fn is_async(self, db: &dyn HirDatabase) -> bool { | ||
879 | db.function_data(self.id).is_async() | ||
880 | } | ||
881 | |||
871 | pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { | 882 | pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { |
872 | let krate = self.module(db).id.krate(); | 883 | let krate = self.module(db).id.krate(); |
873 | hir_def::diagnostics::validate_body(db.upcast(), self.id.into(), sink); | 884 | hir_def::diagnostics::validate_body(db.upcast(), self.id.into(), sink); |
@@ -1905,6 +1916,7 @@ impl Type { | |||
1905 | substs.iter(&Interner).filter_map(|a| a.ty(&Interner)).any(go) | 1916 | substs.iter(&Interner).filter_map(|a| a.ty(&Interner)).any(go) |
1906 | } | 1917 | } |
1907 | 1918 | ||
1919 | TyKind::Array(_ty, len) if len.is_unknown() => true, | ||
1908 | TyKind::Array(ty, _) | 1920 | TyKind::Array(ty, _) |
1909 | | TyKind::Slice(ty) | 1921 | | TyKind::Slice(ty) |
1910 | | TyKind::Raw(_, ty) | 1922 | | TyKind::Raw(_, ty) |
@@ -2066,6 +2078,10 @@ impl Type { | |||
2066 | Some(adt.into()) | 2078 | Some(adt.into()) |
2067 | } | 2079 | } |
2068 | 2080 | ||
2081 | pub fn as_builtin(&self) -> Option<BuiltinType> { | ||
2082 | self.ty.as_builtin().map(|inner| BuiltinType { inner }) | ||
2083 | } | ||
2084 | |||
2069 | pub fn as_dyn_trait(&self) -> Option<Trait> { | 2085 | pub fn as_dyn_trait(&self) -> Option<Trait> { |
2070 | self.ty.dyn_trait().map(Into::into) | 2086 | self.ty.dyn_trait().map(Into::into) |
2071 | } | 2087 | } |