Skip to content

Commit 04e5fa3

Browse files
Remove last instances of HashSet in query result types.
1 parent 422208a commit 04e5fa3

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

compiler/rustc_hir_analysis/src/check_unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
1010
for item_def_id in tcx.hir().body_owners() {
1111
let imports = tcx.used_trait_imports(item_def_id);
1212
debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
13-
used_trait_imports.extend(imports.items().copied());
13+
used_trait_imports.extend_unord(imports.items().copied());
1414
}
1515

1616
for &id in tcx.maybe_unused_trait_imports(()) {

compiler/rustc_middle/src/mir/query.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::mir::{Body, ConstantKind, Promoted};
44
use crate::ty::{self, OpaqueHiddenType, Ty, TyCtxt};
5-
use rustc_data_structures::fx::FxHashSet;
5+
use rustc_data_structures::unord::UnordSet;
66
use rustc_data_structures::vec_map::VecMap;
77
use rustc_errors::ErrorGuaranteed;
88
use rustc_hir as hir;
@@ -123,7 +123,7 @@ pub struct UnsafetyCheckResult {
123123
pub violations: Vec<UnsafetyViolation>,
124124

125125
/// Used `unsafe` blocks in this function. This is used for the "unused_unsafe" lint.
126-
pub used_unsafe_blocks: FxHashSet<hir::HirId>,
126+
pub used_unsafe_blocks: UnordSet<hir::HirId>,
127127

128128
/// This is `Some` iff the item is not a closure.
129129
pub unused_unsafes: Option<Vec<(hir::HirId, UnusedUnsafe)>>,

compiler/rustc_mir_transform/src/check_unsafety.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::fx::FxHashSet;
1+
use rustc_data_structures::unord::{UnordItems, UnordSet};
22
use rustc_errors::struct_span_err;
33
use rustc_hir as hir;
44
use 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

3030
impl<'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

408406
struct 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> {
458456
fn 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

Comments
 (0)