Make it a ui test, update

This commit is contained in:
Manish Goregaokar 2017-09-25 18:32:05 -07:00
parent d7867ef8c1
commit bfc31536c7
3 changed files with 37 additions and 18 deletions

View file

@ -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();
}

View file

@ -37,8 +37,8 @@ fn mut_range_bound_no_mutation() {
fn mut_borrow_range_bound() {
let mut m = 4;
for i in 0..m {
let n = &mut m; // warning here?
*n += 1; // or here?
let n = &mut m; // warning
*n += 1;
}
}

View 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