diff options
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 35 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 52 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/scope.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/per_ns.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 6 | ||||
-rw-r--r-- | xtask/tests/tidy-tests/docs.rs | 1 |
8 files changed, 51 insertions, 61 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 263c557f3..96a5cc857 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -973,6 +973,41 @@ pub struct ImplBlock { | |||
973 | pub(crate) id: ImplId, | 973 | pub(crate) id: ImplId, |
974 | } | 974 | } |
975 | 975 | ||
976 | impl ImplBlock { | ||
977 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { | ||
978 | db.impl_data(self.id).target_trait.clone() | ||
979 | } | ||
980 | |||
981 | pub fn target_type(&self, db: &impl DefDatabase) -> TypeRef { | ||
982 | db.impl_data(self.id).target_type.clone() | ||
983 | } | ||
984 | |||
985 | pub fn target_ty(&self, db: &impl HirDatabase) -> Ty { | ||
986 | Ty::from_hir(db, &self.id.resolver(db), &self.target_type(db)) | ||
987 | } | ||
988 | |||
989 | pub fn target_trait_ref(&self, db: &impl HirDatabase) -> Option<TraitRef> { | ||
990 | let target_ty = self.target_ty(db); | ||
991 | TraitRef::from_hir(db, &self.id.resolver(db), &self.target_trait(db)?, Some(target_ty)) | ||
992 | } | ||
993 | |||
994 | pub fn items(&self, db: &impl DefDatabase) -> Vec<AssocItem> { | ||
995 | db.impl_data(self.id).items.iter().map(|it| (*it).into()).collect() | ||
996 | } | ||
997 | |||
998 | pub fn is_negative(&self, db: &impl DefDatabase) -> bool { | ||
999 | db.impl_data(self.id).is_negative | ||
1000 | } | ||
1001 | |||
1002 | pub fn module(&self, db: &impl DefDatabase) -> Module { | ||
1003 | self.id.module(db).into() | ||
1004 | } | ||
1005 | |||
1006 | pub fn krate(&self, db: &impl DefDatabase) -> Crate { | ||
1007 | Crate { crate_id: self.module(db).id.krate } | ||
1008 | } | ||
1009 | } | ||
1010 | |||
976 | /// For IDE only | 1011 | /// For IDE only |
977 | pub enum ScopeDef { | 1012 | pub enum ScopeDef { |
978 | ModuleDef(ModuleDef), | 1013 | ModuleDef(ModuleDef), |
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index a0e605603..a4e317c20 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -5,8 +5,8 @@ use hir_expand::either::Either; | |||
5 | use ra_syntax::ast; | 5 | use ra_syntax::ast; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, Import, MacroDef, Module, | 8 | db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, Import, MacroDef, |
9 | ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, | 9 | Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, |
10 | }; | 10 | }; |
11 | 11 | ||
12 | pub use hir_expand::Source; | 12 | pub use hir_expand::Source; |
@@ -108,6 +108,12 @@ impl HasSource for MacroDef { | |||
108 | Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) } | 108 | Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) } |
109 | } | 109 | } |
110 | } | 110 | } |
111 | impl HasSource for ImplBlock { | ||
112 | type Ast = ast::ImplBlock; | ||
113 | fn source(self, db: &impl DefDatabase) -> Source<ast::ImplBlock> { | ||
114 | self.id.source(db) | ||
115 | } | ||
116 | } | ||
111 | impl HasSource for Import { | 117 | impl HasSource for Import { |
112 | type Ast = Either<ast::UseTree, ast::ExternCrateItem>; | 118 | type Ast = Either<ast::UseTree, ast::ExternCrateItem>; |
113 | 119 | ||
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs deleted file mode 100644 index 334eeebac..000000000 --- a/crates/ra_hir/src/impl_block.rs +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use hir_def::{resolver::HasResolver, type_ref::TypeRef, AstItemDef}; | ||
4 | use ra_syntax::ast; | ||
5 | |||
6 | use crate::{ | ||
7 | db::{AstDatabase, DefDatabase, HirDatabase}, | ||
8 | ty::Ty, | ||
9 | AssocItem, Crate, HasSource, ImplBlock, Module, Source, TraitRef, | ||
10 | }; | ||
11 | |||
12 | impl HasSource for ImplBlock { | ||
13 | type Ast = ast::ImplBlock; | ||
14 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::ImplBlock> { | ||
15 | self.id.source(db) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | impl ImplBlock { | ||
20 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { | ||
21 | db.impl_data(self.id).target_trait.clone() | ||
22 | } | ||
23 | |||
24 | pub fn target_type(&self, db: &impl DefDatabase) -> TypeRef { | ||
25 | db.impl_data(self.id).target_type.clone() | ||
26 | } | ||
27 | |||
28 | pub fn target_ty(&self, db: &impl HirDatabase) -> Ty { | ||
29 | Ty::from_hir(db, &self.id.resolver(db), &self.target_type(db)) | ||
30 | } | ||
31 | |||
32 | pub fn target_trait_ref(&self, db: &impl HirDatabase) -> Option<TraitRef> { | ||
33 | let target_ty = self.target_ty(db); | ||
34 | TraitRef::from_hir(db, &self.id.resolver(db), &self.target_trait(db)?, Some(target_ty)) | ||
35 | } | ||
36 | |||
37 | pub fn items(&self, db: &impl DefDatabase) -> Vec<AssocItem> { | ||
38 | db.impl_data(self.id).items.iter().map(|it| (*it).into()).collect() | ||
39 | } | ||
40 | |||
41 | pub fn is_negative(&self, db: &impl DefDatabase) -> bool { | ||
42 | db.impl_data(self.id).is_negative | ||
43 | } | ||
44 | |||
45 | pub fn module(&self, db: &impl DefDatabase) -> Module { | ||
46 | self.id.module(db).into() | ||
47 | } | ||
48 | |||
49 | pub fn krate(&self, db: &impl DefDatabase) -> Crate { | ||
50 | Crate { crate_id: self.module(db).id.krate } | ||
51 | } | ||
52 | } | ||
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 70bba2efb..843ce6a88 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -32,7 +32,6 @@ pub mod db; | |||
32 | pub mod source_binder; | 32 | pub mod source_binder; |
33 | 33 | ||
34 | mod ty; | 34 | mod ty; |
35 | mod impl_block; | ||
36 | mod expr; | 35 | mod expr; |
37 | pub mod diagnostics; | 36 | pub mod diagnostics; |
38 | mod util; | 37 | mod util; |
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 5240a59d5..625aa39dd 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Name resolution for expressions. |
2 | use std::sync::Arc; | 2 | use std::sync::Arc; |
3 | 3 | ||
4 | use hir_expand::name::Name; | 4 | use hir_expand::name::Name; |
diff --git a/crates/ra_hir_def/src/per_ns.rs b/crates/ra_hir_def/src/per_ns.rs index 06ef6c9fc..00e866bf9 100644 --- a/crates/ra_hir_def/src/per_ns.rs +++ b/crates/ra_hir_def/src/per_ns.rs | |||
@@ -1,4 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! In rust, it is possible to have a value, a type and a macro with the same |
2 | //! name without conflicts. | ||
3 | //! | ||
4 | //! `PerNs` (per namespace) captures this. | ||
2 | 5 | ||
3 | use hir_expand::MacroDefId; | 6 | use hir_expand::MacroDefId; |
4 | 7 | ||
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index c24a9b165..1f8887c6b 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs | |||
@@ -29,20 +29,20 @@ pub struct Resolver { | |||
29 | 29 | ||
30 | // FIXME how to store these best | 30 | // FIXME how to store these best |
31 | #[derive(Debug, Clone)] | 31 | #[derive(Debug, Clone)] |
32 | pub(crate) struct ModuleItemMap { | 32 | struct ModuleItemMap { |
33 | crate_def_map: Arc<CrateDefMap>, | 33 | crate_def_map: Arc<CrateDefMap>, |
34 | module_id: LocalModuleId, | 34 | module_id: LocalModuleId, |
35 | } | 35 | } |
36 | 36 | ||
37 | #[derive(Debug, Clone)] | 37 | #[derive(Debug, Clone)] |
38 | pub(crate) struct ExprScope { | 38 | struct ExprScope { |
39 | owner: DefWithBodyId, | 39 | owner: DefWithBodyId, |
40 | expr_scopes: Arc<ExprScopes>, | 40 | expr_scopes: Arc<ExprScopes>, |
41 | scope_id: ScopeId, | 41 | scope_id: ScopeId, |
42 | } | 42 | } |
43 | 43 | ||
44 | #[derive(Debug, Clone)] | 44 | #[derive(Debug, Clone)] |
45 | pub(crate) enum Scope { | 45 | enum Scope { |
46 | /// All the items and imported names of a module | 46 | /// All the items and imported names of a module |
47 | ModuleScope(ModuleItemMap), | 47 | ModuleScope(ModuleItemMap), |
48 | /// Brings the generic parameters of an item into scope | 48 | /// Brings the generic parameters of an item into scope |
diff --git a/xtask/tests/tidy-tests/docs.rs b/xtask/tests/tidy-tests/docs.rs index 141219860..fae871285 100644 --- a/xtask/tests/tidy-tests/docs.rs +++ b/xtask/tests/tidy-tests/docs.rs | |||
@@ -74,7 +74,6 @@ fn no_docs_comments() { | |||
74 | "ra_db", | 74 | "ra_db", |
75 | "ra_hir", | 75 | "ra_hir", |
76 | "ra_hir_expand", | 76 | "ra_hir_expand", |
77 | "ra_hir_def", | ||
78 | "ra_ide_api", | 77 | "ra_ide_api", |
79 | "ra_lsp_server", | 78 | "ra_lsp_server", |
80 | "ra_mbe", | 79 | "ra_mbe", |