@@ -240,10 +240,14 @@ fn place_case(db: &dyn HirDatabase, body: &MirBody, lvalue: &Place) -> Projectio
240240/// Returns a map from basic blocks to the set of locals that might be ever initialized before
241241/// the start of the block. Only `StorageDead` can remove something from this map, and we ignore
242242/// `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 > > {
244247 let mut result: ArenaMap < BasicBlockId , ArenaMap < LocalId , bool > > =
245248 body. basic_blocks . iter ( ) . map ( |x| ( x. 0 , ArenaMap :: default ( ) ) ) . collect ( ) ;
246249 fn dfs (
250+ db : & dyn HirDatabase ,
247251 body : & MirBody ,
248252 b : BasicBlockId ,
249253 l : LocalId ,
@@ -267,7 +271,7 @@ fn ever_initialized_map(body: &MirBody) -> ArenaMap<BasicBlockId, ArenaMap<Local
267271 }
268272 }
269273 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 ) ) ;
271275 return ;
272276 } ;
273277 let targets = match & terminator. kind {
@@ -299,18 +303,18 @@ fn ever_initialized_map(body: &MirBody) -> ArenaMap<BasicBlockId, ArenaMap<Local
299303 for target in targets {
300304 if !result[ target] . contains_idx ( l) || !result[ target] [ l] && is_ever_initialized {
301305 result[ target] . insert ( l, is_ever_initialized) ;
302- dfs ( body, target, l, result) ;
306+ dfs ( db , body, target, l, result) ;
303307 }
304308 }
305309 }
306310 for & l in & body. param_locals {
307311 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) ;
309313 }
310314 for l in body. locals . iter ( ) . map ( |x| x. 0 ) {
311315 if !result[ body. start_block ] . contains_idx ( l) {
312316 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) ;
314318 }
315319 }
316320 result
@@ -326,7 +330,7 @@ fn mutability_of_locals(
326330 MutabilityReason :: Mut { spans } => spans. push ( span) ,
327331 x @ MutabilityReason :: Not => * x = MutabilityReason :: Mut { spans : vec ! [ span] } ,
328332 } ;
329- let ever_init_maps = ever_initialized_map ( body) ;
333+ let ever_init_maps = ever_initialized_map ( db , body) ;
330334 for ( block_id, mut ever_init_map) in ever_init_maps. into_iter ( ) {
331335 let block = & body. basic_blocks [ block_id] ;
332336 for statement in & block. statements {
0 commit comments