@@ -88,7 +88,7 @@ use std::fmt;
88
88
use std:: rc:: Rc ;
89
89
use util:: nodemap:: ItemLocalSet ;
90
90
91
- #[ derive( Clone , PartialEq ) ]
91
+ #[ derive( Clone , Debug , PartialEq ) ]
92
92
pub enum Categorization < ' tcx > {
93
93
Rvalue ( ty:: Region < ' tcx > ) , // temporary val, argument is its scope
94
94
StaticItem ,
@@ -109,7 +109,7 @@ pub struct Upvar {
109
109
}
110
110
111
111
// different kinds of pointers:
112
- #[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
112
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
113
113
pub enum PointerKind < ' tcx > {
114
114
/// `Box<T>`
115
115
Unique ,
@@ -177,7 +177,7 @@ pub enum Note {
177
177
// dereference, but its type is the type *before* the dereference
178
178
// (`@T`). So use `cmt.ty` to find the type of the value in a consistent
179
179
// fashion. For more details, see the method `cat_pattern`
180
- #[ derive( Clone , PartialEq ) ]
180
+ #[ derive( Clone , Debug , PartialEq ) ]
181
181
pub struct cmt_ < ' tcx > {
182
182
pub id : ast:: NodeId , // id of expr/pat producing this value
183
183
pub span : Span , // span of same expr/pat
@@ -750,12 +750,13 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
750
750
751
751
let kind = match self . node_ty ( fn_hir_id) ?. sty {
752
752
ty:: TyGenerator ( ..) => ty:: ClosureKind :: FnOnce ,
753
- _ => {
753
+ ty :: TyClosure ( .. ) => {
754
754
match self . tables . closure_kinds ( ) . get ( fn_hir_id) {
755
755
Some ( & ( kind, _) ) => kind,
756
756
None => span_bug ! ( span, "missing closure kind" ) ,
757
757
}
758
758
}
759
+ ref t => span_bug ! ( span, "unexpected type for fn in mem_categorization: {:?}" , t) ,
759
760
} ;
760
761
761
762
let closure_expr_def_index = self . tcx . hir . local_def_id ( fn_node_id) . index ;
@@ -1499,41 +1500,6 @@ impl<'tcx> cmt_<'tcx> {
1499
1500
}
1500
1501
}
1501
1502
1502
- impl < ' tcx > fmt:: Debug for cmt_ < ' tcx > {
1503
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1504
- write ! ( f, "{{{:?} id:{} m:{:?} ty:{:?}}}" ,
1505
- self . cat,
1506
- self . id,
1507
- self . mutbl,
1508
- self . ty)
1509
- }
1510
- }
1511
-
1512
- impl < ' tcx > fmt:: Debug for Categorization < ' tcx > {
1513
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1514
- match * self {
1515
- Categorization :: StaticItem => write ! ( f, "static" ) ,
1516
- Categorization :: Rvalue ( r) => { write ! ( f, "rvalue({:?})" , r) }
1517
- Categorization :: Local ( id) => {
1518
- let name = ty:: tls:: with ( |tcx| tcx. hir . name ( id) ) ;
1519
- write ! ( f, "local({})" , name)
1520
- }
1521
- Categorization :: Upvar ( upvar) => {
1522
- write ! ( f, "upvar({:?})" , upvar)
1523
- }
1524
- Categorization :: Deref ( ref cmt, ptr) => {
1525
- write ! ( f, "{:?}-{:?}->" , cmt. cat, ptr)
1526
- }
1527
- Categorization :: Interior ( ref cmt, interior) => {
1528
- write ! ( f, "{:?}.{:?}" , cmt. cat, interior)
1529
- }
1530
- Categorization :: Downcast ( ref cmt, _) => {
1531
- write ! ( f, "{:?}->(enum)" , cmt. cat)
1532
- }
1533
- }
1534
- }
1535
- }
1536
-
1537
1503
pub fn ptr_sigil ( ptr : PointerKind ) -> & ' static str {
1538
1504
match ptr {
1539
1505
Unique => "Box" ,
@@ -1547,27 +1513,6 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
1547
1513
}
1548
1514
}
1549
1515
1550
- impl < ' tcx > fmt:: Debug for PointerKind < ' tcx > {
1551
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1552
- match * self {
1553
- Unique => write ! ( f, "Box" ) ,
1554
- BorrowedPtr ( ty:: ImmBorrow , ref r) |
1555
- Implicit ( ty:: ImmBorrow , ref r) => {
1556
- write ! ( f, "&{:?}" , r)
1557
- }
1558
- BorrowedPtr ( ty:: MutBorrow , ref r) |
1559
- Implicit ( ty:: MutBorrow , ref r) => {
1560
- write ! ( f, "&{:?} mut" , r)
1561
- }
1562
- BorrowedPtr ( ty:: UniqueImmBorrow , ref r) |
1563
- Implicit ( ty:: UniqueImmBorrow , ref r) => {
1564
- write ! ( f, "&{:?} uniq" , r)
1565
- }
1566
- UnsafePtr ( _) => write ! ( f, "*" )
1567
- }
1568
- }
1569
- }
1570
-
1571
1516
impl fmt:: Debug for InteriorKind {
1572
1517
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1573
1518
match * self {
0 commit comments