Remove PartialOrd
/Ord
impl for PlaceRef
This is a new attempt at #93315. It removes one usage of the `Ord` impl for `DefId`, which should make it easier to eventually remove that impl.
This commit is contained in:
parent
08b4f1be33
commit
6b747aa397
@ -1,5 +1,6 @@
|
|||||||
//! Validates the MIR to ensure that invariants are upheld.
|
//! Validates the MIR to ensure that invariants are upheld.
|
||||||
|
|
||||||
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_index::bit_set::BitSet;
|
use rustc_index::bit_set::BitSet;
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_middle::mir::interpret::Scalar;
|
use rustc_middle::mir::interpret::Scalar;
|
||||||
@ -701,8 +702,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let all_len = self.place_cache.len();
|
let all_len = self.place_cache.len();
|
||||||
self.place_cache.sort_unstable();
|
let mut dedup = FxHashSet::default();
|
||||||
self.place_cache.dedup();
|
self.place_cache.retain(|p| dedup.insert(*p));
|
||||||
let has_duplicates = all_len != self.place_cache.len();
|
let has_duplicates = all_len != self.place_cache.len();
|
||||||
if has_duplicates {
|
if has_duplicates {
|
||||||
self.fail(
|
self.fail(
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#![feature(get_mut_unchecked)]
|
#![feature(get_mut_unchecked)]
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(map_first_last)]
|
#![feature(map_first_last)]
|
||||||
|
#![feature(negative_impls)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(extern_types)]
|
#![feature(extern_types)]
|
||||||
#![feature(new_uninit)]
|
#![feature(new_uninit)]
|
||||||
|
@ -2084,12 +2084,18 @@ rustc_index::newtype_index! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct PlaceRef<'tcx> {
|
pub struct PlaceRef<'tcx> {
|
||||||
pub local: Local,
|
pub local: Local,
|
||||||
pub projection: &'tcx [PlaceElem<'tcx>],
|
pub projection: &'tcx [PlaceElem<'tcx>],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Once we stop implementing `Ord` for `DefId`,
|
||||||
|
// this impl will be unnecessary. Until then, we'll
|
||||||
|
// leave this impl in place to prevent re-adding a
|
||||||
|
// dependnecy on the `Ord` impl for `DefId`
|
||||||
|
impl<'tcx> !PartialOrd for PlaceRef<'tcx> {}
|
||||||
|
|
||||||
impl<'tcx> Place<'tcx> {
|
impl<'tcx> Place<'tcx> {
|
||||||
// FIXME change this to a const fn by also making List::empty a const fn.
|
// FIXME change this to a const fn by also making List::empty a const fn.
|
||||||
pub fn return_place() -> Place<'tcx> {
|
pub fn return_place() -> Place<'tcx> {
|
||||||
|
@ -11,7 +11,7 @@ use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
|
|||||||
use crate::build::{BlockAnd, BlockAndExtension, Builder};
|
use crate::build::{BlockAnd, BlockAndExtension, Builder};
|
||||||
use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
|
use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
|
||||||
use rustc_data_structures::{
|
use rustc_data_structures::{
|
||||||
fx::{FxIndexMap, FxIndexSet},
|
fx::{FxHashSet, FxIndexMap, FxIndexSet},
|
||||||
stack::ensure_sufficient_stack,
|
stack::ensure_sufficient_stack,
|
||||||
};
|
};
|
||||||
use rustc_hir::HirId;
|
use rustc_hir::HirId;
|
||||||
@ -1741,7 +1741,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
all_fake_borrows.push(place.as_ref());
|
all_fake_borrows.push(place.as_ref());
|
||||||
}
|
}
|
||||||
|
|
||||||
all_fake_borrows.dedup();
|
// Deduplicate
|
||||||
|
let mut dedup = FxHashSet::default();
|
||||||
|
all_fake_borrows.retain(|b| dedup.insert(*b));
|
||||||
|
|
||||||
debug!("add_fake_borrows all_fake_borrows = {:?}", all_fake_borrows);
|
debug!("add_fake_borrows all_fake_borrows = {:?}", all_fake_borrows);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user