Remove Resolver from autoderef

Resolver holds onto too much context, including local scopes. Let's
try to pass in only what is necessary -- the trait environment.
This commit is contained in:
Aleksey Kladov
2019-11-25 13:10:26 +03:00
parent bd53bd80bf
commit 8c3e372835
7 changed files with 73 additions and 49 deletions

View File

@@ -26,7 +26,10 @@ use ra_syntax::{
use crate::{
db::HirDatabase,
expr::{BodySourceMap, ExprScopes, ScopeId},
ty::method_resolution::{self, implements_trait},
ty::{
method_resolution::{self, implements_trait},
TraitEnvironment,
},
Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function,
GenericParam, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Ty, TypeAlias,
};
@@ -408,7 +411,10 @@ impl SourceAnalyzer {
// There should be no inference vars in types passed here
// FIXME check that?
let canonical = crate::ty::Canonical { value: ty, num_vars: 0 };
crate::ty::autoderef(db, &self.resolver, canonical).map(|canonical| canonical.value)
let krate = self.resolver.krate();
let environment = TraitEnvironment::lower(db, &self.resolver);
let ty = crate::ty::InEnvironment { value: canonical, environment };
crate::ty::autoderef(db, krate, ty).map(|canonical| canonical.value)
}
/// Checks that particular type `ty` implements `std::future::Future`.