Skip to content

Commit c26ba8d

Browse files
committed
Remove Ord from PlaceRef
1 parent f5fe6cd commit c26ba8d

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Validates the MIR to ensure that invariants are upheld.
22
3+
use rustc_data_structures::fx::FxIndexSet;
34
use rustc_index::bit_set::BitSet;
45
use rustc_infer::infer::TyCtxtInferExt;
56
use rustc_middle::mir::interpret::Scalar;
@@ -54,7 +55,7 @@ impl<'tcx> MirPass<'tcx> for Validator {
5455
mir_phase,
5556
reachable_blocks: traversal::reachable_as_bitset(body),
5657
storage_liveness,
57-
place_cache: Vec::new(),
58+
place_cache: FxIndexSet::default(),
5859
}
5960
.visit_body(body);
6061
}
@@ -108,7 +109,7 @@ struct TypeChecker<'a, 'tcx> {
108109
mir_phase: MirPhase,
109110
reachable_blocks: BitSet<BasicBlock>,
110111
storage_liveness: ResultsCursor<'a, 'tcx, MaybeStorageLive>,
111-
place_cache: Vec<PlaceRef<'tcx>>,
112+
place_cache: FxIndexSet<PlaceRef<'tcx>>,
112113
}
113114

114115
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
@@ -438,16 +439,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
438439
// Currently this simply checks for duplicate places.
439440
self.place_cache.clear();
440441
if let Some((destination, _)) = destination {
441-
self.place_cache.push(destination.as_ref());
442+
self.place_cache.insert(destination.as_ref());
442443
}
443444
for arg in args {
444445
if let Operand::Move(place) = arg {
445-
self.place_cache.push(place.as_ref());
446+
self.place_cache.insert(place.as_ref());
446447
}
447448
}
448449
let all_len = self.place_cache.len();
449-
self.place_cache.sort_unstable();
450-
self.place_cache.dedup();
451450
let has_duplicates = all_len != self.place_cache.len();
452451
if has_duplicates {
453452
self.fail(

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ rustc_index::newtype_index! {
18411841
}
18421842
}
18431843

1844-
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1844+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
18451845
pub struct PlaceRef<'tcx> {
18461846
pub local: Local,
18471847
pub projection: &'tcx [PlaceElem<'tcx>],

compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::build::scope::DropKind;
1010
use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
1111
use crate::build::{BlockAnd, BlockAndExtension, Builder};
1212
use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
13+
use rustc_data_structures::fx::FxIndexSet;
1314
use rustc_data_structures::{
1415
fx::{FxHashSet, FxIndexMap},
1516
stack::ensure_sufficient_stack,
@@ -1722,7 +1723,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17221723

17231724
debug!("add_fake_borrows fake_borrows = {:?}", fake_borrows);
17241725

1725-
let mut all_fake_borrows = Vec::with_capacity(fake_borrows.len());
1726+
let mut all_fake_borrows = FxIndexSet::default();
17261727

17271728
// Insert a Shallow borrow of the prefixes of any fake borrows.
17281729
for place in fake_borrows {
@@ -1734,17 +1735,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17341735
// Insert a shallow borrow after a deref. For other
17351736
// projections the borrow of prefix_cursor will
17361737
// conflict with any mutation of base.
1737-
all_fake_borrows.push(PlaceRef { local: place.local, projection: proj_base });
1738+
all_fake_borrows.insert(PlaceRef { local: place.local, projection: proj_base });
17381739
}
17391740
}
17401741

1741-
all_fake_borrows.push(place.as_ref());
1742+
all_fake_borrows.insert(place.as_ref());
17421743
}
17431744

1744-
// Deduplicate and ensure a deterministic order.
1745-
all_fake_borrows.sort();
1746-
all_fake_borrows.dedup();
1747-
17481745
debug!("add_fake_borrows all_fake_borrows = {:?}", all_fake_borrows);
17491746

17501747
all_fake_borrows

0 commit comments

Comments
 (0)