Move expr resolver to resolve

This commit is contained in:
Aleksey Kladov 2019-11-21 13:28:04 +03:00
parent 0102fb4133
commit 24964ca58e
4 changed files with 35 additions and 33 deletions

View file

@ -13,7 +13,7 @@ use crate::{
diagnostics::{MissingFields, MissingOkInTailExpr},
resolve::HasResolver,
ty::{ApplicationTy, InferenceResult, Ty, TypeCtor},
Adt, DefWithBody, Function, HasBody, Name, Path, Resolver,
Adt, Function, Name, Path,
};
pub use hir_def::{
@ -27,30 +27,6 @@ pub use hir_def::{
},
};
// needs arbitrary_self_types to be a method... or maybe move to the def?
pub(crate) fn resolver_for_expr(
db: &impl HirDatabase,
owner: DefWithBody,
expr_id: ExprId,
) -> Resolver {
let scopes = owner.expr_scopes(db);
resolver_for_scope(db, owner, scopes.scope_for(expr_id))
}
pub(crate) fn resolver_for_scope(
db: &impl HirDatabase,
owner: DefWithBody,
scope_id: Option<ScopeId>,
) -> Resolver {
let mut r = owner.resolver(db);
let scopes = owner.expr_scopes(db);
let scope_chain = scopes.scope_chain(scope_id).collect::<Vec<_>>();
for scope in scope_chain.into_iter().rev() {
r = r.push_expr_scope(owner.into(), Arc::clone(&scopes), scope);
}
r
}
pub(crate) struct ExprValidator<'a, 'b: 'a> {
func: Function,
infer: Arc<InferenceResult>,