aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer/coerce.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-13 15:05:46 +0000
committerAleksey Kladov <[email protected]>2020-03-16 16:42:30 +0000
commit9faea2364dee4fbc9391ad233c570b70256ef002 (patch)
tree160af959553ce57fdfcbc0a6c79bafcc3611aeea /crates/ra_hir_ty/src/infer/coerce.rs
parent648df02953a6ebf87a5876668eceba208687e8a7 (diff)
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).
Diffstat (limited to 'crates/ra_hir_ty/src/infer/coerce.rs')
-rw-r--r--crates/ra_hir_ty/src/infer/coerce.rs8
1 files changed, 3 insertions, 5 deletions
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 @@
7use hir_def::{lang_item::LangItemTarget, type_ref::Mutability}; 7use hir_def::{lang_item::LangItemTarget, type_ref::Mutability};
8use test_utils::tested_by; 8use test_utils::tested_by;
9 9
10use crate::{ 10use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty, TypeCtor};
11 autoderef, db::HirDatabase, traits::Solution, Obligation, Substs, TraitRef, Ty, TypeCtor,
12};
13 11
14use super::{unify::TypeVarValue, InEnvironment, InferTy, InferenceContext}; 12use super::{unify::TypeVarValue, InEnvironment, InferTy, InferenceContext};
15 13
16impl<'a, D: HirDatabase> InferenceContext<'a, D> { 14impl<'a> InferenceContext<'a> {
17 /// Unify two types, but may coerce the first one to the second one 15 /// Unify two types, but may coerce the first one to the second one
18 /// using "implicit coercion rules" if needed. 16 /// using "implicit coercion rules" if needed.
19 pub(super) fn coerce(&mut self, from_ty: &Ty, to_ty: &Ty) -> bool { 17 pub(super) fn coerce(&mut self, from_ty: &Ty, to_ty: &Ty) -> bool {
@@ -126,7 +124,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
126 _ => return None, 124 _ => return None,
127 }; 125 };
128 126
129 let generic_params = crate::utils::generics(self.db, coerce_unsized_trait.into()); 127 let generic_params = crate::utils::generics(self.db.upcast(), coerce_unsized_trait.into());
130 if generic_params.len() != 2 { 128 if generic_params.len() != 2 {
131 // The CoerceUnsized trait should have two generic params: Self and T. 129 // The CoerceUnsized trait should have two generic params: Self and T.
132 return None; 130 return None;