Skip to content

Commit 08c99f8

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 f2c6d5c commit 08c99f8

File tree

27 files changed

+43
-4
lines changed

27 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
@@ -157,6 +157,7 @@ rustc_index::newtype_index! {
157157
/// tree or hash map.
158158
#[derive(HashStable_Generic)]
159159
#[encodable]
160+
#[orderable]
160161
pub struct ItemLocalId {}
161162
}
162163

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
rustc_macros::newtype_index! {
5+
#[orderable]
56
#[max = 0xFFFF_FFFA]
67
struct MyIdx {}
78
}

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_macros/src/newtype.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ 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

2828
attrs.retain(|attr| match attr.path().get_ident() {
2929
Some(ident) => match &*ident.to_string() {
3030
"encodable" => {
3131
encodable = true;
3232
false
3333
}
34-
"no_ord_impl" => {
35-
ord = false;
34+
"orderable" => {
35+
ord = true;
3636
false
3737
}
3838
"max" => {

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

+4
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,7 @@ impl fmt::Debug for EarlyParamRegion {
16111611
rustc_index::newtype_index! {
16121612
/// A **`const`** **v**ariable **ID**.
16131613
#[encodable]
1614+
#[orderable]
16141615
#[debug_format = "?{}c"]
16151616
pub struct ConstVid {}
16161617
}
@@ -1624,6 +1625,7 @@ rustc_index::newtype_index! {
16241625
/// where we are not correctly using the effect var for an effect param. Fallback
16251626
/// is also implemented on top of having separate effect and normal const variables.
16261627
#[encodable]
1628+
#[orderable]
16271629
#[debug_format = "?{}e"]
16281630
pub struct EffectVid {}
16291631
}
@@ -1632,6 +1634,7 @@ rustc_index::newtype_index! {
16321634
/// A **region** (lifetime) **v**ariable **ID**.
16331635
#[derive(HashStable)]
16341636
#[encodable]
1637+
#[orderable]
16351638
#[debug_format = "'?{}"]
16361639
pub struct RegionVid {}
16371640
}
@@ -1645,6 +1648,7 @@ impl Atom for RegionVid {
16451648
rustc_index::newtype_index! {
16461649
#[derive(HashStable)]
16471650
#[encodable]
1651+
#[orderable]
16481652
#[debug_format = "{}"]
16491653
pub struct BoundVar {}
16501654
}

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/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ rustc_index::newtype_index! {
9292
/// [dbi]: https://en.wikipedia.org/wiki/De_Bruijn_index
9393
#[derive(HashStable_Generic)]
9494
#[encodable]
95+
#[orderable]
9596
#[debug_format = "DebruijnIndex({})"]
9697
pub struct DebruijnIndex {
9798
const INNERMOST = 0;
@@ -292,6 +293,7 @@ rustc_index::newtype_index! {
292293
/// use for checking generic functions.
293294
#[derive(HashStable_Generic)]
294295
#[encodable]
296+
#[orderable]
295297
#[debug_format = "U{}"]
296298
pub struct UniverseIndex {}
297299
}

compiler/rustc_type_ir/src/ty_kind.rs

+3
Original file line numberDiff line numberDiff line change
@@ -733,20 +733,23 @@ pub struct FloatVarValue(pub FloatTy);
733733
rustc_index::newtype_index! {
734734
/// A **ty**pe **v**ariable **ID**.
735735
#[encodable]
736+
#[orderable]
736737
#[debug_format = "?{}t"]
737738
pub struct TyVid {}
738739
}
739740

740741
rustc_index::newtype_index! {
741742
/// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
742743
#[encodable]
744+
#[orderable]
743745
#[debug_format = "?{}i"]
744746
pub struct IntVid {}
745747
}
746748

747749
rustc_index::newtype_index! {
748750
/// A **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
749751
#[encodable]
752+
#[orderable]
750753
#[debug_format = "?{}f"]
751754
pub struct FloatVid {}
752755
}

0 commit comments

Comments
 (0)