Rename ast::ImplBlock -> ast::ImplDef

This commit is contained in:
Aleksey Kladov 2020-02-29 21:24:40 +01:00
parent f316e074d2
commit a1e1869554
68 changed files with 216 additions and 224 deletions

View file

@ -40,9 +40,9 @@ impl<'a> SubstituteTypeParams<'a> {
db: &'a RootDatabase, db: &'a RootDatabase,
// FIXME: there's implicit invariant that `trait_` and `source_scope` match... // FIXME: there's implicit invariant that `trait_` and `source_scope` match...
trait_: hir::Trait, trait_: hir::Trait,
impl_block: ast::ImplBlock, impl_def: ast::ImplDef,
) -> SubstituteTypeParams<'a> { ) -> SubstituteTypeParams<'a> {
let substs = get_syntactic_substs(impl_block).unwrap_or_default(); let substs = get_syntactic_substs(impl_def).unwrap_or_default();
let generic_def: hir::GenericDef = trait_.into(); let generic_def: hir::GenericDef = trait_.into();
let substs_by_param: FxHashMap<_, _> = generic_def let substs_by_param: FxHashMap<_, _> = generic_def
.params(db) .params(db)
@ -59,8 +59,8 @@ impl<'a> SubstituteTypeParams<'a> {
// FIXME: It would probably be nicer if we could get this via HIR (i.e. get the // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the
// trait ref, and then go from the types in the substs back to the syntax) // trait ref, and then go from the types in the substs back to the syntax)
fn get_syntactic_substs(impl_block: ast::ImplBlock) -> Option<Vec<ast::TypeRef>> { fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option<Vec<ast::TypeRef>> {
let target_trait = impl_block.target_trait()?; let target_trait = impl_def.target_trait()?;
let path_type = match target_trait { let path_type = match target_trait {
ast::TypeRef::PathType(path) => path, ast::TypeRef::PathType(path) => path,
_ => return None, _ => return None,

View file

@ -101,7 +101,7 @@ fn add_missing_impl_members_inner(
label: &'static str, label: &'static str,
) -> Option<Assist> { ) -> Option<Assist> {
let _p = ra_prof::profile("add_missing_impl_members_inner"); let _p = ra_prof::profile("add_missing_impl_members_inner");
let impl_node = ctx.find_node_at_offset::<ast::ImplBlock>()?; let impl_node = ctx.find_node_at_offset::<ast::ImplDef>()?;
let impl_item_list = impl_node.item_list()?; let impl_item_list = impl_node.item_list()?;
let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?; let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?;
@ -257,7 +257,7 @@ impl Foo for S {
} }
#[test] #[test]
fn test_empty_impl_block() { fn test_empty_impl_def() {
check_assist( check_assist(
add_missing_impl_members, add_missing_impl_members,
" "
@ -308,7 +308,7 @@ impl<U> Foo<U> for S {
} }
#[test] #[test]
fn test_cursor_after_empty_impl_block() { fn test_cursor_after_empty_impl_def() {
check_assist( check_assist(
add_missing_impl_members, add_missing_impl_members,
" "

View file

@ -41,14 +41,14 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> {
}; };
// Return early if we've found an existing new fn // Return early if we've found an existing new fn
let impl_block = find_struct_impl(&ctx, &strukt)?; let impl_def = find_struct_impl(&ctx, &strukt)?;
ctx.add_assist(AssistId("add_new"), "Add default constructor", |edit| { ctx.add_assist(AssistId("add_new"), "Add default constructor", |edit| {
edit.target(strukt.syntax().text_range()); edit.target(strukt.syntax().text_range());
let mut buf = String::with_capacity(512); let mut buf = String::with_capacity(512);
if impl_block.is_some() { if impl_def.is_some() {
buf.push('\n'); buf.push('\n');
} }
@ -71,10 +71,10 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> {
buf.push_str("} }"); buf.push_str("} }");
let (start_offset, end_offset) = impl_block let (start_offset, end_offset) = impl_def
.and_then(|impl_block| { .and_then(|impl_def| {
buf.push('\n'); buf.push('\n');
let start = impl_block let start = impl_def
.syntax() .syntax()
.descendants_with_tokens() .descendants_with_tokens()
.find(|t| t.kind() == T!['{'])? .find(|t| t.kind() == T!['{'])?
@ -128,7 +128,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
// //
// FIXME: change the new fn checking to a more semantic approach when that's more // FIXME: change the new fn checking to a more semantic approach when that's more
// viable (e.g. we process proc macros, etc) // viable (e.g. we process proc macros, etc)
fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplBlock>> { fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> {
let db = ctx.db; let db = ctx.db;
let module = strukt.syntax().ancestors().find(|node| { let module = strukt.syntax().ancestors().find(|node| {
ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())
@ -136,7 +136,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<a
let struct_def = ctx.sema.to_def(strukt)?; let struct_def = ctx.sema.to_def(strukt)?;
let block = module.descendants().filter_map(ast::ImplBlock::cast).find_map(|impl_blk| { let block = module.descendants().filter_map(ast::ImplDef::cast).find_map(|impl_blk| {
let blk = ctx.sema.to_def(&impl_blk)?; let blk = ctx.sema.to_def(&impl_blk)?;
// FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}`
@ -164,7 +164,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<a
Some(block) Some(block)
} }
fn has_new_fn(imp: &ast::ImplBlock) -> bool { fn has_new_fn(imp: &ast::ImplDef) -> bool {
if let Some(il) = imp.item_list() { if let Some(il) = imp.item_list() {
for item in il.impl_items() { for item in il.impl_items() {
if let ast::ImplItem::FnDef(f) = item { if let ast::ImplItem::FnDef(f) = item {

View file

@ -37,7 +37,7 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> Option<Assist> {
let anchor: SyntaxElement = match parent.kind() { let anchor: SyntaxElement = match parent.kind() {
FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(), FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(),
TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(), TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(),
IMPL_BLOCK => ast::ImplBlock::cast(parent)?.item_list()?.syntax().clone().into(), IMPL_DEF => ast::ImplDef::cast(parent)?.item_list()?.syntax().clone().into(),
ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(), ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(),
STRUCT_DEF => parent STRUCT_DEF => parent
.children_with_tokens() .children_with_tokens()

View file

@ -13,14 +13,14 @@ pub use insert_use::insert_use_statement;
pub fn get_missing_impl_items( pub fn get_missing_impl_items(
sema: &Semantics<RootDatabase>, sema: &Semantics<RootDatabase>,
impl_block: &ast::ImplBlock, impl_def: &ast::ImplDef,
) -> Vec<hir::AssocItem> { ) -> Vec<hir::AssocItem> {
// Names must be unique between constants and functions. However, type aliases // Names must be unique between constants and functions. However, type aliases
// may share the same name as a function or constant. // may share the same name as a function or constant.
let mut impl_fns_consts = FxHashSet::default(); let mut impl_fns_consts = FxHashSet::default();
let mut impl_type = FxHashSet::default(); let mut impl_type = FxHashSet::default();
if let Some(item_list) = impl_block.item_list() { if let Some(item_list) = impl_def.item_list() {
for item in item_list.impl_items() { for item in item_list.impl_items() {
match item { match item {
ast::ImplItem::FnDef(f) => { ast::ImplItem::FnDef(f) => {
@ -44,7 +44,7 @@ pub fn get_missing_impl_items(
} }
} }
resolve_target_trait(sema, impl_block).map_or(vec![], |target_trait| { resolve_target_trait(sema, impl_def).map_or(vec![], |target_trait| {
target_trait target_trait
.items(sema.db) .items(sema.db)
.iter() .iter()
@ -65,9 +65,9 @@ pub fn get_missing_impl_items(
pub(crate) fn resolve_target_trait( pub(crate) fn resolve_target_trait(
sema: &Semantics<RootDatabase>, sema: &Semantics<RootDatabase>,
impl_block: &ast::ImplBlock, impl_def: &ast::ImplDef,
) -> Option<hir::Trait> { ) -> Option<hir::Trait> {
let ast_path = impl_block let ast_path = impl_def
.target_trait() .target_trait()
.map(|it| it.syntax().clone()) .map(|it| it.syntax().clone())
.and_then(ast::PathType::cast)? .and_then(ast::PathType::cast)?

View file

@ -229,8 +229,8 @@ impl Module {
} }
} }
for impl_block in self.impl_blocks(db) { for impl_def in self.impl_defs(db) {
for item in impl_block.items(db) { for item in impl_def.items(db) {
if let AssocItem::Function(f) = item { if let AssocItem::Function(f) = item {
f.diagnostics(db, sink); f.diagnostics(db, sink);
} }
@ -243,9 +243,9 @@ impl Module {
def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect()
} }
pub fn impl_blocks(self, db: &impl DefDatabase) -> Vec<ImplBlock> { pub fn impl_defs(self, db: &impl DefDatabase) -> Vec<ImplDef> {
let def_map = db.crate_def_map(self.id.krate); let def_map = db.crate_def_map(self.id.krate);
def_map[self.id.local_id].scope.impls().map(ImplBlock::from).collect() def_map[self.id.local_id].scope.impls().map(ImplDef::from).collect()
} }
pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module { pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module {
@ -686,7 +686,7 @@ pub enum AssocItem {
} }
pub enum AssocItemContainer { pub enum AssocItemContainer {
Trait(Trait), Trait(Trait),
ImplBlock(ImplBlock), ImplDef(ImplDef),
} }
pub trait AsAssocItem { pub trait AsAssocItem {
fn as_assoc_item(self, db: &impl DefDatabase) -> Option<AssocItem>; fn as_assoc_item(self, db: &impl DefDatabase) -> Option<AssocItem>;
@ -736,7 +736,7 @@ impl AssocItem {
}; };
match container { match container {
AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()),
AssocContainerId::ImplId(id) => AssocItemContainer::ImplBlock(id.into()), AssocContainerId::ImplId(id) => AssocItemContainer::ImplDef(id.into()),
AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"),
} }
} }
@ -748,7 +748,7 @@ pub enum GenericDef {
Adt(Adt), Adt(Adt),
Trait(Trait), Trait(Trait),
TypeAlias(TypeAlias), TypeAlias(TypeAlias),
ImplBlock(ImplBlock), ImplDef(ImplDef),
// enum variants cannot have generics themselves, but their parent enums // enum variants cannot have generics themselves, but their parent enums
// can, and this makes some code easier to write // can, and this makes some code easier to write
EnumVariant(EnumVariant), EnumVariant(EnumVariant),
@ -760,7 +760,7 @@ impl_froms!(
Adt(Struct, Enum, Union), Adt(Struct, Enum, Union),
Trait, Trait,
TypeAlias, TypeAlias,
ImplBlock, ImplDef,
EnumVariant, EnumVariant,
Const Const
); );
@ -850,20 +850,20 @@ impl TypeParam {
} }
} }
// FIXME: rename from `ImplBlock` to `Impl` // FIXME: rename from `ImplDef` to `Impl`
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ImplBlock { pub struct ImplDef {
pub(crate) id: ImplId, pub(crate) id: ImplId,
} }
impl ImplBlock { impl ImplDef {
pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplBlock> { pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplDef> {
let impls = db.impls_in_crate(krate.id); let impls = db.impls_in_crate(krate.id);
impls.all_impls().map(Self::from).collect() impls.all_impls().map(Self::from).collect()
} }
pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplBlock> { pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplDef> {
let impls = db.impls_in_crate(krate.id); let impls = db.impls_in_crate(krate.id);
impls.lookup_impl_blocks_for_trait(trait_.id).map(Self::from).collect() impls.lookup_impl_defs_for_trait(trait_.id).map(Self::from).collect()
} }
pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> {
@ -1077,7 +1077,7 @@ impl Type {
} }
// This would be nicer if it just returned an iterator, but that runs into // This would be nicer if it just returned an iterator, but that runs into
// lifetime problems, because we need to borrow temp `CrateImplBlocks`. // lifetime problems, because we need to borrow temp `CrateImplDefs`.
pub fn iterate_impl_items<T>( pub fn iterate_impl_items<T>(
self, self,
db: &impl HirDatabase, db: &impl HirDatabase,
@ -1087,8 +1087,8 @@ impl Type {
for krate in self.ty.value.def_crates(db, krate.id)? { for krate in self.ty.value.def_crates(db, krate.id)? {
let impls = db.impls_in_crate(krate); let impls = db.impls_in_crate(krate);
for impl_block in impls.lookup_impl_blocks(&self.ty.value) { for impl_def in impls.lookup_impl_defs(&self.ty.value) {
for &item in db.impl_data(impl_block).items.iter() { for &item in db.impl_data(impl_def).items.iter() {
if let Some(result) = callback(item.into()) { if let Some(result) = callback(item.into()) {
return Some(result); return Some(result);
} }
@ -1196,7 +1196,7 @@ pub enum ScopeDef {
ModuleDef(ModuleDef), ModuleDef(ModuleDef),
MacroDef(MacroDef), MacroDef(MacroDef),
GenericParam(TypeParam), GenericParam(TypeParam),
ImplSelfType(ImplBlock), ImplSelfType(ImplDef),
AdtSelfType(Adt), AdtSelfType(Adt),
Local(Local), Local(Local),
Unknown, Unknown,

View file

@ -39,7 +39,7 @@ from_id![
(hir_def::StaticId, crate::Static), (hir_def::StaticId, crate::Static),
(hir_def::ConstId, crate::Const), (hir_def::ConstId, crate::Const),
(hir_def::FunctionId, crate::Function), (hir_def::FunctionId, crate::Function),
(hir_def::ImplId, crate::ImplBlock), (hir_def::ImplId, crate::ImplDef),
(hir_def::TypeParamId, crate::TypeParam), (hir_def::TypeParamId, crate::TypeParam),
(hir_expand::MacroDefId, crate::MacroDef) (hir_expand::MacroDefId, crate::MacroDef)
]; ];
@ -145,7 +145,7 @@ impl From<GenericDef> for GenericDefId {
GenericDef::Adt(it) => GenericDefId::AdtId(it.into()), GenericDef::Adt(it) => GenericDefId::AdtId(it.into()),
GenericDef::Trait(it) => GenericDefId::TraitId(it.id), GenericDef::Trait(it) => GenericDefId::TraitId(it.id),
GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id), GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id),
GenericDef::ImplBlock(it) => GenericDefId::ImplId(it.id), GenericDef::ImplDef(it) => GenericDefId::ImplId(it.id),
GenericDef::EnumVariant(it) => { GenericDef::EnumVariant(it) => {
GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id })
} }

View file

@ -9,7 +9,7 @@ use hir_def::{
use ra_syntax::ast; use ra_syntax::ast;
use crate::{ use crate::{
db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, MacroDef, Module, db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplDef, MacroDef, Module,
Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union,
}; };
@ -111,9 +111,9 @@ impl HasSource for MacroDef {
} }
} }
} }
impl HasSource for ImplBlock { impl HasSource for ImplDef {
type Ast = ast::ImplBlock; type Ast = ast::ImplDef;
fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplBlock> { fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplDef> {
self.id.lookup(db).source(db) self.id.lookup(db).source(db)
} }
} }

View file

@ -41,7 +41,7 @@ pub use crate::{
code_model::{ code_model::{
Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency,
DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs,
HasVisibility, ImplBlock, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct,
StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef,
}, },
has_source::HasSource, has_source::HasSource,

View file

@ -262,7 +262,7 @@ to_def_impls![
(crate::Enum, ast::EnumDef, enum_to_def), (crate::Enum, ast::EnumDef, enum_to_def),
(crate::Union, ast::UnionDef, union_to_def), (crate::Union, ast::UnionDef, union_to_def),
(crate::Trait, ast::TraitDef, trait_to_def), (crate::Trait, ast::TraitDef, trait_to_def),
(crate::ImplBlock, ast::ImplBlock, impl_to_def), (crate::ImplDef, ast::ImplDef, impl_to_def),
(crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def), (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def),
(crate::Const, ast::ConstDef, const_to_def), (crate::Const, ast::ConstDef, const_to_def),
(crate::Static, ast::StaticDef, static_to_def), (crate::Static, ast::StaticDef, static_to_def),

View file

@ -67,7 +67,7 @@ impl<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> {
pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> { pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> {
self.to_def(src, keys::TRAIT) self.to_def(src, keys::TRAIT)
} }
pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplBlock>) -> Option<ImplId> { pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplDef>) -> Option<ImplId> {
self.to_def(src, keys::IMPL) self.to_def(src, keys::IMPL)
} }
pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> { pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> {
@ -166,7 +166,7 @@ impl<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> {
let def = self.trait_to_def(container.with_value(it))?; let def = self.trait_to_def(container.with_value(it))?;
def.into() def.into()
}, },
ast::ImplBlock(it) => { ast::ImplDef(it) => {
let def = self.impl_to_def(container.with_value(it))?; let def = self.impl_to_def(container.with_value(it))?;
def.into() def.into()
}, },
@ -213,7 +213,7 @@ impl<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> {
ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() }, ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() },
ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() }, ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() },
ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() }, ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() },
ast::ImplBlock(it) => { self.impl_to_def(container.with_value(it))?.into() }, ast::ImplDef(it) => { self.impl_to_def(container.with_value(it))?.into() },
_ => continue, _ => continue,
} }
}; };

View file

@ -49,7 +49,7 @@ pub enum PathResolution {
Local(Local), Local(Local),
/// A generic parameter /// A generic parameter
TypeParam(TypeParam), TypeParam(TypeParam),
SelfType(crate::ImplBlock), SelfType(crate::ImplDef),
Macro(MacroDef), Macro(MacroDef),
AssocItem(crate::AssocItem), AssocItem(crate::AssocItem),
} }

View file

@ -544,7 +544,7 @@ where
let ast_id = self.expander.ast_id(&def); let ast_id = self.expander.ast_id(&def);
(TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) (TraitLoc { container, ast_id }.intern(self.db).into(), def.name())
} }
ast::ModuleItem::ImplBlock(_) ast::ModuleItem::ImplDef(_)
| ast::ModuleItem::UseItem(_) | ast::ModuleItem::UseItem(_)
| ast::ModuleItem::ExternCrateItem(_) | ast::ModuleItem::ExternCrateItem(_)
| ast::ModuleItem::Module(_) => continue, | ast::ModuleItem::Module(_) => continue,

View file

@ -238,16 +238,16 @@ impl ConstData {
fn collect_impl_items_in_macros( fn collect_impl_items_in_macros(
db: &impl DefDatabase, db: &impl DefDatabase,
module_id: ModuleId, module_id: ModuleId,
impl_block: &InFile<ast::ItemList>, impl_def: &InFile<ast::ItemList>,
id: ImplId, id: ImplId,
) -> Vec<AssocItemId> { ) -> Vec<AssocItemId> {
let mut expander = Expander::new(db, impl_block.file_id, module_id); let mut expander = Expander::new(db, impl_def.file_id, module_id);
let mut res = Vec::new(); let mut res = Vec::new();
// We set a limit to protect against infinite recursion // We set a limit to protect against infinite recursion
let limit = 100; let limit = 100;
for m in impl_block.value.syntax().children().filter_map(ast::MacroCall::cast) { for m in impl_def.value.syntax().children().filter_map(ast::MacroCall::cast) {
res.extend(collect_impl_items_in_macro(db, &mut expander, m, id, limit)) res.extend(collect_impl_items_in_macro(db, &mut expander, m, id, limit))
} }

View file

@ -18,7 +18,7 @@ pub const FUNCTION: Key<ast::FnDef, FunctionId> = Key::new();
pub const CONST: Key<ast::ConstDef, ConstId> = Key::new(); pub const CONST: Key<ast::ConstDef, ConstId> = Key::new();
pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new(); pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new();
pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new(); pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new();
pub const IMPL: Key<ast::ImplBlock, ImplId> = Key::new(); pub const IMPL: Key<ast::ImplDef, ImplId> = Key::new();
pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new(); pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new();
pub const STRUCT: Key<ast::StructDef, StructId> = Key::new(); pub const STRUCT: Key<ast::StructDef, StructId> = Key::new();
pub const UNION: Key<ast::UnionDef, UnionId> = Key::new(); pub const UNION: Key<ast::UnionDef, UnionId> = Key::new();

View file

@ -16,7 +16,7 @@ use crate::{
pub enum LangItemTarget { pub enum LangItemTarget {
EnumId(EnumId), EnumId(EnumId),
FunctionId(FunctionId), FunctionId(FunctionId),
ImplBlockId(ImplId), ImplDefId(ImplId),
StaticId(StaticId), StaticId(StaticId),
StructId(StructId), StructId(StructId),
TraitId(TraitId), TraitId(TraitId),
@ -37,9 +37,9 @@ impl LangItemTarget {
} }
} }
pub fn as_impl_block(self) -> Option<ImplId> { pub fn as_impl_def(self) -> Option<ImplId> {
match self { match self {
LangItemTarget::ImplBlockId(id) => Some(id), LangItemTarget::ImplDefId(id) => Some(id),
_ => None, _ => None,
} }
} }
@ -125,8 +125,8 @@ impl LangItems {
// Look for impl targets // Look for impl targets
let def_map = db.crate_def_map(module.krate); let def_map = db.crate_def_map(module.krate);
let module_data = &def_map[module.local_id]; let module_data = &def_map[module.local_id];
for impl_block in module_data.scope.impls() { for impl_def in module_data.scope.impls() {
self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId) self.collect_lang_item(db, impl_def, LangItemTarget::ImplDefId)
} }
for def in module_data.scope.declarations() { for def in module_data.scope.declarations() {

View file

@ -164,7 +164,7 @@ impl_intern!(TypeAliasId, TypeAliasLoc, intern_type_alias, lookup_intern_type_al
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ImplId(salsa::InternId); pub struct ImplId(salsa::InternId);
type ImplLoc = ItemLoc<ast::ImplBlock>; type ImplLoc = ItemLoc<ast::ImplDef>;
impl_intern!(ImplId, ImplLoc, intern_impl, lookup_intern_impl); impl_intern!(ImplId, ImplLoc, intern_impl, lookup_intern_impl);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

View file

@ -213,7 +213,7 @@ impl_arena_id!(Impl);
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub(super) struct ImplData { pub(super) struct ImplData {
pub(super) ast_id: FileAstId<ast::ImplBlock>, pub(super) ast_id: FileAstId<ast::ImplDef>,
} }
struct RawItemsCollector { struct RawItemsCollector {
@ -249,7 +249,7 @@ impl RawItemsCollector {
self.add_extern_crate_item(current_module, extern_crate); self.add_extern_crate_item(current_module, extern_crate);
return; return;
} }
ast::ModuleItem::ImplBlock(it) => { ast::ModuleItem::ImplDef(it) => {
self.add_impl(current_module, it); self.add_impl(current_module, it);
return; return;
} }
@ -395,7 +395,7 @@ impl RawItemsCollector {
self.push_item(current_module, attrs, RawItemKind::Macro(m)); self.push_item(current_module, attrs, RawItemKind::Macro(m));
} }
fn add_impl(&mut self, current_module: Option<Module>, imp: ast::ImplBlock) { fn add_impl(&mut self, current_module: Option<Module>, imp: ast::ImplDef) {
let attrs = self.parse_attrs(&imp); let attrs = self.parse_attrs(&imp);
let ast_id = self.source_ast_id_map.ast_id(&imp); let ast_id = self.source_ast_id_map.ast_id(&imp);
let imp = self.raw_items.impls.alloc(ImplData { ast_id }); let imp = self.raw_items.impls.alloc(ImplData { ast_id });

View file

@ -52,7 +52,7 @@ enum Scope {
/// Brings the generic parameters of an item into scope /// Brings the generic parameters of an item into scope
GenericParams { def: GenericDefId, params: Arc<GenericParams> }, GenericParams { def: GenericDefId, params: Arc<GenericParams> },
/// Brings `Self` in `impl` block into scope /// Brings `Self` in `impl` block into scope
ImplBlockScope(ImplId), ImplDefScope(ImplId),
/// Brings `Self` in enum, struct and union definitions into scope /// Brings `Self` in enum, struct and union definitions into scope
AdtScope(AdtId), AdtScope(AdtId),
/// Local bindings /// Local bindings
@ -154,7 +154,7 @@ impl Resolver {
match scope { match scope {
Scope::ExprScope(_) => continue, Scope::ExprScope(_) => continue,
Scope::GenericParams { .. } Scope::GenericParams { .. }
| Scope::ImplBlockScope(_) | Scope::ImplDefScope(_)
| Scope::LocalItemsScope(_) | Scope::LocalItemsScope(_)
if skip_to_mod => if skip_to_mod =>
{ {
@ -170,7 +170,7 @@ impl Resolver {
)); ));
} }
} }
Scope::ImplBlockScope(impl_) => { Scope::ImplDefScope(impl_) => {
if first_name == &name![Self] { if first_name == &name![Self] {
let idx = if path.segments.len() == 1 { None } else { Some(1) }; let idx = if path.segments.len() == 1 { None } else { Some(1) };
return Some((TypeNs::SelfType(*impl_), idx)); return Some((TypeNs::SelfType(*impl_), idx));
@ -263,7 +263,7 @@ impl Resolver {
Scope::AdtScope(_) Scope::AdtScope(_)
| Scope::ExprScope(_) | Scope::ExprScope(_)
| Scope::GenericParams { .. } | Scope::GenericParams { .. }
| Scope::ImplBlockScope(_) | Scope::ImplDefScope(_)
| Scope::LocalItemsScope(_) | Scope::LocalItemsScope(_)
if skip_to_mod => if skip_to_mod =>
{ {
@ -291,7 +291,7 @@ impl Resolver {
} }
Scope::GenericParams { .. } => continue, Scope::GenericParams { .. } => continue,
Scope::ImplBlockScope(impl_) if n_segments > 1 => { Scope::ImplDefScope(impl_) if n_segments > 1 => {
if first_name == &name![Self] { if first_name == &name![Self] {
let ty = TypeNs::SelfType(*impl_); let ty = TypeNs::SelfType(*impl_);
return Some(ResolveValueResult::Partial(ty, 1)); return Some(ResolveValueResult::Partial(ty, 1));
@ -303,7 +303,7 @@ impl Resolver {
return Some(ResolveValueResult::Partial(ty, 1)); return Some(ResolveValueResult::Partial(ty, 1));
} }
} }
Scope::ImplBlockScope(_) | Scope::AdtScope(_) => continue, Scope::ImplDefScope(_) | Scope::AdtScope(_) => continue,
Scope::ModuleScope(m) => { Scope::ModuleScope(m) => {
let (module_def, idx) = m.crate_def_map.resolve_path( let (module_def, idx) = m.crate_def_map.resolve_path(
@ -503,7 +503,7 @@ impl Scope {
} }
} }
} }
Scope::ImplBlockScope(i) => { Scope::ImplDefScope(i) => {
f(name![Self], ScopeDef::ImplSelfType(*i)); f(name![Self], ScopeDef::ImplSelfType(*i));
} }
Scope::AdtScope(i) => { Scope::AdtScope(i) => {
@ -550,8 +550,8 @@ impl Resolver {
self.push_scope(Scope::GenericParams { def, params }) self.push_scope(Scope::GenericParams { def, params })
} }
fn push_impl_block_scope(self, impl_block: ImplId) -> Resolver { fn push_impl_def_scope(self, impl_def: ImplId) -> Resolver {
self.push_scope(Scope::ImplBlockScope(impl_block)) self.push_scope(Scope::ImplDefScope(impl_def))
} }
fn push_module_scope( fn push_module_scope(
@ -634,7 +634,7 @@ impl HasResolver for ImplId {
.container .container
.resolver(db) .resolver(db)
.push_generic_params_scope(db, self.into()) .push_generic_params_scope(db, self.into())
.push_impl_block_scope(self) .push_impl_def_scope(self)
} }
} }

View file

@ -11,7 +11,7 @@ use ra_db::{impl_intern_key, salsa, CrateId};
use ra_prof::profile; use ra_prof::profile;
use crate::{ use crate::{
method_resolution::CrateImplBlocks, method_resolution::CrateImplDefs,
traits::{chalk, AssocTyValue, Impl}, traits::{chalk, AssocTyValue, Impl},
Binders, CallableDef, GenericPredicate, InferenceResult, PolyFnSig, Substs, TraitRef, Ty, Binders, CallableDef, GenericPredicate, InferenceResult, PolyFnSig, Substs, TraitRef, Ty,
TyDefId, TypeCtor, ValueTyDefId, TyDefId, TypeCtor, ValueTyDefId,
@ -59,8 +59,8 @@ pub trait HirDatabase: DefDatabase {
#[salsa::invoke(crate::lower::generic_defaults_query)] #[salsa::invoke(crate::lower::generic_defaults_query)]
fn generic_defaults(&self, def: GenericDefId) -> Substs; fn generic_defaults(&self, def: GenericDefId) -> Substs;
#[salsa::invoke(crate::method_resolution::CrateImplBlocks::impls_in_crate_query)] #[salsa::invoke(crate::method_resolution::CrateImplDefs::impls_in_crate_query)]
fn impls_in_crate(&self, krate: CrateId) -> Arc<CrateImplBlocks>; fn impls_in_crate(&self, krate: CrateId) -> Arc<CrateImplDefs>;
#[salsa::invoke(crate::traits::impls_for_trait_query)] #[salsa::invoke(crate::traits::impls_for_trait_query)]
fn impls_for_trait(&self, krate: CrateId, trait_: TraitId) -> Arc<[ImplId]>; fn impls_for_trait(&self, krate: CrateId, trait_: TraitId) -> Arc<[ImplId]>;

View file

@ -42,19 +42,19 @@ impl TyFingerprint {
} }
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct CrateImplBlocks { pub struct CrateImplDefs {
impls: FxHashMap<TyFingerprint, Vec<ImplId>>, impls: FxHashMap<TyFingerprint, Vec<ImplId>>,
impls_by_trait: FxHashMap<TraitId, Vec<ImplId>>, impls_by_trait: FxHashMap<TraitId, Vec<ImplId>>,
} }
impl CrateImplBlocks { impl CrateImplDefs {
pub(crate) fn impls_in_crate_query( pub(crate) fn impls_in_crate_query(
db: &impl HirDatabase, db: &impl HirDatabase,
krate: CrateId, krate: CrateId,
) -> Arc<CrateImplBlocks> { ) -> Arc<CrateImplDefs> {
let _p = profile("impls_in_crate_query"); let _p = profile("impls_in_crate_query");
let mut res = let mut res =
CrateImplBlocks { impls: FxHashMap::default(), impls_by_trait: FxHashMap::default() }; CrateImplDefs { impls: FxHashMap::default(), impls_by_trait: FxHashMap::default() };
let crate_def_map = db.crate_def_map(krate); let crate_def_map = db.crate_def_map(krate);
for (_module_id, module_data) in crate_def_map.modules.iter() { for (_module_id, module_data) in crate_def_map.modules.iter() {
@ -75,12 +75,12 @@ impl CrateImplBlocks {
Arc::new(res) Arc::new(res)
} }
pub fn lookup_impl_blocks(&self, ty: &Ty) -> impl Iterator<Item = ImplId> + '_ { pub fn lookup_impl_defs(&self, ty: &Ty) -> impl Iterator<Item = ImplId> + '_ {
let fingerprint = TyFingerprint::for_impl(ty); let fingerprint = TyFingerprint::for_impl(ty);
fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flatten().copied() fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flatten().copied()
} }
pub fn lookup_impl_blocks_for_trait(&self, tr: TraitId) -> impl Iterator<Item = ImplId> + '_ { pub fn lookup_impl_defs_for_trait(&self, tr: TraitId) -> impl Iterator<Item = ImplId> + '_ {
self.impls_by_trait.get(&tr).into_iter().flatten().copied() self.impls_by_trait.get(&tr).into_iter().flatten().copied()
} }
@ -131,7 +131,7 @@ impl Ty {
let res = lang_item_targets let res = lang_item_targets
.into_iter() .into_iter()
.filter_map(|it| match it { .filter_map(|it| match it {
LangItemTarget::ImplBlockId(it) => Some(it), LangItemTarget::ImplDefId(it) => Some(it),
_ => None, _ => None,
}) })
.map(|it| it.lookup(db).container.module(db).krate) .map(|it| it.lookup(db).container.module(db).krate)
@ -177,7 +177,7 @@ pub enum LookupMode {
} }
// This would be nicer if it just returned an iterator, but that runs into // This would be nicer if it just returned an iterator, but that runs into
// lifetime problems, because we need to borrow temp `CrateImplBlocks`. // lifetime problems, because we need to borrow temp `CrateImplDefs`.
// FIXME add a context type here? // FIXME add a context type here?
pub fn iterate_method_candidates<T>( pub fn iterate_method_candidates<T>(
ty: &Canonical<Ty>, ty: &Canonical<Ty>,
@ -425,8 +425,8 @@ fn iterate_inherent_methods<T>(
for krate in self_ty.value.def_crates(db, krate)? { for krate in self_ty.value.def_crates(db, krate)? {
let impls = db.impls_in_crate(krate); let impls = db.impls_in_crate(krate);
for impl_block in impls.lookup_impl_blocks(&self_ty.value) { for impl_def in impls.lookup_impl_defs(&self_ty.value) {
for &item in db.impl_data(impl_block).items.iter() { for &item in db.impl_data(impl_def).items.iter() {
if !is_valid_candidate(db, name, receiver_ty, item, self_ty) { if !is_valid_candidate(db, name, receiver_ty, item, self_ty) {
continue; continue;
} }
@ -434,8 +434,7 @@ fn iterate_inherent_methods<T>(
// that the impl is for. If we have a receiver type, this // that the impl is for. If we have a receiver type, this
// already happens in `is_valid_candidate` above; if not, we // already happens in `is_valid_candidate` above; if not, we
// check it here // check it here
if receiver_ty.is_none() && inherent_impl_substs(db, impl_block, self_ty).is_none() if receiver_ty.is_none() && inherent_impl_substs(db, impl_def, self_ty).is_none() {
{
test_utils::tested_by!(impl_self_type_match_without_receiver); test_utils::tested_by!(impl_self_type_match_without_receiver);
continue; continue;
} }

View file

@ -4,7 +4,7 @@ use insta::assert_snapshot;
use ra_db::fixture::WithFixture; use ra_db::fixture::WithFixture;
#[test] #[test]
fn cfg_impl_block() { fn cfg_impl_def() {
let (db, pos) = TestDB::with_position( let (db, pos) = TestDB::with_position(
r#" r#"
//- /main.rs crate:main deps:foo cfg:test //- /main.rs crate:main deps:foo cfg:test
@ -354,10 +354,10 @@ fn main() {
@r###" @r###"
[159; 164) '{ 0 }': u64 [159; 164) '{ 0 }': u64
[161; 162) '0': u64 [161; 162) '0': u64
[175; 199) '{ ...f(); }': () [175; 197) '{ ...f(); }': ()
[187; 189) '_a': u64 [185; 187) '_a': u64
[193; 194) 'f': fn f() -> u64 [191; 192) 'f': fn f() -> u64
[193; 196) 'f()': u64 [191; 194) 'f()': u64
"### "###
); );
} }

View file

@ -131,8 +131,8 @@ pub(crate) fn impls_for_trait_query(
for dep in db.crate_graph().dependencies(krate) { for dep in db.crate_graph().dependencies(krate) {
impls.extend(db.impls_for_trait(dep.crate_id, trait_).iter()); impls.extend(db.impls_for_trait(dep.crate_id, trait_).iter());
} }
let crate_impl_blocks = db.impls_in_crate(krate); let crate_impl_defs = db.impls_in_crate(krate);
impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(trait_)); impls.extend(crate_impl_defs.lookup_impl_defs_for_trait(trait_));
impls.into_iter().collect() impls.into_iter().collect()
} }
@ -346,7 +346,7 @@ pub struct UnsizeToSuperTraitObjectData {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Impl { pub enum Impl {
/// A normal impl from an impl block. /// A normal impl from an impl block.
ImplBlock(ImplId), ImplDef(ImplId),
/// Closure types implement the Fn traits synthetically. /// Closure types implement the Fn traits synthetically.
ClosureFnTraitImpl(ClosureFnTraitImplData), ClosureFnTraitImpl(ClosureFnTraitImplData),
/// [T; n]: Unsize<[T]> /// [T; n]: Unsize<[T]>

View file

@ -96,7 +96,7 @@ fn get_builtin_unsize_impls(
pub(super) fn impl_datum(db: &impl HirDatabase, krate: CrateId, impl_: Impl) -> BuiltinImplData { pub(super) fn impl_datum(db: &impl HirDatabase, krate: CrateId, impl_: Impl) -> BuiltinImplData {
match impl_ { match impl_ {
Impl::ImplBlock(_) => unreachable!(), Impl::ImplDef(_) => unreachable!(),
Impl::ClosureFnTraitImpl(data) => closure_fn_trait_impl_datum(db, krate, data), Impl::ClosureFnTraitImpl(data) => closure_fn_trait_impl_datum(db, krate, data),
Impl::UnsizeArray => array_unsize_impl_datum(db, krate), Impl::UnsizeArray => array_unsize_impl_datum(db, krate),
Impl::UnsizeToTraitObject(trait_) => trait_object_unsize_impl_datum(db, krate, trait_), Impl::UnsizeToTraitObject(trait_) => trait_object_unsize_impl_datum(db, krate, trait_),

View file

@ -576,7 +576,7 @@ where
.impls_for_trait(self.krate, trait_) .impls_for_trait(self.krate, trait_)
.iter() .iter()
.copied() .copied()
.map(Impl::ImplBlock) .map(Impl::ImplDef)
.map(|impl_| impl_.to_chalk(self.db)) .map(|impl_| impl_.to_chalk(self.db))
.collect(); .collect();
@ -712,12 +712,12 @@ pub(crate) fn impl_datum_query(
debug!("impl_datum {:?}", impl_id); debug!("impl_datum {:?}", impl_id);
let impl_: Impl = from_chalk(db, impl_id); let impl_: Impl = from_chalk(db, impl_id);
match impl_ { match impl_ {
Impl::ImplBlock(impl_block) => impl_block_datum(db, krate, impl_id, impl_block), Impl::ImplDef(impl_def) => impl_def_datum(db, krate, impl_id, impl_def),
_ => Arc::new(builtin::impl_datum(db, krate, impl_).to_chalk(db)), _ => Arc::new(builtin::impl_datum(db, krate, impl_).to_chalk(db)),
} }
} }
fn impl_block_datum( fn impl_def_datum(
db: &impl HirDatabase, db: &impl HirDatabase,
krate: CrateId, krate: CrateId,
chalk_id: ImplId, chalk_id: ImplId,
@ -815,7 +815,7 @@ fn type_alias_associated_ty_value(
let ty = db.ty(type_alias.into()); let ty = db.ty(type_alias.into());
let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) }; let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) };
let value = chalk_rust_ir::AssociatedTyValue { let value = chalk_rust_ir::AssociatedTyValue {
impl_id: Impl::ImplBlock(impl_id).to_chalk(db), impl_id: Impl::ImplDef(impl_id).to_chalk(db),
associated_ty_id: assoc_ty.to_chalk(db), associated_ty_id: assoc_ty.to_chalk(db),
value: make_binders(value_bound, ty.num_binders), value: make_binders(value_bound, ty.num_binders),
}; };

View file

@ -3,7 +3,7 @@
//! This module adds the completion items related to implementing associated //! This module adds the completion items related to implementing associated
//! items within a `impl Trait for Struct` block. The current context node //! items within a `impl Trait for Struct` block. The current context node
//! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node //! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node
//! and an direct child of an `IMPL_BLOCK`. //! and an direct child of an `IMPL_DEF`.
//! //!
//! # Examples //! # Examples
//! //!
@ -55,49 +55,43 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
_ => false, _ => false,
}); });
let impl_block = trigger let impl_def = trigger
.as_ref() .as_ref()
.and_then(|node| node.parent()) .and_then(|node| node.parent())
.and_then(|node| node.parent()) .and_then(|node| node.parent())
.and_then(ast::ImplBlock::cast); .and_then(ast::ImplDef::cast);
if let (Some(trigger), Some(impl_block)) = (trigger, impl_block) { if let (Some(trigger), Some(impl_def)) = (trigger, impl_def) {
match trigger.kind() { match trigger.kind() {
SyntaxKind::FN_DEF => { SyntaxKind::FN_DEF => {
for missing_fn in for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map(
get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { |item| match item {
match item { hir::AssocItem::Function(fn_item) => Some(fn_item),
hir::AssocItem::Function(fn_item) => Some(fn_item), _ => None,
_ => None, },
} ) {
})
{
add_function_impl(&trigger, acc, ctx, &missing_fn); add_function_impl(&trigger, acc, ctx, &missing_fn);
} }
} }
SyntaxKind::TYPE_ALIAS_DEF => { SyntaxKind::TYPE_ALIAS_DEF => {
for missing_fn in for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map(
get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { |item| match item {
match item { hir::AssocItem::TypeAlias(type_item) => Some(type_item),
hir::AssocItem::TypeAlias(type_item) => Some(type_item), _ => None,
_ => None, },
} ) {
})
{
add_type_alias_impl(&trigger, acc, ctx, &missing_fn); add_type_alias_impl(&trigger, acc, ctx, &missing_fn);
} }
} }
SyntaxKind::CONST_DEF => { SyntaxKind::CONST_DEF => {
for missing_fn in for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map(
get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { |item| match item {
match item { hir::AssocItem::Const(const_item) => Some(const_item),
hir::AssocItem::Const(const_item) => Some(const_item), _ => None,
_ => None, },
} ) {
})
{
add_const_impl(&trigger, acc, ctx, &missing_fn); add_const_impl(&trigger, acc, ctx, &missing_fn);
} }
} }

View file

@ -27,7 +27,7 @@ pub(crate) struct CompletionContext<'a> {
pub(super) use_item_syntax: Option<ast::UseItem>, pub(super) use_item_syntax: Option<ast::UseItem>,
pub(super) record_lit_syntax: Option<ast::RecordLit>, pub(super) record_lit_syntax: Option<ast::RecordLit>,
pub(super) record_lit_pat: Option<ast::RecordPat>, pub(super) record_lit_pat: Option<ast::RecordPat>,
pub(super) impl_block: Option<ast::ImplBlock>, pub(super) impl_def: Option<ast::ImplDef>,
pub(super) is_param: bool, pub(super) is_param: bool,
/// If a name-binding or reference to a const in a pattern. /// If a name-binding or reference to a const in a pattern.
/// Irrefutable patterns (like let) are excluded. /// Irrefutable patterns (like let) are excluded.
@ -81,7 +81,7 @@ impl<'a> CompletionContext<'a> {
use_item_syntax: None, use_item_syntax: None,
record_lit_syntax: None, record_lit_syntax: None,
record_lit_pat: None, record_lit_pat: None,
impl_block: None, impl_def: None,
is_param: false, is_param: false,
is_pat_binding: false, is_pat_binding: false,
is_trivial_path: false, is_trivial_path: false,
@ -161,12 +161,12 @@ impl<'a> CompletionContext<'a> {
self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset); self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset);
} }
self.impl_block = self self.impl_def = self
.token .token
.parent() .parent()
.ancestors() .ancestors()
.take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
.find_map(ast::ImplBlock::cast); .find_map(ast::ImplDef::cast);
let top_node = name_ref let top_node = name_ref
.syntax() .syntax()

View file

@ -269,7 +269,7 @@ impl ToNav for hir::Module {
} }
} }
impl ToNav for hir::ImplBlock { impl ToNav for hir::ImplDef {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
let src = self.source(db); let src = self.source(db);
let frange = if let Some(item) = self.is_builtin_derive(db) { let frange = if let Some(item) = self.is_builtin_derive(db) {

View file

@ -129,7 +129,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
ast::RecordFieldDef(it) => { decl_with_ascription(it) }, ast::RecordFieldDef(it) => { decl_with_ascription(it) },
ast::ConstDef(it) => { decl_with_ascription(it) }, ast::ConstDef(it) => { decl_with_ascription(it) },
ast::StaticDef(it) => { decl_with_ascription(it) }, ast::StaticDef(it) => { decl_with_ascription(it) },
ast::ImplBlock(it) => { ast::ImplDef(it) => {
let target_type = it.target_type()?; let target_type = it.target_type()?;
let target_trait = it.target_trait(); let target_trait = it.target_trait();
let label = match target_trait { let label = match target_trait {
@ -360,7 +360,7 @@ fn very_obsolete() {}
label: "impl E", label: "impl E",
navigation_range: [239; 240), navigation_range: [239; 240),
node_range: [234; 243), node_range: [234; 243),
kind: IMPL_BLOCK, kind: IMPL_DEF,
detail: None, detail: None,
deprecated: false, deprecated: false,
}, },
@ -369,7 +369,7 @@ fn very_obsolete() {}
label: "impl fmt::Debug for E", label: "impl fmt::Debug for E",
navigation_range: [265; 266), navigation_range: [265; 266),
node_range: [245; 269), node_range: [245; 269),
kind: IMPL_BLOCK, kind: IMPL_DEF,
detail: None, detail: None,
deprecated: false, deprecated: false,
}, },

View file

@ -195,7 +195,7 @@ fn some_thing() -> u32 {
mat<|>ch_ast! { mat<|>ch_ast! {
match container { match container {
ast::TraitDef(it) => {}, ast::TraitDef(it) => {},
ast::ImplBlock(it) => {}, ast::ImplDef(it) => {},
_ => { continue }, _ => { continue },
} }
} }
@ -207,7 +207,7 @@ fn some_thing() -> u32 {
assert_snapshot!(res.expansion, @r###" assert_snapshot!(res.expansion, @r###"
{ {
if let Some(it) = ast::TraitDef::cast(container.clone()){} if let Some(it) = ast::TraitDef::cast(container.clone()){}
else if let Some(it) = ast::ImplBlock::cast(container.clone()){} else if let Some(it) = ast::ImplDef::cast(container.clone()){}
else { else {
{ {
continue continue

View file

@ -477,7 +477,7 @@ mod tests {
} }
} }
", ",
"impl IMPL_BLOCK FileId(1) [12; 73)", "impl IMPL_DEF FileId(1) [12; 73)",
"impl Foo {...}", "impl Foo {...}",
); );
@ -491,7 +491,7 @@ mod tests {
} }
} }
", ",
"impl IMPL_BLOCK FileId(1) [12; 73)", "impl IMPL_DEF FileId(1) [12; 73)",
"impl Foo {...}", "impl Foo {...}",
); );
@ -505,7 +505,7 @@ mod tests {
} }
} }
", ",
"impl IMPL_BLOCK FileId(1) [15; 75)", "impl IMPL_DEF FileId(1) [15; 75)",
"impl Foo {...}", "impl Foo {...}",
); );
@ -518,7 +518,7 @@ mod tests {
} }
} }
", ",
"impl IMPL_BLOCK FileId(1) [15; 62)", "impl IMPL_DEF FileId(1) [15; 62)",
"impl Foo {...}", "impl Foo {...}",
); );
} }
@ -538,7 +538,7 @@ mod tests {
} }
} }
", ",
"impl IMPL_BLOCK FileId(1) [49; 115)", "impl IMPL_DEF FileId(1) [49; 115)",
"impl Make for Foo {...}", "impl Make for Foo {...}",
); );
@ -555,7 +555,7 @@ mod tests {
} }
} }
", ",
"impl IMPL_BLOCK FileId(1) [49; 115)", "impl IMPL_DEF FileId(1) [49; 115)",
"impl Make for Foo {...}", "impl Make for Foo {...}",
); );
} }

View file

@ -1,6 +1,6 @@
//! FIXME: write short doc here //! FIXME: write short doc here
use hir::{Crate, ImplBlock, Semantics}; use hir::{Crate, ImplDef, Semantics};
use ra_ide_db::RootDatabase; use ra_ide_db::RootDatabase;
use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
@ -42,12 +42,12 @@ fn impls_for_def(
ast::NominalDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db), ast::NominalDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db),
}; };
let impls = ImplBlock::all_in_crate(sema.db, krate); let impls = ImplDef::all_in_crate(sema.db, krate);
Some( Some(
impls impls
.into_iter() .into_iter()
.filter(|impl_block| ty.is_equal_for_find_impls(&impl_block.target_ty(sema.db))) .filter(|impl_def| ty.is_equal_for_find_impls(&impl_def.target_ty(sema.db)))
.map(|imp| imp.to_nav(sema.db)) .map(|imp| imp.to_nav(sema.db))
.collect(), .collect(),
) )
@ -60,7 +60,7 @@ fn impls_for_trait(
) -> Option<Vec<NavigationTarget>> { ) -> Option<Vec<NavigationTarget>> {
let tr = sema.to_def(node)?; let tr = sema.to_def(node)?;
let impls = ImplBlock::for_trait(sema.db, krate, tr); let impls = ImplDef::for_trait(sema.db, krate, tr);
Some(impls.into_iter().map(|imp| imp.to_nav(sema.db)).collect()) Some(impls.into_iter().map(|imp| imp.to_nav(sema.db)).collect())
} }
@ -86,7 +86,7 @@ mod tests {
struct Foo<|>; struct Foo<|>;
impl Foo {} impl Foo {}
", ",
&["impl IMPL_BLOCK FileId(1) [12; 23)"], &["impl IMPL_DEF FileId(1) [12; 23)"],
); );
} }
@ -99,7 +99,7 @@ mod tests {
impl Foo {} impl Foo {}
impl Foo {} impl Foo {}
", ",
&["impl IMPL_BLOCK FileId(1) [12; 23)", "impl IMPL_BLOCK FileId(1) [24; 35)"], &["impl IMPL_DEF FileId(1) [12; 23)", "impl IMPL_DEF FileId(1) [24; 35)"],
); );
} }
@ -116,7 +116,7 @@ mod tests {
impl super::Foo {} impl super::Foo {}
} }
", ",
&["impl IMPL_BLOCK FileId(1) [24; 42)", "impl IMPL_BLOCK FileId(1) [57; 75)"], &["impl IMPL_DEF FileId(1) [24; 42)", "impl IMPL_DEF FileId(1) [57; 75)"],
); );
} }
@ -133,7 +133,7 @@ mod tests {
//- /b.rs //- /b.rs
impl crate::Foo {} impl crate::Foo {}
", ",
&["impl IMPL_BLOCK FileId(2) [0; 18)", "impl IMPL_BLOCK FileId(3) [0; 18)"], &["impl IMPL_DEF FileId(2) [0; 18)", "impl IMPL_DEF FileId(3) [0; 18)"],
); );
} }
@ -146,7 +146,7 @@ mod tests {
struct Foo; struct Foo;
impl T for Foo {} impl T for Foo {}
", ",
&["impl IMPL_BLOCK FileId(1) [23; 40)"], &["impl IMPL_DEF FileId(1) [23; 40)"],
); );
} }
@ -164,7 +164,7 @@ mod tests {
//- /b.rs //- /b.rs
impl crate::T for crate::Foo {} impl crate::T for crate::Foo {}
", ",
&["impl IMPL_BLOCK FileId(2) [0; 31)", "impl IMPL_BLOCK FileId(3) [0; 31)"], &["impl IMPL_DEF FileId(2) [0; 31)", "impl IMPL_DEF FileId(3) [0; 31)"],
); );
} }
@ -180,9 +180,9 @@ mod tests {
impl T for &Foo {} impl T for &Foo {}
", ",
&[ &[
"impl IMPL_BLOCK FileId(1) [23; 34)", "impl IMPL_DEF FileId(1) [23; 34)",
"impl IMPL_BLOCK FileId(1) [35; 52)", "impl IMPL_DEF FileId(1) [35; 52)",
"impl IMPL_BLOCK FileId(1) [53; 71)", "impl IMPL_DEF FileId(1) [53; 71)",
], ],
); );
} }
@ -195,7 +195,7 @@ mod tests {
#[derive(Copy)] #[derive(Copy)]
struct Foo<|>; struct Foo<|>;
", ",
&["impl IMPL_BLOCK FileId(1) [0; 15)"], &["impl IMPL_DEF FileId(1) [0; 15)"],
); );
} }
} }

View file

@ -61,7 +61,7 @@ pub(crate) fn classify_name_ref(
PathResolution::Local(local) => NameDefinition::Local(local), PathResolution::Local(local) => NameDefinition::Local(local),
PathResolution::TypeParam(par) => NameDefinition::TypeParam(par), PathResolution::TypeParam(par) => NameDefinition::TypeParam(par),
PathResolution::Macro(def) => NameDefinition::Macro(def), PathResolution::Macro(def) => NameDefinition::Macro(def),
PathResolution::SelfType(impl_block) => NameDefinition::SelfType(impl_block), PathResolution::SelfType(impl_def) => NameDefinition::SelfType(impl_def),
}; };
Some(res) Some(res)
} }

View file

@ -6,7 +6,7 @@
// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06).
use hir::{ use hir::{
Adt, FieldSource, HasSource, ImplBlock, Local, MacroDef, Module, ModuleDef, Semantics, Adt, FieldSource, HasSource, ImplDef, Local, MacroDef, Module, ModuleDef, Semantics,
StructField, TypeParam, StructField, TypeParam,
}; };
use ra_prof::profile; use ra_prof::profile;
@ -22,7 +22,7 @@ pub enum NameDefinition {
Macro(MacroDef), Macro(MacroDef),
StructField(StructField), StructField(StructField),
ModuleDef(ModuleDef), ModuleDef(ModuleDef),
SelfType(ImplBlock), SelfType(ImplDef),
Local(Local), Local(Local),
TypeParam(TypeParam), TypeParam(TypeParam),
} }

View file

@ -152,7 +152,7 @@ pub(crate) fn reparser(
EXTERN_ITEM_LIST => items::extern_item_list, EXTERN_ITEM_LIST => items::extern_item_list,
TOKEN_TREE if first_child? == T!['{'] => items::token_tree, TOKEN_TREE if first_child? == T!['{'] => items::token_tree,
ITEM_LIST => match parent? { ITEM_LIST => match parent? {
IMPL_BLOCK => items::impl_item_list, IMPL_DEF => items::impl_item_list,
TRAIT_DEF => items::trait_item_list, TRAIT_DEF => items::trait_item_list,
MODULE => items::mod_item_list, MODULE => items::mod_item_list,
_ => return None, _ => return None,

View file

@ -202,8 +202,8 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
// test unsafe_default_impl // test unsafe_default_impl
// unsafe default impl Foo {} // unsafe default impl Foo {}
T![impl] => { T![impl] => {
traits::impl_block(p); traits::impl_def(p);
m.complete(p, IMPL_BLOCK); m.complete(p, IMPL_DEF);
} }
// test existential_type // test existential_type

View file

@ -53,9 +53,9 @@ pub(crate) fn trait_item_list(p: &mut Parser) {
m.complete(p, ITEM_LIST); m.complete(p, ITEM_LIST);
} }
// test impl_block // test impl_def
// impl Foo {} // impl Foo {}
pub(super) fn impl_block(p: &mut Parser) { pub(super) fn impl_def(p: &mut Parser) {
assert!(p.at(T![impl])); assert!(p.at(T![impl]));
p.bump(T![impl]); p.bump(T![impl]);
if choose_type_params_over_qpath(p) { if choose_type_params_over_qpath(p) {
@ -65,7 +65,7 @@ pub(super) fn impl_block(p: &mut Parser) {
// FIXME: never type // FIXME: never type
// impl ! {} // impl ! {}
// test impl_block_neg // test impl_def_neg
// impl !Send for X {} // impl !Send for X {}
p.eat(T![!]); p.eat(T![!]);
impl_type(p); impl_type(p);

View file

@ -133,7 +133,7 @@ pub enum SyntaxKind {
STATIC_DEF, STATIC_DEF,
CONST_DEF, CONST_DEF,
TRAIT_DEF, TRAIT_DEF,
IMPL_BLOCK, IMPL_DEF,
TYPE_ALIAS_DEF, TYPE_ALIAS_DEF,
MACRO_CALL, MACRO_CALL,
TOKEN_TREE, TOKEN_TREE,

View file

@ -169,7 +169,7 @@ impl ast::UseTreeList {
} }
} }
impl ast::ImplBlock { impl ast::ImplDef {
pub fn target_type(&self) -> Option<ast::TypeRef> { pub fn target_type(&self) -> Option<ast::TypeRef> {
match self.target() { match self.target() {
(Some(t), None) | (_, Some(t)) => Some(t), (Some(t), None) | (_, Some(t)) => Some(t),

View file

@ -552,13 +552,13 @@ impl TypeAliasDef {
} }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ImplBlock { pub struct ImplDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
impl AstNode for ImplBlock { impl AstNode for ImplDef {
fn can_cast(kind: SyntaxKind) -> bool { fn can_cast(kind: SyntaxKind) -> bool {
match kind { match kind {
IMPL_BLOCK => true, IMPL_DEF => true,
_ => false, _ => false,
} }
} }
@ -573,9 +573,9 @@ impl AstNode for ImplBlock {
&self.syntax &self.syntax
} }
} }
impl ast::TypeParamsOwner for ImplBlock {} impl ast::TypeParamsOwner for ImplDef {}
impl ast::AttrsOwner for ImplBlock {} impl ast::AttrsOwner for ImplDef {}
impl ImplBlock { impl ImplDef {
pub fn item_list(&self) -> Option<ItemList> { pub fn item_list(&self) -> Option<ItemList> {
AstChildren::new(&self.syntax).next() AstChildren::new(&self.syntax).next()
} }
@ -3524,7 +3524,7 @@ pub enum ModuleItem {
FnDef(FnDef), FnDef(FnDef),
TraitDef(TraitDef), TraitDef(TraitDef),
TypeAliasDef(TypeAliasDef), TypeAliasDef(TypeAliasDef),
ImplBlock(ImplBlock), ImplDef(ImplDef),
UseItem(UseItem), UseItem(UseItem),
ExternCrateItem(ExternCrateItem), ExternCrateItem(ExternCrateItem),
ConstDef(ConstDef), ConstDef(ConstDef),
@ -3561,9 +3561,9 @@ impl From<TypeAliasDef> for ModuleItem {
ModuleItem::TypeAliasDef(node) ModuleItem::TypeAliasDef(node)
} }
} }
impl From<ImplBlock> for ModuleItem { impl From<ImplDef> for ModuleItem {
fn from(node: ImplBlock) -> ModuleItem { fn from(node: ImplDef) -> ModuleItem {
ModuleItem::ImplBlock(node) ModuleItem::ImplDef(node)
} }
} }
impl From<UseItem> for ModuleItem { impl From<UseItem> for ModuleItem {
@ -3594,8 +3594,8 @@ impl From<Module> for ModuleItem {
impl AstNode for ModuleItem { impl AstNode for ModuleItem {
fn can_cast(kind: SyntaxKind) -> bool { fn can_cast(kind: SyntaxKind) -> bool {
match kind { match kind {
STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
| IMPL_BLOCK | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true, | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
_ => false, _ => false,
} }
} }
@ -3607,7 +3607,7 @@ impl AstNode for ModuleItem {
FN_DEF => ModuleItem::FnDef(FnDef { syntax }), FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }), TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }), TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
IMPL_BLOCK => ModuleItem::ImplBlock(ImplBlock { syntax }), IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
USE_ITEM => ModuleItem::UseItem(UseItem { syntax }), USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
@ -3625,7 +3625,7 @@ impl AstNode for ModuleItem {
ModuleItem::FnDef(it) => &it.syntax, ModuleItem::FnDef(it) => &it.syntax,
ModuleItem::TraitDef(it) => &it.syntax, ModuleItem::TraitDef(it) => &it.syntax,
ModuleItem::TypeAliasDef(it) => &it.syntax, ModuleItem::TypeAliasDef(it) => &it.syntax,
ModuleItem::ImplBlock(it) => &it.syntax, ModuleItem::ImplDef(it) => &it.syntax,
ModuleItem::UseItem(it) => &it.syntax, ModuleItem::UseItem(it) => &it.syntax,
ModuleItem::ExternCrateItem(it) => &it.syntax, ModuleItem::ExternCrateItem(it) => &it.syntax,
ModuleItem::ConstDef(it) => &it.syntax, ModuleItem::ConstDef(it) => &it.syntax,

View file

@ -203,12 +203,11 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
_ => return, _ => return,
} }
let impl_block = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplBlock::cast) let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplDef::cast) {
{
Some(it) => it, Some(it) => it,
None => return, None => return,
}; };
if impl_block.target_trait().is_some() { if impl_def.target_trait().is_some() {
errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range())); errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range()));
} }
} }

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 183) SOURCE_FILE@[0; 183)
IMPL_BLOCK@[0; 182) IMPL_DEF@[0; 182)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 13) PATH_TYPE@[5; 13)

View file

@ -77,7 +77,7 @@ SOURCE_FILE@[0; 112)
ERROR@[54; 55) ERROR@[54; 55)
COMMA@[54; 55) "," COMMA@[54; 55) ","
WHITESPACE@[55; 56) " " WHITESPACE@[55; 56) " "
IMPL_BLOCK@[56; 60) IMPL_DEF@[56; 60)
IMPL_KW@[56; 60) "impl" IMPL_KW@[56; 60) "impl"
EXPR_STMT@[60; 61) EXPR_STMT@[60; 61)
ERROR@[60; 61) ERROR@[60; 61)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 38) SOURCE_FILE@[0; 38)
IMPL_BLOCK@[0; 14) IMPL_DEF@[0; 14)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
TYPE_PARAM_LIST@[4; 14) TYPE_PARAM_LIST@[4; 14)
L_ANGLE@[4; 5) "<" L_ANGLE@[4; 5) "<"
@ -17,7 +17,7 @@ SOURCE_FILE@[0; 38)
IDENT@[8; 13) "Clone" IDENT@[8; 13) "Clone"
R_ANGLE@[13; 14) ">" R_ANGLE@[13; 14) ">"
WHITESPACE@[14; 15) "\n" WHITESPACE@[14; 15) "\n"
IMPL_BLOCK@[15; 37) IMPL_DEF@[15; 37)
IMPL_KW@[15; 19) "impl" IMPL_KW@[15; 19) "impl"
TYPE_PARAM_LIST@[19; 22) TYPE_PARAM_LIST@[19; 22)
L_ANGLE@[19; 20) "<" L_ANGLE@[19; 20) "<"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 118) SOURCE_FILE@[0; 118)
IMPL_BLOCK@[0; 117) IMPL_DEF@[0; 117)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 6) PATH_TYPE@[5; 6)

View file

@ -18,7 +18,7 @@ SOURCE_FILE@[0; 30)
LIFETIME@[16; 21) "\'loop" LIFETIME@[16; 21) "\'loop"
COLON@[21; 22) ":" COLON@[21; 22) ":"
WHITESPACE@[22; 23) " " WHITESPACE@[22; 23) " "
IMPL_BLOCK@[23; 27) IMPL_DEF@[23; 27)
IMPL_KW@[23; 27) "impl" IMPL_KW@[23; 27) "impl"
WHITESPACE@[27; 28) "\n" WHITESPACE@[27; 28) "\n"
R_CURLY@[28; 29) "}" R_CURLY@[28; 29) "}"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 87) SOURCE_FILE@[0; 87)
IMPL_BLOCK@[0; 12) IMPL_DEF@[0; 12)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 9) PATH_TYPE@[5; 9)
@ -12,7 +12,7 @@ SOURCE_FILE@[0; 87)
L_CURLY@[10; 11) "{" L_CURLY@[10; 11) "{"
R_CURLY@[11; 12) "}" R_CURLY@[11; 12) "}"
WHITESPACE@[12; 13) "\n" WHITESPACE@[12; 13) "\n"
IMPL_BLOCK@[13; 33) IMPL_DEF@[13; 33)
IMPL_KW@[13; 17) "impl" IMPL_KW@[13; 17) "impl"
WHITESPACE@[17; 18) " " WHITESPACE@[17; 18) " "
PATH_TYPE@[18; 24) PATH_TYPE@[18; 24)
@ -33,10 +33,10 @@ SOURCE_FILE@[0; 87)
L_CURLY@[31; 32) "{" L_CURLY@[31; 32) "{"
R_CURLY@[32; 33) "}" R_CURLY@[32; 33) "}"
WHITESPACE@[33; 34) "\n" WHITESPACE@[33; 34) "\n"
IMPL_BLOCK@[34; 38) IMPL_DEF@[34; 38)
IMPL_KW@[34; 38) "impl" IMPL_KW@[34; 38) "impl"
WHITESPACE@[38; 39) " " WHITESPACE@[38; 39) " "
IMPL_BLOCK@[39; 54) IMPL_DEF@[39; 54)
IMPL_KW@[39; 43) "impl" IMPL_KW@[39; 43) "impl"
WHITESPACE@[43; 44) " " WHITESPACE@[43; 44) " "
PATH_TYPE@[44; 51) PATH_TYPE@[44; 51)
@ -49,7 +49,7 @@ SOURCE_FILE@[0; 87)
L_CURLY@[52; 53) "{" L_CURLY@[52; 53) "{"
R_CURLY@[53; 54) "}" R_CURLY@[53; 54) "}"
WHITESPACE@[54; 55) "\n" WHITESPACE@[54; 55) "\n"
IMPL_BLOCK@[55; 70) IMPL_DEF@[55; 70)
IMPL_KW@[55; 59) "impl" IMPL_KW@[55; 59) "impl"
WHITESPACE@[59; 60) " " WHITESPACE@[59; 60) " "
PATH_TYPE@[60; 66) PATH_TYPE@[60; 66)
@ -60,7 +60,7 @@ SOURCE_FILE@[0; 87)
WHITESPACE@[66; 67) " " WHITESPACE@[66; 67) " "
FOR_KW@[67; 70) "for" FOR_KW@[67; 70) "for"
WHITESPACE@[70; 71) " " WHITESPACE@[70; 71) " "
IMPL_BLOCK@[71; 86) IMPL_DEF@[71; 86)
IMPL_KW@[71; 75) "impl" IMPL_KW@[71; 75) "impl"
WHITESPACE@[75; 76) " " WHITESPACE@[75; 76) " "
PATH_TYPE@[76; 83) PATH_TYPE@[76; 83)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 83) SOURCE_FILE@[0; 83)
IMPL_BLOCK@[0; 82) IMPL_DEF@[0; 82)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 6) PATH_TYPE@[5; 6)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 128) SOURCE_FILE@[0; 128)
IMPL_BLOCK@[0; 127) IMPL_DEF@[0; 127)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 6) PATH_TYPE@[5; 6)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 69) SOURCE_FILE@[0; 69)
IMPL_BLOCK@[0; 68) IMPL_DEF@[0; 68)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 6) PATH_TYPE@[5; 6)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 89) SOURCE_FILE@[0; 89)
IMPL_BLOCK@[0; 88) IMPL_DEF@[0; 88)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 6) PATH_TYPE@[5; 6)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 27) SOURCE_FILE@[0; 27)
IMPL_BLOCK@[0; 26) IMPL_DEF@[0; 26)
UNSAFE_KW@[0; 6) "unsafe" UNSAFE_KW@[0; 6) "unsafe"
WHITESPACE@[6; 7) " " WHITESPACE@[6; 7) " "
DEFAULT_KW@[7; 14) "default" DEFAULT_KW@[7; 14) "default"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 20) SOURCE_FILE@[0; 20)
IMPL_BLOCK@[0; 19) IMPL_DEF@[0; 19)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
EXCL@[5; 6) "!" EXCL@[5; 6) "!"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 12) SOURCE_FILE@[0; 12)
IMPL_BLOCK@[0; 11) IMPL_DEF@[0; 11)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 8) PATH_TYPE@[5; 8)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 19) SOURCE_FILE@[0; 19)
IMPL_BLOCK@[0; 18) IMPL_DEF@[0; 18)
UNSAFE_KW@[0; 6) "unsafe" UNSAFE_KW@[0; 6) "unsafe"
WHITESPACE@[6; 7) " " WHITESPACE@[6; 7) " "
IMPL_KW@[7; 11) "impl" IMPL_KW@[7; 11) "impl"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 20) SOURCE_FILE@[0; 20)
IMPL_BLOCK@[0; 19) IMPL_DEF@[0; 19)
DEFAULT_KW@[0; 7) "default" DEFAULT_KW@[0; 7) "default"
WHITESPACE@[7; 8) " " WHITESPACE@[7; 8) " "
IMPL_KW@[8; 12) "impl" IMPL_KW@[8; 12) "impl"

