"any loop that will always `break` or `return`"
}
+/// TODO: add documentation
+
+declare_lint! {
+ pub MUT_RANGE_BOUND,
+ Warn,
+ "for loop over a range where one of the bounds is a mutable variable"
+}
+
#[derive(Copy, Clone)]
pub struct Pass;
EMPTY_LOOP,
WHILE_LET_ON_ITERATOR,
FOR_KV_MAP,
- NEVER_LOOP
+ NEVER_LOOP,
+ MUT_RANGE_BOUND
)
}
}
--- /dev/null
+#![feature(plugin)]
+#![plugin(clippy)]
+
+// cause the build to fail if this warning is invoked
+#![deny(check_for_loop_mut_bound)]
+
+// an example
+fn mut_range_bound() {
+ let mut m = 4;
+ for i in 0..m { continue; } // ERROR One of the range bounds is mutable
+}
+
+fn main(){
+ mut_range_bound();
+}