diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-04 20:03:11 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-04 20:03:11 +0000 |
commit | c08cff4fd67bf754897afa45c856f4b9025b9015 (patch) | |
tree | e70984d904f5ce4d6a9719060c6ee7a46fe14637 | |
parent | 9c93fbf346b351795c2e526f5ff7fa693aa50609 (diff) | |
parent | 739babc39188c93eda82ce16a24680bbf2463fa1 (diff) |
Merge #2176
2176: Move Namespace enum closer to usage r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer/expr.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer/path.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/per_ns.rs | 8 |
9 files changed, 29 insertions, 26 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 | ||
82 | pub use hir_def::{ | 82 | pub 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}; | |||
27 | pub use lower::CallableDef; | 27 | pub use lower::CallableDef; |
28 | pub(crate) use lower::{ | 28 | pub(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 | }; |
32 | pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; | 32 | pub(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 | ||
21 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { | 21 | impl<'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}; | |||
6 | use crate::{ | 6 | use 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 | ||
13 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { | 13 | impl<'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)] | ||
40 | pub 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 | |||
36 | impl Ty { | 47 | impl 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), |
diff --git a/crates/ra_hir_def/src/nameres/per_ns.rs b/crates/ra_hir_def/src/nameres/per_ns.rs index 298b0b0c7..717ed1ef9 100644 --- a/crates/ra_hir_def/src/nameres/per_ns.rs +++ b/crates/ra_hir_def/src/nameres/per_ns.rs | |||
@@ -4,14 +4,6 @@ use hir_expand::MacroDefId; | |||
4 | 4 | ||
5 | use crate::ModuleDefId; | 5 | use crate::ModuleDefId; |
6 | 6 | ||
7 | #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
8 | pub enum Namespace { | ||
9 | Types, | ||
10 | Values, | ||
11 | // Note that only type inference uses this enum, and it doesn't care about macros. | ||
12 | // Macro, | ||
13 | } | ||
14 | |||
15 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | 7 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
16 | pub struct PerNs { | 8 | pub struct PerNs { |
17 | pub types: Option<ModuleDefId>, | 9 | pub types: Option<ModuleDefId>, |