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_syntax/src/ast/extensions.rs | 2 +- crates/ra_syntax/src/ast/generated.rs | 28 ++++++++++++++-------------- crates/ra_syntax/src/validation.rs | 5 ++--- 3 files changed, 17 insertions(+), 18 deletions(-) (limited to 'crates/ra_syntax/src') 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())); } } -- cgit v1.2.3