File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
src/librustc_mir/transform Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -641,13 +641,17 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
641641 }
642642 }
643643
644- let mut unsafe_blocks: Vec < _ > = unsafe_blocks. iter ( ) . collect ( ) ;
645- unsafe_blocks. sort_by_cached_key ( |( hir_id, _) | tcx. hir ( ) . hir_id_to_node_id ( * hir_id) ) ;
646- let used_unsafe: FxHashSet < _ > =
647- unsafe_blocks. iter ( ) . flat_map ( |& & ( id, used) | used. then_some ( id) ) . collect ( ) ;
648- for & ( block_id, is_used) in unsafe_blocks {
649- if !is_used {
650- report_unused_unsafe ( tcx, & used_unsafe, block_id) ;
644+ let ( mut unsafe_used, mut unsafe_unused) : ( FxHashSet < _ > , Vec < _ > ) = Default :: default ( ) ;
645+ for & ( block_id, is_used) in unsafe_blocks. iter ( ) {
646+ if is_used {
647+ unsafe_used. insert ( block_id) ;
648+ } else {
649+ unsafe_unused. push ( block_id) ;
651650 }
652651 }
652+ unsafe_unused. sort_by_cached_key ( |hir_id| tcx. hir ( ) . hir_id_to_node_id ( * hir_id) ) ;
653+
654+ for & block_id in & unsafe_unused {
655+ report_unused_unsafe ( tcx, & unsafe_used, block_id) ;
656+ }
653657}
You can’t perform that action at this time.
0 commit comments