Merge #10429
10429: internal: remove deprecated method r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
5faf07d082
2 changed files with 6 additions and 17 deletions
|
|
@ -210,11 +210,7 @@ pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext)
|
|||
ast::Expr::BlockExpr(block) => block,
|
||||
expr => make::block_expr(iter::empty(), Some(expr)),
|
||||
};
|
||||
let else_expr = match else_expr {
|
||||
ast::Expr::BlockExpr(block) if block.is_empty() => None,
|
||||
ast::Expr::TupleExpr(tuple) if tuple.fields().next().is_none() => None,
|
||||
expr => Some(expr),
|
||||
};
|
||||
let else_expr = if is_empty_expr(&else_expr) { None } else { Some(else_expr) };
|
||||
let if_let_expr = make::expr_if(
|
||||
condition,
|
||||
then_block,
|
||||
|
|
@ -257,7 +253,10 @@ fn pick_pattern_and_expr_order(
|
|||
|
||||
fn is_empty_expr(expr: &ast::Expr) -> bool {
|
||||
match expr {
|
||||
ast::Expr::BlockExpr(expr) => expr.is_empty(),
|
||||
ast::Expr::BlockExpr(expr) => match expr.stmt_list() {
|
||||
Some(it) => it.statements().next().is_none() && it.tail_expr().is_none(),
|
||||
None => true,
|
||||
},
|
||||
ast::Expr::TupleExpr(expr) => expr.fields().next().is_none(),
|
||||
_ => false,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ use parser::SyntaxKind;
|
|||
use rowan::{GreenNodeData, GreenTokenData};
|
||||
|
||||
use crate::{
|
||||
ast::{
|
||||
self, support, AstNode, AstToken, HasAttrs, HasGenericParams, HasModuleItem, HasName,
|
||||
SyntaxNode,
|
||||
},
|
||||
ast::{self, support, AstNode, AstToken, HasAttrs, HasGenericParams, HasName, SyntaxNode},
|
||||
NodeOrToken, SmolStr, SyntaxElement, SyntaxToken, TokenText, T,
|
||||
};
|
||||
|
||||
|
|
@ -54,13 +51,6 @@ impl ast::HasModuleItem for ast::StmtList {}
|
|||
|
||||
impl ast::BlockExpr {
|
||||
// FIXME: remove all these methods, they belong to ast::StmtList
|
||||
pub fn items(&self) -> impl Iterator<Item = ast::Item> {
|
||||
self.stmt_list().into_iter().flat_map(|it| it.items())
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.statements().next().is_none() && self.tail_expr().is_none()
|
||||
}
|
||||
pub fn statements(&self) -> impl Iterator<Item = ast::Stmt> {
|
||||
self.stmt_list().into_iter().flat_map(|it| it.statements())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue