From a1e18695548b5cd6661f26a985b34c8b105e1896 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Feb 2020 21:24:40 +0100 Subject: Rename ast::ImplBlock -> ast::ImplDef --- crates/ra_assists/src/ast_transform.rs | 8 ++-- .../src/handlers/add_missing_impl_members.rs | 6 +-- crates/ra_assists/src/handlers/add_new.rs | 16 +++---- crates/ra_assists/src/handlers/move_bounds.rs | 2 +- crates/ra_assists/src/utils.rs | 10 ++--- crates/ra_hir/src/code_model.rs | 36 ++++++++-------- crates/ra_hir/src/from_id.rs | 4 +- crates/ra_hir/src/has_source.rs | 8 ++-- crates/ra_hir/src/lib.rs | 2 +- crates/ra_hir/src/semantics.rs | 2 +- crates/ra_hir/src/semantics/source_to_def.rs | 6 +-- crates/ra_hir/src/source_analyzer.rs | 2 +- crates/ra_hir_def/src/body/lower.rs | 2 +- crates/ra_hir_def/src/data.rs | 6 +-- crates/ra_hir_def/src/keys.rs | 2 +- crates/ra_hir_def/src/lang_item.rs | 10 ++--- crates/ra_hir_def/src/lib.rs | 2 +- crates/ra_hir_def/src/nameres/raw.rs | 6 +-- crates/ra_hir_def/src/resolver.rs | 20 ++++----- crates/ra_hir_ty/src/db.rs | 6 +-- crates/ra_hir_ty/src/method_resolution.rs | 23 +++++----- crates/ra_hir_ty/src/tests/macros.rs | 12 +++--- crates/ra_hir_ty/src/traits.rs | 6 +-- crates/ra_hir_ty/src/traits/builtin.rs | 2 +- crates/ra_hir_ty/src/traits/chalk.rs | 8 ++-- .../ra_ide/src/completion/complete_trait_impl.rs | 50 ++++++++++------------ crates/ra_ide/src/completion/completion_context.rs | 8 ++-- crates/ra_ide/src/display/navigation_target.rs | 2 +- crates/ra_ide/src/display/structure.rs | 6 +-- crates/ra_ide/src/expand_macro.rs | 4 +- crates/ra_ide/src/goto_definition.rs | 12 +++--- crates/ra_ide/src/impls.rs | 28 ++++++------ crates/ra_ide/src/references/classify.rs | 2 +- crates/ra_ide_db/src/defs.rs | 4 +- crates/ra_parser/src/grammar.rs | 2 +- crates/ra_parser/src/grammar/items.rs | 4 +- crates/ra_parser/src/grammar/items/traits.rs | 6 +-- crates/ra_parser/src/syntax_kind/generated.rs | 2 +- crates/ra_syntax/src/ast/extensions.rs | 2 +- crates/ra_syntax/src/ast/generated.rs | 28 ++++++------ crates/ra_syntax/src/validation.rs | 5 +-- .../test_data/parser/err/0018_incomplete_fn.txt | 2 +- .../test_data/parser/err/0022_bad_exprs.txt | 2 +- .../test_data/parser/err/0026_imp_recovery.txt | 4 +- .../parser/err/0037_visibility_in_traits.txt | 2 +- .../parser/inline/err/0002_misplaced_label_err.txt | 2 +- .../test_data/parser/inline/err/0004_impl_type.txt | 12 +++--- .../parser/inline/ok/0001_trait_item_list.txt | 2 +- .../test_data/parser/inline/ok/0006_self_param.txt | 2 +- .../parser/inline/ok/0018_arb_self_types.txt | 2 +- .../parser/inline/ok/0021_impl_item_list.txt | 2 +- .../parser/inline/ok/0047_unsafe_default_impl.txt | 2 +- .../parser/inline/ok/0063_impl_block_neg.rs | 1 - .../parser/inline/ok/0063_impl_block_neg.txt | 23 ---------- .../parser/inline/ok/0063_impl_def_neg.rs | 1 + .../parser/inline/ok/0063_impl_def_neg.txt | 23 ++++++++++ .../test_data/parser/inline/ok/0079_impl_block.rs | 1 - .../test_data/parser/inline/ok/0079_impl_block.txt | 14 ------ .../test_data/parser/inline/ok/0079_impl_def.rs | 1 + .../test_data/parser/inline/ok/0079_impl_def.txt | 14 ++++++ .../parser/inline/ok/0087_unsafe_impl.txt | 2 +- .../parser/inline/ok/0097_default_impl.txt | 2 +- .../inline/ok/0118_impl_inner_attributes.txt | 2 +- .../parser/inline/ok/0132_default_fn_type.txt | 2 +- .../parser/inline/ok/0150_impl_type_params.txt | 2 +- .../parser/inline/ok/0152_fn_patterns.txt | 2 +- .../test_data/parser/ok/0042_ufcs_call_list.txt | 2 +- .../test_data/parser/ok/0045_block_inner_attrs.txt | 2 +- .../test_data/parser/ok/0051_parameter_attrs.txt | 2 +- crates/rust-analyzer/src/cli/analysis_stats.rs | 4 +- crates/rust-analyzer/src/conv.rs | 2 +- xtask/src/ast_src.rs | 6 +-- 72 files changed, 253 insertions(+), 261 deletions(-) delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.txt create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.txt create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index a74ac42d5..0e53c1eee 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -40,9 +40,9 @@ impl<'a> SubstituteTypeParams<'a> { db: &'a RootDatabase, // FIXME: there's implicit invariant that `trait_` and `source_scope` match... trait_: hir::Trait, - impl_block: ast::ImplBlock, + impl_def: ast::ImplDef, ) -> 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 substs_by_param: FxHashMap<_, _> = generic_def .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 // trait ref, and then go from the types in the substs back to the syntax) - fn get_syntactic_substs(impl_block: ast::ImplBlock) -> Option> { - let target_trait = impl_block.target_trait()?; + fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option> { + let target_trait = impl_def.target_trait()?; let path_type = match target_trait { ast::TypeRef::PathType(path) => path, _ => return None, diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index 4005014bd..639180d37 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -101,7 +101,7 @@ fn add_missing_impl_members_inner( label: &'static str, ) -> Option { let _p = ra_prof::profile("add_missing_impl_members_inner"); - let impl_node = ctx.find_node_at_offset::()?; + let impl_node = ctx.find_node_at_offset::()?; let impl_item_list = impl_node.item_list()?; let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?; @@ -257,7 +257,7 @@ impl Foo for S { } #[test] - fn test_empty_impl_block() { + fn test_empty_impl_def() { check_assist( add_missing_impl_members, " @@ -308,7 +308,7 @@ impl Foo for S { } #[test] - fn test_cursor_after_empty_impl_block() { + fn test_cursor_after_empty_impl_def() { check_assist( add_missing_impl_members, " diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 166e907fb..697e7cda6 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs @@ -41,14 +41,14 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { }; // 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| { edit.target(strukt.syntax().text_range()); let mut buf = String::with_capacity(512); - if impl_block.is_some() { + if impl_def.is_some() { buf.push('\n'); } @@ -71,10 +71,10 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { buf.push_str("} }"); - let (start_offset, end_offset) = impl_block - .and_then(|impl_block| { + let (start_offset, end_offset) = impl_def + .and_then(|impl_def| { buf.push('\n'); - let start = impl_block + let start = impl_def .syntax() .descendants_with_tokens() .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 // viable (e.g. we process proc macros, etc) -fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option> { +fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option> { let db = ctx.db; let module = strukt.syntax().ancestors().find(|node| { 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; impl S {}` @@ -164,7 +164,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option bool { +fn has_new_fn(imp: &ast::ImplDef) -> bool { if let Some(il) = imp.item_list() { for item in il.impl_items() { if let ast::ImplItem::FnDef(f) = item { diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index 86b235366..0b501f3e5 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -37,7 +37,7 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> Option { let anchor: SyntaxElement = match parent.kind() { FN_DEF => ast::FnDef::cast(parent)?.body()?.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(), STRUCT_DEF => parent .children_with_tokens() diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index d544caee7..3d6c59bda 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -13,14 +13,14 @@ pub use insert_use::insert_use_statement; pub fn get_missing_impl_items( sema: &Semantics, - impl_block: &ast::ImplBlock, + impl_def: &ast::ImplDef, ) -> Vec { // Names must be unique between constants and functions. However, type aliases // may share the same name as a function or constant. let mut impl_fns_consts = 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() { match item { 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 .items(sema.db) .iter() @@ -65,9 +65,9 @@ pub fn get_missing_impl_items( pub(crate) fn resolve_target_trait( sema: &Semantics, - impl_block: &ast::ImplBlock, + impl_def: &ast::ImplDef, ) -> Option { - let ast_path = impl_block + let ast_path = impl_def .target_trait() .map(|it| it.syntax().clone()) .and_then(ast::PathType::cast)? diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 034fb7cfa..b71ee764a 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -229,8 +229,8 @@ impl Module { } } - for impl_block in self.impl_blocks(db) { - for item in impl_block.items(db) { + for impl_def in self.impl_defs(db) { + for item in impl_def.items(db) { if let AssocItem::Function(f) = item { f.diagnostics(db, sink); } @@ -243,9 +243,9 @@ impl Module { def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() } - pub fn impl_blocks(self, db: &impl DefDatabase) -> Vec { + pub fn impl_defs(self, db: &impl DefDatabase) -> Vec { 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 { @@ -686,7 +686,7 @@ pub enum AssocItem { } pub enum AssocItemContainer { Trait(Trait), - ImplBlock(ImplBlock), + ImplDef(ImplDef), } pub trait AsAssocItem { fn as_assoc_item(self, db: &impl DefDatabase) -> Option; @@ -736,7 +736,7 @@ impl AssocItem { }; match container { 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"), } } @@ -748,7 +748,7 @@ pub enum GenericDef { Adt(Adt), Trait(Trait), TypeAlias(TypeAlias), - ImplBlock(ImplBlock), + ImplDef(ImplDef), // enum variants cannot have generics themselves, but their parent enums // can, and this makes some code easier to write EnumVariant(EnumVariant), @@ -760,7 +760,7 @@ impl_froms!( Adt(Struct, Enum, Union), Trait, TypeAlias, - ImplBlock, + ImplDef, EnumVariant, 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)] -pub struct ImplBlock { +pub struct ImplDef { pub(crate) id: ImplId, } -impl ImplBlock { - pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec { +impl ImplDef { + pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec { let impls = db.impls_in_crate(krate.id); impls.all_impls().map(Self::from).collect() } - pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec { + pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec { 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 { @@ -1077,7 +1077,7 @@ impl Type { } // 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( self, db: &impl HirDatabase, @@ -1087,8 +1087,8 @@ impl Type { for krate in self.ty.value.def_crates(db, krate.id)? { let impls = db.impls_in_crate(krate); - for impl_block in impls.lookup_impl_blocks(&self.ty.value) { - for &item in db.impl_data(impl_block).items.iter() { + for impl_def in impls.lookup_impl_defs(&self.ty.value) { + for &item in db.impl_data(impl_def).items.iter() { if let Some(result) = callback(item.into()) { return Some(result); } @@ -1196,7 +1196,7 @@ pub enum ScopeDef { ModuleDef(ModuleDef), MacroDef(MacroDef), GenericParam(TypeParam), - ImplSelfType(ImplBlock), + ImplSelfType(ImplDef), AdtSelfType(Adt), Local(Local), Unknown, diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index cbfa91d6c..c179b13c6 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_hir/src/from_id.rs @@ -39,7 +39,7 @@ from_id![ (hir_def::StaticId, crate::Static), (hir_def::ConstId, crate::Const), (hir_def::FunctionId, crate::Function), - (hir_def::ImplId, crate::ImplBlock), + (hir_def::ImplId, crate::ImplDef), (hir_def::TypeParamId, crate::TypeParam), (hir_expand::MacroDefId, crate::MacroDef) ]; @@ -145,7 +145,7 @@ impl From for GenericDefId { GenericDef::Adt(it) => GenericDefId::AdtId(it.into()), GenericDef::Trait(it) => GenericDefId::TraitId(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) => { GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) } diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index 5541266e2..f121e1eff 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs @@ -9,7 +9,7 @@ use hir_def::{ use ra_syntax::ast; 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, }; @@ -111,9 +111,9 @@ impl HasSource for MacroDef { } } } -impl HasSource for ImplBlock { - type Ast = ast::ImplBlock; - fn source(self, db: &impl DefDatabase) -> InFile { +impl HasSource for ImplDef { + type Ast = ast::ImplDef; + fn source(self, db: &impl DefDatabase) -> InFile { self.id.lookup(db).source(db) } } diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index cefbd80e6..e1cb12cca 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -41,7 +41,7 @@ pub use crate::{ code_model::{ Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, 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, }, has_source::HasSource, diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 74901e318..a0853957c 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -262,7 +262,7 @@ to_def_impls![ (crate::Enum, ast::EnumDef, enum_to_def), (crate::Union, ast::UnionDef, union_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::Const, ast::ConstDef, const_to_def), (crate::Static, ast::StaticDef, static_to_def), diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 884b535b2..67b243222 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -67,7 +67,7 @@ impl SourceToDefCtx<'_, &'_ DB> { pub(super) fn trait_to_def(&mut self, src: InFile) -> Option { self.to_def(src, keys::TRAIT) } - pub(super) fn impl_to_def(&mut self, src: InFile) -> Option { + pub(super) fn impl_to_def(&mut self, src: InFile) -> Option { self.to_def(src, keys::IMPL) } pub(super) fn fn_to_def(&mut self, src: InFile) -> Option { @@ -166,7 +166,7 @@ impl SourceToDefCtx<'_, &'_ DB> { let def = self.trait_to_def(container.with_value(it))?; def.into() }, - ast::ImplBlock(it) => { + ast::ImplDef(it) => { let def = self.impl_to_def(container.with_value(it))?; def.into() }, @@ -213,7 +213,7 @@ impl SourceToDefCtx<'_, &'_ DB> { 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::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, } }; diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index c650a9e08..4c121eb73 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -49,7 +49,7 @@ pub enum PathResolution { Local(Local), /// A generic parameter TypeParam(TypeParam), - SelfType(crate::ImplBlock), + SelfType(crate::ImplDef), Macro(MacroDef), AssocItem(crate::AssocItem), } diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index b3fb6d452..c18e6879b 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -544,7 +544,7 @@ where let ast_id = self.expander.ast_id(&def); (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) } - ast::ModuleItem::ImplBlock(_) + ast::ModuleItem::ImplDef(_) | ast::ModuleItem::UseItem(_) | ast::ModuleItem::ExternCrateItem(_) | ast::ModuleItem::Module(_) => continue, diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index c900a6a18..c5fb9428e 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -238,16 +238,16 @@ impl ConstData { fn collect_impl_items_in_macros( db: &impl DefDatabase, module_id: ModuleId, - impl_block: &InFile, + impl_def: &InFile, id: ImplId, ) -> Vec { - 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(); // We set a limit to protect against infinite recursion 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)) } diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index 5913f12b1..8cd70eb9a 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs @@ -18,7 +18,7 @@ pub const FUNCTION: Key = Key::new(); pub const CONST: Key = Key::new(); pub const STATIC: Key = Key::new(); pub const TYPE_ALIAS: Key = Key::new(); -pub const IMPL: Key = Key::new(); +pub const IMPL: Key = Key::new(); pub const TRAIT: Key = Key::new(); pub const STRUCT: Key = Key::new(); pub const UNION: Key = Key::new(); diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs index 37c861a87..5a336ea1f 100644 --- a/crates/ra_hir_def/src/lang_item.rs +++ b/crates/ra_hir_def/src/lang_item.rs @@ -16,7 +16,7 @@ use crate::{ pub enum LangItemTarget { EnumId(EnumId), FunctionId(FunctionId), - ImplBlockId(ImplId), + ImplDefId(ImplId), StaticId(StaticId), StructId(StructId), TraitId(TraitId), @@ -37,9 +37,9 @@ impl LangItemTarget { } } - pub fn as_impl_block(self) -> Option { + pub fn as_impl_def(self) -> Option { match self { - LangItemTarget::ImplBlockId(id) => Some(id), + LangItemTarget::ImplDefId(id) => Some(id), _ => None, } } @@ -125,8 +125,8 @@ impl LangItems { // Look for impl targets let def_map = db.crate_def_map(module.krate); let module_data = &def_map[module.local_id]; - for impl_block in module_data.scope.impls() { - self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId) + for impl_def in module_data.scope.impls() { + self.collect_lang_item(db, impl_def, LangItemTarget::ImplDefId) } for def in module_data.scope.declarations() { diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 564b5fec5..c9b14d0c8 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -164,7 +164,7 @@ impl_intern!(TypeAliasId, TypeAliasLoc, intern_type_alias, lookup_intern_type_al #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ImplId(salsa::InternId); -type ImplLoc = ItemLoc; +type ImplLoc = ItemLoc; impl_intern!(ImplId, ImplLoc, intern_impl, lookup_intern_impl); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 0e8c9da76..ea3c00da8 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -213,7 +213,7 @@ impl_arena_id!(Impl); #[derive(Debug, PartialEq, Eq)] pub(super) struct ImplData { - pub(super) ast_id: FileAstId, + pub(super) ast_id: FileAstId, } struct RawItemsCollector { @@ -249,7 +249,7 @@ impl RawItemsCollector { self.add_extern_crate_item(current_module, extern_crate); return; } - ast::ModuleItem::ImplBlock(it) => { + ast::ModuleItem::ImplDef(it) => { self.add_impl(current_module, it); return; } @@ -395,7 +395,7 @@ impl RawItemsCollector { self.push_item(current_module, attrs, RawItemKind::Macro(m)); } - fn add_impl(&mut self, current_module: Option, imp: ast::ImplBlock) { + fn add_impl(&mut self, current_module: Option, imp: ast::ImplDef) { let attrs = self.parse_attrs(&imp); let ast_id = self.source_ast_id_map.ast_id(&imp); let imp = self.raw_items.impls.alloc(ImplData { ast_id }); diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 9dd4fa555..2734d51a0 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs @@ -52,7 +52,7 @@ enum Scope { /// Brings the generic parameters of an item into scope GenericParams { def: GenericDefId, params: Arc }, /// Brings `Self` in `impl` block into scope - ImplBlockScope(ImplId), + ImplDefScope(ImplId), /// Brings `Self` in enum, struct and union definitions into scope AdtScope(AdtId), /// Local bindings @@ -154,7 +154,7 @@ impl Resolver { match scope { Scope::ExprScope(_) => continue, Scope::GenericParams { .. } - | Scope::ImplBlockScope(_) + | Scope::ImplDefScope(_) | Scope::LocalItemsScope(_) if skip_to_mod => { @@ -170,7 +170,7 @@ impl Resolver { )); } } - Scope::ImplBlockScope(impl_) => { + Scope::ImplDefScope(impl_) => { if first_name == &name![Self] { let idx = if path.segments.len() == 1 { None } else { Some(1) }; return Some((TypeNs::SelfType(*impl_), idx)); @@ -263,7 +263,7 @@ impl Resolver { Scope::AdtScope(_) | Scope::ExprScope(_) | Scope::GenericParams { .. } - | Scope::ImplBlockScope(_) + | Scope::ImplDefScope(_) | Scope::LocalItemsScope(_) if skip_to_mod => { @@ -291,7 +291,7 @@ impl Resolver { } Scope::GenericParams { .. } => continue, - Scope::ImplBlockScope(impl_) if n_segments > 1 => { + Scope::ImplDefScope(impl_) if n_segments > 1 => { if first_name == &name![Self] { let ty = TypeNs::SelfType(*impl_); return Some(ResolveValueResult::Partial(ty, 1)); @@ -303,7 +303,7 @@ impl Resolver { return Some(ResolveValueResult::Partial(ty, 1)); } } - Scope::ImplBlockScope(_) | Scope::AdtScope(_) => continue, + Scope::ImplDefScope(_) | Scope::AdtScope(_) => continue, Scope::ModuleScope(m) => { 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)); } Scope::AdtScope(i) => { @@ -550,8 +550,8 @@ impl Resolver { self.push_scope(Scope::GenericParams { def, params }) } - fn push_impl_block_scope(self, impl_block: ImplId) -> Resolver { - self.push_scope(Scope::ImplBlockScope(impl_block)) + fn push_impl_def_scope(self, impl_def: ImplId) -> Resolver { + self.push_scope(Scope::ImplDefScope(impl_def)) } fn push_module_scope( @@ -634,7 +634,7 @@ impl HasResolver for ImplId { .container .resolver(db) .push_generic_params_scope(db, self.into()) - .push_impl_block_scope(self) + .push_impl_def_scope(self) } } diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index e9bfcfa17..85d85182f 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs @@ -11,7 +11,7 @@ use ra_db::{impl_intern_key, salsa, CrateId}; use ra_prof::profile; use crate::{ - method_resolution::CrateImplBlocks, + method_resolution::CrateImplDefs, traits::{chalk, AssocTyValue, Impl}, Binders, CallableDef, GenericPredicate, InferenceResult, PolyFnSig, Substs, TraitRef, Ty, TyDefId, TypeCtor, ValueTyDefId, @@ -59,8 +59,8 @@ pub trait HirDatabase: DefDatabase { #[salsa::invoke(crate::lower::generic_defaults_query)] fn generic_defaults(&self, def: GenericDefId) -> Substs; - #[salsa::invoke(crate::method_resolution::CrateImplBlocks::impls_in_crate_query)] - fn impls_in_crate(&self, krate: CrateId) -> Arc; + #[salsa::invoke(crate::method_resolution::CrateImplDefs::impls_in_crate_query)] + fn impls_in_crate(&self, krate: CrateId) -> Arc; #[salsa::invoke(crate::traits::impls_for_trait_query)] fn impls_for_trait(&self, krate: CrateId, trait_: TraitId) -> Arc<[ImplId]>; diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 988d83af5..df5901835 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -42,19 +42,19 @@ impl TyFingerprint { } #[derive(Debug, PartialEq, Eq)] -pub struct CrateImplBlocks { +pub struct CrateImplDefs { impls: FxHashMap>, impls_by_trait: FxHashMap>, } -impl CrateImplBlocks { +impl CrateImplDefs { pub(crate) fn impls_in_crate_query( db: &impl HirDatabase, krate: CrateId, - ) -> Arc { + ) -> Arc { let _p = profile("impls_in_crate_query"); 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); for (_module_id, module_data) in crate_def_map.modules.iter() { @@ -75,12 +75,12 @@ impl CrateImplBlocks { Arc::new(res) } - pub fn lookup_impl_blocks(&self, ty: &Ty) -> impl Iterator + '_ { + pub fn lookup_impl_defs(&self, ty: &Ty) -> impl Iterator + '_ { let fingerprint = TyFingerprint::for_impl(ty); fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flatten().copied() } - pub fn lookup_impl_blocks_for_trait(&self, tr: TraitId) -> impl Iterator + '_ { + pub fn lookup_impl_defs_for_trait(&self, tr: TraitId) -> impl Iterator + '_ { self.impls_by_trait.get(&tr).into_iter().flatten().copied() } @@ -131,7 +131,7 @@ impl Ty { let res = lang_item_targets .into_iter() .filter_map(|it| match it { - LangItemTarget::ImplBlockId(it) => Some(it), + LangItemTarget::ImplDefId(it) => Some(it), _ => None, }) .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 -// lifetime problems, because we need to borrow temp `CrateImplBlocks`. +// lifetime problems, because we need to borrow temp `CrateImplDefs`. // FIXME add a context type here? pub fn iterate_method_candidates( ty: &Canonical, @@ -425,8 +425,8 @@ fn iterate_inherent_methods( for krate in self_ty.value.def_crates(db, krate)? { let impls = db.impls_in_crate(krate); - for impl_block in impls.lookup_impl_blocks(&self_ty.value) { - for &item in db.impl_data(impl_block).items.iter() { + for impl_def in impls.lookup_impl_defs(&self_ty.value) { + for &item in db.impl_data(impl_def).items.iter() { if !is_valid_candidate(db, name, receiver_ty, item, self_ty) { continue; } @@ -434,8 +434,7 @@ fn iterate_inherent_methods( // that the impl is for. If we have a receiver type, this // already happens in `is_valid_candidate` above; if not, we // 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); continue; } diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 652420ea8..53cd81d46 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -4,7 +4,7 @@ use insta::assert_snapshot; use ra_db::fixture::WithFixture; #[test] -fn cfg_impl_block() { +fn cfg_impl_def() { let (db, pos) = TestDB::with_position( r#" //- /main.rs crate:main deps:foo cfg:test @@ -347,17 +347,17 @@ mod m { m::foo!(foo); use foo as bar; fn f() -> bar { 0 } -fn main() { +fn main() { let _a = f(); } "#), @r###" [159; 164) '{ 0 }': u64 [161; 162) '0': u64 - [175; 199) '{ ...f(); }': () - [187; 189) '_a': u64 - [193; 194) 'f': fn f() -> u64 - [193; 196) 'f()': u64 + [175; 197) '{ ...f(); }': () + [185; 187) '_a': u64 + [191; 192) 'f': fn f() -> u64 + [191; 194) 'f()': u64 "### ); } diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 17aef9490..bc6ee2600 100644 --- a/crates/ra_hir_ty/src/traits.rs +++ b/crates/ra_hir_ty/src/traits.rs @@ -131,8 +131,8 @@ pub(crate) fn impls_for_trait_query( for dep in db.crate_graph().dependencies(krate) { impls.extend(db.impls_for_trait(dep.crate_id, trait_).iter()); } - let crate_impl_blocks = db.impls_in_crate(krate); - impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(trait_)); + let crate_impl_defs = db.impls_in_crate(krate); + impls.extend(crate_impl_defs.lookup_impl_defs_for_trait(trait_)); impls.into_iter().collect() } @@ -346,7 +346,7 @@ pub struct UnsizeToSuperTraitObjectData { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Impl { /// A normal impl from an impl block. - ImplBlock(ImplId), + ImplDef(ImplId), /// Closure types implement the Fn traits synthetically. ClosureFnTraitImpl(ClosureFnTraitImplData), /// [T; n]: Unsize<[T]> diff --git a/crates/ra_hir_ty/src/traits/builtin.rs b/crates/ra_hir_ty/src/traits/builtin.rs index cc0f3eeb4..03f9b4e27 100644 --- a/crates/ra_hir_ty/src/traits/builtin.rs +++ b/crates/ra_hir_ty/src/traits/builtin.rs @@ -96,7 +96,7 @@ fn get_builtin_unsize_impls( pub(super) fn impl_datum(db: &impl HirDatabase, krate: CrateId, impl_: Impl) -> BuiltinImplData { match impl_ { - Impl::ImplBlock(_) => unreachable!(), + Impl::ImplDef(_) => unreachable!(), Impl::ClosureFnTraitImpl(data) => closure_fn_trait_impl_datum(db, krate, data), Impl::UnsizeArray => array_unsize_impl_datum(db, krate), Impl::UnsizeToTraitObject(trait_) => trait_object_unsize_impl_datum(db, krate, trait_), diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 5b6c1a62e..4001aa941 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -576,7 +576,7 @@ where .impls_for_trait(self.krate, trait_) .iter() .copied() - .map(Impl::ImplBlock) + .map(Impl::ImplDef) .map(|impl_| impl_.to_chalk(self.db)) .collect(); @@ -712,12 +712,12 @@ pub(crate) fn impl_datum_query( debug!("impl_datum {:?}", impl_id); let impl_: Impl = from_chalk(db, impl_id); 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)), } } -fn impl_block_datum( +fn impl_def_datum( db: &impl HirDatabase, krate: CrateId, chalk_id: ImplId, @@ -815,7 +815,7 @@ fn type_alias_associated_ty_value( let ty = db.ty(type_alias.into()); let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) }; 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), value: make_binders(value_bound, ty.num_binders), }; diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index 9a27c164b..18a1d2995 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -3,7 +3,7 @@ //! This module adds the completion items related to implementing associated //! 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 -//! and an direct child of an `IMPL_BLOCK`. +//! and an direct child of an `IMPL_DEF`. //! //! # Examples //! @@ -55,49 +55,43 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext _ => false, }); - let impl_block = trigger + let impl_def = trigger .as_ref() .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() { SyntaxKind::FN_DEF => { - for missing_fn in - get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { - match item { - hir::AssocItem::Function(fn_item) => Some(fn_item), - _ => None, - } - }) - { + for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map( + |item| match item { + hir::AssocItem::Function(fn_item) => Some(fn_item), + _ => None, + }, + ) { add_function_impl(&trigger, acc, ctx, &missing_fn); } } SyntaxKind::TYPE_ALIAS_DEF => { - for missing_fn in - get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { - match item { - hir::AssocItem::TypeAlias(type_item) => Some(type_item), - _ => None, - } - }) - { + for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map( + |item| match item { + hir::AssocItem::TypeAlias(type_item) => Some(type_item), + _ => None, + }, + ) { add_type_alias_impl(&trigger, acc, ctx, &missing_fn); } } SyntaxKind::CONST_DEF => { - for missing_fn in - get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { - match item { - hir::AssocItem::Const(const_item) => Some(const_item), - _ => None, - } - }) - { + for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map( + |item| match item { + hir::AssocItem::Const(const_item) => Some(const_item), + _ => None, + }, + ) { add_const_impl(&trigger, acc, ctx, &missing_fn); } } diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 81321a897..9aa5a705d 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -27,7 +27,7 @@ pub(crate) struct CompletionContext<'a> { pub(super) use_item_syntax: Option, pub(super) record_lit_syntax: Option, pub(super) record_lit_pat: Option, - pub(super) impl_block: Option, + pub(super) impl_def: Option, pub(super) is_param: bool, /// If a name-binding or reference to a const in a pattern. /// Irrefutable patterns (like let) are excluded. @@ -81,7 +81,7 @@ impl<'a> CompletionContext<'a> { use_item_syntax: None, record_lit_syntax: None, record_lit_pat: None, - impl_block: None, + impl_def: None, is_param: false, is_pat_binding: 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.impl_block = self + self.impl_def = self .token .parent() .ancestors() .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 .syntax() diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 5afb23764..4d3dd477e 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -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 { let src = self.source(db); let frange = if let Some(item) = self.is_builtin_derive(db) { diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs index 944cc79df..5774e9a8b 100644 --- a/crates/ra_ide/src/display/structure.rs +++ b/crates/ra_ide/src/display/structure.rs @@ -129,7 +129,7 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::RecordFieldDef(it) => { decl_with_ascription(it) }, ast::ConstDef(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_trait = it.target_trait(); let label = match target_trait { @@ -360,7 +360,7 @@ fn very_obsolete() {} label: "impl E", navigation_range: [239; 240), node_range: [234; 243), - kind: IMPL_BLOCK, + kind: IMPL_DEF, detail: None, deprecated: false, }, @@ -369,7 +369,7 @@ fn very_obsolete() {} label: "impl fmt::Debug for E", navigation_range: [265; 266), node_range: [245; 269), - kind: IMPL_BLOCK, + kind: IMPL_DEF, detail: None, deprecated: false, }, diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs index 5a079de27..f6667cb33 100644 --- a/crates/ra_ide/src/expand_macro.rs +++ b/crates/ra_ide/src/expand_macro.rs @@ -195,7 +195,7 @@ fn some_thing() -> u32 { mat<|>ch_ast! { match container { ast::TraitDef(it) => {}, - ast::ImplBlock(it) => {}, + ast::ImplDef(it) => {}, _ => { continue }, } } @@ -207,7 +207,7 @@ fn some_thing() -> u32 { assert_snapshot!(res.expansion, @r###" { 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 { { continue diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 621ab982c..e67585203 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -477,7 +477,7 @@ mod tests { } } ", - "impl IMPL_BLOCK FileId(1) [12; 73)", + "impl IMPL_DEF FileId(1) [12; 73)", "impl Foo {...}", ); @@ -491,7 +491,7 @@ mod tests { } } ", - "impl IMPL_BLOCK FileId(1) [12; 73)", + "impl IMPL_DEF FileId(1) [12; 73)", "impl Foo {...}", ); @@ -505,7 +505,7 @@ mod tests { } } ", - "impl IMPL_BLOCK FileId(1) [15; 75)", + "impl IMPL_DEF FileId(1) [15; 75)", "impl Foo {...}", ); @@ -518,7 +518,7 @@ mod tests { } } ", - "impl IMPL_BLOCK FileId(1) [15; 62)", + "impl IMPL_DEF FileId(1) [15; 62)", "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 {...}", ); @@ -555,7 +555,7 @@ mod tests { } } ", - "impl IMPL_BLOCK FileId(1) [49; 115)", + "impl IMPL_DEF FileId(1) [49; 115)", "impl Make for Foo {...}", ); } diff --git a/crates/ra_ide/src/impls.rs b/crates/ra_ide/src/impls.rs index bf82b2a16..68529c8a5 100644 --- a/crates/ra_ide/src/impls.rs +++ b/crates/ra_ide/src/impls.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -use hir::{Crate, ImplBlock, Semantics}; +use hir::{Crate, ImplDef, Semantics}; use ra_ide_db::RootDatabase; 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), }; - let impls = ImplBlock::all_in_crate(sema.db, krate); + let impls = ImplDef::all_in_crate(sema.db, krate); Some( impls .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)) .collect(), ) @@ -60,7 +60,7 @@ fn impls_for_trait( ) -> Option> { 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()) } @@ -86,7 +86,7 @@ mod tests { struct 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 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 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 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; 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 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 IMPL_BLOCK FileId(1) [23; 34)", - "impl IMPL_BLOCK FileId(1) [35; 52)", - "impl IMPL_BLOCK FileId(1) [53; 71)", + "impl IMPL_DEF FileId(1) [23; 34)", + "impl IMPL_DEF FileId(1) [35; 52)", + "impl IMPL_DEF FileId(1) [53; 71)", ], ); } @@ -195,7 +195,7 @@ mod tests { #[derive(Copy)] struct Foo<|>; ", - &["impl IMPL_BLOCK FileId(1) [0; 15)"], + &["impl IMPL_DEF FileId(1) [0; 15)"], ); } } diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs index 91b21429a..fdd07d8d1 100644 --- a/crates/ra_ide/src/references/classify.rs +++ b/crates/ra_ide/src/references/classify.rs @@ -61,7 +61,7 @@ pub(crate) fn classify_name_ref( PathResolution::Local(local) => NameDefinition::Local(local), PathResolution::TypeParam(par) => NameDefinition::TypeParam(par), PathResolution::Macro(def) => NameDefinition::Macro(def), - PathResolution::SelfType(impl_block) => NameDefinition::SelfType(impl_block), + PathResolution::SelfType(impl_def) => NameDefinition::SelfType(impl_def), }; Some(res) } diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 93f32ba85..ad4638906 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -6,7 +6,7 @@ // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). use hir::{ - Adt, FieldSource, HasSource, ImplBlock, Local, MacroDef, Module, ModuleDef, Semantics, + Adt, FieldSource, HasSource, ImplDef, Local, MacroDef, Module, ModuleDef, Semantics, StructField, TypeParam, }; use ra_prof::profile; @@ -22,7 +22,7 @@ pub enum NameDefinition { Macro(MacroDef), StructField(StructField), ModuleDef(ModuleDef), - SelfType(ImplBlock), + SelfType(ImplDef), Local(Local), TypeParam(TypeParam), } diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index a46e11e1d..58098e810 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -152,7 +152,7 @@ pub(crate) fn reparser( EXTERN_ITEM_LIST => items::extern_item_list, TOKEN_TREE if first_child? == T!['{'] => items::token_tree, ITEM_LIST => match parent? { - IMPL_BLOCK => items::impl_item_list, + IMPL_DEF => items::impl_item_list, TRAIT_DEF => items::trait_item_list, MODULE => items::mod_item_list, _ => return None, diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index f8b43866c..433ed6812 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs @@ -202,8 +202,8 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul // test unsafe_default_impl // unsafe default impl Foo {} T![impl] => { - traits::impl_block(p); - m.complete(p, IMPL_BLOCK); + traits::impl_def(p); + m.complete(p, IMPL_DEF); } // test existential_type diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs index 03dae3cdb..c819e33be 100644 --- a/crates/ra_parser/src/grammar/items/traits.rs +++ b/crates/ra_parser/src/grammar/items/traits.rs @@ -53,9 +53,9 @@ pub(crate) fn trait_item_list(p: &mut Parser) { m.complete(p, ITEM_LIST); } -// test impl_block +// test impl_def // impl Foo {} -pub(super) fn impl_block(p: &mut Parser) { +pub(super) fn impl_def(p: &mut Parser) { assert!(p.at(T![impl])); p.bump(T![impl]); if choose_type_params_over_qpath(p) { @@ -65,7 +65,7 @@ pub(super) fn impl_block(p: &mut Parser) { // FIXME: never type // impl ! {} - // test impl_block_neg + // test impl_def_neg // impl !Send for X {} p.eat(T![!]); impl_type(p); diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 1068da0a0..dfc30d727 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs @@ -133,7 +133,7 @@ pub enum SyntaxKind { STATIC_DEF, CONST_DEF, TRAIT_DEF, - IMPL_BLOCK, + IMPL_DEF, TYPE_ALIAS_DEF, MACRO_CALL, TOKEN_TREE, diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 44de4af89..d5986e8b4 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -169,7 +169,7 @@ impl ast::UseTreeList { } } -impl ast::ImplBlock { +impl ast::ImplDef { pub fn target_type(&self) -> Option { match self.target() { (Some(t), None) | (_, Some(t)) => Some(t), diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 8eb240801..150893e39 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -552,13 +552,13 @@ impl TypeAliasDef { } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ImplBlock { +pub struct ImplDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for ImplBlock { +impl AstNode for ImplDef { fn can_cast(kind: SyntaxKind) -> bool { match kind { - IMPL_BLOCK => true, + IMPL_DEF => true, _ => false, } } @@ -573,9 +573,9 @@ impl AstNode for ImplBlock { &self.syntax } } -impl ast::TypeParamsOwner for ImplBlock {} -impl ast::AttrsOwner for ImplBlock {} -impl ImplBlock { +impl ast::TypeParamsOwner for ImplDef {} +impl ast::AttrsOwner for ImplDef {} +impl ImplDef { pub fn item_list(&self) -> Option { AstChildren::new(&self.syntax).next() } @@ -3524,7 +3524,7 @@ pub enum ModuleItem { FnDef(FnDef), TraitDef(TraitDef), TypeAliasDef(TypeAliasDef), - ImplBlock(ImplBlock), + ImplDef(ImplDef), UseItem(UseItem), ExternCrateItem(ExternCrateItem), ConstDef(ConstDef), @@ -3561,9 +3561,9 @@ impl From for ModuleItem { ModuleItem::TypeAliasDef(node) } } -impl From for ModuleItem { - fn from(node: ImplBlock) -> ModuleItem { - ModuleItem::ImplBlock(node) +impl From for ModuleItem { + fn from(node: ImplDef) -> ModuleItem { + ModuleItem::ImplDef(node) } } impl From for ModuleItem { @@ -3594,8 +3594,8 @@ impl From for ModuleItem { impl AstNode for ModuleItem { fn can_cast(kind: SyntaxKind) -> bool { match kind { - STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF - | IMPL_BLOCK | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true, + STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF + | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true, _ => false, } } @@ -3607,7 +3607,7 @@ impl AstNode for ModuleItem { FN_DEF => ModuleItem::FnDef(FnDef { syntax }), TRAIT_DEF => ModuleItem::TraitDef(TraitDef { 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 }), EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), @@ -3625,7 +3625,7 @@ impl AstNode for ModuleItem { ModuleItem::FnDef(it) => &it.syntax, ModuleItem::TraitDef(it) => &it.syntax, ModuleItem::TypeAliasDef(it) => &it.syntax, - ModuleItem::ImplBlock(it) => &it.syntax, + ModuleItem::ImplDef(it) => &it.syntax, ModuleItem::UseItem(it) => &it.syntax, ModuleItem::ExternCrateItem(it) => &it.syntax, ModuleItem::ConstDef(it) => &it.syntax, diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 863859dca..7915cf8cb 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs @@ -203,12 +203,11 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec) { _ => 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, 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())); } } diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt index b9e60f6c1..4b13a7236 100644 --- a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt +++ b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 183) - IMPL_BLOCK@[0; 182) + IMPL_DEF@[0; 182) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 13) diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt index bb87022b0..9f50c85e5 100644 --- a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt +++ b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt @@ -77,7 +77,7 @@ SOURCE_FILE@[0; 112) ERROR@[54; 55) COMMA@[54; 55) "," WHITESPACE@[55; 56) " " - IMPL_BLOCK@[56; 60) + IMPL_DEF@[56; 60) IMPL_KW@[56; 60) "impl" EXPR_STMT@[60; 61) ERROR@[60; 61) diff --git a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt index 3942e0904..f239b7b1e 100644 --- a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt +++ b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 38) - IMPL_BLOCK@[0; 14) + IMPL_DEF@[0; 14) IMPL_KW@[0; 4) "impl" TYPE_PARAM_LIST@[4; 14) L_ANGLE@[4; 5) "<" @@ -17,7 +17,7 @@ SOURCE_FILE@[0; 38) IDENT@[8; 13) "Clone" R_ANGLE@[13; 14) ">" WHITESPACE@[14; 15) "\n" - IMPL_BLOCK@[15; 37) + IMPL_DEF@[15; 37) IMPL_KW@[15; 19) "impl" TYPE_PARAM_LIST@[19; 22) L_ANGLE@[19; 20) "<" diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt index d0a128a5f..d8622d45f 100644 --- a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt +++ b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 118) - IMPL_BLOCK@[0; 117) + IMPL_DEF@[0; 117) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 6) diff --git a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt index 0187d872d..01a853d63 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt +++ b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt @@ -18,7 +18,7 @@ SOURCE_FILE@[0; 30) LIFETIME@[16; 21) "\'loop" COLON@[21; 22) ":" WHITESPACE@[22; 23) " " - IMPL_BLOCK@[23; 27) + IMPL_DEF@[23; 27) IMPL_KW@[23; 27) "impl" WHITESPACE@[27; 28) "\n" R_CURLY@[28; 29) "}" diff --git a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt index d5aea05c2..124f0a891 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt +++ b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 87) - IMPL_BLOCK@[0; 12) + IMPL_DEF@[0; 12) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 9) @@ -12,7 +12,7 @@ SOURCE_FILE@[0; 87) L_CURLY@[10; 11) "{" R_CURLY@[11; 12) "}" WHITESPACE@[12; 13) "\n" - IMPL_BLOCK@[13; 33) + IMPL_DEF@[13; 33) IMPL_KW@[13; 17) "impl" WHITESPACE@[17; 18) " " PATH_TYPE@[18; 24) @@ -33,10 +33,10 @@ SOURCE_FILE@[0; 87) L_CURLY@[31; 32) "{" R_CURLY@[32; 33) "}" WHITESPACE@[33; 34) "\n" - IMPL_BLOCK@[34; 38) + IMPL_DEF@[34; 38) IMPL_KW@[34; 38) "impl" WHITESPACE@[38; 39) " " - IMPL_BLOCK@[39; 54) + IMPL_DEF@[39; 54) IMPL_KW@[39; 43) "impl" WHITESPACE@[43; 44) " " PATH_TYPE@[44; 51) @@ -49,7 +49,7 @@ SOURCE_FILE@[0; 87) L_CURLY@[52; 53) "{" R_CURLY@[53; 54) "}" WHITESPACE@[54; 55) "\n" - IMPL_BLOCK@[55; 70) + IMPL_DEF@[55; 70) IMPL_KW@[55; 59) "impl" WHITESPACE@[59; 60) " " PATH_TYPE@[60; 66) @@ -60,7 +60,7 @@ SOURCE_FILE@[0; 87) WHITESPACE@[66; 67) " " FOR_KW@[67; 70) "for" WHITESPACE@[70; 71) " " - IMPL_BLOCK@[71; 86) + IMPL_DEF@[71; 86) IMPL_KW@[71; 75) "impl" WHITESPACE@[75; 76) " " PATH_TYPE@[76; 83) diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt index d4e710dd4..ad9f0965e 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 83) - IMPL_BLOCK@[0; 82) + IMPL_DEF@[0; 82) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 6) diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt index 0ccd12b0a..757ac092a 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 128) - IMPL_BLOCK@[0; 127) + IMPL_DEF@[0; 127) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 6) diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt index d0beeb81e..89caee543 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 69) - IMPL_BLOCK@[0; 68) + IMPL_DEF@[0; 68) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 6) diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt index 0768f0518..b1af67976 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 89) - IMPL_BLOCK@[0; 88) + IMPL_DEF@[0; 88) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 6) diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt index 8f3dcaf88..0a768a8e3 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 27) - IMPL_BLOCK@[0; 26) + IMPL_DEF@[0; 26) UNSAFE_KW@[0; 6) "unsafe" WHITESPACE@[6; 7) " " DEFAULT_KW@[7; 14) "default" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.rs b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.rs deleted file mode 100644 index b7527c870..000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.rs +++ /dev/null @@ -1 +0,0 @@ -impl !Send for X {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.txt deleted file mode 100644 index dfff947fe..000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.txt +++ /dev/null @@ -1,23 +0,0 @@ -SOURCE_FILE@[0; 20) - IMPL_BLOCK@[0; 19) - IMPL_KW@[0; 4) "impl" - WHITESPACE@[4; 5) " " - EXCL@[5; 6) "!" - PATH_TYPE@[6; 10) - PATH@[6; 10) - PATH_SEGMENT@[6; 10) - NAME_REF@[6; 10) - IDENT@[6; 10) "Send" - WHITESPACE@[10; 11) " " - FOR_KW@[11; 14) "for" - WHITESPACE@[14; 15) " " - PATH_TYPE@[15; 16) - PATH@[15; 16) - PATH_SEGMENT@[15; 16) - NAME_REF@[15; 16) - IDENT@[15; 16) "X" - WHITESPACE@[16; 17) " " - ITEM_LIST@[17; 19) - L_CURLY@[17; 18) "{" - R_CURLY@[18; 19) "}" - WHITESPACE@[19; 20) "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs new file mode 100644 index 000000000..b7527c870 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs @@ -0,0 +1 @@ +impl !Send for X {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt new file mode 100644 index 000000000..0cc3ac085 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt @@ -0,0 +1,23 @@ +SOURCE_FILE@[0; 20) + IMPL_DEF@[0; 19) + IMPL_KW@[0; 4) "impl" + WHITESPACE@[4; 5) " " + EXCL@[5; 6) "!" + PATH_TYPE@[6; 10) + PATH@[6; 10) + PATH_SEGMENT@[6; 10) + NAME_REF@[6; 10) + IDENT@[6; 10) "Send" + WHITESPACE@[10; 11) " " + FOR_KW@[11; 14) "for" + WHITESPACE@[14; 15) " " + PATH_TYPE@[15; 16) + PATH@[15; 16) + PATH_SEGMENT@[15; 16) + NAME_REF@[15; 16) + IDENT@[15; 16) "X" + WHITESPACE@[16; 17) " " + ITEM_LIST@[17; 19) + L_CURLY@[17; 18) "{" + R_CURLY@[18; 19) "}" + WHITESPACE@[19; 20) "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.rs b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.rs deleted file mode 100644 index d6337f6b3..000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.rs +++ /dev/null @@ -1 +0,0 @@ -impl Foo {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.txt deleted file mode 100644 index bda3435e8..000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.txt +++ /dev/null @@ -1,14 +0,0 @@ -SOURCE_FILE@[0; 12) - IMPL_BLOCK@[0; 11) - IMPL_KW@[0; 4) "impl" - WHITESPACE@[4; 5) " " - PATH_TYPE@[5; 8) - PATH@[5; 8) - PATH_SEGMENT@[5; 8) - NAME_REF@[5; 8) - IDENT@[5; 8) "Foo" - WHITESPACE@[8; 9) " " - ITEM_LIST@[9; 11) - L_CURLY@[9; 10) "{" - R_CURLY@[10; 11) "}" - WHITESPACE@[11; 12) "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs new file mode 100644 index 000000000..d6337f6b3 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs @@ -0,0 +1 @@ +impl Foo {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt new file mode 100644 index 000000000..4c2863ba7 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt @@ -0,0 +1,14 @@ +SOURCE_FILE@[0; 12) + IMPL_DEF@[0; 11) + IMPL_KW@[0; 4) "impl" + WHITESPACE@[4; 5) " " + PATH_TYPE@[5; 8) + PATH@[5; 8) + PATH_SEGMENT@[5; 8) + NAME_REF@[5; 8) + IDENT@[5; 8) "Foo" + WHITESPACE@[8; 9) " " + ITEM_LIST@[9; 11) + L_CURLY@[9; 10) "{" + R_CURLY@[10; 11) "}" + WHITESPACE@[11; 12) "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt index 590e2a88f..e614acc6f 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 19) - IMPL_BLOCK@[0; 18) + IMPL_DEF@[0; 18) UNSAFE_KW@[0; 6) "unsafe" WHITESPACE@[6; 7) " " IMPL_KW@[7; 11) "impl" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt index ada94a824..af9077270 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 20) - IMPL_BLOCK@[0; 19) + IMPL_DEF@[0; 19) DEFAULT_KW@[0; 7) "default" WHITESPACE@[7; 8) " " IMPL_KW@[8; 12) "impl" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt index 0e9e9b95b..5053ebde7 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt @@ -8,7 +8,7 @@ SOURCE_FILE@[0; 94) L_CURLY@[6; 7) "{" R_CURLY@[7; 8) "}" WHITESPACE@[8; 9) "\n" - IMPL_BLOCK@[9; 93) + IMPL_DEF@[9; 93) IMPL_KW@[9; 13) "impl" WHITESPACE@[13; 14) " " PATH_TYPE@[14; 15) diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt index 022070b0c..e1734224b 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 69) - IMPL_BLOCK@[0; 68) + IMPL_DEF@[0; 68) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 6) diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt index 47fadef85..2d46eebb3 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 29) - IMPL_BLOCK@[0; 28) + IMPL_DEF@[0; 28) IMPL_KW@[0; 4) "impl" TYPE_PARAM_LIST@[4; 18) L_ANGLE@[4; 5) "<" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt index 933f5b7bd..b30030de3 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt @@ -1,5 +1,5 @@ SOURCE_FILE@[0; 137) - IMPL_BLOCK@[0; 136) + IMPL_DEF@[0; 136) IMPL_KW@[0; 4) "impl" WHITESPACE@[4; 5) " " PATH_TYPE@[5; 6) diff --git a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt index 72f053dfc..341e02704 100644 --- a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt +++ b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt @@ -8,7 +8,7 @@ SOURCE_FILE@[0; 199) IDENT@[69; 72) "Foo" SEMI@[72; 73) ";" WHITESPACE@[73; 75) "\n\n" - IMPL_BLOCK@[75; 141) + IMPL_DEF@[75; 141) IMPL_KW@[75; 79) "impl" WHITESPACE@[79; 80) " " PATH_TYPE@[80; 83) diff --git a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt index 3d9aab500..e15447ca7 100644 --- a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt +++ b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt @@ -92,7 +92,7 @@ SOURCE_FILE@[0; 686) WHITESPACE@[461; 463) "\n\n" COMMENT@[463; 523) "// https://github.com ..." WHITESPACE@[523; 524) "\n" - IMPL_BLOCK@[524; 685) + IMPL_DEF@[524; 685) IMPL_KW@[524; 528) "impl" WHITESPACE@[528; 529) " " PATH_TYPE@[529; 537) diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt index bfd47d2e1..719c99c17 100644 --- a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt +++ b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt @@ -253,7 +253,7 @@ SOURCE_FILE@[0; 519) WHITESPACE@[234; 235) "\n" R_CURLY@[235; 236) "}" WHITESPACE@[236; 238) "\n\n" - IMPL_BLOCK@[238; 519) + IMPL_DEF@[238; 519) IMPL_KW@[238; 242) "impl" WHITESPACE@[242; 243) " " PATH_TYPE@[243; 244) diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index d70d34bdc..6bf0be565 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -76,8 +76,8 @@ pub fn analysis_stats( } } - for impl_block in module.impl_blocks(db) { - for item in impl_block.items(db) { + for impl_def in module.impl_defs(db) { + for item in impl_def.items(db) { num_decls += 1; if let AssocItem::Function(f) = item { funcs.push(f); diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs index ff156307a..eeeb33e8f 100644 --- a/crates/rust-analyzer/src/conv.rs +++ b/crates/rust-analyzer/src/conv.rs @@ -57,7 +57,7 @@ impl Conv for SyntaxKind { SyntaxKind::RECORD_FIELD_DEF => SymbolKind::Field, SyntaxKind::STATIC_DEF => SymbolKind::Constant, SyntaxKind::CONST_DEF => SymbolKind::Constant, - SyntaxKind::IMPL_BLOCK => SymbolKind::Object, + SyntaxKind::IMPL_DEF => SymbolKind::Object, _ => SymbolKind::Variable, } } diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 98d8104e5..9b58aad97 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -104,7 +104,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "STATIC_DEF", "CONST_DEF", "TRAIT_DEF", - "IMPL_BLOCK", + "IMPL_DEF", "TYPE_ALIAS_DEF", "MACRO_CALL", "TOKEN_TREE", @@ -357,7 +357,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { TypeRef, } - struct ImplBlock: TypeParamsOwner, AttrsOwner { + struct ImplDef: TypeParamsOwner, AttrsOwner { ItemList, } @@ -560,7 +560,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { FnDef, TraitDef, TypeAliasDef, - ImplBlock, + ImplDef, UseItem, ExternCrateItem, ConstDef, -- cgit v1.2.3