diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 0c811d7dff1..5454f6661a9 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -218,8 +218,6 @@ rustc_index::newtype_index! { /// /// You can create a `DefId` from a `LocalDefId` using `local_def_id.to_def_id()`. #[derive(Clone, PartialEq, Eq, Copy)] -// Don't derive order on 64-bit big-endian, so we can be consistent regardless of field order. -#[cfg_attr(not(all(target_pointer_width = "64", target_endian = "big")), derive(PartialOrd, Ord))] // On below-64 bit systems we can simply use the derived `Hash` impl #[cfg_attr(not(target_pointer_width = "64"), derive(Hash))] #[repr(C)] @@ -261,22 +259,6 @@ impl Hash for DefId { } } -// Implement the same comparison as derived with the other field order. -#[cfg(all(target_pointer_width = "64", target_endian = "big"))] -impl Ord for DefId { - #[inline] - fn cmp(&self, other: &DefId) -> std::cmp::Ordering { - Ord::cmp(&(self.index, self.krate), &(other.index, other.krate)) - } -} -#[cfg(all(target_pointer_width = "64", target_endian = "big"))] -impl PartialOrd for DefId { - #[inline] - fn partial_cmp(&self, other: &DefId) -> Option { - Some(self.cmp(other)) - } -} - impl DefId { /// Makes a local `DefId` from the given `DefIndex`. #[inline] diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index bd67fdbfb2b..ae1e1902f14 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -9,7 +9,7 @@ use crate::{ }; pub trait Interner: Sized { - type DefId: Copy + Debug + Hash + Ord; + type DefId: Copy + Debug + Hash + Eq; type AdtDef: Copy + Debug + Hash + Eq; type GenericArgs: Copy diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ef707d179ea..0cdf52bfb00 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -41,7 +41,7 @@ use std::hash::Hash; use std::mem; use thin_vec::ThinVec; -use crate::core::{self, DocContext, ImplTraitParam}; +use crate::core::{self, DocContext}; use crate::formats::item_type::ItemType; use crate::visit_ast::Module as DocModule; @@ -761,7 +761,7 @@ fn clean_ty_generics<'tcx>( ) -> Generics { // Don't populate `cx.impl_trait_bounds` before `clean`ning `where` clauses, // since `Clean for ty::Predicate` would consume them. - let mut impl_trait = BTreeMap::>::default(); + let mut impl_trait = BTreeMap::>::default(); // Bounds in the type_params and lifetimes fields are repeated in the // predicates field (see rustc_hir_analysis::collect::ty_generics), so remove @@ -778,7 +778,7 @@ fn clean_ty_generics<'tcx>( return None; } if synthetic { - impl_trait.insert(param.index.into(), vec![]); + impl_trait.insert(param.index, vec![]); return None; } Some(clean_generic_param_def(param, cx)) @@ -823,7 +823,7 @@ fn clean_ty_generics<'tcx>( })(); if let Some(param_idx) = param_idx - && let Some(bounds) = impl_trait.get_mut(¶m_idx.into()) + && let Some(bounds) = impl_trait.get_mut(¶m_idx) { let pred = clean_predicate(*pred, cx)?; @@ -847,7 +847,7 @@ fn clean_ty_generics<'tcx>( }) .collect::>(); - for (param, mut bounds) in impl_trait { + for (idx, mut bounds) in impl_trait { let mut has_sized = false; bounds.retain(|b| { if b.is_sized_bound(cx) { @@ -870,7 +870,6 @@ fn clean_ty_generics<'tcx>( bounds.insert(0, GenericBound::sized(cx)); } - let crate::core::ImplTraitParam::ParamIndex(idx) = param else { unreachable!() }; if let Some(proj) = impl_trait_proj.remove(&idx) { for (trait_did, name, rhs) in proj { let rhs = clean_middle_term(rhs, cx); @@ -878,7 +877,7 @@ fn clean_ty_generics<'tcx>( } } - cx.impl_trait_bounds.insert(param, bounds); + cx.impl_trait_bounds.insert(idx.into(), bounds); } // Now that `cx.impl_trait_bounds` is populated, we can process diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 80a30ac2727..25b78d9598d 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -509,7 +509,7 @@ impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> { /// `DefId` or parameter index (`ty::ParamTy.index`) of a synthetic type parameter /// for `impl Trait` in argument position. -#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub(crate) enum ImplTraitParam { DefId(DefId), ParamIndex(u32), diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index f153a908329..b244309da69 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -65,8 +65,8 @@ pub(crate) fn build_index<'tcx>( // Sort search index items. This improves the compressibility of the search index. cache.search_index.sort_unstable_by(|k1, k2| { // `sort_unstable_by_key` produces lifetime errors - let k1 = (&k1.path, k1.name.as_str(), &k1.ty, &k1.parent); - let k2 = (&k2.path, k2.name.as_str(), &k2.ty, &k2.parent); + let k1 = (&k1.path, k1.name.as_str(), &k1.ty, &k1.parent.map(|id| tcx.def_path_str(id))); + let k2 = (&k2.path, k2.name.as_str(), &k2.ty, &k2.parent.map(|id| tcx.def_path_str(id))); Ord::cmp(&k1, &k2) });