From f3a82c372ccaa079842f151b749fbe9b8b9eb004 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 2 Apr 2019 12:25:24 +0300 Subject: remove flavor --- crates/ra_assists/src/replace_if_let_with_match.rs | 4 ++-- crates/ra_hir/src/expr.rs | 8 ++++---- crates/ra_syntax/src/ast.rs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'crates') diff --git a/crates/ra_assists/src/replace_if_let_with_match.rs b/crates/ra_assists/src/replace_if_let_with_match.rs index 230573499..2b451f08d 100644 --- a/crates/ra_assists/src/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/replace_if_let_with_match.rs @@ -11,8 +11,8 @@ pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx) -> let expr = cond.expr()?; let then_block = if_expr.then_branch()?; let else_block = match if_expr.else_branch()? { - ast::ElseBranchFlavor::Block(it) => it, - ast::ElseBranchFlavor::IfExpr(_) => return None, + ast::ElseBranch::Block(it) => it, + ast::ElseBranch::IfExpr(_) => return None, }; ctx.add_action(AssistId("replace_if_let_with_match"), "replace with match", |edit| { diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 946c9faf2..ee2c4475c 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -516,8 +516,8 @@ impl ExprCollector { let else_branch = e .else_branch() .map(|b| match b { - ast::ElseBranchFlavor::Block(it) => self.collect_block(it), - ast::ElseBranchFlavor::IfExpr(elif) => { + ast::ElseBranch::Block(it) => self.collect_block(it), + ast::ElseBranch::IfExpr(elif) => { let expr: &ast::Expr = ast::Expr::cast(elif.syntax()).unwrap(); self.collect_expr(expr) } @@ -533,8 +533,8 @@ impl ExprCollector { let condition = self.collect_expr_opt(e.condition().and_then(|c| c.expr())); let then_branch = self.collect_block_opt(e.then_branch()); let else_branch = e.else_branch().map(|b| match b { - ast::ElseBranchFlavor::Block(it) => self.collect_block(it), - ast::ElseBranchFlavor::IfExpr(elif) => { + ast::ElseBranch::Block(it) => self.collect_block(it), + ast::ElseBranch::IfExpr(elif) => { let expr: &ast::Expr = ast::Expr::cast(elif.syntax()).unwrap(); self.collect_expr(expr) } diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index beef2c6e2..b0e0f8bf9 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -164,7 +164,7 @@ impl LetStmt { } #[derive(Debug, Clone, PartialEq, Eq)] -pub enum ElseBranchFlavor<'a> { +pub enum ElseBranch<'a> { Block(&'a Block), IfExpr(&'a IfExpr), } @@ -173,12 +173,12 @@ impl IfExpr { pub fn then_branch(&self) -> Option<&Block> { self.blocks().nth(0) } - pub fn else_branch(&self) -> Option { + pub fn else_branch(&self) -> Option { let res = match self.blocks().nth(1) { - Some(block) => ElseBranchFlavor::Block(block), + Some(block) => ElseBranch::Block(block), None => { let elif: &IfExpr = child_opt(self)?; - ElseBranchFlavor::IfExpr(elif) + ElseBranch::IfExpr(elif) } }; Some(res) -- cgit v1.2.3