From f377b94628a265cb5335fbe4594a47cc8ddc9e2c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Sep 2019 19:45:41 +0300 Subject: remove useless trait --- crates/ra_hir/src/expr.rs | 4 ++-- crates/ra_syntax/src/ast/generated.rs | 7 +++++-- crates/ra_syntax/src/ast/traits.rs | 6 ------ crates/ra_syntax/src/grammar.ron | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 7cdc7555c..c7530849b 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -7,7 +7,7 @@ use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; use ra_syntax::{ ast::{ self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner, - TryBlockBodyOwner, TypeAscriptionOwner, + TypeAscriptionOwner, }, AstNode, AstPtr, SyntaxNodePtr, }; @@ -640,7 +640,7 @@ where self.alloc_expr(Expr::If { condition, then_branch, else_branch }, syntax_ptr) } ast::Expr::TryBlockExpr(e) => { - let body = self.collect_block_opt(e.try_body()); + let body = self.collect_block_opt(e.block()); self.alloc_expr(Expr::TryBlock { body }, syntax_ptr) } ast::Expr::BlockExpr(e) => self.collect_block_opt(e.block()), diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 90480b6ca..7f91417c5 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -3134,8 +3134,11 @@ impl AstNode for TryBlockExpr { &self.syntax } } -impl ast::TryBlockBodyOwner for TryBlockExpr {} -impl TryBlockExpr {} +impl TryBlockExpr { + pub fn block(&self) -> Option { + AstChildren::new(&self.syntax).next() + } +} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TryExpr { pub(crate) syntax: SyntaxNode, diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index 1b9a2b20c..20c251fba 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs @@ -33,12 +33,6 @@ pub trait LoopBodyOwner: AstNode { } } -pub trait TryBlockBodyOwner: AstNode { - fn try_body(&self) -> Option { - child_opt(self) - } -} - pub trait ArgListOwner: AstNode { fn arg_list(&self) -> Option { child_opt(self) diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 1836862fe..9f17a10ed 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -426,7 +426,7 @@ Grammar( traits: ["LoopBodyOwner"], ), "TryBlockExpr": ( - traits: ["TryBlockBodyOwner"], + options: ["Block"], ), "ForExpr": ( traits: ["LoopBodyOwner"], -- cgit v1.2.3