Skip to content

Commit d679764

Browse files
committed
Make #[debug_format] an attribute in newtype_index
This removes the `custom` format functionality as its only user was trivially migrated to using a normal format. If a new use case for a custom formatting impl pops up, you can add it back.
1 parent 91c3c20 commit d679764

File tree

24 files changed

+64
-92
lines changed

24 files changed

+64
-92
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2555,8 +2555,8 @@ pub enum AttrStyle {
25552555

25562556
rustc_index::newtype_index! {
25572557
#[custom_encodable]
2558+
#[debug_format = "AttrId({})]"]
25582559
pub struct AttrId {
2559-
DEBUG_FORMAT = "AttrId({})"
25602560
}
25612561
}
25622562

compiler/rustc_ast/src/node_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ rustc_index::newtype_index! {
88
/// This is later turned into [`DefId`] and `HirId` for the HIR.
99
///
1010
/// [`DefId`]: rustc_span::def_id::DefId
11+
#[debug_format = "NodeId({})"]
1112
pub struct NodeId {
12-
DEBUG_FORMAT = "NodeId({})"
1313
}
1414
}
1515

compiler/rustc_borrowck/src/constraints/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ impl<'tcx> fmt::Debug for OutlivesConstraint<'tcx> {
115115
}
116116

117117
rustc_index::newtype_index! {
118+
#[debug_format = "OutlivesConstraintIndex({})"]
118119
pub struct OutlivesConstraintIndex {
119-
DEBUG_FORMAT = "OutlivesConstraintIndex({})"
120120
}
121121
}
122122

123123
rustc_index::newtype_index! {
124+
#[debug_format = "ConstraintSccIndex({})"]
124125
pub struct ConstraintSccIndex {
125-
DEBUG_FORMAT = "ConstraintSccIndex({})"
126126
}
127127
}

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ impl_visitable! {
108108
}
109109

110110
rustc_index::newtype_index! {
111+
#[debug_format = "bw{}"]
111112
pub struct BorrowIndex {
112-
DEBUG_FORMAT = "bw{}"
113113
}
114114
}
115115

compiler/rustc_borrowck/src/location.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub struct LocationTable {
2020
}
2121

2222
rustc_index::newtype_index! {
23+
#[debug_format = "LocationIndex({})"]
2324
pub struct LocationIndex {
24-
DEBUG_FORMAT = "LocationIndex({})"
2525
}
2626
}
2727

compiler/rustc_borrowck/src/member_constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub(crate) struct NllMemberConstraint<'tcx> {
5555
}
5656

5757
rustc_index::newtype_index! {
58+
#[debug_format = "MemberConstraintIndex({})"]
5859
pub(crate) struct NllMemberConstraintIndex {
59-
DEBUG_FORMAT = "MemberConstraintIndex({})"
6060
}
6161
}
6262

compiler/rustc_borrowck/src/region_infer/values.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ 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-
pub struct PointIndex { DEBUG_FORMAT = "PointIndex({})" }
93+
#[debug_format = "PointIndex({})"]
94+
pub struct PointIndex {}
9495
}
9596

9697
rustc_index::newtype_index! {
9798
/// A single integer representing a `ty::Placeholder`.
98-
pub struct PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" }
99+
#[debug_format = "PlaceholderIndex({})"]
100+
pub struct PlaceholderIndex {}
99101
}
100102

101103
/// An individual element in a region value -- the value of a

compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use rustc_index::vec::IndexVec;
44
use rustc_middle::ty::error::TypeError;
55

66
rustc_index::newtype_index! {
7+
#[debug_format = "ExpectedIdx({})"]
78
pub(crate) struct ExpectedIdx {
8-
DEBUG_FORMAT = "ExpectedIdx({})",
99
}
1010
}
1111

1212
rustc_index::newtype_index! {
13+
#[debug_format = "ProvidedIdx({})"]
1314
pub(crate) struct ProvidedIdx {
14-
DEBUG_FORMAT = "ProvidedIdx({})",
1515
}
1616
}
1717

compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ fn for_each_consumable<'tcx>(hir: Map<'tcx>, place: TrackedValue, mut f: impl Fn
9696
}
9797

9898
rustc_index::newtype_index! {
99+
#[debug_format = "id({})"]
99100
pub struct PostOrderId {
100-
DEBUG_FORMAT = "id({})",
101101
}
102102
}
103103

104104
rustc_index::newtype_index! {
105+
#[debug_format = "hidx({})"]
105106
pub struct TrackedValueIndex {
106-
DEBUG_FORMAT = "hidx({})",
107107
}
108108
}
109109

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,14 @@ impl<'tcx> SccUniverse<'tcx> {
357357
}
358358

359359
rustc_index::newtype_index! {
360+
#[debug_format = "LeakCheckNode({})"]
360361
struct LeakCheckNode {
361-
DEBUG_FORMAT = "LeakCheckNode({})"
362362
}
363363
}
364364

365365
rustc_index::newtype_index! {
366+
#[debug_format = "LeakCheckScc({})"]
366367
struct LeakCheckScc {
367-
DEBUG_FORMAT = "LeakCheckScc({})"
368368
}
369369
}
370370

0 commit comments

Comments
 (0)