View file

@ -8,7 +8,7 @@ SOURCE_FILE@[0; 94)
L_CURLY@[6; 7) "{" L_CURLY@[6; 7) "{"
R_CURLY@[7; 8) "}" R_CURLY@[7; 8) "}"
WHITESPACE@[8; 9) "\n" WHITESPACE@[8; 9) "\n"
IMPL_BLOCK@[9; 93) IMPL_DEF@[9; 93)
IMPL_KW@[9; 13) "impl" IMPL_KW@[9; 13) "impl"
WHITESPACE@[13; 14) " " WHITESPACE@[13; 14) " "
PATH_TYPE@[14; 15) PATH_TYPE@[14; 15)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 69) SOURCE_FILE@[0; 69)
IMPL_BLOCK@[0; 68) IMPL_DEF@[0; 68)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 6) PATH_TYPE@[5; 6)

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 29) SOURCE_FILE@[0; 29)
IMPL_BLOCK@[0; 28) IMPL_DEF@[0; 28)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
TYPE_PARAM_LIST@[4; 18) TYPE_PARAM_LIST@[4; 18)
L_ANGLE@[4; 5) "<" L_ANGLE@[4; 5) "<"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@[0; 137) SOURCE_FILE@[0; 137)
IMPL_BLOCK@[0; 136) IMPL_DEF@[0; 136)
IMPL_KW@[0; 4) "impl" IMPL_KW@[0; 4) "impl"
WHITESPACE@[4; 5) " " WHITESPACE@[4; 5) " "
PATH_TYPE@[5; 6) PATH_TYPE@[5; 6)

