avoid op-ref in macros

Avoid running op-ref inspection in macros since the macro
may be invoked in many different types of contexts.

Solves #2818 and incidentally avoids #2689.
This commit is contained in:
Mikael Zayenz Lagerkvist 2018-05-29 13:17:37 +02:00
parent ce229b2025
commit f97c38de94

View file

@ -53,7 +53,10 @@ impl LintPass for EqOp {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
if let ExprBinary(ref op, ref left, ref right) = e.node {
if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) && !in_macro(e.span) {
if in_macro(e.span) {
return;
}
if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) {
span_lint(
cx,
EQ_OP,