From 6d64798a2300858c74b1cc0a22f6d3df578288b3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 21 Nov 2019 15:39:09 +0300 Subject: Move resolver to hir_def --- crates/ra_hir/src/ty/autoderef.rs | 3 ++- crates/ra_hir/src/ty/infer.rs | 2 +- crates/ra_hir/src/ty/infer/coerce.rs | 6 +++--- crates/ra_hir/src/ty/infer/expr.rs | 5 +++-- crates/ra_hir/src/ty/infer/path.rs | 9 ++++++--- crates/ra_hir/src/ty/lower.rs | 2 +- crates/ra_hir/src/ty/method_resolution.rs | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs index f77492170..5d8518041 100644 --- a/crates/ra_hir/src/ty/autoderef.rs +++ b/crates/ra_hir/src/ty/autoderef.rs @@ -5,11 +5,12 @@ use std::iter::successors; +use hir_def::resolver::Resolver; use hir_expand::name; use log::{info, warn}; use super::{traits::Solution, Canonical, Substs, Ty, TypeWalk}; -use crate::{db::HirDatabase, generics::HasGenericParams, Resolver}; +use crate::{db::HirDatabase, generics::HasGenericParams}; const AUTODEREF_RECURSION_LIMIT: usize = 10; diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index c3d65afa6..69b13baef 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -23,6 +23,7 @@ use rustc_hash::FxHashMap; use hir_def::{ path::known, + resolver::{HasResolver, Resolver, TypeNs}, type_ref::{Mutability, TypeRef}, AdtId, DefWithBodyId, }; @@ -41,7 +42,6 @@ use crate::{ code_model::TypeAlias, db::HirDatabase, expr::{BindingAnnotation, Body, ExprId, PatId}, - resolve::{HasResolver, Resolver, TypeNs}, ty::infer::diagnostics::InferenceDiagnostic, Adt, AssocItem, ConstData, DefWithBody, FloatTy, FnData, Function, HasBody, IntTy, Path, StructField, Trait, VariantDef, diff --git a/crates/ra_hir/src/ty/infer/coerce.rs b/crates/ra_hir/src/ty/infer/coerce.rs index 6d297c268..0772b9df5 100644 --- a/crates/ra_hir/src/ty/infer/coerce.rs +++ b/crates/ra_hir/src/ty/infer/coerce.rs @@ -4,19 +4,19 @@ //! //! See: https://doc.rust-lang.org/nomicon/coercions.html +use hir_def::resolver::Resolver; use rustc_hash::FxHashMap; - use test_utils::tested_by; -use super::{InferTy, InferenceContext, TypeVarValue}; use crate::{ db::HirDatabase, lang_item::LangItemTarget, - resolve::Resolver, ty::{autoderef, Substs, Ty, TypeCtor, TypeWalk}, Adt, Mutability, }; +use super::{InferTy, InferenceContext, TypeVarValue}; + impl<'a, D: HirDatabase> InferenceContext<'a, D> { /// Unify two types, but may coerce the first one to the second one /// using "implicit coercion rules" if needed. diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs index 1ac2709f5..ac570075f 100644 --- a/crates/ra_hir/src/ty/infer/expr.rs +++ b/crates/ra_hir/src/ty/infer/expr.rs @@ -6,15 +6,14 @@ use std::sync::Arc; use hir_def::{ builtin_type::Signedness, path::{GenericArg, GenericArgs}, + resolver::resolver_for_expr, }; use hir_expand::name; -use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch}; use crate::{ db::HirDatabase, expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, generics::{GenericParams, HasGenericParams}, - resolve::resolver_for_expr, ty::{ autoderef, method_resolution, op, CallableDef, InferTy, IntTy, Mutability, Namespace, Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk, @@ -23,6 +22,8 @@ use crate::{ Adt, Name, }; +use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch}; + impl<'a, D: HirDatabase> InferenceContext<'a, D> { pub(super) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty { let ty = self.infer_expr_inner(tgt_expr, expected); diff --git a/crates/ra_hir/src/ty/infer/path.rs b/crates/ra_hir/src/ty/infer/path.rs index 55a5dbec7..70136e514 100644 --- a/crates/ra_hir/src/ty/infer/path.rs +++ b/crates/ra_hir/src/ty/infer/path.rs @@ -1,16 +1,19 @@ //! Path expression resolution. -use hir_def::path::PathSegment; +use hir_def::{ + path::PathSegment, + resolver::{ResolveValueResult, Resolver, TypeNs, ValueNs}, +}; -use super::{ExprOrPatId, InferenceContext, TraitRef}; use crate::{ db::HirDatabase, generics::HasGenericParams, - resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs}, ty::{method_resolution, Namespace, Substs, Ty, TypableDef, TypeWalk}, AssocItem, Container, Function, Name, Path, }; +use super::{ExprOrPatId, InferenceContext, TraitRef}; + impl<'a, D: HirDatabase> InferenceContext<'a, D> { pub(super) fn infer_path( &mut self, diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index e477b2439..c6ad0811b 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs @@ -11,6 +11,7 @@ use std::sync::Arc; use hir_def::{ builtin_type::{BuiltinFloat, BuiltinInt, BuiltinType}, path::{GenericArg, PathSegment}, + resolver::{HasResolver, Resolver, TypeNs}, type_ref::{TypeBound, TypeRef}, GenericDefId, }; @@ -23,7 +24,6 @@ use crate::{ db::HirDatabase, generics::HasGenericParams, generics::{GenericDef, WherePredicate}, - resolve::{HasResolver, Resolver, TypeNs}, ty::{ primitive::{FloatTy, IntTy, Uncertain}, Adt, diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 5ad72ef9f..64adb814d 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs @@ -5,11 +5,11 @@ use std::sync::Arc; use arrayvec::ArrayVec; +use hir_def::resolver::Resolver; use rustc_hash::FxHashMap; use crate::{ db::HirDatabase, - resolve::Resolver, ty::primitive::{FloatBitness, Uncertain}, ty::{Ty, TypeCtor}, AssocItem, Crate, Function, ImplBlock, Module, Mutability, Name, Trait, -- cgit v1.2.3