1- use rustc_data_structures:: fx :: FxHashSet ;
1+ use rustc_data_structures:: unord :: { UnordItems , UnordSet } ;
22use rustc_errors:: struct_span_err;
33use rustc_hir as hir;
44use rustc_hir:: def:: DefKind ;
@@ -24,7 +24,7 @@ pub struct UnsafetyChecker<'a, 'tcx> {
2424 param_env : ty:: ParamEnv < ' tcx > ,
2525
2626 /// Used `unsafe` blocks in this function. This is used for the "unused_unsafe" lint.
27- used_unsafe_blocks : FxHashSet < HirId > ,
27+ used_unsafe_blocks : UnordSet < HirId > ,
2828}
2929
3030impl < ' a , ' tcx > UnsafetyChecker < ' a , ' tcx > {
@@ -129,7 +129,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
129129 let def_id = def_id. expect_local ( ) ;
130130 let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } =
131131 self . tcx . unsafety_check_result ( def_id) ;
132- self . register_violations ( violations, used_unsafe_blocks. iter ( ) . copied ( ) ) ;
132+ self . register_violations ( violations, used_unsafe_blocks. items ( ) . copied ( ) ) ;
133133 }
134134 } ,
135135 _ => { }
@@ -151,7 +151,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
151151 let local_def_id = def_id. expect_local ( ) ;
152152 let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } =
153153 self . tcx . unsafety_check_result ( local_def_id) ;
154- self . register_violations ( violations, used_unsafe_blocks. iter ( ) . copied ( ) ) ;
154+ self . register_violations ( violations, used_unsafe_blocks. items ( ) . copied ( ) ) ;
155155 }
156156 }
157157 }
@@ -268,14 +268,14 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
268268 . lint_root ;
269269 self . register_violations (
270270 [ & UnsafetyViolation { source_info, lint_root, kind, details } ] ,
271- [ ] ,
271+ UnordItems :: empty ( ) ,
272272 ) ;
273273 }
274274
275275 fn register_violations < ' a > (
276276 & mut self ,
277277 violations : impl IntoIterator < Item = & ' a UnsafetyViolation > ,
278- new_used_unsafe_blocks : impl IntoIterator < Item = HirId > ,
278+ new_used_unsafe_blocks : UnordItems < HirId , impl Iterator < Item = HirId > > ,
279279 ) {
280280 let safety = self . body . source_scopes [ self . source_info . scope ]
281281 . local_data
@@ -308,9 +308,7 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
308308 } ) ,
309309 } ;
310310
311- new_used_unsafe_blocks. into_iter ( ) . for_each ( |hir_id| {
312- self . used_unsafe_blocks . insert ( hir_id) ;
313- } ) ;
311+ self . used_unsafe_blocks . extend_unord ( new_used_unsafe_blocks) ;
314312 }
315313 fn check_mut_borrowing_layout_constrained_field (
316314 & mut self ,
@@ -407,7 +405,7 @@ enum Context {
407405
408406struct UnusedUnsafeVisitor < ' a , ' tcx > {
409407 tcx : TyCtxt < ' tcx > ,
410- used_unsafe_blocks : & ' a FxHashSet < HirId > ,
408+ used_unsafe_blocks : & ' a UnordSet < HirId > ,
411409 context : Context ,
412410 unused_unsafes : & ' a mut Vec < ( HirId , UnusedUnsafe ) > ,
413411}
@@ -458,7 +456,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'_, 'tcx> {
458456fn check_unused_unsafe (
459457 tcx : TyCtxt < ' _ > ,
460458 def_id : LocalDefId ,
461- used_unsafe_blocks : & FxHashSet < HirId > ,
459+ used_unsafe_blocks : & UnordSet < HirId > ,
462460) -> Vec < ( HirId , UnusedUnsafe ) > {
463461 let body_id = tcx. hir ( ) . maybe_body_owned_by ( def_id) ;
464462
@@ -505,7 +503,7 @@ fn unsafety_check_result(
505503 if body. is_custom_mir ( ) {
506504 return tcx. arena . alloc ( UnsafetyCheckResult {
507505 violations : Vec :: new ( ) ,
508- used_unsafe_blocks : FxHashSet :: default ( ) ,
506+ used_unsafe_blocks : Default :: default ( ) ,
509507 unused_unsafes : Some ( Vec :: new ( ) ) ,
510508 } ) ;
511509 }
0 commit comments