add lint declaration and example that should trigger the lint
This commit is contained in:
parent
4ab2223e59
commit
b091fb9b24
|
@ -328,6 +328,14 @@ declare_lint! {
|
|||
"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;
|
||||
|
||||
|
@ -348,7 +356,8 @@ impl LintPass for Pass {
|
|||
EMPTY_LOOP,
|
||||
WHILE_LET_ON_ITERATOR,
|
||||
FOR_KV_MAP,
|
||||
NEVER_LOOP
|
||||
NEVER_LOOP,
|
||||
MUT_RANGE_BOUND
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,15 @@
|
|||
#![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();
|
||||
}
|
Loading…
Reference in New Issue