Skip to content

Commit 5f42a0f

Browse files
committed
Change debug printing to print in the old concise style
1 parent 68298a5 commit 5f42a0f

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

src/librustc/middle/region.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use util::nodemap::{FxHashMap, FxHashSet};
2121
use ty;
2222

2323
use std::mem;
24+
use std::fmt;
2425
use rustc_data_structures::sync::Lrc;
2526
use syntax::source_map;
2627
use syntax::ast;
@@ -50,7 +51,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
5051
/// `DestructionScope`, but those that are `terminating_scopes` do;
5152
/// see discussion with `ScopeTree`.
5253
///
53-
/// `Remainder(BlockRemainder { block, statement_index })` represents
54+
/// `Remainder { block, statement_index }` represents
5455
/// the scope of user code running immediately after the initializer
5556
/// expression for the indexed statement, until the end of the block.
5657
///
@@ -99,12 +100,29 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
99100
/// placate the same deriving in `ty::FreeRegion`, but we may want to
100101
/// actually attach a more meaningful ordering to scopes than the one
101102
/// generated via deriving here.
102-
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug, Copy, RustcEncodable, RustcDecodable)]
103+
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Copy, RustcEncodable, RustcDecodable)]
103104
pub struct Scope {
104105
pub(crate) id: hir::ItemLocalId,
105106
pub(crate) data: ScopeData,
106107
}
107108

109+
impl fmt::Debug for Scope {
110+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
111+
match self.data {
112+
ScopeData::Node => write!(fmt, "Node({:?})", self.id),
113+
ScopeData::CallSite => write!(fmt, "CallSite({:?})", self.id),
114+
ScopeData::Arguments => write!(fmt, "Arguments({:?})", self.id),
115+
ScopeData::Destruction => write!(fmt, "Destruction({:?})", self.id),
116+
ScopeData::Remainder(fsi) => write!(
117+
fmt,
118+
"Remainder {{ block: {:?}, first_statement_index: {}}}",
119+
self.id,
120+
fsi.as_u32(),
121+
),
122+
}
123+
}
124+
}
125+
108126
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug, Copy, RustcEncodable, RustcDecodable)]
109127
pub enum ScopeData {
110128
Node,
@@ -159,7 +177,7 @@ impl Scope {
159177
#[inline]
160178
pub fn data(self) -> ScopeData {
161179
self.data
162-
}
180+
}
163181

164182
#[inline]
165183
pub fn new(id: hir::ItemLocalId, data: ScopeData) -> Self {

src/test/mir-opt/validate_1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ fn main() {
6464
// bb0: {
6565
// Validate(Acquire, [_1: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]);
6666
// StorageLive(_3);
67-
// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(25), first_statement_index: 0 }))), [(*_2): i32]);
67+
// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 })), [(*_2): i32]);
6868
// _3 = &ReErased (*_2);
69-
// Validate(Acquire, [(*_3): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(25), first_statement_index: 0 })) (imm)]);
69+
// Validate(Acquire, [(*_3): i32/ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 }) (imm)]);
7070
// _0 = (*_3);
71-
// EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(25), first_statement_index: 0 })));
71+
// EndRegion(ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 }));
7272
// StorageDead(_3);
7373
// return;
7474
// }

src/test/mir-opt/validate_3.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ fn main() {
4848
// StorageLive(_1);
4949
// _1 = Test { x: const 0i32 };
5050
// StorageLive(_2);
51-
// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(20), first_statement_index: 3 }))), [_1: Test]);
51+
// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 })), [_1: Test]);
5252
// _2 = &ReErased _1;
53-
// Validate(Acquire, [(*_2): Test/ReScope(Remainder(BlockRemainder { block: ItemLocalId(20), first_statement_index: 3 })) (imm)]);
53+
// Validate(Acquire, [(*_2): Test/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]);
5454
// StorageLive(_4);
5555
// StorageLive(_5);
56-
// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [((*_2).0: i32): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(20), first_statement_index: 3 })) (imm)]);
56+
// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [((*_2).0: i32): i32/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]);
5757
// _5 = &ReErased ((*_2).0: i32);
5858
// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(18))) (imm)]);
5959
// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [(*_5): i32/ReScope(Node(ItemLocalId(18))) (imm)]);
@@ -68,7 +68,7 @@ fn main() {
6868
// StorageDead(_4);
6969
// StorageDead(_5);
7070
// _0 = ();
71-
// EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(20), first_statement_index: 3 })));
71+
// EndRegion(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }));
7272
// StorageDead(_2);
7373
// StorageDead(_1);
7474
// return;

0 commit comments

Comments
 (0)