Improve end of expression check in for loop lints

The code should to check that the current expression _is_ the end
expression; not that it's equal to it. The equality check seems very
wasteful in terms of performance.
This commit is contained in:
Michael Wright
2020-06-11 20:25:14 +02:00
parent fa0f6a8dbf
commit 52c4864757
+1 -1
View File
@@ -2042,7 +2042,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if self.state == VarState::DontWarn {
return;
}
if SpanlessEq::new(self.cx).eq_expr(&expr, self.end_expr) {
if expr.hir_id == self.end_expr.hir_id {
self.past_loop = true;
return;
}