aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/autoderef.rs4
-rw-r--r--crates/ra_hir/src/ty/infer.rs39
-rw-r--r--crates/ra_hir/src/ty/infer/unify.rs4
-rw-r--r--crates/ra_hir/src/ty/lower.rs21
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs12
-rw-r--r--crates/ra_hir/src/ty/op.rs4
-rw-r--r--crates/ra_hir/src/ty/tests.rs15
-rw-r--r--crates/ra_hir/src/ty/traits.rs12
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs19
9 files changed, 67 insertions, 63 deletions
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs
index 1f443d49b..90c1ae630 100644
--- a/crates/ra_hir/src/ty/autoderef.rs
+++ b/crates/ra_hir/src/ty/autoderef.rs
@@ -7,8 +7,8 @@ use std::iter::successors;
7 7
8use log::{info, warn}; 8use log::{info, warn};
9 9
10use crate::{HirDatabase, Name, Resolver, HasGenericParams}; 10use super::{traits::Solution, Canonical, Ty};
11use super::{traits::Solution, Ty, Canonical}; 11use crate::{HasGenericParams, HirDatabase, Name, Resolver};
12 12
13const AUTODEREF_RECURSION_LIMIT: usize = 10; 13const AUTODEREF_RECURSION_LIMIT: usize = 10;
14 14
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 2c05ca734..a2dc92370 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -15,38 +15,37 @@
15 15
16use std::borrow::Cow; 16use std::borrow::Cow;
17use std::iter::repeat; 17use std::iter::repeat;
18use std::mem;
18use std::ops::Index; 19use std::ops::Index;
19use std::sync::Arc; 20use std::sync::Arc;
20use std::mem;
21 21
22use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError}; 22use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
23use rustc_hash::FxHashMap; 23use rustc_hash::FxHashMap;
24 24
25use ra_arena::map::ArenaMap; 25use ra_arena::map::ArenaMap;
26use ra_prof::profile; 26use ra_prof::profile;
27use test_utils::tested_by; 27use test_utils::tested_by;
28 28
29use super::{
30 autoderef, method_resolution, op, primitive,
31 traits::{Guidance, Obligation, Solution},
32 ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypableDef, TypeCtor,
33};
29use crate::{ 34use crate::{
30 Function, StructField, Path, Name, FnData, AdtDef, ConstData, HirDatabase, 35 adt::VariantDef,
31 DefWithBody, ImplItem, 36 diagnostics::DiagnosticSink,
32 type_ref::{TypeRef, Mutability},
33 expr::{ 37 expr::{
34 Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, 38 self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, FieldPat, Literal, Pat,
35 FieldPat, Array, self, 39 PatId, Statement, UnaryOp,
36 }, 40 },
37 generics::{GenericParams, HasGenericParams}, 41 generics::{GenericParams, HasGenericParams},
38 path::{GenericArgs, GenericArg},
39 ModuleDef,
40 adt::VariantDef,
41 resolve::{Resolver, Resolution},
42 nameres::Namespace, 42 nameres::Namespace,
43 path::{GenericArg, GenericArgs},
44 resolve::{Resolution, Resolver},
43 ty::infer::diagnostics::InferenceDiagnostic, 45 ty::infer::diagnostics::InferenceDiagnostic,
44 diagnostics::DiagnosticSink, 46 type_ref::{Mutability, TypeRef},
45}; 47 AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, ModuleDef, Name, Path,
46use super::{ 48 StructField,
47 Ty, TypableDef, Substs, primitive, op, ApplicationTy, TypeCtor, CallableDef, TraitRef,
48 traits::{Solution, Obligation, Guidance},
49 method_resolution, autoderef,
50}; 49};
51 50
52mod unify; 51mod unify;
@@ -1415,10 +1414,10 @@ impl Expectation {
1415 1414
1416mod diagnostics { 1415mod diagnostics {
1417 use crate::{ 1416 use crate::{
1418 expr::ExprId,
1419 diagnostics::{DiagnosticSink, NoSuchField}, 1417 diagnostics::{DiagnosticSink, NoSuchField},
1420 HirDatabase, Function, HasSource, 1418 expr::ExprId,
1421}; 1419 Function, HasSource, HirDatabase,
1420 };
1422 1421
1423 #[derive(Debug, PartialEq, Eq, Clone)] 1422 #[derive(Debug, PartialEq, Eq, Clone)]
1424 pub(super) enum InferenceDiagnostic { 1423 pub(super) enum InferenceDiagnostic {
diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs
index bc9719725..04633bdb2 100644
--- a/crates/ra_hir/src/ty/infer/unify.rs
+++ b/crates/ra_hir/src/ty/infer/unify.rs
@@ -1,8 +1,8 @@
1//! Unification and canonicalization logic. 1//! Unification and canonicalization logic.
2 2
3use crate::db::HirDatabase;
4use crate::ty::{Ty, Canonical, TraitRef, InferTy};
5use super::InferenceContext; 3use super::InferenceContext;
4use crate::db::HirDatabase;
5use crate::ty::{Canonical, InferTy, TraitRef, Ty};
6 6
7impl<'a, D: HirDatabase> InferenceContext<'a, D> { 7impl<'a, D: HirDatabase> InferenceContext<'a, D> {
8 pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> 8 pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D>
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index cb494baf4..8b1b2a7f9 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -5,23 +5,22 @@
5//! - Building the type for an item: This happens through the `type_for_def` query. 5//! - Building the type for an item: This happens through the `type_for_def` query.
6//! 6//!
7//! This usually involves resolving names, collecting generic arguments etc. 7//! This usually involves resolving names, collecting generic arguments etc.
8use std::sync::Arc;
9use std::iter; 8use std::iter;
9use std::sync::Arc;
10 10
11use super::{FnSig, GenericPredicate, Substs, TraitRef, Ty, TypeCtor};
11use crate::{ 12use crate::{
12 Function, Struct, Union, StructField, Enum, EnumVariant, Path, ModuleDef, TypeAlias, Const, Static,
13 HirDatabase, BuiltinType,
14 type_ref::TypeRef,
15 nameres::Namespace,
16 resolve::{Resolver, Resolution},
17 path::{PathSegment, GenericArg},
18 generics::{HasGenericParams},
19 adt::VariantDef, 13 adt::VariantDef,
20 Trait, 14 generics::HasGenericParams,
21 generics::{WherePredicate, GenericDef}, 15 generics::{GenericDef, WherePredicate},
16 nameres::Namespace,
17 path::{GenericArg, PathSegment},
18 resolve::{Resolution, Resolver},
22 ty::AdtDef, 19 ty::AdtDef,
20 type_ref::TypeRef,
21 BuiltinType, Const, Enum, EnumVariant, Function, HirDatabase, ModuleDef, Path, Static, Struct,
22 StructField, Trait, TypeAlias, Union,
23}; 23};
24use super::{Ty, FnSig, Substs, TypeCtor, TraitRef, GenericPredicate};
25 24
26impl Ty { 25impl Ty {
27 pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self { 26 pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self {
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index e023ff25a..bc890fe79 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -7,17 +7,17 @@ use std::sync::Arc;
7use arrayvec::ArrayVec; 7use arrayvec::ArrayVec;
8use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
9 9
10use super::{autoderef, Canonical, TraitRef};
10use crate::{ 11use crate::{
11 HirDatabase, Module, Crate, Name, Function, Trait, 12 generics::HasGenericParams,
12 impl_block::{ImplId, ImplBlock, ImplItem}, 13 impl_block::{ImplBlock, ImplId, ImplItem},
13 ty::{Ty, TypeCtor},
14 nameres::CrateModuleId, 14 nameres::CrateModuleId,
15 resolve::Resolver, 15 resolve::Resolver,
16 traits::TraitItem, 16 traits::TraitItem,
17 generics::HasGenericParams, 17 ty::primitive::{UncertainFloatTy, UncertainIntTy},
18 ty::primitive::{UncertainIntTy, UncertainFloatTy} 18 ty::{Ty, TypeCtor},
19 Crate, Function, HirDatabase, Module, Name, Trait,
19}; 20};
20use super::{TraitRef, Canonical, autoderef};
21 21
22/// This is used as a key for indexing impls. 22/// This is used as a key for indexing impls.
23#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] 23#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir/src/ty/op.rs b/crates/ra_hir/src/ty/op.rs
index 235661a5d..9ba868298 100644
--- a/crates/ra_hir/src/ty/op.rs
+++ b/crates/ra_hir/src/ty/op.rs
@@ -1,5 +1,5 @@
1use crate::{ ty::ApplicationTy, expr::BinaryOp}; 1use super::{InferTy, Ty, TypeCtor};
2use super::{Ty, TypeCtor, InferTy}; 2use crate::{expr::BinaryOp, ty::ApplicationTy};
3 3
4pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { 4pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty {
5 match op { 5 match op {
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 0fe7805e2..20fa74fb4 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -1,17 +1,18 @@
1use std::sync::Arc;
2use std::fmt::Write; 1use std::fmt::Write;
2use std::sync::Arc;
3 3
4use insta::assert_snapshot_matches; 4use insta::assert_snapshot_matches;
5 5
6use ra_db::{SourceDatabase, salsa::Database, FilePosition}; 6use ra_db::{salsa::Database, FilePosition, SourceDatabase};
7use ra_syntax::{algo, ast::{self, AstNode}, SyntaxKind::*}; 7use ra_syntax::{
8 algo,
9 ast::{self, AstNode},
10 SyntaxKind::*,
11};
8use test_utils::covers; 12use test_utils::covers;
9 13
10use crate::{ 14use crate::{
11 mock::MockDatabase, 15 expr::BodySourceMap, mock::MockDatabase, ty::display::HirDisplay, ty::InferenceResult,
12 ty::display::HirDisplay,
13 ty::InferenceResult,
14 expr::BodySourceMap,
15 SourceAnalyzer, 16 SourceAnalyzer,
16}; 17};
17 18
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs
index 69c03a36c..3c902451b 100644
--- a/crates/ra_hir/src/ty/traits.rs
+++ b/crates/ra_hir/src/ty/traits.rs
@@ -1,16 +1,16 @@
1//! Trait solving using Chalk. 1//! Trait solving using Chalk.
2use std::sync::Arc; 2use std::sync::Arc;
3 3
4use parking_lot::Mutex;
5use rustc_hash::FxHashSet;
6use log::debug;
7use chalk_ir::cast::Cast; 4use chalk_ir::cast::Cast;
5use log::debug;
6use parking_lot::Mutex;
8use ra_prof::profile; 7use ra_prof::profile;
8use rustc_hash::FxHashSet;
9 9
10use crate::{Crate, Trait, db::HirDatabase, ImplBlock}; 10use super::{Canonical, ProjectionTy, TraitRef, Ty};
11use super::{TraitRef, Ty, Canonical, ProjectionTy}; 11use crate::{db::HirDatabase, Crate, ImplBlock, Trait};
12 12
13use self::chalk::{ToChalk, from_chalk}; 13use self::chalk::{from_chalk, ToChalk};
14 14
15pub(crate) mod chalk; 15pub(crate) mod chalk;
16 16
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 4ceb8b70b..2a0537bc3 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -3,20 +3,25 @@ use std::sync::Arc;
3 3
4use log::debug; 4use log::debug;
5 5
6use chalk_ir::{TypeId, ImplId, TypeKindId, Parameter, Identifier, cast::Cast, PlaceholderIndex, UniverseIndex, TypeName}; 6use chalk_ir::{
7use chalk_rust_ir::{AssociatedTyDatum, TraitDatum, StructDatum, ImplDatum}; 7 cast::Cast, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId, TypeKindId, TypeName,
8 UniverseIndex,
9};
10use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum};
8 11
9use test_utils::tested_by;
10use ra_db::salsa::{InternId, InternKey}; 12use ra_db::salsa::{InternId, InternKey};
13use test_utils::tested_by;
11 14
15use super::ChalkContext;
12use crate::{ 16use crate::{
13 Trait, HasGenericParams, ImplBlock, Crate,
14 db::HirDatabase, 17 db::HirDatabase,
15 ty::{TraitRef, Ty, ApplicationTy, TypeCtor, Substs, GenericPredicate, CallableDef, ProjectionTy}, 18 generics::GenericDef,
16 ty::display::HirDisplay, 19 ty::display::HirDisplay,
17 generics::GenericDef, TypeAlias, ImplItem, 20 ty::{
21 ApplicationTy, CallableDef, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
22 },
23 Crate, HasGenericParams, ImplBlock, ImplItem, Trait, TypeAlias,
18}; 24};
19use super::ChalkContext;
20 25
21/// This represents a trait whose name we could not resolve. 26/// This represents a trait whose name we could not resolve.
22const UNKNOWN_TRAIT: chalk_ir::TraitId = 27const UNKNOWN_TRAIT: chalk_ir::TraitId =