mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Make it a ui test, update
This commit is contained in:
parent
d7867ef8c1
commit
bfc31536c7
3 changed files with 37 additions and 18 deletions
|
@ -1,15 +0,0 @@
|
||||||
#![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();
|
|
||||||
}
|
|
|
@ -37,8 +37,8 @@ fn mut_range_bound_no_mutation() {
|
||||||
fn mut_borrow_range_bound() {
|
fn mut_borrow_range_bound() {
|
||||||
let mut m = 4;
|
let mut m = 4;
|
||||||
for i in 0..m {
|
for i in 0..m {
|
||||||
let n = &mut m; // warning here?
|
let n = &mut m; // warning
|
||||||
*n += 1; // or here?
|
*n += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
34
tests/ui/mut_range_bound.stderr
Normal file
34
tests/ui/mut_range_bound.stderr
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
error: attempt to mutate range bound within loop; note that the range of the loop is unchanged
|
||||||
|
--> $DIR/mut_range_bound.rs:18:21
|
||||||
|
|
|
||||||
|
18 | for i in 0..m { m = 5; } // warning
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: `-D mut-range-bound` implied by `-D warnings`
|
||||||
|
|
||||||
|
error: attempt to mutate range bound within loop; note that the range of the loop is unchanged
|
||||||
|
--> $DIR/mut_range_bound.rs:23:22
|
||||||
|
|
|
||||||
|
23 | for i in m..10 { m *= 2; } // warning
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: attempt to mutate range bound within loop; note that the range of the loop is unchanged
|
||||||
|
--> $DIR/mut_range_bound.rs:29:21
|
||||||
|
|
|
||||||
|
29 | for i in m..n { m = 5; n = 7; } // warning (1 for each mutated bound)
|
||||||
|
| ^^^^^
|
||||||
|
|
||||||
|
error: attempt to mutate range bound within loop; note that the range of the loop is unchanged
|
||||||
|
--> $DIR/mut_range_bound.rs:29:28
|
||||||
|
|
|
||||||
|
29 | for i in m..n { m = 5; n = 7; } // warning (1 for each mutated bound)
|
||||||
|
| ^^^^^
|
||||||
|
|
||||||
|
error: attempt to mutate range bound within loop; note that the range of the loop is unchanged
|
||||||
|
--> $DIR/mut_range_bound.rs:40:22
|
||||||
|
|
|
||||||
|
40 | let n = &mut m; // warning
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: aborting due to 5 previous errors
|
||||||
|
|
Loading…
Reference in a new issue