Skip to content

Commit f27eb1e

Browse files
committed
change region display to '_#Nr, update the newtype_index! macro
The macro now takes a format string. It no longer defaults to using the type name. Didn't seem worth going through contortions to maintain. I also changed most of the debug formats to be `foo[N]` instead of `fooN`.
1 parent a94b01a commit f27eb1e

File tree

12 files changed

+40
-38
lines changed

12 files changed

+40
-38
lines changed

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub struct BlockRemainder {
158158

159159
newtype_index!(FirstStatementIndex
160160
{
161-
DEBUG_NAME = "",
161+
DEBUG_FORMAT = "{}",
162162
MAX = SCOPE_DATA_REMAINDER_MAX,
163163
});
164164

src/librustc/mir/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ pub enum BorrowKind {
417417

418418
newtype_index!(Local
419419
{
420-
DEBUG_NAME = "_",
420+
DEBUG_FORMAT = "_{}",
421421
const RETURN_POINTER = 0,
422422
});
423423

@@ -553,7 +553,7 @@ pub struct UpvarDecl {
553553
///////////////////////////////////////////////////////////////////////////
554554
// BasicBlock
555555

556-
newtype_index!(BasicBlock { DEBUG_NAME = "bb" });
556+
newtype_index!(BasicBlock { DEBUG_FORMAT = "bb{}" });
557557

558558
///////////////////////////////////////////////////////////////////////////
559559
// BasicBlockData and Terminator
@@ -1135,7 +1135,7 @@ pub type LvalueProjection<'tcx> = Projection<'tcx, Lvalue<'tcx>, Local, Ty<'tcx>
11351135
/// and the index is a local.
11361136
pub type LvalueElem<'tcx> = ProjectionElem<'tcx, Local, Ty<'tcx>>;
11371137

1138-
newtype_index!(Field { DEBUG_NAME = "field" });
1138+
newtype_index!(Field { DEBUG_FORMAT = "field[{}]" });
11391139

11401140
impl<'tcx> Lvalue<'tcx> {
11411141
pub fn field(self, f: Field, ty: Ty<'tcx>) -> Lvalue<'tcx> {
@@ -1202,7 +1202,7 @@ impl<'tcx> Debug for Lvalue<'tcx> {
12021202

12031203
newtype_index!(VisibilityScope
12041204
{
1205-
DEBUG_NAME = "scope",
1205+
DEBUG_FORMAT = "scope[{}]",
12061206
const ARGUMENT_VISIBILITY_SCOPE = 0,
12071207
});
12081208

@@ -1529,7 +1529,7 @@ pub struct Constant<'tcx> {
15291529
pub literal: Literal<'tcx>,
15301530
}
15311531

1532-
newtype_index!(Promoted { DEBUG_NAME = "promoted" });
1532+
newtype_index!(Promoted { DEBUG_FORMAT = "promoted[{}]" });
15331533

15341534
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
15351535
pub enum Literal<'tcx> {

src/librustc_data_structures/indexed_vec.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ macro_rules! newtype_index {
4747
newtype_index!(
4848
@type[$name]
4949
@max[::std::u32::MAX]
50-
@debug_name[unsafe {::std::intrinsics::type_name::<$name>() }]);
50+
@debug_format["{}"]);
5151
);
5252

5353
// Define any constants
5454
($name:ident { $($tokens:tt)+ }) => (
5555
newtype_index!(
5656
@type[$name]
5757
@max[::std::u32::MAX]
58-
@debug_name[unsafe {::std::intrinsics::type_name::<$name>() }]
58+
@debug_format["{}"]
5959
$($tokens)+);
6060
);
6161

6262
// ---- private rules ----
6363

6464
// Base case, user-defined constants (if any) have already been defined
65-
(@type[$type:ident] @max[$max:expr] @debug_name[$debug_name:expr]) => (
65+
(@type[$type:ident] @max[$max:expr] @debug_format[$debug_format:expr]) => (
6666
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord,
6767
RustcEncodable, RustcDecodable)]
6868
pub struct $type(pub u32);
@@ -79,40 +79,43 @@ macro_rules! newtype_index {
7979

8080
impl ::std::fmt::Debug for $type {
8181
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
82-
write!(fmt, "{}{}", $debug_name, self.0)
82+
write!(fmt, $debug_format, self.0)
8383
}
8484
}
8585
);
8686

8787
// Rewrite final without comma to one that includes comma
88-
(@type[$type:ident] @max[$max:expr] @debug_name[$debug_name:expr]
88+
(@type[$type:ident] @max[$max:expr] @debug_format[$debug_format:expr]
8989
$name:ident = $constant:expr) => (
90-
newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] $name = $constant,);
90+
newtype_index!(@type[$type] @max[$max] @debug_format[$debug_format] $name = $constant,);
9191
);
9292

9393
// Rewrite final const without comma to one that includes comma
94-
(@type[$type:ident] @max[$_max:expr] @debug_name[$debug_name:expr]
94+
(@type[$type:ident] @max[$_max:expr] @debug_format[$debug_format:expr]
9595
const $name:ident = $constant:expr) => (
96-
newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] const $name = $constant,);
96+
newtype_index!(@type[$type]
97+
@max[$max]
98+
@debug_format[$debug_format]
99+
const $name = $constant,);
97100
);
98101

99102
// Replace existing default for max
100-
(@type[$type:ident] @max[$_max:expr] @debug_name[$debug_name:expr]
103+
(@type[$type:ident] @max[$_max:expr] @debug_format[$debug_format:expr]
101104
MAX = $max:expr, $($tokens:tt)*) => (
102-
newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] $($tokens)*);
105+
newtype_index!(@type[$type] @max[$max] @debug_format[$debug_format] $($tokens)*);
103106
);
104107

105-
// Replace existing default for debug_name
106-
(@type[$type:ident] @max[$max:expr] @debug_name[$_debug_name:expr]
107-
DEBUG_NAME = $debug_name:expr, $($tokens:tt)*) => (
108-
newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] $($tokens)*);
108+
// Replace existing default for debug_format
109+
(@type[$type:ident] @max[$max:expr] @debug_format[$_debug_format:expr]
110+
DEBUG_FORMAT = $debug_format:expr, $($tokens:tt)*) => (
111+
newtype_index!(@type[$type] @max[$max] @debug_format[$debug_format] $($tokens)*);
109112
);
110113

