1751: remove useless trait r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-09-02 16:46:10 +00:00 committed by GitHub
commit a8397deab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 11 deletions

View file

@ -7,7 +7,7 @@ use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
use ra_syntax::{ use ra_syntax::{
ast::{ ast::{
self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner, self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner,
TryBlockBodyOwner, TypeAscriptionOwner, TypeAscriptionOwner,
}, },
AstNode, AstPtr, SyntaxNodePtr, AstNode, AstPtr, SyntaxNodePtr,
}; };
@ -640,7 +640,7 @@ where
self.alloc_expr(Expr::If { condition, then_branch, else_branch }, syntax_ptr) self.alloc_expr(Expr::If { condition, then_branch, else_branch }, syntax_ptr)
} }
ast::Expr::TryBlockExpr(e) => { 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) self.alloc_expr(Expr::TryBlock { body }, syntax_ptr)
} }
ast::Expr::BlockExpr(e) => self.collect_block_opt(e.block()), ast::Expr::BlockExpr(e) => self.collect_block_opt(e.block()),

View file

@ -3134,8 +3134,11 @@ impl AstNode for TryBlockExpr {
&self.syntax &self.syntax
} }
} }
impl ast::TryBlockBodyOwner for TryBlockExpr {} impl TryBlockExpr {
impl TryBlockExpr {} pub fn block(&self) -> Option<Block> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TryExpr { pub struct TryExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,

View file

@ -33,12 +33,6 @@ pub trait LoopBodyOwner: AstNode {
} }
} }
pub trait TryBlockBodyOwner: AstNode {
fn try_body(&self) -> Option<ast::Block> {
child_opt(self)
}
}
pub trait ArgListOwner: AstNode { pub trait ArgListOwner: AstNode {
fn arg_list(&self) -> Option<ast::ArgList> { fn arg_list(&self) -> Option<ast::ArgList> {
child_opt(self) child_opt(self)

View file

@ -426,7 +426,7 @@ Grammar(
traits: ["LoopBodyOwner"], traits: ["LoopBodyOwner"],
), ),
"TryBlockExpr": ( "TryBlockExpr": (
traits: ["TryBlockBodyOwner"], options: ["Block"],
), ),
"ForExpr": ( "ForExpr": (
traits: ["LoopBodyOwner"], traits: ["LoopBodyOwner"],