mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Remove DefId
's Partial/Ord
impls
This commit is contained in:
parent
e522d2906d
commit
5f4ac61ebd
@ -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<std::cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl DefId {
|
||||
/// Makes a local `DefId` from the given `DefIndex`.
|
||||
#[inline]
|
||||
|
@ -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
|
||||
|
@ -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::<ImplTraitParam, Vec<GenericBound>>::default();
|
||||
let mut impl_trait = BTreeMap::<u32, Vec<GenericBound>>::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::<Vec<_>>();
|
||||
|
||||
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
|
||||
|
@ -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),
|
||||
|
@ -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)
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user