From 05178c92b900caeee17bfc4acbaf6baf6600f089 Mon Sep 17 00:00:00 2001 From: mcarton Date: Sat, 27 Feb 2016 18:14:37 +0100 Subject: [PATCH] Cleanup --- src/formatting.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/formatting.rs b/src/formatting.rs index f82aa7d8188e..efcb222ebed8 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -88,8 +88,9 @@ fn check_assign(cx: &EarlyContext, expr: &ast::Expr) { if !differing_macro_contexts(lhs.span, rhs.span) && !in_macro(cx, lhs.span) { let eq_span = mk_sp(lhs.span.hi, rhs.span.lo); - if let Some((sub_rhs, op)) = check_unop(rhs) { + if let ast::ExprKind::Unary(op, ref sub_rhs) = rhs.node { if let Some(eq_snippet) = snippet_opt(cx, eq_span) { + let op = ast::UnOp::to_string(op); let eqop_span = mk_sp(lhs.span.hi, sub_rhs.span.lo); if eq_snippet.ends_with('=') { span_note_and_lint(cx, @@ -105,13 +106,6 @@ fn check_assign(cx: &EarlyContext, expr: &ast::Expr) { } } -fn check_unop(expr: &ast::Expr) -> Option<(&P, &'static str)> { - match expr.node { - ast::ExprKind::Unary(op, ref expr) => Some((expr, ast::UnOp::to_string(op))), - _ => None, - } -} - /// Implementation of the SUSPICIOUS_ELSE_FORMATTING lint for weird `else if`. fn check_else_if(cx: &EarlyContext, expr: &ast::Expr) { if let Some((then, &Some(ref else_))) = unsugar_if(expr) {