diff options
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 1a790b2f3..d865c972e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -5,8 +5,15 @@ pub(crate) mod docs; | |||
5 | 5 | ||
6 | use std::sync::Arc; | 6 | use std::sync::Arc; |
7 | 7 | ||
8 | use hir_def::{CrateModuleId, ModuleId}; | 8 | use hir_def::{ |
9 | use ra_db::{CrateId, Edition, FileId}; | 9 | name::{ |
10 | self, AsName, BOOL, CHAR, F32, F64, I128, I16, I32, I64, I8, ISIZE, SELF_TYPE, STR, U128, | ||
11 | U16, U32, U64, U8, USIZE, | ||
12 | }, | ||
13 | type_ref::{Mutability, TypeRef}, | ||
14 | CrateModuleId, ModuleId, | ||
15 | }; | ||
16 | use ra_db::{CrateId, Edition}; | ||
10 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; | 17 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; |
11 | 18 | ||
12 | use crate::{ | 19 | use crate::{ |
@@ -20,10 +27,6 @@ use crate::{ | |||
20 | TypeAliasId, | 27 | TypeAliasId, |
21 | }, | 28 | }, |
22 | impl_block::ImplBlock, | 29 | impl_block::ImplBlock, |
23 | name::{ | ||
24 | BOOL, CHAR, F32, F64, I128, I16, I32, I64, I8, ISIZE, SELF_TYPE, STR, U128, U16, U32, U64, | ||
25 | U8, USIZE, | ||
26 | }, | ||
27 | nameres::{ImportId, ModuleScope, Namespace}, | 30 | nameres::{ImportId, ModuleScope, Namespace}, |
28 | resolve::{Resolver, Scope, TypeNs}, | 31 | resolve::{Resolver, Scope, TypeNs}, |
29 | traits::TraitData, | 32 | traits::TraitData, |
@@ -31,9 +34,7 @@ use crate::{ | |||
31 | primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness}, | 34 | primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness}, |
32 | InferenceResult, TraitRef, | 35 | InferenceResult, TraitRef, |
33 | }, | 36 | }, |
34 | type_ref::Mutability, | 37 | Either, HasSource, Name, Ty, |
35 | type_ref::TypeRef, | ||
36 | AsName, AstId, Either, HasSource, Name, Ty, | ||
37 | }; | 38 | }; |
38 | 39 | ||
39 | /// hir::Crate describes a single crate. It's the main interface with which | 40 | /// hir::Crate describes a single crate. It's the main interface with which |
@@ -147,31 +148,7 @@ impl_froms!( | |||
147 | BuiltinType | 148 | BuiltinType |
148 | ); | 149 | ); |
149 | 150 | ||
150 | pub enum ModuleSource { | 151 | pub use hir_def::ModuleSource; |
151 | SourceFile(ast::SourceFile), | ||
152 | Module(ast::Module), | ||
153 | } | ||
154 | |||
155 | impl ModuleSource { | ||
156 | pub(crate) fn new( | ||
157 | db: &(impl DefDatabase + AstDatabase), | ||
158 | file_id: Option<FileId>, | ||
159 | decl_id: Option<AstId<ast::Module>>, | ||
160 | ) -> ModuleSource { | ||
161 | match (file_id, decl_id) { | ||
162 | (Some(file_id), _) => { | ||
163 | let source_file = db.parse(file_id).tree(); | ||
164 | ModuleSource::SourceFile(source_file) | ||
165 | } | ||
166 | (None, Some(item_id)) => { | ||
167 | let module = item_id.to_node(db); | ||
168 | assert!(module.item_list().is_some(), "expected inline module"); | ||
169 | ModuleSource::Module(module) | ||
170 | } | ||
171 | (None, None) => panic!(), | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | 152 | ||
176 | impl Module { | 153 | impl Module { |
177 | pub(crate) fn new(krate: Crate, crate_module_id: CrateModuleId) -> Module { | 154 | pub(crate) fn new(krate: Crate, crate_module_id: CrateModuleId) -> Module { |
@@ -922,9 +899,7 @@ impl Trait { | |||
922 | .where_predicates | 899 | .where_predicates |
923 | .iter() | 900 | .iter() |
924 | .filter_map(|pred| match &pred.type_ref { | 901 | .filter_map(|pred| match &pred.type_ref { |
925 | TypeRef::Path(p) if p.as_ident() == Some(&crate::name::SELF_TYPE) => { | 902 | TypeRef::Path(p) if p.as_ident() == Some(&name::SELF_TYPE) => pred.bound.as_path(), |
926 | pred.bound.as_path() | ||
927 | } | ||
928 | _ => None, | 903 | _ => None, |
929 | }) | 904 | }) |
930 | .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path) { | 905 | .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path) { |