Skip to content

Commit 587a542

Browse files
committed
Replace no_ord_impl with orderable.
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
1 parent f608a80 commit 587a542

File tree

28 files changed

+43
-4
lines changed

28 files changed

+43
-4
lines changed

compiler/rustc_ast/src/ast.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2574,6 +2574,7 @@ pub enum AttrStyle {
25742574
}
25752575

25762576
rustc_index::newtype_index! {
2577+
#[orderable]
25772578
#[debug_format = "AttrId({})"]
25782579
pub struct AttrId {}
25792580
}

compiler/rustc_ast/src/node_id.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rustc_index::newtype_index! {
99
///
1010
/// [`DefId`]: rustc_span::def_id::DefId
1111
#[encodable]
12+
#[orderable]
1213
#[debug_format = "NodeId({})"]
1314
pub struct NodeId {
1415
/// The [`NodeId`] used to represent the root of the crate.

compiler/rustc_borrowck/src/constraints/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ rustc_index::newtype_index! {
122122
}
123123

124124
rustc_index::newtype_index! {
125+
#[orderable]
125126
#[debug_format = "ConstraintSccIndex({})"]
126127
pub struct ConstraintSccIndex {}
127128
}

compiler/rustc_borrowck/src/dataflow.rs

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ impl_visitable! {
109109
}
110110

111111
rustc_index::newtype_index! {
112+
#[orderable]
112113
#[debug_format = "bw{}"]
113114
pub struct BorrowIndex {}
114115
}

compiler/rustc_borrowck/src/location.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub struct LocationTable {
2020
}
2121

2222
rustc_index::newtype_index! {
23+
#[orderable]
2324
#[debug_format = "LocationIndex({})"]
2425
pub struct LocationIndex {}
2526
}

compiler/rustc_borrowck/src/region_infer/values.rs

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ impl RegionValueElements {
9090
rustc_index::newtype_index! {
9191
/// A single integer representing a `Location` in the MIR control-flow
9292
/// graph. Constructed efficiently from `RegionValueElements`.
93+
#[orderable]
9394
#[debug_format = "PointIndex({})"]
9495
pub struct PointIndex {}
9596
}

compiler/rustc_data_structures/src/graph/dominators/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct PreOrderFrame<Iter> {
2323
}
2424

2525
rustc_index::newtype_index! {
26+
#[orderable]
2627
struct PreorderIndex {}
2728
}
2829

compiler/rustc_hir/src/hir_id.rs

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ rustc_index::newtype_index! {
155155
/// tree or hash map.
156156
#[derive(HashStable_Generic)]
157157
#[encodable]
158+
#[orderable]
158159
pub struct ItemLocalId {}
159160
}
160161

compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
198198
// entire graph when there are many connected regions.
199199

200200
rustc_index::newtype_index! {
201+
#[orderable]
201202
pub struct RegionId {}
202203
}
203204

compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs

+2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ use rustc_middle::ty::error::TypeError;
44
use std::cmp;
55

66
rustc_index::newtype_index! {
7+
#[orderable]
78
#[debug_format = "ExpectedIdx({})"]
89
pub(crate) struct ExpectedIdx {}
910
}
1011

1112
rustc_index::newtype_index! {
13+
#[orderable]
1214
#[debug_format = "ProvidedIdx({})"]
1315
pub(crate) struct ProvidedIdx {}
1416
}

compiler/rustc_index/src/vec/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
use crate as rustc_index;
33

44
crate::newtype_index! {
5+
#[orderable]
56
#[max = 0xFFFF_FFFA]
67
struct MyIdx {}
78
}

compiler/rustc_index_macros/src/newtype.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Parse for Newtype {
2323
let mut max = None;
2424
let mut consts = Vec::new();
2525
let mut encodable = false;
26-
let mut ord = true;
26+
let mut ord = false;
2727
let mut gate_rustc_only = quote! {};
2828
let mut gate_rustc_only_cfg = quote! { all() };
2929

@@ -38,8 +38,8 @@ impl Parse for Newtype {
3838
encodable = true;
3939
false
4040
}
41-
"no_ord_impl" => {
42-
ord = false;
41+
"orderable" => {
42+
ord = true;
4343
false
4444
}
4545
"max" => {

compiler/rustc_infer/src/infer/region_constraints/leak_check.rs

+2
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,13 @@ impl<'tcx> SccUniverse<'tcx> {
341341
}
342342

343343
rustc_index::newtype_index! {
344+
#[orderable]
344345
#[debug_format = "LeakCheckNode({})"]
345346
struct LeakCheckNode {}
346347
}
347348

348349
rustc_index::newtype_index! {
350+
#[orderable]
349351
#[debug_format = "LeakCheckScc({})"]
350352
struct LeakCheckScc {}
351353
}

compiler/rustc_middle/src/middle/region.rs

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ rustc_index::newtype_index! {
149149
/// and thus does not include EXPR_2, but covers the `...`.
150150
#[derive(HashStable)]
151151
#[encodable]
152+
#[orderable]
152153
pub struct FirstStatementIndex {}
153154
}
154155

compiler/rustc_middle/src/mir/coverage.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ rustc_index::newtype_index! {
1818
/// to use a larger representation on the Rust side.
1919
#[derive(HashStable)]
2020
#[encodable]
21+
#[orderable]
2122
#[max = 0xFFFF_FFFF]
2223
#[debug_format = "CounterId({})"]
2324
pub struct CounterId {}
@@ -39,6 +40,7 @@ rustc_index::newtype_index! {
3940
/// to use a larger representation on the Rust side.
4041
#[derive(HashStable)]
4142
#[encodable]
43+
#[orderable]
4244
#[max = 0xFFFF_FFFF]
4345
#[debug_format = "ExpressionId({})"]
4446
pub struct ExpressionId {}

compiler/rustc_middle/src/mir/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ impl SourceInfo {
737737
rustc_index::newtype_index! {
738738
#[derive(HashStable)]
739739
#[encodable]
740+
#[orderable]
740741
#[debug_format = "_{}"]
741742
pub struct Local {
742743
const RETURN_PLACE = 0;
@@ -1173,6 +1174,7 @@ rustc_index::newtype_index! {
11731174
/// [guide-mir]: https://rustc-dev-guide.rust-lang.org/mir/
11741175
#[derive(HashStable)]
11751176
#[encodable]
1177+
#[orderable]
11761178
#[debug_format = "bb{}"]
11771179
pub struct BasicBlock {
11781180
const START_BLOCK = 0;
@@ -1537,6 +1539,7 @@ impl UserTypeProjection {
15371539
rustc_index::newtype_index! {
15381540
#[derive(HashStable)]
15391541
#[encodable]
1542+
#[orderable]
15401543
#[debug_format = "promoted[{}]"]
15411544
pub struct Promoted {}
15421545
}

compiler/rustc_middle/src/ty/sty.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,7 @@ rustc_index::newtype_index! {
16121612
/// A **region** (lifetime) **v**ariable **ID**.
16131613
#[derive(HashStable)]
16141614
#[encodable]
1615+
#[orderable]
16151616
#[debug_format = "'?{}"]
16161617
pub struct RegionVid {}
16171618
}
@@ -1625,6 +1626,7 @@ impl Atom for RegionVid {
16251626
rustc_index::newtype_index! {
16261627
#[derive(HashStable)]
16271628
#[encodable]
1629+
#[orderable]
16281630
#[debug_format = "{}"]
16291631
pub struct BoundVar {}
16301632
}

compiler/rustc_mir_build/src/build/scope.rs

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ pub(crate) enum BreakableTarget {
186186
}
187187

188188
rustc_index::newtype_index! {
189+
#[orderable]
189190
struct DropIdx {}
190191
}
191192

compiler/rustc_mir_dataflow/src/move_paths/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use self::abs_domain::{AbstractElem, Lift};
1414
mod abs_domain;
1515

1616
rustc_index::newtype_index! {
17+
#[orderable]
1718
#[debug_format = "mp{}"]
1819
pub struct MovePathIndex {}
1920
}
@@ -25,6 +26,7 @@ impl polonius_engine::Atom for MovePathIndex {
2526
}
2627

2728
rustc_index::newtype_index! {
29+
#[orderable]
2830
#[debug_format = "mo{}"]
2931
pub struct MoveOutIndex {}
3032
}

compiler/rustc_mir_transform/src/coverage/graph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ impl graph::WithPredecessors for CoverageGraph {
264264

265265
rustc_index::newtype_index! {
266266
/// A node in the control-flow graph of CoverageGraph.
267+
#[orderable]
267268
#[debug_format = "bcb{}"]
268269
pub(super) struct BasicCoverageBlock {
269270
const START_BCB = 0;

compiler/rustc_span/src/def_id.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub type StableCrateIdMap =
1313
indexmap::IndexMap<StableCrateId, CrateNum, BuildHasherDefault<Unhasher>>;
1414

1515
rustc_index::newtype_index! {
16+
#[orderable]
1617
#[debug_format = "crate{}"]
1718
pub struct CrateNum {}
1819
}
@@ -212,6 +213,7 @@ rustc_index::newtype_index! {
212213
/// A DefIndex is an index into the hir-map for a crate, identifying a
213214
/// particular definition. It should really be considered an interned
214215
/// shorthand for a particular DefPath.
216+
#[orderable]
215217
#[debug_format = "DefIndex({})"]
216218
pub struct DefIndex {
217219
/// The crate root is always assigned index 0 by the AST Map code,

compiler/rustc_span/src/hygiene.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub struct SyntaxContextData {
6060

6161
rustc_index::newtype_index! {
6262
/// A unique ID associated with a macro invocation and expansion.
63+
#[orderable]
6364
pub struct ExpnIndex {}
6465
}
6566

@@ -79,7 +80,6 @@ impl fmt::Debug for ExpnId {
7980

8081
rustc_index::newtype_index! {
8182
/// A unique ID associated with a macro invocation and expansion.
82-
#[no_ord_impl]
8383
#[debug_format = "expn{}"]
8484
pub struct LocalExpnId {}
8585
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,7 @@ impl fmt::Display for MacroRulesNormalizedIdent {
20182018
pub struct Symbol(SymbolIndex);
20192019

20202020
rustc_index::newtype_index! {
2021+
#[orderable]
20212022
struct SymbolIndex {}
20222023
}
20232024

compiler/rustc_target/src/abi/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ rustc_index::newtype_index! {
4343
/// `f` is `FieldIdx(1)` in `VariantIdx(0)`.
4444
#[derive(HashStable_Generic)]
4545
#[encodable]
46+
#[orderable]
4647
pub struct FieldIdx {}
4748
}
4849

@@ -59,6 +60,7 @@ rustc_index::newtype_index! {
5960
/// with variant index zero, aka [`FIRST_VARIANT`].
6061
#[derive(HashStable_Generic)]
6162
#[encodable]
63+
#[orderable]
6264
pub struct VariantIdx {
6365
/// Equivalent to `VariantIdx(0)`.
6466
const FIRST_VARIANT = 0;

compiler/rustc_trait_selection/src/solve/search_graph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_session::Limit;
1313
use std::collections::hash_map::Entry;
1414

1515
rustc_index::newtype_index! {
16+
#[orderable]
1617
pub struct StackDepth {}
1718
}
1819

compiler/rustc_type_ir/src/const_kind.rs

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ impl<I: Interner> DebugWithInfcx<I> for ConstKind<I> {
9696
rustc_index::newtype_index! {
9797
/// A **`const`** **v**ariable **ID**.
9898
#[encodable]
99+
#[orderable]
99100
#[debug_format = "?{}c"]
100101
#[gate_rustc_only]
101102
pub struct ConstVid {}
@@ -110,6 +111,7 @@ rustc_index::newtype_index! {
110111
/// where we are not correctly using the effect var for an effect param. Fallback
111112
/// is also implemented on top of having separate effect and normal const variables.
112113
#[encodable]
114+
#[orderable]
113115
#[debug_format = "?{}e"]
114116
#[gate_rustc_only]
115117
pub struct EffectVid {}

compiler/rustc_type_ir/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ rustc_index::newtype_index! {
9393
/// [dbi]: https://en.wikipedia.org/wiki/De_Bruijn_index
9494
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
9595
#[encodable]
96+
#[orderable]
9697
#[debug_format = "DebruijnIndex({})"]
9798
#[gate_rustc_only]
9899
pub struct DebruijnIndex {
@@ -295,6 +296,7 @@ rustc_index::newtype_index! {
295296
/// use for checking generic functions.
296297
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
297298
#[encodable]
299+
#[orderable]
298300
#[debug_format = "U{}"]
299301
#[gate_rustc_only]
300302
pub struct UniverseIndex {}

compiler/rustc_type_ir/src/ty_kind.rs

+3
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ pub struct FloatVarValue(pub FloatTy);
623623
rustc_index::newtype_index! {
624624
/// A **ty**pe **v**ariable **ID**.
625625
#[encodable]
626+
#[orderable]
626627
#[debug_format = "?{}t"]
627628
#[gate_rustc_only]
628629
pub struct TyVid {}
@@ -631,6 +632,7 @@ rustc_index::newtype_index! {
631632
rustc_index::newtype_index! {
632633
/// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
633634
#[encodable]
635+
#[orderable]
634636
#[debug_format = "?{}i"]
635637
#[gate_rustc_only]
636638
pub struct IntVid {}
@@ -639,6 +641,7 @@ rustc_index::newtype_index! {
639641
rustc_index::newtype_index! {
640642
/// A **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
641643
#[encodable]
644+
#[orderable]
642645
#[debug_format = "?{}f"]
643646
#[gate_rustc_only]
644647
pub struct FloatVid {}

0 commit comments

Comments
 (0)