@@ -29,7 +29,6 @@ use serialize::Encodable;
29
29
use std:: cell:: RefCell ;
30
30
use std:: hash:: Hash ;
31
31
use std:: hash;
32
- use std:: mem;
33
32
use std:: collections:: HashMap ;
34
33
use syntax:: abi;
35
34
use syntax:: ast:: * ;
@@ -1508,44 +1507,36 @@ fn my_visit_expr(_e: &Expr) { }
1508
1507
1509
1508
fn my_visit_item ( i : & Item ,
1510
1509
rbml_w : & mut Encoder ,
1511
- ecx_ptr : * const int ,
1510
+ ecx : & EncodeContext ,
1512
1511
index : & mut Vec < entry < i64 > > ) {
1513
- let mut rbml_w = unsafe { rbml_w. unsafe_clone ( ) } ;
1514
- // See above
1515
- let ecx: & EncodeContext = unsafe { mem:: transmute ( ecx_ptr) } ;
1516
1512
ecx. tcx . map . with_path ( i. id , |path| {
1517
- encode_info_for_item ( ecx, & mut rbml_w, i, index, path, i. vis ) ;
1513
+ encode_info_for_item ( ecx, rbml_w, i, index, path, i. vis ) ;
1518
1514
} ) ;
1519
1515
}
1520
1516
1521
1517
fn my_visit_foreign_item ( ni : & ForeignItem ,
1522
1518
rbml_w : & mut Encoder ,
1523
- ecx_ptr : * const int ,
1519
+ ecx : & EncodeContext ,
1524
1520
index : & mut Vec < entry < i64 > > ) {
1525
- // See above
1526
- let ecx: & EncodeContext = unsafe { mem:: transmute ( ecx_ptr) } ;
1527
1521
debug ! ( "writing foreign item {}::{}" ,
1528
1522
ecx. tcx. map. path_to_string( ni. id) ,
1529
1523
token:: get_ident( ni. ident) ) ;
1530
1524
1531
- let mut rbml_w = unsafe {
1532
- rbml_w. unsafe_clone ( )
1533
- } ;
1534
1525
let abi = ecx. tcx . map . get_foreign_abi ( ni. id ) ;
1535
1526
ecx. tcx . map . with_path ( ni. id , |path| {
1536
- encode_info_for_foreign_item ( ecx, & mut rbml_w,
1527
+ encode_info_for_foreign_item ( ecx, rbml_w,
1537
1528
ni, index,
1538
1529
path, abi) ;
1539
1530
} ) ;
1540
1531
}
1541
1532
1542
- struct EncodeVisitor < ' a , ' b : ' a > {
1533
+ struct EncodeVisitor < ' a , ' b : ' a , ' c : ' a , ' tcx : ' c > {
1543
1534
rbml_w_for_visit_item : & ' a mut Encoder < ' b > ,
1544
- ecx_ptr : * const int ,
1535
+ ecx : & ' a EncodeContext < ' c , ' tcx > ,
1545
1536
index : & ' a mut Vec < entry < i64 > > ,
1546
1537
}
1547
1538
1548
- impl < ' a , ' b , ' v > Visitor < ' v > for EncodeVisitor < ' a , ' b > {
1539
+ impl < ' a , ' b , ' c , ' tcx , ' v > Visitor < ' v > for EncodeVisitor < ' a , ' b , ' c , ' tcx > {
1549
1540
fn visit_expr ( & mut self , ex : & Expr ) {
1550
1541
visit:: walk_expr ( self , ex) ;
1551
1542
my_visit_expr ( ex) ;
@@ -1554,14 +1545,14 @@ impl<'a, 'b, 'v> Visitor<'v> for EncodeVisitor<'a, 'b> {
1554
1545
visit:: walk_item ( self , i) ;
1555
1546
my_visit_item ( i,
1556
1547
self . rbml_w_for_visit_item ,
1557
- self . ecx_ptr ,
1548
+ self . ecx ,
1558
1549
self . index ) ;
1559
1550
}
1560
1551
fn visit_foreign_item ( & mut self , ni : & ForeignItem ) {
1561
1552
visit:: walk_foreign_item ( self , ni) ;
1562
1553
my_visit_foreign_item ( ni,
1563
1554
self . rbml_w_for_visit_item ,
1564
- self . ecx_ptr ,
1555
+ self . ecx ,
1565
1556
self . index ) ;
1566
1557
}
1567
1558
}
@@ -1585,11 +1576,9 @@ fn encode_info_for_items(ecx: &EncodeContext,
1585
1576
syntax:: parse:: token:: special_idents:: invalid,
1586
1577
Public ) ;
1587
1578
1588
- // See comment in `encode_side_tables_for_ii` in astencode
1589
- let ecx_ptr: * const int = unsafe { mem:: transmute ( ecx) } ;
1590
1579
visit:: walk_crate ( & mut EncodeVisitor {
1591
1580
index : & mut index,
1592
- ecx_ptr : ecx_ptr ,
1581
+ ecx : ecx ,
1593
1582
rbml_w_for_visit_item : & mut * rbml_w,
1594
1583
} , krate) ;
1595
1584
0 commit comments