Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MISC) Double Negation inspection #713

Merged
merged 2 commits into from
Oct 5, 2016

Conversation

alygin
Copy link
Member

@alygin alygin commented Oct 5, 2016

Inspection that is an analogue of Clippy's double_neg lint. Catches expressions of the form --x which are no-op in Rust.

}
}

private fun isNegation(el: RustExprElement?) =
Copy link
Member

@matklad matklad Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A possible alternative is an extension function on a nullable reciever:

private val RustExprElement?.isNegation: Boolean 
    get() = this is RustUnaryExprElement && minus != null

Note that this is RustUnaryExprElement implies that this != null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, that looks better

@matklad
Copy link
Member

matklad commented Oct 5, 2016

Thanks!

@matklad matklad merged commit e6e9f6f into intellij-rust:master Oct 5, 2016
@alygin alygin deleted the double-neg-inspection branch October 5, 2016 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants