mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Merge #2332
2332: Add HasResolver trait r=matklad a=matklad bors merge Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
2cb2fb1a48
10 changed files with 127 additions and 141 deletions
|
@ -2,3 +2,4 @@
|
||||||
xtask = "run --package xtask --bin xtask --"
|
xtask = "run --package xtask --bin xtask --"
|
||||||
install-ra = "run --package xtask --bin xtask -- install" # for backwards compat
|
install-ra = "run --package xtask --bin xtask -- install" # for backwards compat
|
||||||
tq = "test -- -q"
|
tq = "test -- -q"
|
||||||
|
qt = "tq"
|
||||||
|
|
|
@ -30,7 +30,7 @@ use crate::{
|
||||||
AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
|
AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
|
||||||
TypeAliasId,
|
TypeAliasId,
|
||||||
},
|
},
|
||||||
resolve::{Resolver, Scope, TypeNs},
|
resolve::{HasResolver, TypeNs},
|
||||||
ty::{InferenceResult, Namespace, TraitRef},
|
ty::{InferenceResult, Namespace, TraitRef},
|
||||||
Either, HasSource, ImportId, Name, ScopeDef, Source, Ty,
|
Either, HasSource, ImportId, Name, ScopeDef, Source, Ty,
|
||||||
};
|
};
|
||||||
|
@ -223,11 +223,6 @@ impl Module {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
|
||||||
let def_map = db.crate_def_map(self.id.krate);
|
|
||||||
Resolver::default().push_module_scope(def_map, self.id.module_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn declarations(self, db: &impl DefDatabase) -> Vec<ModuleDef> {
|
pub fn declarations(self, db: &impl DefDatabase) -> Vec<ModuleDef> {
|
||||||
let def_map = db.crate_def_map(self.id.krate);
|
let def_map = db.crate_def_map(self.id.krate);
|
||||||
def_map[self.id.module_id].scope.declarations().map(ModuleDef::from).collect()
|
def_map[self.id.module_id].scope.declarations().map(ModuleDef::from).collect()
|
||||||
|
@ -315,15 +310,6 @@ impl Struct {
|
||||||
db.type_for_def(self.into(), Namespace::Values)
|
db.type_for_def(self.into(), Namespace::Values)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME move to a more general type
|
|
||||||
/// Builds a resolver for type references inside this struct.
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
|
||||||
// take the outer scope...
|
|
||||||
let r = self.module(db).resolver(db);
|
|
||||||
// ...and add generic params, if present
|
|
||||||
r.push_generic_params_scope(db, self.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||||
db.struct_data(self.id.into()).variant_data.clone()
|
db.struct_data(self.id.into()).variant_data.clone()
|
||||||
}
|
}
|
||||||
|
@ -339,22 +325,13 @@ impl Union {
|
||||||
db.struct_data(self.id.into()).name.clone()
|
db.struct_data(self.id.into()).name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module(self, db: &impl HirDatabase) -> Module {
|
pub fn module(self, db: &impl DefDatabase) -> Module {
|
||||||
Module { id: self.id.0.module(db) }
|
Module { id: self.id.0.module(db) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
||||||
db.type_for_def(self.into(), Namespace::Types)
|
db.type_for_def(self.into(), Namespace::Types)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME move to a more general type
|
|
||||||
/// Builds a resolver for type references inside this union.
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
|
||||||
// take the outer scope...
|
|
||||||
let r = self.module(db).resolver(db);
|
|
||||||
// ...and add generic params, if present
|
|
||||||
r.push_generic_params_scope(db, self.into())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
@ -394,16 +371,6 @@ impl Enum {
|
||||||
pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
||||||
db.type_for_def(self.into(), Namespace::Types)
|
db.type_for_def(self.into(), Namespace::Types)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: move to a more general type
|
|
||||||
/// Builds a resolver for type references inside this struct.
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
|
||||||
// take the outer scope...
|
|
||||||
let r = self.module(db).resolver(db);
|
|
||||||
// ...and add generic params, if present
|
|
||||||
let r = r.push_generic_params_scope(db, self.into());
|
|
||||||
r.push_scope(Scope::AdtScope(self.into()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
@ -465,23 +432,16 @@ impl Adt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
pub fn module(self, db: &impl DefDatabase) -> Module {
|
||||||
Some(
|
|
||||||
match self {
|
match self {
|
||||||
Adt::Struct(s) => s.module(db),
|
Adt::Struct(s) => s.module(db),
|
||||||
Adt::Union(s) => s.module(db),
|
Adt::Union(s) => s.module(db),
|
||||||
Adt::Enum(e) => e.module(db),
|
Adt::Enum(e) => e.module(db),
|
||||||
}
|
}
|
||||||
.krate(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
pub fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
||||||
match self {
|
Some(self.module(db).krate())
|
||||||
Adt::Struct(it) => it.resolver(db),
|
|
||||||
Adt::Union(it) => it.resolver(db),
|
|
||||||
Adt::Enum(it) => it.resolver(db),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,15 +493,6 @@ pub enum DefWithBody {
|
||||||
impl_froms!(DefWithBody: Function, Const, Static);
|
impl_froms!(DefWithBody: Function, Const, Static);
|
||||||
|
|
||||||
impl DefWithBody {
|
impl DefWithBody {
|
||||||
/// Builds a resolver for code inside this item.
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
|
||||||
match self {
|
|
||||||
DefWithBody::Const(c) => c.resolver(db),
|
|
||||||
DefWithBody::Function(f) => f.resolver(db),
|
|
||||||
DefWithBody::Static(s) => s.resolver(db),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
||||||
match self {
|
match self {
|
||||||
DefWithBody::Const(c) => c.krate(db),
|
DefWithBody::Const(c) => c.krate(db),
|
||||||
|
@ -738,15 +689,6 @@ impl Function {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: move to a more general type for 'body-having' items
|
|
||||||
/// Builds a resolver for code inside this item.
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
|
||||||
// take the outer scope...
|
|
||||||
let r = self.container(db).map_or_else(|| self.module(db).resolver(db), |c| c.resolver(db));
|
|
||||||
// ...and add generic params, if present
|
|
||||||
r.push_generic_params_scope(db, self.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) {
|
pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) {
|
||||||
let infer = self.infer(db);
|
let infer = self.infer(db);
|
||||||
infer.add_diagnostics(db, self, sink);
|
infer.add_diagnostics(db, self, sink);
|
||||||
|
@ -804,17 +746,6 @@ impl Const {
|
||||||
ContainerId::ModuleId(_) => None,
|
ContainerId::ModuleId(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: move to a more general type for 'body-having' items
|
|
||||||
/// Builds a resolver for code inside this item.
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
|
||||||
// take the outer scope...
|
|
||||||
let r = self
|
|
||||||
.impl_block(db)
|
|
||||||
.map(|ib| ib.resolver(db))
|
|
||||||
.unwrap_or_else(|| self.module(db).resolver(db));
|
|
||||||
r
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
@ -874,12 +805,6 @@ impl Static {
|
||||||
db.static_data(self)
|
db.static_data(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a resolver for code inside this item.
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
|
||||||
// take the outer scope...
|
|
||||||
self.module(db).resolver(db)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
||||||
db.infer(self.into())
|
db.infer(self.into())
|
||||||
}
|
}
|
||||||
|
@ -975,12 +900,6 @@ impl Trait {
|
||||||
pub fn is_auto(self, db: &impl DefDatabase) -> bool {
|
pub fn is_auto(self, db: &impl DefDatabase) -> bool {
|
||||||
self.trait_data(db).auto
|
self.trait_data(db).auto
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
|
||||||
let r = self.module(db).resolver(db);
|
|
||||||
// add generic params, if present
|
|
||||||
r.push_generic_params_scope(db, self.into())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
@ -1032,17 +951,6 @@ impl TypeAlias {
|
||||||
pub fn name(self, db: &impl DefDatabase) -> Name {
|
pub fn name(self, db: &impl DefDatabase) -> Name {
|
||||||
db.type_alias_data(self).name.clone()
|
db.type_alias_data(self).name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a resolver for the type references in this type alias.
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
|
||||||
// take the outer scope...
|
|
||||||
let r = self
|
|
||||||
.impl_block(db)
|
|
||||||
.map(|ib| ib.resolver(db))
|
|
||||||
.unwrap_or_else(|| self.module(db).resolver(db));
|
|
||||||
// ...and add generic params, if present
|
|
||||||
r.push_generic_params_scope(db, self.into())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
@ -1058,15 +966,6 @@ pub enum Container {
|
||||||
}
|
}
|
||||||
impl_froms!(Container: Trait, ImplBlock);
|
impl_froms!(Container: Trait, ImplBlock);
|
||||||
|
|
||||||
impl Container {
|
|
||||||
pub(crate) fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
|
||||||
match self {
|
|
||||||
Container::Trait(trait_) => trait_.resolver(db),
|
|
||||||
Container::ImplBlock(impl_block) => impl_block.resolver(db),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum AssocItem {
|
pub enum AssocItem {
|
||||||
Function(Function),
|
Function(Function),
|
||||||
|
|
|
@ -11,6 +11,7 @@ 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, DefWithBody, Function, HasBody, Name, Path, Resolver,
|
Adt, DefWithBody, Function, HasBody, Name, Path, Resolver,
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::{DefDatabase, HirDatabase},
|
db::DefDatabase, Adt, Const, Container, Enum, EnumVariant, Function, ImplBlock, Struct, Trait,
|
||||||
Adt, Const, Container, Enum, EnumVariant, Function, ImplBlock, Struct, Trait, TypeAlias, Union,
|
TypeAlias, Union,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use hir_def::generics::{GenericParam, GenericParams, WherePredicate};
|
pub use hir_def::generics::{GenericParam, GenericParams, WherePredicate};
|
||||||
|
@ -31,20 +31,6 @@ impl_froms!(
|
||||||
Const
|
Const
|
||||||
);
|
);
|
||||||
|
|
||||||
impl GenericDef {
|
|
||||||
pub(crate) fn resolver(&self, db: &impl HirDatabase) -> crate::Resolver {
|
|
||||||
match self {
|
|
||||||
GenericDef::Function(inner) => inner.resolver(db),
|
|
||||||
GenericDef::Adt(adt) => adt.resolver(db),
|
|
||||||
GenericDef::Trait(inner) => inner.resolver(db),
|
|
||||||
GenericDef::TypeAlias(inner) => inner.resolver(db),
|
|
||||||
GenericDef::ImplBlock(inner) => inner.resolver(db),
|
|
||||||
GenericDef::EnumVariant(inner) => inner.parent_enum(db).resolver(db),
|
|
||||||
GenericDef::Const(inner) => inner.resolver(db),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Container> for GenericDef {
|
impl From<Container> for GenericDef {
|
||||||
fn from(c: Container) -> Self {
|
fn from(c: Container) -> Self {
|
||||||
match c {
|
match c {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use ra_syntax::ast::{self};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||||
resolve::Resolver,
|
resolve::HasResolver,
|
||||||
ty::Ty,
|
ty::Ty,
|
||||||
AssocItem, Crate, HasSource, ImplBlock, Module, Source, TraitRef,
|
AssocItem, Crate, HasSource, ImplBlock, Module, Source, TraitRef,
|
||||||
};
|
};
|
||||||
|
@ -50,12 +50,4 @@ impl ImplBlock {
|
||||||
pub fn krate(&self, db: &impl DefDatabase) -> Crate {
|
pub fn krate(&self, db: &impl DefDatabase) -> Crate {
|
||||||
Crate { crate_id: self.module(db).id.krate }
|
Crate { crate_id: self.module(db).id.krate }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
|
||||||
let r = self.module(db).resolver(db);
|
|
||||||
// add generic params, if present
|
|
||||||
let r = r.push_generic_params_scope(db, self.into());
|
|
||||||
let r = r.push_impl_block_scope(self);
|
|
||||||
r
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ use crate::{
|
||||||
db::{DefDatabase, HirDatabase},
|
db::{DefDatabase, HirDatabase},
|
||||||
expr::{ExprScopes, PatId, ScopeId},
|
expr::{ExprScopes, PatId, ScopeId},
|
||||||
generics::{GenericParams, HasGenericParams},
|
generics::{GenericParams, HasGenericParams},
|
||||||
Adt, Const, DefWithBody, Enum, EnumVariant, Function, GenericDef, ImplBlock, Local, MacroDef,
|
Adt, Const, Container, DefWithBody, Enum, EnumVariant, Function, GenericDef, ImplBlock, Local,
|
||||||
ModuleDef, PerNs, Static, Struct, Trait, TypeAlias,
|
MacroDef, Module, ModuleDef, PerNs, Static, Struct, Trait, TypeAlias,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
@ -486,3 +486,103 @@ impl Scope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) trait HasResolver {
|
||||||
|
/// Builds a resolver for type references inside this def.
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for Module {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
let def_map = db.crate_def_map(self.id.krate);
|
||||||
|
Resolver::default().push_module_scope(def_map, self.id.module_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for Trait {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
self.module(db).resolver(db).push_generic_params_scope(db, self.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Into<Adt>> HasResolver for T {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
let def = self.into();
|
||||||
|
def.module(db)
|
||||||
|
.resolver(db)
|
||||||
|
.push_generic_params_scope(db, def.into())
|
||||||
|
.push_scope(Scope::AdtScope(def))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for Function {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
self.container(db)
|
||||||
|
.map(|c| c.resolver(db))
|
||||||
|
.unwrap_or_else(|| self.module(db).resolver(db))
|
||||||
|
.push_generic_params_scope(db, self.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for DefWithBody {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
match self {
|
||||||
|
DefWithBody::Const(c) => c.resolver(db),
|
||||||
|
DefWithBody::Function(f) => f.resolver(db),
|
||||||
|
DefWithBody::Static(s) => s.resolver(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for Const {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
self.container(db).map(|c| c.resolver(db)).unwrap_or_else(|| self.module(db).resolver(db))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for Static {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
self.module(db).resolver(db)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for TypeAlias {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
self.container(db)
|
||||||
|
.map(|ib| ib.resolver(db))
|
||||||
|
.unwrap_or_else(|| self.module(db).resolver(db))
|
||||||
|
.push_generic_params_scope(db, self.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for Container {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
match self {
|
||||||
|
Container::Trait(trait_) => trait_.resolver(db),
|
||||||
|
Container::ImplBlock(impl_block) => impl_block.resolver(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for GenericDef {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> crate::Resolver {
|
||||||
|
match self {
|
||||||
|
GenericDef::Function(inner) => inner.resolver(db),
|
||||||
|
GenericDef::Adt(adt) => adt.resolver(db),
|
||||||
|
GenericDef::Trait(inner) => inner.resolver(db),
|
||||||
|
GenericDef::TypeAlias(inner) => inner.resolver(db),
|
||||||
|
GenericDef::ImplBlock(inner) => inner.resolver(db),
|
||||||
|
GenericDef::EnumVariant(inner) => inner.parent_enum(db).resolver(db),
|
||||||
|
GenericDef::Const(inner) => inner.resolver(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasResolver for ImplBlock {
|
||||||
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
|
self.module(db)
|
||||||
|
.resolver(db)
|
||||||
|
.push_generic_params_scope(db, self.into())
|
||||||
|
.push_impl_block_scope(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::{
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
expr::{self, BodySourceMap, ExprScopes, ScopeId},
|
expr::{self, BodySourceMap, ExprScopes, ScopeId},
|
||||||
ids::LocationCtx,
|
ids::LocationCtx,
|
||||||
resolve::{ScopeDef, TypeNs, ValueNs},
|
resolve::{HasResolver, ScopeDef, TypeNs, ValueNs},
|
||||||
ty::method_resolution::{self, implements_trait},
|
ty::method_resolution::{self, implements_trait},
|
||||||
AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, GenericParam, HasBody,
|
AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, GenericParam, HasBody,
|
||||||
HirFileId, Local, MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty,
|
HirFileId, Local, MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty,
|
||||||
|
|
|
@ -40,7 +40,7 @@ use crate::{
|
||||||
code_model::TypeAlias,
|
code_model::TypeAlias,
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
expr::{BindingAnnotation, Body, ExprId, PatId},
|
expr::{BindingAnnotation, Body, ExprId, PatId},
|
||||||
resolve::{Resolver, TypeNs},
|
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, VariantDef,
|
StructField, VariantDef,
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::{
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
generics::HasGenericParams,
|
generics::HasGenericParams,
|
||||||
generics::{GenericDef, WherePredicate},
|
generics::{GenericDef, WherePredicate},
|
||||||
resolve::{Resolver, TypeNs},
|
resolve::{HasResolver, Resolver, TypeNs},
|
||||||
ty::{
|
ty::{
|
||||||
primitive::{FloatTy, IntTy, Uncertain},
|
primitive::{FloatTy, IntTy, Uncertain},
|
||||||
Adt,
|
Adt,
|
||||||
|
|
|
@ -304,6 +304,13 @@ mod tests {
|
||||||
),
|
),
|
||||||
@r###"
|
@r###"
|
||||||
[
|
[
|
||||||
|
CompletionItem {
|
||||||
|
label: "Self",
|
||||||
|
source_range: [54; 54),
|
||||||
|
delete: [54; 54),
|
||||||
|
insert: "Self",
|
||||||
|
kind: TypeParam,
|
||||||
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "T",
|
label: "T",
|
||||||
source_range: [54; 54),
|
source_range: [54; 54),
|
||||||
|
|
Loading…
Reference in a new issue