aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-29 20:40:29 +0000
committerGitHub <[email protected]>2020-02-29 20:40:29 +0000
commit5e78036e6c8752fda350818afdd411ab25f405ce (patch)
treee099bb9e9c04392dcb7fed54200a989f663f3659 /crates/ra_syntax/src
parente91320632a9dfee937c3c2ba3ffafd3f5ffb22dc (diff)
parenta1e18695548b5cd6661f26a985b34c8b105e1896 (diff)
Merge #3379
3379: Rename ast::ImplBlock -> ast::ImplDef r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated.rs28
-rw-r--r--crates/ra_syntax/src/validation.rs5
3 files changed, 17 insertions, 18 deletions
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 {
169 } 169 }
170} 170}
171 171
172impl ast::ImplBlock { 172impl ast::ImplDef {
173 pub fn target_type(&self) -> Option<ast::TypeRef> { 173 pub fn target_type(&self) -> Option<ast::TypeRef> {
174 match self.target() { 174 match self.target() {
175 (Some(t), None) | (_, Some(t)) => Some(t), 175 (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 {
552 } 552 }
553} 553}
554#[derive(Debug, Clone, PartialEq, Eq, Hash)] 554#[derive(Debug, Clone, PartialEq, Eq, Hash)]
555pub struct ImplBlock { 555pub struct ImplDef {
556 pub(crate) syntax: SyntaxNode, 556 pub(crate) syntax: SyntaxNode,
557} 557}
558impl AstNode for ImplBlock { 558impl AstNode for ImplDef {
559 fn can_cast(kind: SyntaxKind) -> bool { 559 fn can_cast(kind: SyntaxKind) -> bool {
560 match kind { 560 match kind {
561 IMPL_BLOCK => true, 561 IMPL_DEF => true,
562 _ => false, 562 _ => false,
563 } 563 }
564 } 564 }
@@ -573,9 +573,9 @@ impl AstNode for ImplBlock {
573 &self.syntax 573 &self.syntax
574 } 574 }
575} 575}
576impl ast::TypeParamsOwner for ImplBlock {} 576impl ast::TypeParamsOwner for ImplDef {}
577impl ast::AttrsOwner for ImplBlock {} 577impl ast::AttrsOwner for ImplDef {}
578impl ImplBlock { 578impl ImplDef {
579 pub fn item_list(&self) -> Option<ItemList> { 579 pub fn item_list(&self) -> Option<ItemList> {
580 AstChildren::new(&self.syntax).next() 580 AstChildren::new(&self.syntax).next()
581 } 581 }
@@ -3524,7 +3524,7 @@ pub enum ModuleItem {
3524 FnDef(FnDef), 3524 FnDef(FnDef),
3525 TraitDef(TraitDef), 3525 TraitDef(TraitDef),
3526 TypeAliasDef(TypeAliasDef), 3526 TypeAliasDef(TypeAliasDef),
3527 ImplBlock(ImplBlock), 3527 ImplDef(ImplDef),
3528 UseItem(UseItem), 3528 UseItem(UseItem),
3529 ExternCrateItem(ExternCrateItem), 3529 ExternCrateItem(ExternCrateItem),
3530 ConstDef(ConstDef), 3530 ConstDef(ConstDef),
@@ -3561,9 +3561,9 @@ impl From<TypeAliasDef> for ModuleItem {
3561 ModuleItem::TypeAliasDef(node) 3561 ModuleItem::TypeAliasDef(node)
3562 } 3562 }
3563} 3563}
3564impl From<ImplBlock> for ModuleItem { 3564impl From<ImplDef> for ModuleItem {
3565 fn from(node: ImplBlock) -> ModuleItem { 3565 fn from(node: ImplDef) -> ModuleItem {
3566 ModuleItem::ImplBlock(node) 3566 ModuleItem::ImplDef(node)
3567 } 3567 }
3568} 3568}
3569impl From<UseItem> for ModuleItem { 3569impl From<UseItem> for ModuleItem {
@@ -3594,8 +3594,8 @@ impl From<Module> for ModuleItem {
3594impl AstNode for ModuleItem { 3594impl AstNode for ModuleItem {
3595 fn can_cast(kind: SyntaxKind) -> bool { 3595 fn can_cast(kind: SyntaxKind) -> bool {
3596 match kind { 3596 match kind {
3597 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF 3597 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
3598 | IMPL_BLOCK | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true, 3598 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
3599 _ => false, 3599 _ => false,
3600 } 3600 }
3601 } 3601 }
@@ -3607,7 +3607,7 @@ impl AstNode for ModuleItem {
3607 FN_DEF => ModuleItem::FnDef(FnDef { syntax }), 3607 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
3608 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }), 3608 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
3609 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }), 3609 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
3610 IMPL_BLOCK => ModuleItem::ImplBlock(ImplBlock { syntax }), 3610 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
3611 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }), 3611 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
3612 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), 3612 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
3613 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), 3613 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
@@ -3625,7 +3625,7 @@ impl AstNode for ModuleItem {
3625 ModuleItem::FnDef(it) => &it.syntax, 3625 ModuleItem::FnDef(it) => &it.syntax,
3626 ModuleItem::TraitDef(it) => &it.syntax, 3626 ModuleItem::TraitDef(it) => &it.syntax,
3627 ModuleItem::TypeAliasDef(it) => &it.syntax, 3627 ModuleItem::TypeAliasDef(it) => &it.syntax,
3628 ModuleItem::ImplBlock(it) => &it.syntax, 3628 ModuleItem::ImplDef(it) => &it.syntax,
3629 ModuleItem::UseItem(it) => &it.syntax, 3629 ModuleItem::UseItem(it) => &it.syntax,
3630 ModuleItem::ExternCrateItem(it) => &it.syntax, 3630 ModuleItem::ExternCrateItem(it) => &it.syntax,
3631 ModuleItem::ConstDef(it) => &it.syntax, 3631 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<SyntaxError>) {
203 _ => return, 203 _ => return,
204 } 204 }
205 205
206 let impl_block = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplBlock::cast) 206 let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplDef::cast) {
207 {
208 Some(it) => it, 207 Some(it) => it,
209 None => return, 208 None => return,
210 }; 209 };
211 if impl_block.target_trait().is_some() { 210 if impl_def.target_trait().is_some() {
212 errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range())); 211 errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range()));
213 } 212 }
214} 213}