diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index e311352c93d..83fe95f16f9 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2574,6 +2574,7 @@ pub enum AttrStyle { } rustc_index::newtype_index! { + #[orderable] #[debug_format = "AttrId({})"] pub struct AttrId {} } diff --git a/compiler/rustc_ast/src/node_id.rs b/compiler/rustc_ast/src/node_id.rs index 48081582fc3..1cd24495309 100644 --- a/compiler/rustc_ast/src/node_id.rs +++ b/compiler/rustc_ast/src/node_id.rs @@ -9,6 +9,7 @@ rustc_index::newtype_index! { /// /// [`DefId`]: rustc_span::def_id::DefId #[encodable] + #[orderable] #[debug_format = "NodeId({})"] pub struct NodeId { /// The [`NodeId`] used to represent the root of the crate. diff --git a/compiler/rustc_borrowck/src/constraints/mod.rs b/compiler/rustc_borrowck/src/constraints/mod.rs index 315886bbe29..041ac75ec01 100644 --- a/compiler/rustc_borrowck/src/constraints/mod.rs +++ b/compiler/rustc_borrowck/src/constraints/mod.rs @@ -122,6 +122,7 @@ rustc_index::newtype_index! { } rustc_index::newtype_index! { + #[orderable] #[debug_format = "ConstraintSccIndex({})"] pub struct ConstraintSccIndex {} } diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs index 8676d2ba7c4..27b558be3b7 100644 --- a/compiler/rustc_borrowck/src/dataflow.rs +++ b/compiler/rustc_borrowck/src/dataflow.rs @@ -109,6 +109,7 @@ impl_visitable! { } rustc_index::newtype_index! { + #[orderable] #[debug_format = "bw{}"] pub struct BorrowIndex {} } diff --git a/compiler/rustc_borrowck/src/location.rs b/compiler/rustc_borrowck/src/location.rs index 0e669abfd14..6f09393169f 100644 --- a/compiler/rustc_borrowck/src/location.rs +++ b/compiler/rustc_borrowck/src/location.rs @@ -20,6 +20,7 @@ pub struct LocationTable { } rustc_index::newtype_index! { + #[orderable] #[debug_format = "LocationIndex({})"] pub struct LocationIndex {} } diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index 38452df32e9..96b3a4e6d18 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -90,6 +90,7 @@ impl RegionValueElements { rustc_index::newtype_index! { /// A single integer representing a `Location` in the MIR control-flow /// graph. Constructed efficiently from `RegionValueElements`. + #[orderable] #[debug_format = "PointIndex({})"] pub struct PointIndex {} } diff --git a/compiler/rustc_data_structures/src/graph/dominators/mod.rs b/compiler/rustc_data_structures/src/graph/dominators/mod.rs index 5dd414cfd41..4b819e1cbd6 100644 --- a/compiler/rustc_data_structures/src/graph/dominators/mod.rs +++ b/compiler/rustc_data_structures/src/graph/dominators/mod.rs @@ -23,6 +23,7 @@ struct PreOrderFrame { } rustc_index::newtype_index! { + #[orderable] struct PreorderIndex {} } diff --git a/compiler/rustc_hir/src/hir_id.rs b/compiler/rustc_hir/src/hir_id.rs index c40a317947c..d339075c171 100644 --- a/compiler/rustc_hir/src/hir_id.rs +++ b/compiler/rustc_hir/src/hir_id.rs @@ -155,6 +155,7 @@ rustc_index::newtype_index! { /// tree or hash map. #[derive(HashStable_Generic)] #[encodable] + #[orderable] pub struct ItemLocalId {} } diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs index cbce8c4b8b8..3f8c0db8752 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs @@ -198,6 +198,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> { // entire graph when there are many connected regions. rustc_index::newtype_index! { + #[orderable] pub struct RegionId {} } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs index 7aadb95d939..566d407d23c 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs @@ -4,11 +4,13 @@ use rustc_middle::ty::error::TypeError; use std::cmp; rustc_index::newtype_index! { + #[orderable] #[debug_format = "ExpectedIdx({})"] pub(crate) struct ExpectedIdx {} } rustc_index::newtype_index! { + #[orderable] #[debug_format = "ProvidedIdx({})"] pub(crate) struct ProvidedIdx {} } diff --git a/compiler/rustc_index/src/vec/tests.rs b/compiler/rustc_index/src/vec/tests.rs index 1959f4e07b7..381d79c24fc 100644 --- a/compiler/rustc_index/src/vec/tests.rs +++ b/compiler/rustc_index/src/vec/tests.rs @@ -2,6 +2,7 @@ use crate as rustc_index; crate::newtype_index! { + #[orderable] #[max = 0xFFFF_FFFA] struct MyIdx {} } diff --git a/compiler/rustc_index_macros/src/newtype.rs b/compiler/rustc_index_macros/src/newtype.rs index 62de5c7c6c1..df1318c835e 100644 --- a/compiler/rustc_index_macros/src/newtype.rs +++ b/compiler/rustc_index_macros/src/newtype.rs @@ -23,7 +23,7 @@ impl Parse for Newtype { let mut max = None; let mut consts = Vec::new(); let mut encodable = false; - let mut ord = true; + let mut ord = false; let mut gate_rustc_only = quote! {}; let mut gate_rustc_only_cfg = quote! { all() }; @@ -38,8 +38,8 @@ impl Parse for Newtype { encodable = true; false } - "no_ord_impl" => { - ord = false; + "orderable" => { + ord = true; false } "max" => { diff --git a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs index 479343c3ec2..e06596df7b9 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs @@ -341,11 +341,13 @@ impl<'tcx> SccUniverse<'tcx> { } rustc_index::newtype_index! { + #[orderable] #[debug_format = "LeakCheckNode({})"] struct LeakCheckNode {} } rustc_index::newtype_index! { + #[orderable] #[debug_format = "LeakCheckScc({})"] struct LeakCheckScc {} } diff --git a/compiler/rustc_middle/src/middle/region.rs b/compiler/rustc_middle/src/middle/region.rs index a0765770a8f..b8f04ed03dc 100644 --- a/compiler/rustc_middle/src/middle/region.rs +++ b/compiler/rustc_middle/src/middle/region.rs @@ -149,6 +149,7 @@ rustc_index::newtype_index! { /// and thus does not include EXPR_2, but covers the `...`. #[derive(HashStable)] #[encodable] + #[orderable] pub struct FirstStatementIndex {} } diff --git a/compiler/rustc_middle/src/mir/coverage.rs b/compiler/rustc_middle/src/mir/coverage.rs index ccd2cd76ad8..f15ee0082ce 100644 --- a/compiler/rustc_middle/src/mir/coverage.rs +++ b/compiler/rustc_middle/src/mir/coverage.rs @@ -18,6 +18,7 @@ rustc_index::newtype_index! { /// to use a larger representation on the Rust side. #[derive(HashStable)] #[encodable] + #[orderable] #[max = 0xFFFF_FFFF] #[debug_format = "CounterId({})"] pub struct CounterId {} @@ -39,6 +40,7 @@ rustc_index::newtype_index! { /// to use a larger representation on the Rust side. #[derive(HashStable)] #[encodable] + #[orderable] #[max = 0xFFFF_FFFF] #[debug_format = "ExpressionId({})"] pub struct ExpressionId {} diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 4e6f5c3fb4e..1e5a7401c6f 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -737,6 +737,7 @@ impl SourceInfo { rustc_index::newtype_index! { #[derive(HashStable)] #[encodable] + #[orderable] #[debug_format = "_{}"] pub struct Local { const RETURN_PLACE = 0; @@ -1173,6 +1174,7 @@ rustc_index::newtype_index! { /// [guide-mir]: https://rustc-dev-guide.rust-lang.org/mir/ #[derive(HashStable)] #[encodable] + #[orderable] #[debug_format = "bb{}"] pub struct BasicBlock { const START_BLOCK = 0; @@ -1537,6 +1539,7 @@ impl UserTypeProjection { rustc_index::newtype_index! { #[derive(HashStable)] #[encodable] + #[orderable] #[debug_format = "promoted[{}]"] pub struct Promoted {} } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index f3915f6b410..f12a512da31 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1613,6 +1613,7 @@ rustc_index::newtype_index! { /// A **region** (lifetime) **v**ariable **ID**. #[derive(HashStable)] #[encodable] + #[orderable] #[debug_format = "'?{}"] pub struct RegionVid {} } diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index d6ca873e992..993fee95895 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -186,6 +186,7 @@ pub(crate) enum BreakableTarget { } rustc_index::newtype_index! { + #[orderable] struct DropIdx {} } diff --git a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs index 7ab1a9ed069..22cf3999239 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs @@ -14,6 +14,7 @@ use self::abs_domain::{AbstractElem, Lift}; mod abs_domain; rustc_index::newtype_index! { + #[orderable] #[debug_format = "mp{}"] pub struct MovePathIndex {} } @@ -25,6 +26,7 @@ impl polonius_engine::Atom for MovePathIndex { } rustc_index::newtype_index! { + #[orderable] #[debug_format = "mo{}"] pub struct MoveOutIndex {} } diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 7defc9ec148..0d807db404c 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -264,6 +264,7 @@ impl graph::WithPredecessors for CoverageGraph { rustc_index::newtype_index! { /// A node in the control-flow graph of CoverageGraph. + #[orderable] #[debug_format = "bcb{}"] pub(super) struct BasicCoverageBlock { const START_BCB = 0; diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 595456e6d6a..4b5bd75d5b1 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -13,6 +13,7 @@ pub type StableCrateIdMap = indexmap::IndexMap>; rustc_index::newtype_index! { + #[orderable] #[debug_format = "crate{}"] pub struct CrateNum {} } @@ -212,6 +213,7 @@ rustc_index::newtype_index! { /// A DefIndex is an index into the hir-map for a crate, identifying a /// particular definition. It should really be considered an interned /// shorthand for a particular DefPath. + #[orderable] #[debug_format = "DefIndex({})"] pub struct DefIndex { /// The crate root is always assigned index 0 by the AST Map code, diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 8c6600c4e53..b717229b68d 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -60,6 +60,7 @@ pub struct SyntaxContextData { rustc_index::newtype_index! { /// A unique ID associated with a macro invocation and expansion. + #[orderable] pub struct ExpnIndex {} } @@ -79,7 +80,6 @@ impl fmt::Debug for ExpnId { rustc_index::newtype_index! { /// A unique ID associated with a macro invocation and expansion. - #[no_ord_impl] #[debug_format = "expn{}"] pub struct LocalExpnId {} } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 2e3b5446405..ea80bc82bd1 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -2018,6 +2018,7 @@ impl fmt::Display for MacroRulesNormalizedIdent { pub struct Symbol(SymbolIndex); rustc_index::newtype_index! { + #[orderable] struct SymbolIndex {} } diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index c1fbc2980a9..a274790bffc 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -43,6 +43,7 @@ rustc_index::newtype_index! { /// `f` is `FieldIdx(1)` in `VariantIdx(0)`. #[derive(HashStable_Generic)] #[encodable] + #[orderable] pub struct FieldIdx {} } @@ -59,6 +60,7 @@ rustc_index::newtype_index! { /// with variant index zero, aka [`FIRST_VARIANT`]. #[derive(HashStable_Generic)] #[encodable] + #[orderable] pub struct VariantIdx { /// Equivalent to `VariantIdx(0)`. const FIRST_VARIANT = 0; diff --git a/compiler/rustc_trait_selection/src/solve/search_graph.rs b/compiler/rustc_trait_selection/src/solve/search_graph.rs index 68f81a05536..71adebffc15 100644 --- a/compiler/rustc_trait_selection/src/solve/search_graph.rs +++ b/compiler/rustc_trait_selection/src/solve/search_graph.rs @@ -13,6 +13,7 @@ use rustc_session::Limit; use std::collections::hash_map::Entry; rustc_index::newtype_index! { + #[orderable] pub struct StackDepth {} } diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index 765cbceb7d1..409033a2d8d 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -96,6 +96,7 @@ impl DebugWithInfcx for ConstKind { rustc_index::newtype_index! { /// A **`const`** **v**ariable **ID**. #[encodable] + #[orderable] #[debug_format = "?{}c"] #[gate_rustc_only] pub struct ConstVid {} @@ -110,6 +111,7 @@ rustc_index::newtype_index! { /// where we are not correctly using the effect var for an effect param. Fallback /// is also implemented on top of having separate effect and normal const variables. #[encodable] + #[orderable] #[debug_format = "?{}e"] #[gate_rustc_only] pub struct EffectVid {} diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index ba7774863ef..2aeb4230bb8 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -93,6 +93,7 @@ rustc_index::newtype_index! { /// [dbi]: https://en.wikipedia.org/wiki/De_Bruijn_index #[cfg_attr(feature = "nightly", derive(HashStable_NoContext))] #[encodable] + #[orderable] #[debug_format = "DebruijnIndex({})"] #[gate_rustc_only] pub struct DebruijnIndex { @@ -295,6 +296,7 @@ rustc_index::newtype_index! { /// use for checking generic functions. #[cfg_attr(feature = "nightly", derive(HashStable_NoContext))] #[encodable] + #[orderable] #[debug_format = "U{}"] #[gate_rustc_only] pub struct UniverseIndex {} @@ -338,6 +340,7 @@ impl UniverseIndex { rustc_index::newtype_index! { #[cfg_attr(feature = "nightly", derive(HashStable_NoContext))] #[encodable] + #[orderable] #[debug_format = "{}"] #[gate_rustc_only] pub struct BoundVar {} diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index a3e94d5c137..3d4e7f77a4f 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -623,6 +623,7 @@ pub struct FloatVarValue(pub FloatTy); rustc_index::newtype_index! { /// A **ty**pe **v**ariable **ID**. #[encodable] + #[orderable] #[debug_format = "?{}t"] #[gate_rustc_only] pub struct TyVid {} @@ -631,6 +632,7 @@ rustc_index::newtype_index! { rustc_index::newtype_index! { /// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**. #[encodable] + #[orderable] #[debug_format = "?{}i"] #[gate_rustc_only] pub struct IntVid {} @@ -639,6 +641,7 @@ rustc_index::newtype_index! { rustc_index::newtype_index! { /// A **float**ing-point (`f32` or `f64`) type **v**ariable **ID**. #[encodable] + #[orderable] #[debug_format = "?{}f"] #[gate_rustc_only] pub struct FloatVid {}