@@ -10,6 +10,7 @@ use rustc_front::hir::*;
1010use rustc_front:: intravisit:: { Visitor , walk_expr, walk_block, walk_decl} ;
1111use std:: borrow:: Cow ;
1212use std:: collections:: HashMap ;
13+ use syntax:: ast;
1314
1415use utils:: { snippet, span_lint, get_parent_expr, match_trait_method, match_type, in_external_macro,
1516 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 {
417418
418419fn check_for_loop_reverse_range ( cx : & LateContext , arg : & Expr , expr : & Expr ) {
419420 // 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) {
421422 // ...and both sides are compile-time constant integers...
422423 if let Ok ( start_idx) = eval_const_expr_partial ( & cx. tcx , start, ExprTypeChecked , None ) {
423424 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) {
450451 over this range in reverse",
451452 format ! ( "({}..{}).rev()` " , end_snippet, start_snippet) ) ;
452453 } ) ;
453- } else if eq {
454+ } else if eq && limits != ast :: RangeLimits :: Closed {
454455 // if they are equal, it's also problematic - this loop
455456 // will never run.
456457 span_lint ( cx,
0 commit comments