Move resolver to hir_def

This commit is contained in:
Aleksey Kladov 2019-11-21 15:39:09 +03:00
parent 00684d708b
commit 6d64798a23
14 changed files with 63 additions and 77 deletions

View file

@ -11,6 +11,7 @@ use hir_def::{
body::scope::ExprScopes, body::scope::ExprScopes,
builtin_type::BuiltinType, builtin_type::BuiltinType,
nameres::per_ns::PerNs, nameres::per_ns::PerNs,
resolver::{HasResolver, TypeNs},
traits::TraitData, traits::TraitData,
type_ref::{Mutability, TypeRef}, type_ref::{Mutability, TypeRef},
ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup, ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup,
@ -31,7 +32,6 @@ use crate::{
AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId, AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
TypeAliasId, TypeAliasId,
}, },
resolve::{HasResolver, TypeNs},
ty::{InferenceResult, Namespace, TraitRef}, ty::{InferenceResult, Namespace, TraitRef},
Either, HasSource, ImportId, Name, Source, Ty, Either, HasSource, ImportId, Name, Source, Ty,
}; };

View file

@ -2,7 +2,7 @@
use std::sync::Arc; use std::sync::Arc;
use hir_def::path::known; use hir_def::{path::known, resolver::HasResolver};
use hir_expand::diagnostics::DiagnosticSink; use hir_expand::diagnostics::DiagnosticSink;
use ra_syntax::ast; use ra_syntax::ast;
use ra_syntax::AstPtr; use ra_syntax::AstPtr;
@ -11,7 +11,6 @@ use rustc_hash::FxHashSet;
use crate::{ use crate::{
db::HirDatabase, db::HirDatabase,
diagnostics::{MissingFields, MissingOkInTailExpr}, diagnostics::{MissingFields, MissingOkInTailExpr},
resolve::HasResolver,
ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, ty::{ApplicationTy, InferenceResult, Ty, TypeCtor},
Adt, Function, Name, Path, Adt, Function, Name, Path,
}; };

View file

@ -1,11 +1,10 @@
//! FIXME: write short doc here //! FIXME: write short doc here
use hir_def::{type_ref::TypeRef, AstItemDef}; use hir_def::{resolver::HasResolver, type_ref::TypeRef, AstItemDef};
use ra_syntax::ast::{self}; use ra_syntax::ast;
use crate::{ use crate::{
db::{AstDatabase, DefDatabase, HirDatabase}, db::{AstDatabase, DefDatabase, HirDatabase},
resolve::HasResolver,
ty::Ty, ty::Ty,
AssocItem, Crate, HasSource, ImplBlock, Module, Source, TraitRef, AssocItem, Crate, HasSource, ImplBlock, Module, Source, TraitRef,
}; };

View file

