Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit dc95bd6

Browse files
committed
Remove Ord from Ty, Const, and Region
1 parent 939df29 commit dc95bd6

File tree

12 files changed

+51
-86
lines changed

12 files changed

+51
-86
lines changed

compiler/rustc_middle/src/thir.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,11 @@ impl<'tcx> PatRangeBoundary<'tcx> {
10181018
(Finite(mir::Const::Ty(a)), Finite(mir::Const::Ty(b)))
10191019
if matches!(ty.kind(), ty::Uint(_) | ty::Char) =>
10201020
{
1021-
return Some(a.kind().cmp(&b.kind()));
1021+
if let Some(a) = a.try_to_valtree() {
1022+
if let Some(b) = b.try_to_valtree() {
1023+
return Some(a.cmp(&b));
1024+
}
1025+
}
10221026
}
10231027
(
10241028
Finite(mir::Const::Val(mir::ConstValue::Scalar(Scalar::Int(a)), _)),

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub use valtree::*;
2323
pub type ConstKind<'tcx> = IrConstKind<TyCtxt<'tcx>>;
2424

2525
/// Use this rather than `ConstData`, whenever possible.
26-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
26+
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
2727
#[rustc_pass_by_value]
2828
pub struct Const<'tcx>(pub(super) Interned<'tcx, WithCachedTypeInfo<ConstData<'tcx>>>);
2929

@@ -52,7 +52,7 @@ impl<'tcx> ConstTy<TyCtxt<'tcx>> for Const<'tcx> {
5252
}
5353

5454
/// Typed constant value.
55-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
55+
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
5656
#[derive(HashStable, TyEncodable, TyDecodable)]
5757
pub struct ConstData<'tcx> {
5858
pub ty: Ty<'tcx>,

compiler/rustc_middle/src/ty/consts/kind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::def_id::DefId;
77
use rustc_macros::HashStable;
88

99
/// An unevaluated (potentially generic) constant used in the type-system.
10-
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)]
10+
#[derive(Copy, Clone, Eq, PartialEq, TyEncodable, TyDecodable)]
1111
#[derive(Hash, HashStable, TypeFoldable, TypeVisitable)]
1212
pub struct UnevaluatedConst<'tcx> {
1313
pub def: DefId,
@@ -62,7 +62,7 @@ impl<'tcx> UnevaluatedConst<'tcx> {
6262
}
6363
}
6464

65-
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
65+
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
6666
#[derive(HashStable, TyEncodable, TyDecodable, TypeVisitable, TypeFoldable)]
6767
pub enum Expr<'tcx> {
6868
Binop(mir::BinOp, Const<'tcx>, Const<'tcx>),

compiler/rustc_middle/src/ty/generic_args.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use rustc_type_ir::WithCachedTypeInfo;
1717
use smallvec::SmallVec;
1818

1919
use core::intrinsics;
20-
use std::cmp::Ordering;
2120
use std::marker::PhantomData;
2221
use std::mem;
2322
use std::num::NonZero;
@@ -68,7 +67,7 @@ const TYPE_TAG: usize = 0b00;
6867
const REGION_TAG: usize = 0b01;
6968
const CONST_TAG: usize = 0b10;
7069

71-
#[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, PartialOrd, Ord, HashStable)]
70+
#[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, HashStable)]
7271
pub enum GenericArgKind<'tcx> {
7372
Lifetime(ty::Region<'tcx>),
7473
Type(Ty<'tcx>),
@@ -100,18 +99,6 @@ impl<'tcx> GenericArgKind<'tcx> {
10099
}
101100
}
102101

103-
impl<'tcx> Ord for GenericArg<'tcx> {
104-
fn cmp(&self, other: &GenericArg<'tcx>) -> Ordering {
105-
self.unpack().cmp(&other.unpack())
106-
}
107-
}
108-
109-
impl<'tcx> PartialOrd for GenericArg<'tcx> {
110-
fn partial_cmp(&self, other: &GenericArg<'tcx>) -> Option<Ordering> {
111-
Some(self.cmp(other))
112-
}
113-
}
114-
115102
impl<'tcx> From<ty::Region<'tcx>> for GenericArg<'tcx> {
116103
#[inline]
117104
fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> {

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ pub struct CReaderCacheKey {
517517
}
518518

519519
/// Use this rather than `TyKind`, whenever possible.
520-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
520+
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
521521
#[rustc_diagnostic_item = "Ty"]
522522
#[rustc_pass_by_value]
523523
pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
@@ -702,7 +702,7 @@ const TAG_MASK: usize = 0b11;
702702
const TYPE_TAG: usize = 0b00;
703703
const CONST_TAG: usize = 0b01;
704704

705-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, TyEncodable, TyDecodable)]
705+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
706706
#[derive(HashStable, TypeFoldable, TypeVisitable)]
707707
pub enum TermKind<'tcx> {
708708
Ty(Ty<'tcx>),
@@ -980,7 +980,7 @@ impl PlaceholderLike for PlaceholderType {
980980
}
981981

982982
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
983-
#[derive(TyEncodable, TyDecodable, PartialOrd, Ord)]
983+
#[derive(TyEncodable, TyDecodable)]
984984
pub struct BoundConst<'tcx> {
985985
pub var: BoundVar,
986986
pub ty: Ty<'tcx>,

compiler/rustc_middle/src/ty/predicate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'tcx> Clause<'tcx> {
192192
}
193193
}
194194

