diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index b0d24398575..fa0ef165cb4 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1092,15 +1092,9 @@ impl Expr { if let ExprKind::Block(ref block, _) = self.kind { match block.stmts.last().map(|last_stmt| &last_stmt.kind) { // Implicit return - Some(&StmtKind::Expr(_)) => true, - Some(&StmtKind::Semi(ref expr)) => { - if let ExprKind::Ret(_) = expr.kind { - // Last statement is explicit return. - true - } else { - false - } - } + Some(StmtKind::Expr(_)) => true, + // Last statement is an explicit return? + Some(StmtKind::Semi(expr)) => matches!(expr.kind, ExprKind::Ret(_)), // This is a block that doesn't end in either an implicit or explicit return. _ => false, } @@ -1950,7 +1944,7 @@ impl TyKind { } pub fn is_unit(&self) -> bool { - if let TyKind::Tup(ref tys) = *self { tys.is_empty() } else { false } + matches!(self, TyKind::Tup(tys) if tys.is_empty()) } } diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 2e1b5a74a7b..5bcfe2fedee 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1806,12 +1806,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { output, c_variadic, implicit_self: decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| { - let is_mutable_pat = match arg.pat.kind { - PatKind::Ident(BindingMode::ByValue(mt) | BindingMode::ByRef(mt), _, _) => { - mt == Mutability::Mut - } - _ => false, - }; + use BindingMode::{ByRef, ByValue}; + let is_mutable_pat = matches!( + arg.pat.kind, + PatKind::Ident(ByValue(Mutability::Mut) | ByRef(Mutability::Mut), ..) + ); match arg.ty.kind { TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut,