make it more readable by faster early exitting
This commit is contained in:
parent
0ea88b90d8
commit
0eb9f41a07
@ -258,10 +258,10 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
|||||||
|
|
||||||
fn check_unnecessary_operation(cx: &LateContext<'_>, stmt: &Stmt<'_>) {
|
fn check_unnecessary_operation(cx: &LateContext<'_>, stmt: &Stmt<'_>) {
|
||||||
if let StmtKind::Semi(expr) = stmt.kind
|
if let StmtKind::Semi(expr) = stmt.kind
|
||||||
|
&& !in_external_macro(cx.sess(), stmt.span)
|
||||||
&& let ctxt = stmt.span.ctxt()
|
&& let ctxt = stmt.span.ctxt()
|
||||||
&& expr.span.ctxt() == ctxt
|
&& expr.span.ctxt() == ctxt
|
||||||
&& let Some(reduced) = reduce_expression(cx, expr)
|
&& let Some(reduced) = reduce_expression(cx, expr)
|
||||||
&& !in_external_macro(cx.sess(), stmt.span)
|
|
||||||
&& reduced.iter().all(|e| e.span.ctxt() == ctxt)
|
&& reduced.iter().all(|e| e.span.ctxt() == ctxt)
|
||||||
{
|
{
|
||||||
if let ExprKind::Index(..) = &expr.kind {
|
if let ExprKind::Index(..) = &expr.kind {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user