@ -38,7 +38,6 @@ mod impl_block;
mod expr; mod expr;
mod lang_item; mod lang_item;
pub mod generics; pub mod generics;
mod resolve;
pub mod diagnostics; pub mod diagnostics;
mod util; mod util;
@ -52,8 +51,6 @@ mod test_db;
#[cfg(test)] #[cfg(test)]
mod marks; mod marks;
use crate::resolve::Resolver;
pub use crate::{ pub use crate::{
code_model::{ code_model::{
attrs::{AttrDef, Attrs}, attrs::{AttrDef, Attrs},

View file

@ -10,6 +10,7 @@ use std::sync::Arc;
use hir_def::{ use hir_def::{
expr::{ExprId, PatId}, expr::{ExprId, PatId},
path::known, path::known,
resolver::{self, resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs},
DefWithBodyId, DefWithBodyId,
}; };
use hir_expand::{name::AsName, AstId, MacroCallId, MacroCallLoc, MacroFileKind, Source}; use hir_expand::{name::AsName, AstId, MacroCallId, MacroCallLoc, MacroFileKind, Source};
@ -24,11 +25,10 @@ use crate::{
db::HirDatabase, db::HirDatabase,
expr::{BodySourceMap, ExprScopes, ScopeId}, expr::{BodySourceMap, ExprScopes, ScopeId},
ids::LocationCtx, ids::LocationCtx,
resolve::{self, resolver_for_scope, HasResolver, TypeNs, ValueNs},
ty::method_resolution::{self, implements_trait}, ty::method_resolution::{self, implements_trait},
Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function,
GenericParam, HasBody, HirFileId, Local, MacroDef, Module, Name, Path, Resolver, ScopeDef, GenericParam, HasBody, HirFileId, Local, MacroDef, Module, Name, Path, ScopeDef, Static,
Static, Struct, Trait, Ty, TypeAlias, Struct, Trait, Ty, TypeAlias,
}; };
fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> {
@ -317,14 +317,14 @@ impl SourceAnalyzer {
pub fn process_all_names(&self, db: &impl HirDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { pub fn process_all_names(&self, db: &impl HirDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {
self.resolver.process_all_names(db, &mut |name, def| { self.resolver.process_all_names(db, &mut |name, def| {
let def = match def { let def = match def {
resolve::ScopeDef::PerNs(it) => it.into(), resolver::ScopeDef::PerNs(it) => it.into(),
resolve::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()),
resolve::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()),
resolve::ScopeDef::GenericParam(idx) => { resolver::ScopeDef::GenericParam(idx) => {
let parent = self.resolver.generic_def().unwrap().into(); let parent = self.resolver.generic_def().unwrap().into();
ScopeDef::GenericParam(GenericParam { parent, idx }) ScopeDef::GenericParam(GenericParam { parent, idx })
} }
resolve::ScopeDef::Local(pat_id) => { resolver::ScopeDef::Local(pat_id) => {
let parent = self.resolver.body_owner().unwrap().into(); let parent = self.resolver.body_owner().unwrap().into();
ScopeDef::Local(Local { parent, pat_id }) ScopeDef::Local(Local { parent, pat_id })
} }

View file

@ -5,11 +5,12 @@
use std::iter::successors; use std::iter::successors;
use hir_def::resolver::Resolver;
use hir_expand::name; use hir_expand::name;
use log::{info, warn}; use log::{info, warn};
use super::{traits::Solution, Canonical, Substs, Ty, TypeWalk}; use super::{traits::Solution, Canonical, Substs, Ty, TypeWalk};
use crate::{db::HirDatabase, generics::HasGenericParams, Resolver}; use crate::{db::HirDatabase, generics::HasGenericParams};
const AUTODEREF_RECURSION_LIMIT: usize = 10; const AUTODEREF_RECURSION_LIMIT: usize = 10;

View file

@ -23,6 +23,7 @@ use rustc_hash::FxHashMap;
use hir_def::{ use hir_def::{
path::known, path::known,
resolver::{HasResolver, Resolver, TypeNs},
type_ref::{Mutability, TypeRef}, type_ref::{Mutability, TypeRef},
AdtId, DefWithBodyId, AdtId, DefWithBodyId,
}; };
@ -41,7 +42,6 @@ use crate::{
code_model::TypeAlias, code_model::TypeAlias,
db::HirDatabase, db::HirDatabase,
expr::{BindingAnnotation, Body, ExprId, PatId}, expr::{BindingAnnotation, Body, ExprId, PatId},
resolve::{HasResolver, Resolver, TypeNs},
ty::infer::diagnostics::InferenceDiagnostic, ty::infer::diagnostics::InferenceDiagnostic,
Adt, AssocItem, ConstData, DefWithBody, FloatTy, FnData, Function, HasBody, IntTy, Path, Adt, AssocItem, ConstData, DefWithBody, FloatTy, FnData, Function, HasBody, IntTy, Path,
StructField, Trait, VariantDef, StructField, Trait, VariantDef,

View file

@ -4,19 +4,19 @@
//! //!
//! See: https://doc.rust-lang.org/nomicon/coercions.html //! See: https://doc.rust-lang.org/nomicon/coercions.html
use hir_def::resolver::Resolver;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use test_utils::tested_by; use test_utils::tested_by;
use super::{InferTy, InferenceContext, TypeVarValue};
use crate::{ use crate::{
db::HirDatabase, db::HirDatabase,
lang_item::LangItemTarget, lang_item::LangItemTarget,
resolve::Resolver,
ty::{autoderef, Substs, Ty, TypeCtor, TypeWalk}, ty::{autoderef, Substs, Ty, TypeCtor, TypeWalk},
Adt, Mutability, Adt, Mutability,
}; };
use super::{InferTy, InferenceContext, TypeVarValue};
impl<'a, D: HirDatabase> InferenceContext<'a, D> { impl<'a, D: HirDatabase> InferenceContext<'a, D> {
/// Unify two types, but may coerce the first one to the second one /// Unify two types, but may coerce the first one to the second one
/// using "implicit coercion rules" if needed. /// using "implicit coercion rules" if needed.

View file

@ -6,15 +6,14 @@ use std::sync::Arc;
use hir_def::{ use hir_def::{
builtin_type::Signedness, builtin_type::Signedness,
path::{GenericArg, GenericArgs}, path::{GenericArg, GenericArgs},
resolver::resolver_for_expr,
}; };
use hir_expand::name; use hir_expand::name;
use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch};
use crate::{ use crate::{
db::HirDatabase, db::HirDatabase,
expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
generics::{GenericParams, HasGenericParams}, generics::{GenericParams, HasGenericParams},
resolve::resolver_for_expr,
ty::{ ty::{
autoderef, method_resolution, op, CallableDef, InferTy, IntTy, Mutability, Namespace, autoderef, method_resolution, op, CallableDef, InferTy, IntTy, Mutability, Namespace,
Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk, Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk,
@ -23,6 +22,8 @@ use crate::{
Adt, Name, Adt, Name,
}; };
use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch};
impl<'a, D: HirDatabase> InferenceContext<'a, D> { impl<'a, D: HirDatabase> InferenceContext<'a, D> {
pub(super) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty { pub(super) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
let ty = self.infer_expr_inner(tgt_expr, expected); let ty = self.infer_expr_inner(tgt_expr, expected);

View file

@ -1,16 +1,19 @@
//! Path expression resolution. //! Path expression resolution.
use hir_def::path::PathSegment; use hir_def::{
path::PathSegment,
resolver::{ResolveValueResult, Resolver, TypeNs, ValueNs},
};
use super::{ExprOrPatId, InferenceContext, TraitRef};
use crate::{ use crate::{
db::HirDatabase, db::HirDatabase,
generics::HasGenericParams, generics::HasGenericParams,
resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs},
ty::{method_resolution, Namespace, Substs, Ty, TypableDef, TypeWalk}, ty::{method_resolution, Namespace, Substs, Ty, TypableDef, TypeWalk},
AssocItem, Container, Function, Name, Path, AssocItem, Container, Function, Name, Path,
}; };
use super::{ExprOrPatId, InferenceContext, TraitRef};
impl<'a, D: HirDatabase> InferenceContext<'a, D> { impl<'a, D: HirDatabase> InferenceContext<'a, D> {
pub(super) fn infer_path( pub(super) fn infer_path(
&mut self, &mut self,

View file

@ -11,6 +11,7 @@ use std::sync::Arc;
use hir_def::{ use hir_def::{
builtin_type::{BuiltinFloat, BuiltinInt, BuiltinType}, builtin_type::{BuiltinFloat, BuiltinInt, BuiltinType},
path::{GenericArg, PathSegment}, path::{GenericArg, PathSegment},
resolver::{HasResolver, Resolver, TypeNs},
type_ref::{TypeBound, TypeRef}, type_ref::{TypeBound, TypeRef},
GenericDefId, GenericDefId,
}; };
@ -23,7 +24,6 @@ use crate::{
db::HirDatabase, db::HirDatabase,
generics::HasGenericParams, generics::HasGenericParams,
generics::{GenericDef, WherePredicate}, generics::{GenericDef, WherePredicate},
resolve::{HasResolver, Resolver, TypeNs},
ty::{ ty::{
primitive::{FloatTy, IntTy, Uncertain}, primitive::{FloatTy, IntTy, Uncertain},
Adt, Adt,

View file

@ -5,11 +5,11 @@
use std::sync::Arc; use std::sync::Arc;
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use hir_def::resolver::Resolver;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use crate::{ use crate::{
db::HirDatabase, db::HirDatabase,
resolve::Resolver,
ty::primitive::{FloatBitness, Uncertain}, ty::primitive::{FloatBitness, Uncertain},
ty::{Ty, TypeCtor}, ty::{Ty, TypeCtor},
AssocItem, Crate, Function, ImplBlock, Module, Mutability, Name, Trait, AssocItem, Crate, Function, ImplBlock, Module, Mutability, Name, Trait,

View file

@ -19,6 +19,7 @@ pub mod expr;
pub mod body; pub mod body;
pub mod generics; pub mod generics;
pub mod traits; pub mod traits;
pub mod resolver;
#[cfg(test)] #[cfg(test)]
mod test_db; mod test_db;

View file

@ -1,7 +1,14 @@
//! Name resolution. //! Name resolution façade.
use std::sync::Arc; use std::sync::Arc;
use hir_def::{ use hir_expand::{
name::{self, Name},
MacroDefId,
};
use ra_db::CrateId;
use rustc_hash::FxHashSet;
use crate::{
body::scope::{ExprScopes, ScopeId}, body::scope::{ExprScopes, ScopeId},
builtin_type::BuiltinType, builtin_type::BuiltinType,
db::DefDatabase2, db::DefDatabase2,
@ -13,15 +20,9 @@ use hir_def::{
FunctionId, GenericDefId, ImplId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId, FunctionId, GenericDefId, ImplId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId,
TypeAliasId, UnionId, TypeAliasId, UnionId,
}; };
use hir_expand::{
name::{self, Name},
MacroDefId,
};
use ra_db::CrateId;
use rustc_hash::FxHashSet;
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
pub(crate) struct Resolver { pub struct Resolver {
scopes: Vec<Scope>, scopes: Vec<Scope>,
} }
@ -54,7 +55,7 @@ pub(crate) enum Scope {
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub(crate) enum TypeNs { pub enum TypeNs {
SelfType(ImplId), SelfType(ImplId),
GenericParam(u32), GenericParam(u32),
AdtId(AdtId), AdtId(AdtId),
@ -69,13 +70,13 @@ pub(crate) enum TypeNs {
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub(crate) enum ResolveValueResult { pub enum ResolveValueResult {
ValueNs(ValueNs), ValueNs(ValueNs),
Partial(TypeNs, usize), Partial(TypeNs, usize),
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub(crate) enum ValueNs { pub enum ValueNs {
LocalBinding(PatId), LocalBinding(PatId),
FunctionId(FunctionId), FunctionId(FunctionId),
ConstId(ConstId), ConstId(ConstId),
@ -86,11 +87,7 @@ pub(crate) enum ValueNs {
impl Resolver { impl Resolver {
/// Resolve known trait from std, like `std::futures::Future` /// Resolve known trait from std, like `std::futures::Future`
pub(crate) fn resolve_known_trait( pub fn resolve_known_trait(&self, db: &impl DefDatabase2, path: &Path) -> Option<TraitId> {
&self,
db: &impl DefDatabase2,
path: &Path,
) -> Option<TraitId> {
let res = self.resolve_module_path(db, path).take_types()?; let res = self.resolve_module_path(db, path).take_types()?;
match res { match res {
ModuleDefId::TraitId(it) => Some(it), ModuleDefId::TraitId(it) => Some(it),
@ -99,11 +96,7 @@ impl Resolver {
} }
/// Resolve known struct from std, like `std::boxed::Box` /// Resolve known struct from std, like `std::boxed::Box`
pub(crate) fn resolve_known_struct( pub fn resolve_known_struct(&self, db: &impl DefDatabase2, path: &Path) -> Option<StructId> {
&self,
db: &impl DefDatabase2,
path: &Path,
) -> Option<StructId> {
let res = self.resolve_module_path(db, path).take_types()?; let res = self.resolve_module_path(db, path).take_types()?;
match res { match res {
ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it), ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it),
@ -112,7 +105,7 @@ impl Resolver {
} }
/// Resolve known enum from std, like `std::result::Result` /// Resolve known enum from std, like `std::result::Result`
pub(crate) fn resolve_known_enum(&self, db: &impl DefDatabase2, path: &Path) -> Option<EnumId> { pub fn resolve_known_enum(&self, db: &impl DefDatabase2, path: &Path) -> Option<EnumId> {
let res = self.resolve_module_path(db, path).take_types()?; let res = self.resolve_module_path(db, path).take_types()?;
match res { match res {
ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it), ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it),
@ -121,7 +114,7 @@ impl Resolver {
} }
/// pub only for source-binder /// pub only for source-binder
pub(crate) fn resolve_module_path(&self, db: &impl DefDatabase2, path: &Path) -> PerNs { pub fn resolve_module_path(&self, db: &impl DefDatabase2, path: &Path) -> PerNs {
let (item_map, module) = match self.module() { let (item_map, module) = match self.module() {
Some(it) => it, Some(it) => it,
None => return PerNs::none(), None => return PerNs::none(),
@ -133,7 +126,7 @@ impl Resolver {
module_res module_res
} }
pub(crate) fn resolve_path_in_type_ns( pub fn resolve_path_in_type_ns(
&self, &self,
db: &impl DefDatabase2, db: &impl DefDatabase2,
path: &Path, path: &Path,
@ -189,7 +182,7 @@ impl Resolver {
None None
} }
pub(crate) fn resolve_path_in_type_ns_fully( pub fn resolve_path_in_type_ns_fully(
&self, &self,
db: &impl DefDatabase2, db: &impl DefDatabase2,
path: &Path, path: &Path,
@ -201,7 +194,7 @@ impl Resolver {
Some(res) Some(res)
} }
pub(crate) fn resolve_path_in_value_ns<'p>( pub fn resolve_path_in_value_ns<'p>(
&self, &self,
db: &impl DefDatabase2, db: &impl DefDatabase2,
path: &'p Path, path: &'p Path,
@ -301,7 +294,7 @@ impl Resolver {
None None
} }
pub(crate) fn resolve_path_in_value_ns_fully( pub fn resolve_path_in_value_ns_fully(
&self, &self,
db: &impl DefDatabase2, db: &impl DefDatabase2,
path: &Path, path: &Path,
@ -312,26 +305,18 @@ impl Resolver {
} }
} }
pub(crate) fn resolve_path_as_macro( pub fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> {
&self,
db: &impl DefDatabase2,
path: &Path,
) -> Option<MacroDefId> {
let (item_map, module) = self.module()?; let (item_map, module) = self.module()?;
item_map.resolve_path(db, module, path).0.get_macros() item_map.resolve_path(db, module, path).0.get_macros()
} }
pub(crate) fn process_all_names( pub fn process_all_names(&self, db: &impl DefDatabase2, f: &mut dyn FnMut(Name, ScopeDef)) {
&self,
db: &impl DefDatabase2,
f: &mut dyn FnMut(Name, ScopeDef),
) {
for scope in self.scopes.iter().rev() { for scope in self.scopes.iter().rev() {
scope.process_names(db, f); scope.process_names(db, f);
} }
} }
pub(crate) fn traits_in_scope(&self, db: &impl DefDatabase2) -> FxHashSet<TraitId> { pub fn traits_in_scope(&self, db: &impl DefDatabase2) -> FxHashSet<TraitId> {
let mut traits = FxHashSet::default(); let mut traits = FxHashSet::default();
for scope in &self.scopes { for scope in &self.scopes {
if let Scope::ModuleScope(m) = scope { if let Scope::ModuleScope(m) = scope {
@ -353,11 +338,11 @@ impl Resolver {
}) })
} }
pub(crate) fn krate(&self) -> Option<CrateId> { pub fn krate(&self) -> Option<CrateId> {
self.module().map(|t| t.0.krate()) self.module().map(|t| t.0.krate())
} }
pub(crate) fn where_predicates_in_scope<'a>( pub fn where_predicates_in_scope<'a>(
&'a self, &'a self,
) -> impl Iterator<Item = &'a crate::generics::WherePredicate> + 'a { ) -> impl Iterator<Item = &'a crate::generics::WherePredicate> + 'a {
self.scopes self.scopes
@ -369,14 +354,14 @@ impl Resolver {
.flat_map(|params| params.where_predicates.iter()) .flat_map(|params| params.where_predicates.iter())
} }
pub(crate) fn generic_def(&self) -> Option<GenericDefId> { pub fn generic_def(&self) -> Option<GenericDefId> {
self.scopes.iter().find_map(|scope| match scope { self.scopes.iter().find_map(|scope| match scope {
Scope::GenericParams { def, .. } => Some(*def), Scope::GenericParams { def, .. } => Some(*def),
_ => None, _ => None,
}) })
} }
pub(crate) fn body_owner(&self) -> Option<DefWithBodyId> { pub fn body_owner(&self) -> Option<DefWithBodyId> {
self.scopes.iter().find_map(|scope| match scope { self.scopes.iter().find_map(|scope| match scope {
Scope::ExprScope(it) => Some(it.owner), Scope::ExprScope(it) => Some(it.owner),
_ => None, _ => None,
@ -425,7 +410,7 @@ impl Resolver {
} }
} }
pub(crate) enum ScopeDef { pub enum ScopeDef {
PerNs(PerNs), PerNs(PerNs),
ImplSelfType(ImplId), ImplSelfType(ImplId),
AdtSelfType(AdtId), AdtSelfType(AdtId),
@ -481,7 +466,7 @@ impl Scope {
} }
// needs arbitrary_self_types to be a method... or maybe move to the def? // needs arbitrary_self_types to be a method... or maybe move to the def?
pub(crate) fn resolver_for_expr( pub fn resolver_for_expr(
db: &impl DefDatabase2, db: &impl DefDatabase2,
owner: DefWithBodyId, owner: DefWithBodyId,
expr_id: ExprId, expr_id: ExprId,
@ -490,7 +475,7 @@ pub(crate) fn resolver_for_expr(
resolver_for_scope(db, owner, scopes.scope_for(expr_id)) resolver_for_scope(db, owner, scopes.scope_for(expr_id))
} }
pub(crate) fn resolver_for_scope( pub fn resolver_for_scope(
db: &impl DefDatabase2, db: &impl DefDatabase2,
owner: DefWithBodyId, owner: DefWithBodyId,
scope_id: Option<ScopeId>, scope_id: Option<ScopeId>,
@ -504,7 +489,7 @@ pub(crate) fn resolver_for_scope(
r r
} }
pub(crate) trait HasResolver { pub trait HasResolver {
/// Builds a resolver for type references inside this def. /// Builds a resolver for type references inside this def.
fn resolver(self, db: &impl DefDatabase2) -> Resolver; fn resolver(self, db: &impl DefDatabase2) -> Resolver;
} }
@ -600,7 +585,7 @@ impl HasResolver for ContainerId {
} }
impl HasResolver for GenericDefId { impl HasResolver for GenericDefId {
fn resolver(self, db: &impl DefDatabase2) -> crate::Resolver { fn resolver(self, db: &impl DefDatabase2) -> Resolver {
match self { match self {
GenericDefId::FunctionId(inner) => inner.resolver(db), GenericDefId::FunctionId(inner) => inner.resolver(db),
GenericDefId::AdtId(adt) => adt.resolver(db), GenericDefId::AdtId(adt) => adt.resolver(db),