@@ -160,75 +160,66 @@ pub(super) const fn sort_bindings<Callback, SorterUseInfoList, VertexList>(
160
160
assert ! ( temp_uses. is_empty( ) ) ;
161
161
assert ! ( temp_vertices. is_empty( ) ) ;
162
162
163
- {
164
- // `for` loops are unusable in `const fn` [ref:const_for]
165
- let mut bind_i = 0 ;
166
- while bind_i < num_binds {
167
- let bind_users = cb. bind_users ( bind_i) ;
168
-
169
- let mut num_indefinite_shared = 0 ;
170
- let mut num_indefinite_exclusive = 0 ;
171
-
172
- // `for` loops are unusable in `const fn` [ref:const_for]
173
- let mut i = 0 ;
174
- while i < bind_users. len ( ) {
175
- // Reject impossible combinations that should be caught earlier
176
- match bind_users[ i] {
177
- ( BindUsage :: Bind ( _) , BindBorrowType :: Borrow )
178
- | ( BindUsage :: Bind ( _) , BindBorrowType :: BorrowMut )
179
- | ( BindUsage :: Bind ( _) , BindBorrowType :: Take )
180
- | ( BindUsage :: Bind ( _) , BindBorrowType :: TakeRef )
181
- | ( BindUsage :: Bind ( _) , BindBorrowType :: TakeMut )
182
- | ( BindUsage :: Executable , BindBorrowType :: Take )
183
- | ( BindUsage :: Executable , BindBorrowType :: TakeRef )
184
- | ( BindUsage :: Executable , BindBorrowType :: TakeMut ) => { }
185
- // [ref:borrow_is_indefinite_for_executable]
186
- ( BindUsage :: Executable , BindBorrowType :: Borrow )
187
- | ( BindUsage :: Executable , BindBorrowType :: BorrowMut ) => {
188
- unreachable ! ( )
189
- }
163
+ for bind_i in 0 ..num_binds {
164
+ let bind_users = cb. bind_users ( bind_i) ;
165
+
166
+ let mut num_indefinite_shared = 0 ;
167
+ let mut num_indefinite_exclusive = 0 ;
168
+
169
+ // `[T]::iter` is unusable in `const fn` [ref:const_slice_iter]
170
+ for i in 0 ..bind_users. len ( ) {
171
+ // Reject impossible combinations that should be caught earlier
172
+ match bind_users[ i] {
173
+ ( BindUsage :: Bind ( _) , BindBorrowType :: Borrow )
174
+ | ( BindUsage :: Bind ( _) , BindBorrowType :: BorrowMut )
175
+ | ( BindUsage :: Bind ( _) , BindBorrowType :: Take )
176
+ | ( BindUsage :: Bind ( _) , BindBorrowType :: TakeRef )
177
+ | ( BindUsage :: Bind ( _) , BindBorrowType :: TakeMut )
178
+ | ( BindUsage :: Executable , BindBorrowType :: Take )
179
+ | ( BindUsage :: Executable , BindBorrowType :: TakeRef )
180
+ | ( BindUsage :: Executable , BindBorrowType :: TakeMut ) => { }
181
+ // [ref:borrow_is_indefinite_for_executable]
182
+ ( BindUsage :: Executable , BindBorrowType :: Borrow )
183
+ | ( BindUsage :: Executable , BindBorrowType :: BorrowMut ) => {
184
+ unreachable ! ( )
190
185
}
186
+ }
191
187
192
- // Count indefinite borrows
193
- match bind_users[ i] . 1 {
194
- BindBorrowType :: Borrow | BindBorrowType :: BorrowMut => { }
195
- BindBorrowType :: TakeRef => {
196
- num_indefinite_shared += 1 ;
197
- }
198
- BindBorrowType :: Take | BindBorrowType :: TakeMut => {
199
- num_indefinite_exclusive += 1 ;
200
- }
188
+ // Count indefinite borrows
189
+ match bind_users[ i] . 1 {
190
+ BindBorrowType :: Borrow | BindBorrowType :: BorrowMut => { }
191
+ BindBorrowType :: TakeRef => {
192
+ num_indefinite_shared += 1 ;
201
193
}
202
-
203
- // Collect dependencies in the reverse direction
204
- if let ( BindUsage :: Bind ( user_bind_i) , borrow_type) = bind_users[ i] {
205
- let use_i = temp_uses. len ( ) ;
206
- let other_bind_first_use_i = & mut temp_binds1[ user_bind_i] . first_use_i ;
207
- temp_uses. push ( SorterUseInfo {
208
- bind_i,
209
- borrow_type,
210
- next_use_i : * other_bind_first_use_i,
211
- } ) ;
212
- * other_bind_first_use_i = Some ( use_i) ;
194
+ BindBorrowType :: Take | BindBorrowType :: TakeMut => {
195
+ num_indefinite_exclusive += 1 ;
213
196
}
214
-
215
- i += 1 ;
216
197
}
217
198
218
- temp_binds1[ bind_i] . borrowed_indefinitely =
219
- match ( num_indefinite_shared, num_indefinite_exclusive) {
220
- ( 0 , 0 ) => None ,
221
- ( _, 0 ) => Some ( false ) ,
222
- ( 0 , 1 ) => Some ( true ) ,
223
- _ => {
224
- // [ref:bind_conflicting_take]
225
- cb. report_error ( SorterError :: ConflictingIndefiniteBorrow { bind_i } ) ;
226
- Some ( false )
227
- }
228
- } ;
229
-
230
- bind_i += 1 ;
199
+ // Collect dependencies in the reverse direction
200
+ if let ( BindUsage :: Bind ( user_bind_i) , borrow_type) = bind_users[ i] {
201
+ let use_i = temp_uses. len ( ) ;
202
+ let other_bind_first_use_i = & mut temp_binds1[ user_bind_i] . first_use_i ;
203
+ temp_uses. push ( SorterUseInfo {
204
+ bind_i,
205
+ borrow_type,
206
+ next_use_i : * other_bind_first_use_i,
207
+ } ) ;
208
+ * other_bind_first_use_i = Some ( use_i) ;
209
+ }
231
210
}
211
+
212
+ temp_binds1[ bind_i] . borrowed_indefinitely =
213
+ match ( num_indefinite_shared, num_indefinite_exclusive) {
214
+ ( 0 , 0 ) => None ,
215
+ ( _, 0 ) => Some ( false ) ,
216
+ ( 0 , 1 ) => Some ( true ) ,
217
+ _ => {
218
+ // [ref:bind_conflicting_take]
219
+ cb. report_error ( SorterError :: ConflictingIndefiniteBorrow { bind_i } ) ;
220
+ Some ( false )
221
+ }
222
+ } ;
232
223
}
233
224
234
225
// Helper types needed for topological sorting. `Vertex` is defined outside
0 commit comments