]> git.lizzy.rs Git - rust.git/commitdiff
change region display to `'_#Nr`, update the `newtype_index!` macro
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 30 Oct 2017 13:01:12 +0000 (09:01 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 31 Oct 2017 16:41:40 +0000 (12:41 -0400)
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`.

12 files changed:
src/librustc/middle/region.rs
src/librustc/mir/mod.rs
src/librustc_data_structures/indexed_vec.rs
src/librustc_mir/lib.rs
src/librustc_mir/transform/nll/mod.rs
src/test/mir-opt/end_region_destruction_extents_1.rs
src/test/mir-opt/nll/reborrow-basic.rs
src/test/mir-opt/nll/region-liveness-basic.rs
src/test/mir-opt/nll/region-liveness-drop-may-dangle.rs
src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs
src/test/mir-opt/nll/region-liveness-two-disjoint-uses.rs
src/test/mir-opt/nll/region-subtyping-basic.rs

index fa4ee7c00929152db196d7ec8b431e42cbf5d27d..e725592ff99e6877ee3ac2662c6aaf10e77bfb2c 100644 (file)
@@ -158,7 +158,7 @@ pub struct BlockRemainder {
 
 newtype_index!(FirstStatementIndex
     {
-        DEBUG_NAME = "",
+        DEBUG_FORMAT = "{}",
         MAX = SCOPE_DATA_REMAINDER_MAX,
     });
 
index 307637b2f1d6469108ffc25e3f076460542d828f..c4a33bb07cdf21d4fd067dfbb17872d04d1f642a 100644 (file)
@@ -417,7 +417,7 @@ pub enum BorrowKind {
 
 newtype_index!(Local
     {
-        DEBUG_NAME = "_",
+        DEBUG_FORMAT = "_{}",
         const RETURN_POINTER = 0,
     });
 
@@ -553,7 +553,7 @@ pub struct UpvarDecl {
 ///////////////////////////////////////////////////////////////////////////
 // BasicBlock
 
-newtype_index!(BasicBlock { DEBUG_NAME = "bb" });
+newtype_index!(BasicBlock { DEBUG_FORMAT = "bb{}" });
 
 ///////////////////////////////////////////////////////////////////////////
 // BasicBlockData and Terminator
@@ -1135,7 +1135,7 @@ pub enum ProjectionElem<'tcx, V, T> {
 /// and the index is a local.
 pub type LvalueElem<'tcx> = ProjectionElem<'tcx, Local, Ty<'tcx>>;
 
-newtype_index!(Field { DEBUG_NAME = "field" });
+newtype_index!(Field { DEBUG_FORMAT = "field[{}]" });
 
 impl<'tcx> Lvalue<'tcx> {
     pub fn field(self, f: Field, ty: Ty<'tcx>) -> Lvalue<'tcx> {
@@ -1202,7 +1202,7 @@ fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
 
 newtype_index!(VisibilityScope
     {
-        DEBUG_NAME = "scope",
+        DEBUG_FORMAT = "scope[{}]",
         const ARGUMENT_VISIBILITY_SCOPE = 0,
     });
 
@@ -1529,7 +1529,7 @@ pub struct Constant<'tcx> {
     pub literal: Literal<'tcx>,
 }
 
-newtype_index!(Promoted { DEBUG_NAME = "promoted" });
+newtype_index!(Promoted { DEBUG_FORMAT = "promoted[{}]" });
 
 #[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
 pub enum Literal<'tcx> {
index 1d1b367de200eead52088b3b4440ebb678b5b377..0660cd96a4a34ee6be812e7e11637d23ca67f103 100644 (file)
@@ -47,7 +47,7 @@ macro_rules! newtype_index {
         newtype_index!(
             @type[$name]
             @max[::std::u32::MAX]
-            @debug_name[unsafe {::std::intrinsics::type_name::<$name>() }]);
+            @debug_format["{}"]);
     );
 
     // Define any constants
@@ -55,14 +55,14 @@ macro_rules! newtype_index {
         newtype_index!(
             @type[$name]
             @max[::std::u32::MAX]
-            @debug_name[unsafe {::std::intrinsics::type_name::<$name>() }]
+            @debug_format["{}"]
             $($tokens)+);
     );
 
     // ---- private rules ----
 
     // Base case, user-defined constants (if any) have already been defined
-    (@type[$type:ident] @max[$max:expr] @debug_name[$debug_name:expr]) => (
+    (@type[$type:ident] @max[$max:expr] @debug_format[$debug_format:expr]) => (
         #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord,
             RustcEncodable, RustcDecodable)]
         pub struct $type(pub u32);
@@ -79,40 +79,43 @@ fn index(self) -> usize {
 
         impl ::std::fmt::Debug for $type {
             fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
-                write!(fmt, "{}{}", $debug_name, self.0)
+                write!(fmt, $debug_format, self.0)
             }
         }
     );
 
     // Rewrite final without comma to one that includes comma
-    (@type[$type:ident] @max[$max:expr] @debug_name[$debug_name:expr]
+    (@type[$type:ident] @max[$max:expr] @debug_format[$debug_format:expr]
             $name:ident = $constant:expr) => (
-        newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] $name = $constant,);
+        newtype_index!(@type[$type] @max[$max] @debug_format[$debug_format] $name = $constant,);
     );
 
     // Rewrite final const without comma to one that includes comma
-    (@type[$type:ident] @max[$_max:expr] @debug_name[$debug_name:expr]
+    (@type[$type:ident] @max[$_max:expr] @debug_format[$debug_format:expr]
             const $name:ident = $constant:expr) => (
-        newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] const $name = $constant,);
+        newtype_index!(@type[$type]
+                       @max[$max]
+                       @debug_format[$debug_format]
+                       const $name = $constant,);
     );
 
     // Replace existing default for max
-    (@type[$type:ident] @max[$_max:expr] @debug_name[$debug_name:expr]
+    (@type[$type:ident] @max[$_max:expr] @debug_format[$debug_format:expr]
             MAX = $max:expr, $($tokens:tt)*) => (
-        newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] $($tokens)*);
+        newtype_index!(@type[$type] @max[$max] @debug_format[$debug_format] $($tokens)*);
     );
 
-    // Replace existing default for debug_name
-    (@type[$type:ident] @max[$max:expr] @debug_name[$_debug_name:expr]
-            DEBUG_NAME = $debug_name:expr, $($tokens:tt)*) => (
-        newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] $($tokens)*);
+    // Replace existing default for debug_format
+    (@type[$type:ident] @max[$max:expr] @debug_format[$_debug_format:expr]
+            DEBUG_FORMAT = $debug_format:expr, $($tokens:tt)*) => (
+        newtype_index!(@type[$type] @max[$max] @debug_format[$debug_format] $($tokens)*);
     );
 
     // Assign a user-defined constant (as final param)
-    (@type[$type:ident] @max[$max:expr] @debug_name[$debug_name:expr]
+    (@type[$type:ident] @max[$max:expr] @debug_format[$debug_format:expr]
             const $name:ident = $constant:expr, $($tokens:tt)*) => (
         pub const $name: $type = $type($constant);
-        newtype_index!(@type[$type] @max[$max] @debug_name[$debug_name] $($tokens)*);
+        newtype_index!(@type[$type] @max[$max] @debug_format[$debug_format] $($tokens)*);
     );
 }
 
index 16753cee7e0e24c8c7b7737b84420b94013f22b5..66de35bd7f53a6904fce2f2bc653bce178cb9e5a 100644 (file)
@@ -20,7 +20,6 @@
 #![feature(box_syntax)]
 #![feature(conservative_impl_trait)]
 #![feature(const_fn)]
-#![feature(core_intrinsics)]
 #![feature(i128_type)]
 #![feature(rustc_diagnostic_macros)]
 #![feature(placement_in_syntax)]
index 7df217c62e35a97fc2d74d7b50c3afe38d592287..66a9da2c72aa614887e76b41ea07ad1c80689078 100644 (file)
@@ -192,7 +192,7 @@ pub fn may_contain(&self, point: Location) -> bool {
 }
 
 newtype_index!(RegionIndex {
-    DEBUG_NAME = "R",
+    DEBUG_FORMAT = "'_#{}r",
 });
 
 /// Right now, we piggy back on the `ReVar` to store our NLL inference
index 1f9ad988acc0b90dd0687221bff1ea72a6334307..61dc1d206596178964190166a64b53fb4445401a 100644 (file)
@@ -133,11 +133,11 @@ fn drop(&mut self) {
 //         StorageLive(_3);
 //         StorageLive(_4);
 //         StorageLive(_5);
-//         _5 = promoted1;
+//         _5 = promoted[1];
 //         _4 = &'12ds (*_5);
 //         StorageLive(_7);
 //         StorageLive(_8);
-//         _8 = promoted0;
+//         _8 = promoted[0];
 //         _7 = &'10s (*_8);
 //         _3 = D1<'12ds, '10s>::{{constructor}}(_4, _7);
 //         EndRegion('10s);
index 1983478a4e1a3fef55f89164507824135c6457cd..60a4da430b96e5fce16d96359ea8ea40ce8c4077 100644 (file)
@@ -28,9 +28,9 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.node13.nll.0.mir
-// | R5: {bb0[6], bb0[7], bb0[8], bb0[9], bb0[10], bb0[11], bb0[12], bb0[13], bb0[14]}
+// | '_#5r: {bb0[6], bb0[7], bb0[8], bb0[9], bb0[10], bb0[11], bb0[12], bb0[13], bb0[14]}
 // ...
-// | R7: {bb0[11], bb0[12], bb0[13], bb0[14]}
+// | '_#7r: {bb0[11], bb0[12], bb0[13], bb0[14]}
 // END rustc.node13.nll.0.mir
 // START rustc.node13.nll.0.mir
 // let _2: &'_#5r mut i32;
index fa4eb9627db5e0669aa80c29cd4f51af5c7c5c33..7792f0a36f318df3c1b29091a9b2c4201c2edcfa 100644 (file)
@@ -31,8 +31,8 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.node12.nll.0.mir
-// | R0: {bb1[1], bb2[0], bb2[1]}
-// | R1: {bb1[1], bb2[0], bb2[1]}
+// | '_#0r: {bb1[1], bb2[0], bb2[1]}
+// | '_#1r: {bb1[1], bb2[0], bb2[1]}
 // ...
 //             let _2: &'_#1r usize;
 // END rustc.node12.nll.0.mir
index 7482288e9117fc4b7e67a8a40205a64f38ecc3f2..4f4bb596e5f8fa3ded771b7598a5ff5ed82a0989 100644 (file)
@@ -44,5 +44,5 @@ fn drop(&mut self) { }
 
 // END RUST SOURCE
 // START rustc.node12.nll.0.mir
-// | R4: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1]}
+// | '_#4r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1]}
 // END rustc.node12.nll.0.mir
index 5f4da966281e21ca0d1cd3881baf162ad725092c..20865fdfe9b6cf48ab16067ac0e30af68cec49aa 100644 (file)
@@ -46,5 +46,5 @@ fn drop(&mut self) { }
 
 // END RUST SOURCE
 // START rustc.node12.nll.0.mir
-// | 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]}
+// | '_#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]}
 // END rustc.node12.nll.0.mir
index eb904af39ac06545cb4614707f275d5a4c3f16cd..1387fe52563da224706d414f07113365a5fe5016 100644 (file)
@@ -36,10 +36,10 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.node12.nll.0.mir
-// | R0: {bb1[1], bb2[0], bb2[1]}
+// | '_#0r: {bb1[1], bb2[0], bb2[1]}
 // ...
-// | R2: {bb7[2], bb7[3], bb7[4]}
-// | R3: {bb1[1], bb2[0], bb2[1], bb7[2], bb7[3], bb7[4]}
+// | '_#2r: {bb7[2], bb7[3], bb7[4]}
+// | '_#3r: {bb1[1], bb2[0], bb2[1], bb7[2], bb7[3], bb7[4]}
 // ...
 // let mut _2: &'_#3r usize;
 // ...
index bc97858e03d974db05a07c999685a464b547c061..4ae891f5b70eb91004e4d3ce78249a1c74219535 100644 (file)
@@ -32,9 +32,9 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.node12.nll.0.mir
-// | R0: {bb1[1], bb1[2], bb1[3], bb1[4], bb1[5], bb1[6], bb2[0], bb2[1]}
-// | R1: {bb1[1], bb1[2], bb1[3], bb1[4], bb1[5], bb1[6], bb2[0], bb2[1]}
-// | R2: {bb1[5], bb1[6], bb2[0], bb2[1]}
+// | '_#0r: {bb1[1], bb1[2], bb1[3], bb1[4], bb1[5], bb1[6], bb2[0], bb2[1]}
+// | '_#1r: {bb1[1], bb1[2], bb1[3], bb1[4], bb1[5], bb1[6], bb2[0], bb2[1]}
+// | '_#2r: {bb1[5], bb1[6], bb2[0], bb2[1]}
 // END rustc.node12.nll.0.mir
 // START rustc.node12.nll.0.mir
 // let _2: &'_#1r usize;