195-
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, TyEncodable, TyDecodable)]
195+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
196196
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
197197
pub enum ExistentialPredicate<'tcx> {
198198
/// E.g., `Iterator`.
@@ -336,7 +336,7 @@ impl<'tcx> ty::List<ty::PolyExistentialPredicate<'tcx>> {
336336
///
337337
/// Trait references also appear in object types like `Foo<U>`, but in
338338
/// that case the `Self` parameter is absent from the generic parameters.
339-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
339+
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
340340
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
341341
pub struct TraitRef<'tcx> {
342342
pub def_id: DefId,
@@ -420,7 +420,7 @@ impl<'tcx> IntoDiagArg for TraitRef<'tcx> {
420420
/// ```
421421
/// The generic parameters don't include the erased `Self`, only trait
422422
/// type and lifetime parameters (`[X, Y]` and `['a, 'b]` above).
423-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
423+
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
424424
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
425425
pub struct ExistentialTraitRef<'tcx> {
426426
pub def_id: DefId,
@@ -476,7 +476,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
476476
}
477477

478478
/// A `ProjectionPredicate` for an `ExistentialTraitRef`.
479-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
479+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)]
480480
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
481481
pub struct ExistentialProjection<'tcx> {
482482
pub def_id: DefId,

compiler/rustc_middle/src/ty/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::ty::{self, BoundVar, TyCtxt, TypeFlags};
1414
pub type RegionKind<'tcx> = IrRegionKind<TyCtxt<'tcx>>;
1515

