From 9faea2364dee4fbc9391ad233c570b70256ef002 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 13 Mar 2020 16:05:46 +0100 Subject: Use `dyn Trait` for working with databse It improves compile time in `--release` mode quite a bit, it doesn't really slow things down and, conceptually, it seems closer to what we want the physical architecture to look like (we don't want to monomorphise EVERYTHING in a single leaf crate). --- crates/ra_hir_ty/src/infer/coerce.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir_ty/src/infer/coerce.rs') diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs index 95ac3c713..959b1e212 100644 --- a/crates/ra_hir_ty/src/infer/coerce.rs +++ b/crates/ra_hir_ty/src/infer/coerce.rs @@ -7,13 +7,11 @@ use hir_def::{lang_item::LangItemTarget, type_ref::Mutability}; use test_utils::tested_by; -use crate::{ - autoderef, db::HirDatabase, traits::Solution, Obligation, Substs, TraitRef, Ty, TypeCtor, -}; +use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty, TypeCtor}; use super::{unify::TypeVarValue, InEnvironment, InferTy, InferenceContext}; -impl<'a, D: HirDatabase> InferenceContext<'a, D> { +impl<'a> InferenceContext<'a> { /// Unify two types, but may coerce the first one to the second one /// using "implicit coercion rules" if needed. pub(super) fn coerce(&mut self, from_ty: &Ty, to_ty: &Ty) -> bool { @@ -126,7 +124,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { _ => return None, }; - let generic_params = crate::utils::generics(self.db, coerce_unsized_trait.into()); + let generic_params = crate::utils::generics(self.db.upcast(), coerce_unsized_trait.into()); if generic_params.len() != 2 { // The CoerceUnsized trait should have two generic params: Self and T. return None; -- cgit v1.2.3