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::{
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()),

View file

@ -3134,8 +3134,11 @@ impl AstNode for TryBlockExpr {
&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)]
pub struct TryExpr {
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 {
fn arg_list(&self) -> Option<ast::ArgList> {
child_opt(self)

View file

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