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/unify.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'crates/ra_hir_ty/src/infer/unify.rs') diff --git a/crates/ra_hir_ty/src/infer/unify.rs b/crates/ra_hir_ty/src/infer/unify.rs index 82b85d570..0bf8fbd63 100644 --- a/crates/ra_hir_ty/src/infer/unify.rs +++ b/crates/ra_hir_ty/src/infer/unify.rs @@ -7,10 +7,10 @@ use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; use test_utils::tested_by; use super::{InferenceContext, Obligation}; -use crate::{db::HirDatabase, Canonical, InEnvironment, InferTy, Substs, Ty, TypeCtor, TypeWalk}; +use crate::{Canonical, InEnvironment, InferTy, Substs, Ty, TypeCtor, TypeWalk}; -impl<'a, D: HirDatabase> InferenceContext<'a, D> { - pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> +impl<'a> InferenceContext<'a> { + pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b> where 'a: 'b, { @@ -18,11 +18,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } } -pub(super) struct Canonicalizer<'a, 'b, D: HirDatabase> +pub(super) struct Canonicalizer<'a, 'b> where 'a: 'b, { - ctx: &'b mut InferenceContext<'a, D>, + ctx: &'b mut InferenceContext<'a>, free_vars: Vec, /// A stack of type variables that is used to detect recursive types (which /// are an error, but we need to protect against them to avoid stack @@ -35,7 +35,7 @@ pub(super) struct Canonicalized { free_vars: Vec, } -impl<'a, 'b, D: HirDatabase> Canonicalizer<'a, 'b, D> +impl<'a, 'b> Canonicalizer<'a, 'b> where 'a: 'b, { @@ -123,11 +123,7 @@ impl Canonicalized { ty } - pub fn apply_solution( - &self, - ctx: &mut InferenceContext<'_, impl HirDatabase>, - solution: Canonical>, - ) { + pub fn apply_solution(&self, ctx: &mut InferenceContext<'_>, solution: Canonical>) { // the solution may contain new variables, which we need to convert to new inference vars let new_vars = Substs((0..solution.num_vars).map(|_| ctx.table.new_type_var()).collect()); for (i, ty) in solution.value.into_iter().enumerate() { -- cgit v1.2.3