aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer/path.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-16 16:42:58 +0000
committerGitHub <[email protected]>2020-03-16 16:42:58 +0000
commitadcc89137d3feea8f19fad461bbde6f4bce048e5 (patch)
tree160af959553ce57fdfcbc0a6c79bafcc3611aeea /crates/ra_hir_ty/src/infer/path.rs
parent648df02953a6ebf87a5876668eceba208687e8a7 (diff)
parent9faea2364dee4fbc9391ad233c570b70256ef002 (diff)
Merge #3584
3584: Switch to dynamic dispatch r=matklad a=matklad Benches are in https://github.com/rust-analyzer/rust-analyzer/issues/1987#issuecomment-598807185 TL;DR: * 33% faster release build * slightly worse/same perf * no changes for debug build * slightly smaller binary cc @flodiebold I genuinely don't know if it is a good idea or not. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/infer/path.rs')
-rw-r--r--crates/ra_hir_ty/src/infer/path.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs
index c733b9e1d..318652c61 100644
--- a/crates/ra_hir_ty/src/infer/path.rs
+++ b/crates/ra_hir_ty/src/infer/path.rs
@@ -9,11 +9,11 @@ use hir_def::{
9}; 9};
10use hir_expand::name::Name; 10use hir_expand::name::Name;
11 11
12use crate::{db::HirDatabase, method_resolution, Substs, Ty, ValueTyDefId}; 12use crate::{method_resolution, Substs, Ty, ValueTyDefId};
13 13
14use super::{ExprOrPatId, InferenceContext, TraitRef}; 14use super::{ExprOrPatId, InferenceContext, TraitRef};
15 15
16impl<'a, D: HirDatabase> InferenceContext<'a, D> { 16impl<'a> InferenceContext<'a> {
17 pub(super) fn infer_path( 17 pub(super) fn infer_path(
18 &mut self, 18 &mut self,
19 resolver: &Resolver, 19 resolver: &Resolver,
@@ -47,7 +47,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
47 id, 47 id,
48 )? 48 )?
49 } else { 49 } else {
50 let value_or_partial = resolver.resolve_path_in_value_ns(self.db, path.mod_path())?; 50 let value_or_partial =
51 resolver.resolve_path_in_value_ns(self.db.upcast(), path.mod_path())?;
51 52
52 match value_or_partial { 53 match value_or_partial {
53 ResolveValueResult::ValueNs(it) => (it, None), 54 ResolveValueResult::ValueNs(it) => (it, None),
@@ -192,7 +193,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
192 193
193 let canonical_ty = self.canonicalizer().canonicalize_ty(ty.clone()); 194 let canonical_ty = self.canonicalizer().canonicalize_ty(ty.clone());
194 let krate = self.resolver.krate()?; 195 let krate = self.resolver.krate()?;
195 let traits_in_scope = self.resolver.traits_in_scope(self.db); 196 let traits_in_scope = self.resolver.traits_in_scope(self.db.upcast());
196 197
197 method_resolution::iterate_method_candidates( 198 method_resolution::iterate_method_candidates(
198 &canonical_ty.value, 199 &canonical_ty.value,
@@ -205,9 +206,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
205 move |_ty, item| { 206 move |_ty, item| {
206 let (def, container) = match item { 207 let (def, container) = match item {
207 AssocItemId::FunctionId(f) => { 208 AssocItemId::FunctionId(f) => {
208 (ValueNs::FunctionId(f), f.lookup(self.db).container) 209 (ValueNs::FunctionId(f), f.lookup(self.db.upcast()).container)
210 }
211 AssocItemId::ConstId(c) => {
212 (ValueNs::ConstId(c), c.lookup(self.db.upcast()).container)
209 } 213 }
210 AssocItemId::ConstId(c) => (ValueNs::ConstId(c), c.lookup(self.db).container),
211 AssocItemId::TypeAliasId(_) => unreachable!(), 214 AssocItemId::TypeAliasId(_) => unreachable!(),
212 }; 215 };
213 let substs = match container { 216 let substs = match container {