aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-11-12 01:17:52 +0000
committerSeivan Heidari <[email protected]>2019-11-12 01:17:52 +0000
commite847822cec025e483109cddee9c5dadc91ce1eab (patch)
treeec371bec3ac14e44d3c707250ef9e3afc3111d00 /crates/ra_hir
parent68a5ff050faf514e9d122212a66703ca8ce66ab7 (diff)
parent602f11f27bec82ae646b46e5266d8c202c39e431 (diff)
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs8
-rw-r--r--crates/ra_hir/src/lib.rs8
-rw-r--r--crates/ra_hir/src/source_binder.rs11
-rw-r--r--crates/ra_hir/src/ty.rs12
-rw-r--r--crates/ra_hir/src/ty/autoderef.rs2
-rw-r--r--crates/ra_hir/src/ty/infer/path.rs3
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs4
7 files changed, 29 insertions, 19 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 09c4e97fa..5a0bd0c19 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -23,7 +23,7 @@ use crate::{
23 adt::VariantDef, 23 adt::VariantDef,
24 db::{AstDatabase, DefDatabase, HirDatabase}, 24 db::{AstDatabase, DefDatabase, HirDatabase},
25 expr::{validation::ExprValidator, BindingAnnotation, Body, BodySourceMap, Pat, PatId}, 25 expr::{validation::ExprValidator, BindingAnnotation, Body, BodySourceMap, Pat, PatId},
26 generics::HasGenericParams, 26 generics::{GenericDef, HasGenericParams},
27 ids::{ 27 ids::{
28 AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId, 28 AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
29 TypeAliasId, 29 TypeAliasId,
@@ -1121,3 +1121,9 @@ impl Local {
1121 src.map(|ast| ast.map(|it| it.cast().unwrap().to_node(&root), |it| it.to_node(&root))) 1121 src.map(|ast| ast.map(|it| it.cast().unwrap().to_node(&root), |it| it.to_node(&root)))
1122 } 1122 }
1123} 1123}
1124
1125#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1126pub struct GenericParam {
1127 pub(crate) parent: GenericDef,
1128 pub(crate) idx: u32,
1129}
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 806f1daed..92d71b9e8 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -39,7 +39,7 @@ mod ty;
39mod impl_block; 39mod impl_block;
40mod expr; 40mod expr;
41mod lang_item; 41mod lang_item;
42mod generics; 42pub mod generics;
43mod resolve; 43mod resolve;
44pub mod diagnostics; 44pub mod diagnostics;
45mod util; 45mod util;
@@ -65,12 +65,12 @@ pub use crate::{
65 docs::{DocDef, Docs, Documentation}, 65 docs::{DocDef, Docs, Documentation},
66 src::{HasBodySource, HasSource}, 66 src::{HasBodySource, HasSource},
67 Adt, AssocItem, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum, 67 Adt, AssocItem, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
68 EnumVariant, FieldSource, FnData, Function, HasBody, Local, MacroDef, Module, ModuleDef, 68 EnumVariant, FieldSource, FnData, Function, GenericParam, HasBody, Local, MacroDef, Module,
69 ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, 69 ModuleDef, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
70 }, 70 },
71 expr::ExprScopes, 71 expr::ExprScopes,
72 from_source::FromSource, 72 from_source::FromSource,
73 generics::{GenericDef, GenericParam, GenericParams, HasGenericParams}, 73 generics::GenericDef,
74 ids::{HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile}, 74 ids::{HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile},
75 impl_block::ImplBlock, 75 impl_block::ImplBlock,
76 resolve::ScopeDef, 76 resolve::ScopeDef,
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index c5fdf3bab..fe4211819 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -28,8 +28,8 @@ use crate::{
28 ids::LocationCtx, 28 ids::LocationCtx,
29 resolve::{ScopeDef, TypeNs, ValueNs}, 29 resolve::{ScopeDef, TypeNs, ValueNs},
30 ty::method_resolution::{self, implements_trait}, 30 ty::method_resolution::{self, implements_trait},
31 AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, HasBody, HirFileId, Local, 31 AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, GenericParam, HasBody,
32 MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty, 32 HirFileId, Local, MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty,
33}; 33};
34 34
35fn try_get_resolver_for_node( 35fn try_get_resolver_for_node(
@@ -107,7 +107,7 @@ pub enum PathResolution {
107 /// A local binding (only value namespace) 107 /// A local binding (only value namespace)
108 Local(Local), 108 Local(Local),
109 /// A generic parameter 109 /// A generic parameter
110 GenericParam(u32), 110 GenericParam(GenericParam),
111 SelfType(crate::ImplBlock), 111 SelfType(crate::ImplBlock),
112 Macro(MacroDef), 112 Macro(MacroDef),
113 AssocItem(crate::AssocItem), 113 AssocItem(crate::AssocItem),
@@ -227,7 +227,10 @@ impl SourceAnalyzer {
227 ) -> Option<PathResolution> { 227 ) -> Option<PathResolution> {
228 let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { 228 let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty {
229 TypeNs::SelfType(it) => PathResolution::SelfType(it), 229 TypeNs::SelfType(it) => PathResolution::SelfType(it),
230 TypeNs::GenericParam(it) => PathResolution::GenericParam(it), 230 TypeNs::GenericParam(idx) => PathResolution::GenericParam(GenericParam {
231 parent: self.resolver.generic_def().unwrap(),
232 idx,
233 }),
231 TypeNs::AdtSelfType(it) | TypeNs::Adt(it) => PathResolution::Def(it.into()), 234 TypeNs::AdtSelfType(it) | TypeNs::Adt(it) => PathResolution::Def(it.into()),
232 TypeNs::EnumVariant(it) => PathResolution::Def(it.into()), 235 TypeNs::EnumVariant(it) => PathResolution::Def(it.into()),
233 TypeNs::TypeAlias(it) => PathResolution::Def(it.into()), 236 TypeNs::TypeAlias(it) => PathResolution::Def(it.into()),
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index cd2ac0e8b..6f24cfad6 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -17,8 +17,11 @@ use std::sync::Arc;
17use std::{fmt, iter, mem}; 17use std::{fmt, iter, mem};
18 18
19use crate::{ 19use crate::{
20 db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, DefWithBody, GenericParams, 20 db::HirDatabase,
21 HasGenericParams, Mutability, Name, Trait, TypeAlias, 21 expr::ExprId,
22 generics::{GenericParams, HasGenericParams},
23 util::make_mut_slice,
24 Adt, Crate, DefWithBody, Mutability, Name, Trait, TypeAlias,
22}; 25};
23use display::{HirDisplay, HirFormatter}; 26use display::{HirDisplay, HirFormatter};
24 27
@@ -342,10 +345,7 @@ impl Substs {
342 ) 345 )
343 } 346 }
344 347
345 pub fn build_for_def( 348 pub fn build_for_def(db: &impl HirDatabase, def: impl HasGenericParams) -> SubstsBuilder {
346 db: &impl HirDatabase,
347 def: impl crate::HasGenericParams,
348 ) -> SubstsBuilder {
349 let params = def.generic_params(db); 349 let params = def.generic_params(db);
350 let param_count = params.count_params_including_parent(); 350 let param_count = params.count_params_including_parent();
351 Substs::builder(param_count) 351 Substs::builder(param_count)
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs
index 3645ee831..872a4517d 100644
--- a/crates/ra_hir/src/ty/autoderef.rs
+++ b/crates/ra_hir/src/ty/autoderef.rs
@@ -9,7 +9,7 @@ use hir_expand::name;
9use log::{info, warn}; 9use log::{info, warn};
10 10
11use super::{traits::Solution, Canonical, Substs, Ty, TypeWalk}; 11use super::{traits::Solution, Canonical, Substs, Ty, TypeWalk};
12use crate::{db::HirDatabase, HasGenericParams, Resolver}; 12use crate::{db::HirDatabase, generics::HasGenericParams, Resolver};
13 13
14const AUTODEREF_RECURSION_LIMIT: usize = 10; 14const AUTODEREF_RECURSION_LIMIT: usize = 10;
15 15
diff --git a/crates/ra_hir/src/ty/infer/path.rs b/crates/ra_hir/src/ty/infer/path.rs
index 865ced5a1..31ca675aa 100644
--- a/crates/ra_hir/src/ty/infer/path.rs
+++ b/crates/ra_hir/src/ty/infer/path.rs
@@ -5,9 +5,10 @@ use hir_def::path::PathSegment;
5use super::{ExprOrPatId, InferenceContext, TraitRef}; 5use super::{ExprOrPatId, InferenceContext, TraitRef};
6use crate::{ 6use crate::{
7 db::HirDatabase, 7 db::HirDatabase,
8 generics::HasGenericParams,
8 resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs}, 9 resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs},
9 ty::{method_resolution, Namespace, Substs, Ty, TypableDef, TypeWalk}, 10 ty::{method_resolution, Namespace, Substs, Ty, TypableDef, TypeWalk},
10 AssocItem, Container, HasGenericParams, Name, Path, 11 AssocItem, Container, Name, Path,
11}; 12};
12 13
13impl<'a, D: HirDatabase> InferenceContext<'a, D> { 14impl<'a, D: HirDatabase> InferenceContext<'a, D> {
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index c694952f3..14c54b9fb 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -16,13 +16,13 @@ use ra_db::salsa::{InternId, InternKey};
16use super::{Canonical, ChalkContext, Impl, Obligation}; 16use super::{Canonical, ChalkContext, Impl, Obligation};
17use crate::{ 17use crate::{
18 db::HirDatabase, 18 db::HirDatabase,
19 generics::GenericDef, 19 generics::{GenericDef, HasGenericParams},
20 ty::display::HirDisplay, 20 ty::display::HirDisplay,
21 ty::{ 21 ty::{
22 ApplicationTy, GenericPredicate, Namespace, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, 22 ApplicationTy, GenericPredicate, Namespace, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
23 TypeWalk, 23 TypeWalk,
24 }, 24 },
25 AssocItem, Crate, HasGenericParams, ImplBlock, Trait, TypeAlias, 25 AssocItem, Crate, ImplBlock, Trait, TypeAlias,
26}; 26};
27 27
28/// This represents a trait whose name we could not resolve. 28/// This represents a trait whose name we could not resolve.