]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/mut_range_bound.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / mut_range_bound.rs
CommitLineData
f20569fa
XL
1#![allow(unused)]
2
3fn main() {
4 mut_range_bound_upper();
5 mut_range_bound_lower();
6 mut_range_bound_both();
7 mut_range_bound_no_mutation();
8 immut_range_bound();
9 mut_borrow_range_bound();
10 immut_borrow_range_bound();
11}
12
13fn mut_range_bound_upper() {
14 let mut m = 4;
15 for i in 0..m {
16 m = 5;
17 } // warning
18}
19
20fn mut_range_bound_lower() {
21 let mut m = 4;
22 for i in m..10 {
23 m *= 2;
24 } // warning
25}
26
27fn mut_range_bound_both() {
28 let mut m = 4;
29 let mut n = 6;
30 for i in m..n {
31 m = 5;
32 n = 7;
33 } // warning (1 for each mutated bound)
34}
35
36fn mut_range_bound_no_mutation() {
37 let mut m = 4;
38 for i in 0..m {
39 continue;
40 } // no warning
41}
42
43fn mut_borrow_range_bound() {
44 let mut m = 4;
45 for i in 0..m {
46 let n = &mut m; // warning
47 *n += 1;
48 }
49}
50
51fn immut_borrow_range_bound() {
52 let mut m = 4;
53 for i in 0..m {
54 let n = &m; // should be no warning?
55 }
56}
57
58fn immut_range_bound() {
59 let m = 4;
60 for i in 0..m {
61 continue;
62 } // no warning
63}