View file

@ -8,7 +8,7 @@ SOURCE_FILE@[0; 199)
IDENT@[69; 72) "Foo" IDENT@[69; 72) "Foo"
SEMI@[72; 73) ";" SEMI@[72; 73) ";"
WHITESPACE@[73; 75) "\n\n" WHITESPACE@[73; 75) "\n\n"
IMPL_BLOCK@[75; 141) IMPL_DEF@[75; 141)
IMPL_KW@[75; 79) "impl" IMPL_KW@[75; 79) "impl"
WHITESPACE@[79; 80) " " WHITESPACE@[79; 80) " "
PATH_TYPE@[80; 83) PATH_TYPE@[80; 83)

View file

@ -92,7 +92,7 @@ SOURCE_FILE@[0; 686)
WHITESPACE@[461; 463) "\n\n" WHITESPACE@[461; 463) "\n\n"
COMMENT@[463; 523) "// https://github.com ..." COMMENT@[463; 523) "// https://github.com ..."
WHITESPACE@[523; 524) "\n" WHITESPACE@[523; 524) "\n"
IMPL_BLOCK@[524; 685) IMPL_DEF@[524; 685)
IMPL_KW@[524; 528) "impl" IMPL_KW@[524; 528) "impl"
WHITESPACE@[528; 529) " " WHITESPACE@[528; 529) " "
PATH_TYPE@[529; 537) PATH_TYPE@[529; 537)

