File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ fn main() {
8
8
immut_range_bound ( ) ;
9
9
mut_borrow_range_bound ( ) ;
10
10
immut_borrow_range_bound ( ) ;
11
+ mut_range_bound_break ( ) ;
12
+ mut_range_bound_nested_break ( ) ;
13
+ multiple_mut_range_bound_break ( ) ;
11
14
}
12
15
13
16
fn mut_range_bound_upper ( ) {
@@ -61,3 +64,36 @@ fn immut_range_bound() {
61
64
continue ;
62
65
} // no warning
63
66
}
67
+
68
+ fn mut_range_bound_break ( ) {
69
+ let mut m = 4 ;
70
+ for i in 0 ..m {
71
+ if m == 4 {
72
+ m = 5 ;
73
+ break ;
74
+ }
75
+ } // no warning because of immediate break
76
+ }
77
+
78
+ fn mut_range_bound_nested_break ( ) {
79
+ let mut m = 4 ;
80
+ for i in 0 ..m {
81
+ if m == 5 {
82
+ break ;
83
+ }
84
+
85
+ m = 4 ; // warning because it is not immediately followed by break
86
+ }
87
+ }
88
+
89
+ fn multiple_mut_range_bound_break ( ) {
90
+ let mut m = 4 ;
91
+ for i in 0 ..m {
92
+ m = 5 ;
93
+
94
+ if m == 4 {
95
+ m = 0 ;
96
+ break ;
97
+ }
98
+ } // warning because the break is not always reachable
99
+ }
You can’t perform that action at this time.
0 commit comments