From 27ce1e822b9b5e498aec8ce9efd8efc7c5a80b5f Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Mon, 18 Nov 2019 18:13:56 +0000 Subject: [PATCH] Remove the custom impl of AttrsOwner for ImplItem The default impl should have the same behaviour, and it can be generated by codegen. See also `ModuleItem` and `NominalDef` --- crates/ra_syntax/src/ast/extensions.rs | 12 +----------- crates/ra_syntax/src/ast/generated.rs | 1 + crates/ra_syntax/src/grammar.ron | 3 ++- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index cefc004027..761b2435cc 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -2,7 +2,7 @@ //! Extensions for various expressions live in a sibling `expr_extensions` module. use crate::{ - ast::{self, child_opt, children, AstChildren, AstNode, AttrInput, SyntaxNode}, + ast::{self, child_opt, children, AstNode, AttrInput, SyntaxNode}, SmolStr, SyntaxElement, SyntaxKind::*, SyntaxToken, T, @@ -176,16 +176,6 @@ impl ast::ImplBlock { } } -impl ast::AttrsOwner for ast::ImplItem { - fn attrs(&self) -> AstChildren { - match self { - ast::ImplItem::FnDef(it) => it.attrs(), - ast::ImplItem::TypeAliasDef(it) => it.attrs(), - ast::ImplItem::ConstDef(it) => it.attrs(), - } - } -} - #[derive(Debug, Clone, PartialEq, Eq)] pub enum StructKind { Tuple(ast::TupleFieldDefList), diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 34b22c3e2a..2b381dcdba 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1298,6 +1298,7 @@ impl AstNode for ImplItem { } } } +impl ast::AttrsOwner for ImplItem {} impl ImplItem {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ImplTraitType { diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 0a8fd06121..70d85a8e6a 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -401,7 +401,8 @@ Grammar( traits: ["AttrsOwner"] ), "ImplItem": ( - enum: ["FnDef", "TypeAliasDef", "ConstDef"] + enum: ["FnDef", "TypeAliasDef", "ConstDef"], + traits: ["AttrsOwner"] ), "TupleExpr": (