@@ -240,10 +240,14 @@ fn place_case(db: &dyn HirDatabase, body: &MirBody, lvalue: &Place) -> Projectio
240
240
/// Returns a map from basic blocks to the set of locals that might be ever initialized before
241
241
/// the start of the block. Only `StorageDead` can remove something from this map, and we ignore
242
242
/// `Uninit` and `drop` and similar after initialization.
243
- fn ever_initialized_map ( body : & MirBody ) -> ArenaMap < BasicBlockId , ArenaMap < LocalId , bool > > {
243
+ fn ever_initialized_map (
244
+ db : & dyn HirDatabase ,
245
+ body : & MirBody ,
246
+ ) -> ArenaMap < BasicBlockId , ArenaMap < LocalId , bool > > {
244
247
let mut result: ArenaMap < BasicBlockId , ArenaMap < LocalId , bool > > =
245
248
body. basic_blocks . iter ( ) . map ( |x| ( x. 0 , ArenaMap :: default ( ) ) ) . collect ( ) ;
246
249
fn dfs (
250
+ db : & dyn HirDatabase ,
247
251
body : & MirBody ,
248
252
b : BasicBlockId ,
249
253
l : LocalId ,
@@ -267,7 +271,7 @@ fn ever_initialized_map(body: &MirBody) -> ArenaMap<BasicBlockId, ArenaMap<Local
267
271
}
268
272
}
269
273
let Some ( terminator) = & block. terminator else {
270
- never ! ( "Terminator should be none only in construction" ) ;
274
+ never ! ( "Terminator should be none only in construction. \n The body: \n {}" , body . pretty_print ( db ) ) ;
271
275
return ;
272
276
} ;
273
277
let targets = match & terminator. kind {
@@ -299,18 +303,18 @@ fn ever_initialized_map(body: &MirBody) -> ArenaMap<BasicBlockId, ArenaMap<Local
299
303
for target in targets {
300
304
if !result[ target] . contains_idx ( l) || !result[ target] [ l] && is_ever_initialized {
301
305
result[ target] . insert ( l, is_ever_initialized) ;
302
- dfs ( body, target, l, result) ;
306
+ dfs ( db , body, target, l, result) ;
303
307
}
304
308
}
305
309
}
306
310
for & l in & body. param_locals {
307
311
result[ body. start_block ] . insert ( l, true ) ;
308
- dfs ( body, body. start_block , l, & mut result) ;
312
+ dfs ( db , body, body. start_block , l, & mut result) ;
309
313
}
310
314
for l in body. locals . iter ( ) . map ( |x| x. 0 ) {
311
315
if !result[ body. start_block ] . contains_idx ( l) {
312
316
result[ body. start_block ] . insert ( l, false ) ;
313
- dfs ( body, body. start_block , l, & mut result) ;
317
+ dfs ( db , body, body. start_block , l, & mut result) ;
314
318
}
315
319
}
316
320
result
@@ -326,7 +330,7 @@ fn mutability_of_locals(
326
330
MutabilityReason :: Mut { spans } => spans. push ( span) ,
327
331
x @ MutabilityReason :: Not => * x = MutabilityReason :: Mut { spans : vec ! [ span] } ,
328
332
} ;
329
- let ever_init_maps = ever_initialized_map ( body) ;
333
+ let ever_init_maps = ever_initialized_map ( db , body) ;
330
334
for ( block_id, mut ever_init_map) in ever_init_maps. into_iter ( ) {
331
335
let block = & body. basic_blocks [ block_id] ;
332
336
for statement in & block. statements {
0 commit comments