aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs27
-rw-r--r--crates/ra_hir/src/lib.rs1
2 files changed, 19 insertions, 9 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 840cfdfc8..4a06f3bcd 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -532,7 +532,7 @@ impl Adt {
532 Some(self.module(db).krate()) 532 Some(self.module(db).krate())
533 } 533 }
534 534
535 pub fn name(&self, db: &dyn HirDatabase) -> Name { 535 pub fn name(self, db: &dyn HirDatabase) -> Name {
536 match self { 536 match self {
537 Adt::Struct(s) => s.name(db), 537 Adt::Struct(s) => s.name(db),
538 Adt::Union(u) => u.name(db), 538 Adt::Union(u) => u.name(db),
@@ -637,6 +637,10 @@ impl Function {
637 db.function_data(self.id).params.clone() 637 db.function_data(self.id).params.clone()
638 } 638 }
639 639
640 pub fn is_unsafe(self, db: &dyn HirDatabase) -> bool {
641 db.function_data(self.id).is_unsafe
642 }
643
640 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { 644 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
641 let _p = profile("Function::diagnostics"); 645 let _p = profile("Function::diagnostics");
642 let infer = db.infer(self.id.into()); 646 let infer = db.infer(self.id.into());
@@ -1018,15 +1022,15 @@ impl ImplDef {
1018 impls.lookup_impl_defs_for_trait(trait_.id).map(Self::from).collect() 1022 impls.lookup_impl_defs_for_trait(trait_.id).map(Self::from).collect()
1019 } 1023 }
1020 1024
1021 pub fn target_trait(&self, db: &dyn HirDatabase) -> Option<TypeRef> { 1025 pub fn target_trait(self, db: &dyn HirDatabase) -> Option<TypeRef> {
1022 db.impl_data(self.id).target_trait.clone() 1026 db.impl_data(self.id).target_trait.clone()
1023 } 1027 }
1024 1028
1025 pub fn target_type(&self, db: &dyn HirDatabase) -> TypeRef { 1029 pub fn target_type(self, db: &dyn HirDatabase) -> TypeRef {
1026 db.impl_data(self.id).target_type.clone() 1030 db.impl_data(self.id).target_type.clone()
1027 } 1031 }
1028 1032
1029 pub fn target_ty(&self, db: &dyn HirDatabase) -> Type { 1033 pub fn target_ty(self, db: &dyn HirDatabase) -> Type {
1030 let impl_data = db.impl_data(self.id); 1034 let impl_data = db.impl_data(self.id);
1031 let resolver = self.id.resolver(db.upcast()); 1035 let resolver = self.id.resolver(db.upcast());
1032 let ctx = hir_ty::TyLoweringContext::new(db, &resolver); 1036 let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
@@ -1038,23 +1042,23 @@ impl ImplDef {
1038 } 1042 }
1039 } 1043 }
1040 1044
1041 pub fn items(&self, db: &dyn HirDatabase) -> Vec<AssocItem> { 1045 pub fn items(self, db: &dyn HirDatabase) -> Vec<AssocItem> {
1042 db.impl_data(self.id).items.iter().map(|it| (*it).into()).collect() 1046 db.impl_data(self.id).items.iter().map(|it| (*it).into()).collect()
1043 } 1047 }
1044 1048
1045 pub fn is_negative(&self, db: &dyn HirDatabase) -> bool { 1049 pub fn is_negative(self, db: &dyn HirDatabase) -> bool {
1046 db.impl_data(self.id).is_negative 1050 db.impl_data(self.id).is_negative
1047 } 1051 }
1048 1052
1049 pub fn module(&self, db: &dyn HirDatabase) -> Module { 1053 pub fn module(self, db: &dyn HirDatabase) -> Module {
1050 self.id.lookup(db.upcast()).container.module(db.upcast()).into() 1054 self.id.lookup(db.upcast()).container.module(db.upcast()).into()
1051 } 1055 }
1052 1056
1053 pub fn krate(&self, db: &dyn HirDatabase) -> Crate { 1057 pub fn krate(self, db: &dyn HirDatabase) -> Crate {
1054 Crate { id: self.module(db).id.krate } 1058 Crate { id: self.module(db).id.krate }
1055 } 1059 }
1056 1060
1057 pub fn is_builtin_derive(&self, db: &dyn HirDatabase) -> Option<InFile<ast::Attr>> { 1061 pub fn is_builtin_derive(self, db: &dyn HirDatabase) -> Option<InFile<ast::Attr>> {
1058 let src = self.source(db); 1062 let src = self.source(db);
1059 let item = src.file_id.is_builtin_derive(db.upcast())?; 1063 let item = src.file_id.is_builtin_derive(db.upcast())?;
1060 let hygenic = hir_expand::hygiene::Hygiene::new(db.upcast(), item.file_id); 1064 let hygenic = hir_expand::hygiene::Hygiene::new(db.upcast(), item.file_id);
@@ -1190,6 +1194,10 @@ impl Type {
1190 ) 1194 )
1191 } 1195 }
1192 1196
1197 pub fn is_raw_ptr(&self) -> bool {
1198 matches!(&self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::RawPtr(..), .. }))
1199 }
1200
1193 pub fn contains_unknown(&self) -> bool { 1201 pub fn contains_unknown(&self) -> bool {
1194 return go(&self.ty.value); 1202 return go(&self.ty.value);
1195 1203
@@ -1363,6 +1371,7 @@ impl HirDisplay for Type {
1363} 1371}
1364 1372
1365/// For IDE only 1373/// For IDE only
1374#[derive(Debug)]
1366pub enum ScopeDef { 1375pub enum ScopeDef {
1367 ModuleDef(ModuleDef), 1376 ModuleDef(ModuleDef),
1368 MacroDef(MacroDef), 1377 MacroDef(MacroDef),
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 4af0f046a..f4a6b0503 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -62,6 +62,7 @@ pub use crate::{
62 62
63pub use hir_def::{ 63pub use hir_def::{
64 adt::StructKind, 64 adt::StructKind,
65 attr::Attrs,
65 body::scope::ExprScopes, 66 body::scope::ExprScopes,
66 builtin_type::BuiltinType, 67 builtin_type::BuiltinType,
67 docs::Documentation, 68 docs::Documentation,