1
- use rustc_data_structures:: fx :: FxHashSet ;
1
+ use rustc_data_structures:: unord :: { UnordItems , UnordSet } ;
2
2
use rustc_errors:: struct_span_err;
3
3
use rustc_hir as hir;
4
4
use rustc_hir:: def:: DefKind ;
@@ -24,7 +24,7 @@ pub struct UnsafetyChecker<'a, 'tcx> {
24
24
param_env : ty:: ParamEnv < ' tcx > ,
25
25
26
26
/// 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 > ,
28
28
}
29
29
30
30
impl < ' a , ' tcx > UnsafetyChecker < ' a , ' tcx > {
@@ -129,7 +129,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
129
129
let def_id = def_id. expect_local ( ) ;
130
130
let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } =
131
131
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 ( ) ) ;
133
133
}
134
134
} ,
135
135
_ => { }
@@ -151,7 +151,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
151
151
let local_def_id = def_id. expect_local ( ) ;
152
152
let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } =
153
153
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 ( ) ) ;
155
155
}
156
156
}
157
157
}
@@ -268,14 +268,14 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
268
268
. lint_root ;
269
269
self . register_violations (
270
270
[ & UnsafetyViolation { source_info, lint_root, kind, details } ] ,
271
- [ ] ,
271
+ UnordItems :: empty ( ) ,
272
272
) ;
273
273
}
274
274
275
275
fn register_violations < ' a > (
276
276
& mut self ,
277
277
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 > > ,
279
279
) {
280
280
let safety = self . body . source_scopes [ self . source_info . scope ]
281
281
. local_data
@@ -308,9 +308,7 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
308
308
} ) ,
309
309
} ;
310
310
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) ;
314
312
}
315
313
fn check_mut_borrowing_layout_constrained_field (
316
314
& mut self ,
@@ -407,7 +405,7 @@ enum Context {
407
405
408
406
struct UnusedUnsafeVisitor < ' a , ' tcx > {
409
407
tcx : TyCtxt < ' tcx > ,
410
- used_unsafe_blocks : & ' a FxHashSet < HirId > ,
408
+ used_unsafe_blocks : & ' a UnordSet < HirId > ,
411
409
context : Context ,
412
410
unused_unsafes : & ' a mut Vec < ( HirId , UnusedUnsafe ) > ,
413
411
}
@@ -458,7 +456,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'_, 'tcx> {
458
456
fn check_unused_unsafe (
459
457
tcx : TyCtxt < ' _ > ,
460
458
def_id : LocalDefId ,
461
- used_unsafe_blocks : & FxHashSet < HirId > ,
459
+ used_unsafe_blocks : & UnordSet < HirId > ,
462
460
) -> Vec < ( HirId , UnusedUnsafe ) > {
463
461
let body_id = tcx. hir ( ) . maybe_body_owned_by ( def_id) ;
464
462
@@ -505,7 +503,7 @@ fn unsafety_check_result(
505
503
if body. is_custom_mir ( ) {
506
504
return tcx. arena . alloc ( UnsafetyCheckResult {
507
505
violations : Vec :: new ( ) ,
508
- used_unsafe_blocks : FxHashSet :: default ( ) ,
506
+ used_unsafe_blocks : Default :: default ( ) ,
509
507
unused_unsafes : Some ( Vec :: new ( ) ) ,
510
508
} ) ;
511
509
}
0 commit comments