1616
/// Use this rather than `RegionKind`, whenever possible.
17-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
17+
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
1818
#[rustc_pass_by_value]
1919
pub struct Region<'tcx>(pub Interned<'tcx, RegionKind<'tcx>>);
2020

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ where
11091109
/// * For a projection, this would be `<Ty as Trait<...>>::N<...>`.
11101110
/// * For an inherent projection, this would be `Ty::N<...>`.
11111111
/// * For an opaque type, there is no explicit syntax.
1112-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
1112+
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
11131113
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
11141114
pub struct AliasTy<'tcx> {
11151115
/// The parameters of the associated or opaque item.
@@ -1278,7 +1278,7 @@ pub struct GenSig<'tcx> {
12781278
/// - `inputs`: is the list of arguments and their modes.
12791279
/// - `output`: is the return type.
12801280
/// - `c_variadic`: indicates whether this is a C-variadic function.
1281-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
1281+
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
12821282
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
12831283
pub struct FnSig<'tcx> {
12841284
pub inputs_and_output: &'tcx List<Ty<'tcx>>,
@@ -2661,7 +2661,7 @@ impl<'tcx> Ty<'tcx> {
26612661
/// a miscompilation or unsoundness.
26622662
///
26632663
/// When in doubt, use `VarianceDiagInfo::default()`
2664-
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
2664+
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
26652665
pub enum VarianceDiagInfo<'tcx> {
26662666
/// No additional information - this is the default.
26672667
/// We will not add any additional information to error messages.

compiler/rustc_type_ir/src/const_kind.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ use self::ConstKind::*;
88

99
/// Represents a constant in Rust.
1010
#[derive(derivative::Derivative)]
11-
#[derivative(
12-
Clone(bound = ""),
13-
Copy(bound = ""),
14-
PartialOrd(bound = ""),
15-
PartialOrd = "feature_allow_slow_enum",
16-
Ord(bound = ""),
17-
Ord = "feature_allow_slow_enum",
18-
Hash(bound = "")
19-
)]
11+
#[derivative(Clone(bound = ""), Copy(bound = ""), Hash(bound = ""))]
2012
#[cfg_attr(feature = "nightly", derive(TyEncodable, TyDecodable, HashStable_NoContext))]
2113
pub enum ConstKind<I: Interner> {
2214
/// A const generic parameter.

compiler/rustc_type_ir/src/interner.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ use crate::{
1010

1111
pub trait Interner: Sized {
1212
type DefId: Copy + Debug + Hash + Ord;
13-
type AdtDef: Copy + Debug + Hash + Ord;
13+
type AdtDef: Copy + Debug + Hash + Eq;
1414

1515
type GenericArgs: Copy
1616
+ DebugWithInfcx<Self>
1717
+ Hash
18-
+ Ord
18+
+ Eq
1919
+ IntoIterator<Item = Self::GenericArg>;
20-
type GenericArg: Copy + DebugWithInfcx<Self> + Hash + Ord;
21-
type Term: Copy + Debug + Hash + Ord;
20+
type GenericArg: Copy + DebugWithInfcx<Self> + Hash + Eq;
21+
type Term: Copy + Debug + Hash + Eq;
2222

2323
type Binder<T: TypeVisitable<Self>>: BoundVars<Self> + TypeSuperVisitable<Self>;
2424
type BoundVars: IntoIterator<Item = Self::BoundVar>;
@@ -30,56 +30,56 @@ pub trait Interner: Sized {
3030
type Ty: Copy
3131
+ DebugWithInfcx<Self>
3232
+ Hash
33-
+ Ord
33+
+ Eq
3434
+ Into<Self::GenericArg>
3535
+ IntoKind<Kind = TyKind<Self>>
3636
+ TypeSuperVisitable<Self>
3737
+ Flags
3838
+ new::Ty<Self>;
39-
type Tys: Copy + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>;
40-
type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Ord;
41-
type ParamTy: Copy + Debug + Hash + Ord;
42-
type BoundTy: Copy + Debug + Hash + Ord;
43-
type PlaceholderTy: Copy + Debug + Hash + Ord + PlaceholderLike;
39+
type Tys: Copy + Debug + Hash + Eq + IntoIterator<Item = Self::Ty>;
40+
type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Eq;
41+
type ParamTy: Copy + Debug + Hash + Eq;
42+
type BoundTy: Copy + Debug + Hash + Eq;
43+
type PlaceholderTy: Copy + Debug + Hash + Eq + PlaceholderLike;
4444

4545
// Things stored inside of tys
46-
type ErrorGuaranteed: Copy + Debug + Hash + Ord;
47-
type BoundExistentialPredicates: Copy + DebugWithInfcx<Self> + Hash + Ord;
48-
type PolyFnSig: Copy + DebugWithInfcx<Self> + Hash + Ord;
49-
type AllocId: Copy + Debug + Hash + Ord;
46+
type ErrorGuaranteed: Copy + Debug + Hash + Eq;
47+
type BoundExistentialPredicates: Copy + DebugWithInfcx<Self> + Hash + Eq;
48+
type PolyFnSig: Copy + DebugWithInfcx<Self> + Hash + Eq;
49+
type AllocId: Copy + Debug + Hash + Eq;
5050

5151
// Kinds of consts
5252
type Const: Copy
5353
+ DebugWithInfcx<Self>
5454
+ Hash
55-
+ Ord
55+
+ Eq
5656
+ Into<Self::GenericArg>
5757
+ IntoKind<Kind = ConstKind<Self>>
5858
+ ConstTy<Self>
5959
+ TypeSuperVisitable<Self>
6060
+ Flags
6161
+ new::Const<Self>;
62-
type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Ord;
63-
type PlaceholderConst: Copy + Debug + Hash + Ord + PlaceholderLike;
64-
type ParamConst: Copy + Debug + Hash + Ord;
65-
type BoundConst: Copy + Debug + Hash + Ord;
66-
type ValueConst: Copy + Debug + Hash + Ord;
67-
type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Ord;
62+
type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Eq;
63+
type PlaceholderConst: Copy + Debug + Hash + Eq + PlaceholderLike;
64+
type ParamConst: Copy + Debug + Hash + Eq;
65+
type BoundConst: Copy + Debug + Hash + Eq;
66+
type ValueConst: Copy + Debug + Hash + Eq;
67+
type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Eq;
6868

6969
// Kinds of regions
7070
type Region: Copy
7171
+ DebugWithInfcx<Self>
7272
+ Hash
73-
+ Ord
73+
+ Eq
7474
+ Into<Self::GenericArg>
7575
+ IntoKind<Kind = RegionKind<Self>>
7676
+ Flags
7777
+ new::Region<Self>;
78-
type EarlyParamRegion: Copy + Debug + Hash + Ord;
79-
type LateParamRegion: Copy + Debug + Hash + Ord;
80-
type BoundRegion: Copy + Debug + Hash + Ord;
81-
type InferRegion: Copy + DebugWithInfcx<Self> + Hash + Ord;
82-
type PlaceholderRegion: Copy + Debug + Hash + Ord + PlaceholderLike;
78+
type EarlyParamRegion: Copy + Debug + Hash + Eq;
79+
type LateParamRegion: Copy + Debug + Hash + Eq;
80+
type BoundRegion: Copy + Debug + Hash + Eq;
81+
type InferRegion: Copy + DebugWithInfcx<Self> + Hash + Eq;
82+
type PlaceholderRegion: Copy + Debug + Hash + Eq + PlaceholderLike;
8383

8484
// Predicates
8585
type Predicate: Copy + Debug + Hash + Eq + TypeSuperVisitable<Self> + Flags;

0 commit comments

Comments
 (0)