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: 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(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index cefc00402..761b2435c 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 34b22c3e2..2b381dcdb 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 0a8fd0612..70d85a8e6 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": ( -- cgit v1.2.3