111114
// Assign a user-defined constant (as final param)
112-
(@type[$type:ident] @max[$max:expr] @debug_name[$debug_name:expr]
115+
(@type[$type:ident] @max[$max:expr] @debug_format[$debug_format:expr]
113116
const $name:ident = $constant:expr, $($tokens:tt)*) => (
114117
pub const $name: $type = $type($constant);
115-
newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] $($tokens)*);
118+
newtype_index!(@type[$type] @max[$max] @debug_format[$debug_format] $($tokens)*);
116119
);
117120
}
118121

src/librustc_mir/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2020
#![feature(box_syntax)]
2121
#![feature(conservative_impl_trait)]
2222
#![feature(const_fn)]
23-
#![feature(core_intrinsics)]
2423
#![feature(i128_type)]
2524
#![feature(rustc_diagnostic_macros)]
2625
#![feature(placement_in_syntax)]

src/librustc_mir/transform/nll/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl Region {
192192
}
193193

194194
newtype_index!(RegionIndex {
195-
DEBUG_NAME = "R",
195+
DEBUG_FORMAT = "'_#{}r",
196196
});
197197

198198
/// Right now, we piggy back on the `ReVar` to store our NLL inference

src/test/mir-opt/end_region_destruction_extents_1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ unsafe impl<'a, #[may_dangle] 'b> Drop for D1<'a, 'b> {
133133
// StorageLive(_3);
134134
// StorageLive(_4);
135135
// StorageLive(_5);
136-
// _5 = promoted1;
136+
// _5 = promoted[1];
137137
// _4 = &'12ds (*_5);
138138
// StorageLive(_7);
139139
// StorageLive(_8);
140-
// _8 = promoted0;
140+
// _8 = promoted[0];
141141
// _7 = &'10s (*_8);
142142
// _3 = D1<'12ds, '10s>::{{constructor}}(_4, _7);
143143
// EndRegion('10s);

src/test/mir-opt/nll/reborrow-basic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ fn main() {
2828

2929
// END RUST SOURCE
3030
// START rustc.node13.nll.0.mir
31-
// | R5: {bb0[6], bb0[7], bb0[8], bb0[9], bb0[10], bb0[11], bb0[12], bb0[13], bb0[14]}
31+
// | '_#5r: {bb0[6], bb0[7], bb0[8], bb0[9], bb0[10], bb0[11], bb0[12], bb0[13], bb0[14]}
3232
// ...
33-
// | R7: {bb0[11], bb0[12], bb0[13], bb0[14]}
33+
// | '_#7r: {bb0[11], bb0[12], bb0[13], bb0[14]}
3434
// END rustc.node13.nll.0.mir
3535
// START rustc.node13.nll.0.mir
3636
// let _2: &'_#5r mut i32;

src/test/mir-opt/nll/region-liveness-basic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ fn main() {
3131

3232
// END RUST SOURCE
3333
// START rustc.node12.nll.0.mir
34-
// | R0: {bb1[1], bb2[0], bb2[1]}
35-
// | R1: {bb1[1], bb2[0], bb2[1]}
34+
// | '_#0r: {bb1[1], bb2[0], bb2[1]}
35+
// | '_#1r: {bb1[1], bb2[0], bb2[1]}
3636
// ...
3737
// let _2: &'_#1r usize;
3838
// END rustc.node12.nll.0.mir

src/test/mir-opt/nll/region-liveness-drop-may-dangle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ unsafe impl<#[may_dangle] T> Drop for Wrap<T> {
4444

4545
// END RUST SOURCE
4646
// START rustc.node12.nll.0.mir
47-
// | R4: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1]}
47+
// | '_#4r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1]}
4848
// END rustc.node12.nll.0.mir

src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ impl<T> Drop for Wrap<T> {
4646

4747
// END RUST SOURCE
4848
// START rustc.node12.nll.0.mir
49-
// | R4: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1], bb2[2], bb3[0], bb4[0], bb4[1], bb4[2], bb6[0], bb7[0], bb7[1], bb8[0]}
49+
// | '_#4r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1], bb2[2], bb3[0], bb4[0], bb4[1], bb4[2], bb6[0], bb7[0], bb7[1], bb8[0]}
5050
// END rustc.node12.nll.0.mir

0 commit comments

Comments
 (0)