aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs4
-rw-r--r--crates/ra_hir/src/db.rs4
-rw-r--r--crates/ra_hir/src/lib.rs5
-rw-r--r--crates/ra_hir/src/ty.rs2
-rw-r--r--crates/ra_hir/src/ty/infer/expr.rs6
-rw-r--r--crates/ra_hir/src/ty/infer/path.rs4
-rw-r--r--crates/ra_hir/src/ty/lower.rs15
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs7
8 files changed, 29 insertions, 18 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 181c5d47a..4e273d9e4 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -30,8 +30,8 @@ use crate::{
30 impl_block::ImplBlock, 30 impl_block::ImplBlock,
31 resolve::{Resolver, Scope, TypeNs}, 31 resolve::{Resolver, Scope, TypeNs},
32 traits::TraitData, 32 traits::TraitData,
33 ty::{InferenceResult, TraitRef}, 33 ty::{InferenceResult, Namespace, TraitRef},
34 Either, HasSource, Name, ScopeDef, Ty, {ImportId, Namespace}, 34 Either, HasSource, ImportId, Name, ScopeDef, Ty,
35}; 35};
36 36
37/// hir::Crate describes a single crate. It's the main interface with which 37/// hir::Crate describes a single crate. It's the main interface with which
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index eb66325f7..11b3f94ae 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -14,10 +14,10 @@ use crate::{
14 traits::TraitData, 14 traits::TraitData,
15 ty::{ 15 ty::{
16 method_resolution::CrateImplBlocks, traits::Impl, CallableDef, FnSig, GenericPredicate, 16 method_resolution::CrateImplBlocks, traits::Impl, CallableDef, FnSig, GenericPredicate,
17 InferenceResult, Substs, Ty, TypableDef, TypeCtor, 17 InferenceResult, Namespace, Substs, Ty, TypableDef, TypeCtor,
18 }, 18 },
19 type_alias::TypeAliasData, 19 type_alias::TypeAliasData,
20 Const, ConstData, Crate, DefWithBody, ExprScopes, FnData, Function, Module, Namespace, Static, 20 Const, ConstData, Crate, DefWithBody, ExprScopes, FnData, Function, Module, Static,
21 StructField, Trait, TypeAlias, 21 StructField, Trait, TypeAlias,
22}; 22};
23 23
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index da6aa2ed8..5f2a05e76 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -81,10 +81,7 @@ pub use crate::{
81 81
82pub use hir_def::{ 82pub use hir_def::{
83 builtin_type::BuiltinType, 83 builtin_type::BuiltinType,
84 nameres::{ 84 nameres::{per_ns::PerNs, raw::ImportId},
85 per_ns::{Namespace, PerNs},
86 raw::ImportId,
87 },
88 path::{Path, PathKind}, 85 path::{Path, PathKind},
89 type_ref::Mutability, 86 type_ref::Mutability,
90}; 87};
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index d1a9d7411..cd2ac0e8b 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -27,7 +27,7 @@ pub(crate) use infer::{infer_query, InferTy, InferenceResult};
27pub use lower::CallableDef; 27pub use lower::CallableDef;
28pub(crate) use lower::{ 28pub(crate) use lower::{
29 callable_item_sig, generic_defaults_query, generic_predicates_for_param_query, 29 callable_item_sig, generic_defaults_query, generic_predicates_for_param_query,
30 generic_predicates_query, type_for_def, type_for_field, TypableDef, 30 generic_predicates_query, type_for_def, type_for_field, Namespace, TypableDef,
31}; 31};
32pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; 32pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
33 33
diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs
index a09ef5c5d..4af1d65ee 100644
--- a/crates/ra_hir/src/ty/infer/expr.rs
+++ b/crates/ra_hir/src/ty/infer/expr.rs
@@ -12,10 +12,10 @@ use crate::{
12 expr::{self, Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, 12 expr::{self, Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
13 generics::{GenericParams, HasGenericParams}, 13 generics::{GenericParams, HasGenericParams},
14 ty::{ 14 ty::{
15 autoderef, method_resolution, op, primitive, CallableDef, InferTy, Mutability, Obligation, 15 autoderef, method_resolution, op, primitive, CallableDef, InferTy, Mutability, Namespace,
16 ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk, 16 Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk,
17 }, 17 },
18 Adt, Name, Namespace, 18 Adt, Name,
19}; 19};
20 20
21impl<'a, D: HirDatabase> InferenceContext<'a, D> { 21impl<'a, D: HirDatabase> InferenceContext<'a, D> {
diff --git a/crates/ra_hir/src/ty/infer/path.rs b/crates/ra_hir/src/ty/infer/path.rs
index 59b7f7eb6..865ced5a1 100644
--- a/crates/ra_hir/src/ty/infer/path.rs
+++ b/crates/ra_hir/src/ty/infer/path.rs
@@ -6,8 +6,8 @@ use super::{ExprOrPatId, InferenceContext, TraitRef};
6use crate::{ 6use crate::{
7 db::HirDatabase, 7 db::HirDatabase,
8 resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs}, 8 resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs},
9 ty::{method_resolution, Substs, Ty, TypableDef, TypeWalk}, 9 ty::{method_resolution, Namespace, Substs, Ty, TypableDef, TypeWalk},
10 AssocItem, Container, HasGenericParams, Name, Namespace, Path, 10 AssocItem, Container, HasGenericParams, Name, Path,
11}; 11};
12 12
13impl<'a, D: HirDatabase> InferenceContext<'a, D> { 13impl<'a, D: HirDatabase> InferenceContext<'a, D> {
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index e29ab8492..d26b16cb2 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -29,10 +29,21 @@ use crate::{
29 Adt, 29 Adt,
30 }, 30 },
31 util::make_mut_slice, 31 util::make_mut_slice,
32 Const, Enum, EnumVariant, Function, ModuleDef, Namespace, Path, Static, Struct, StructField, 32 Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField, Trait,
33 Trait, TypeAlias, Union, 33 TypeAlias, Union,
34}; 34};
35 35
36// FIXME: this is only really used in `type_for_def`, which contains a bunch of
37// impossible cases. Perhaps we should recombine `TypeableDef` and `Namespace`
38// into a `AsTypeDef`, `AsValueDef` enums?
39#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
40pub enum Namespace {
41 Types,
42 Values,
43 // Note that only type inference uses this enum, and it doesn't care about macros.
44 // Macro,
45}
46
36impl Ty { 47impl Ty {
37 pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self { 48 pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self {
38 match type_ref { 49 match type_ref {
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 39ef92182..c694952f3 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -18,7 +18,10 @@ use crate::{
18 db::HirDatabase, 18 db::HirDatabase,
19 generics::GenericDef, 19 generics::GenericDef,
20 ty::display::HirDisplay, 20 ty::display::HirDisplay,
21 ty::{ApplicationTy, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk}, 21 ty::{
22 ApplicationTy, GenericPredicate, Namespace, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
23 TypeWalk,
24 },
22 AssocItem, Crate, HasGenericParams, ImplBlock, Trait, TypeAlias, 25 AssocItem, Crate, HasGenericParams, ImplBlock, Trait, TypeAlias,
23}; 26};
24 27
@@ -652,7 +655,7 @@ fn impl_block_datum(
652 }) 655 })
653 .filter_map(|t| { 656 .filter_map(|t| {
654 let assoc_ty = trait_.associated_type_by_name(db, &t.name(db))?; 657 let assoc_ty = trait_.associated_type_by_name(db, &t.name(db))?;
655 let ty = db.type_for_def(t.into(), crate::Namespace::Types).subst(&bound_vars); 658 let ty = db.type_for_def(t.into(), Namespace::Types).subst(&bound_vars);
656 Some(chalk_rust_ir::AssociatedTyValue { 659 Some(chalk_rust_ir::AssociatedTyValue {
657 impl_id, 660 impl_id,
658 associated_ty_id: assoc_ty.to_chalk(db), 661 associated_ty_id: assoc_ty.to_chalk(db),