View file

@ -253,7 +253,7 @@ SOURCE_FILE@[0; 519)
WHITESPACE@[234; 235) "\n" WHITESPACE@[234; 235) "\n"
R_CURLY@[235; 236) "}" R_CURLY@[235; 236) "}"
WHITESPACE@[236; 238) "\n\n" WHITESPACE@[236; 238) "\n\n"
IMPL_BLOCK@[238; 519) IMPL_DEF@[238; 519)
IMPL_KW@[238; 242) "impl" IMPL_KW@[238; 242) "impl"
WHITESPACE@[242; 243) " " WHITESPACE@[242; 243) " "
PATH_TYPE@[243; 244) PATH_TYPE@[243; 244)

View file

@ -76,8 +76,8 @@ pub fn analysis_stats(
} }
} }
for impl_block in module.impl_blocks(db) { for impl_def in module.impl_defs(db) {
for item in impl_block.items(db) { for item in impl_def.items(db) {
num_decls += 1; num_decls += 1;
if let AssocItem::Function(f) = item { if let AssocItem::Function(f) = item {
funcs.push(f); funcs.push(f);

View file

@ -57,7 +57,7 @@ impl Conv for SyntaxKind {
SyntaxKind::RECORD_FIELD_DEF => SymbolKind::Field, SyntaxKind::RECORD_FIELD_DEF => SymbolKind::Field,
SyntaxKind::STATIC_DEF => SymbolKind::Constant, SyntaxKind::STATIC_DEF => SymbolKind::Constant,
SyntaxKind::CONST_DEF => SymbolKind::Constant, SyntaxKind::CONST_DEF => SymbolKind::Constant,
SyntaxKind::IMPL_BLOCK => SymbolKind::Object, SyntaxKind::IMPL_DEF => SymbolKind::Object,
_ => SymbolKind::Variable, _ => SymbolKind::Variable,
} }
} }

View file

@ -104,7 +104,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
"STATIC_DEF", "STATIC_DEF",
"CONST_DEF", "CONST_DEF",
"TRAIT_DEF", "TRAIT_DEF",
"IMPL_BLOCK", "IMPL_DEF",
"TYPE_ALIAS_DEF", "TYPE_ALIAS_DEF",
"MACRO_CALL", "MACRO_CALL",
"TOKEN_TREE", "TOKEN_TREE",
@ -357,7 +357,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
TypeRef, TypeRef,
} }
struct ImplBlock: TypeParamsOwner, AttrsOwner { struct ImplDef: TypeParamsOwner, AttrsOwner {
ItemList, ItemList,
} }
@ -560,7 +560,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
FnDef, FnDef,
TraitDef, TraitDef,
TypeAliasDef, TypeAliasDef,
ImplBlock, ImplDef,
UseItem, UseItem,
ExternCrateItem, ExternCrateItem,
ConstDef, ConstDef,