@@ -10,6 +10,7 @@ use rustc_front::hir::*;
10
10
use rustc_front:: intravisit:: { Visitor , walk_expr, walk_block, walk_decl} ;
11
11
use std:: borrow:: Cow ;
12
12
use std:: collections:: HashMap ;
13
+ use syntax:: ast;
13
14
14
15
use utils:: { snippet, span_lint, get_parent_expr, match_trait_method, match_type, in_external_macro,
15
16
span_help_and_lint, is_integer_literal, get_enclosing_block, span_lint_and_then,
@@ -417,7 +418,7 @@ fn is_len_call(expr: &Expr, var: &Name) -> bool {
417
418
418
419
fn check_for_loop_reverse_range ( cx : & LateContext , arg : & Expr , expr : & Expr ) {
419
420
// if this for loop is iterating over a two-sided range...
420
- if let Some ( UnsugaredRange { start : Some ( ref start) , end : Some ( ref end) , .. } ) = unsugar_range ( & arg) {
421
+ if let Some ( UnsugaredRange { start : Some ( ref start) , end : Some ( ref end) , limits } ) = unsugar_range ( & arg) {
421
422
// ...and both sides are compile-time constant integers...
422
423
if let Ok ( start_idx) = eval_const_expr_partial ( & cx. tcx , start, ExprTypeChecked , None ) {
423
424
if let Ok ( end_idx) = eval_const_expr_partial ( & cx. tcx , end, ExprTypeChecked , None ) {
@@ -450,7 +451,7 @@ fn check_for_loop_reverse_range(cx: &LateContext, arg: &Expr, expr: &Expr) {
450
451
over this range in reverse",
451
452
format ! ( "({}..{}).rev()` " , end_snippet, start_snippet) ) ;
452
453
} ) ;
453
- } else if eq {
454
+ } else if eq && limits != ast :: RangeLimits :: Closed {
454
455
// if they are equal, it's also problematic - this loop
455
456
// will never run.
456
457
span_lint ( cx,
0 commit comments