@@ -1499,30 +1499,18 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1499
1499
fn first_non_private_clean_path < ' tcx > (
1500
1500
cx : & mut DocContext < ' tcx > ,
1501
1501
path : & hir:: Path < ' tcx > ,
1502
- mut new_path_segments : Vec < hir:: PathSegment < ' tcx > > ,
1502
+ new_path_segments : & ' tcx mut [ hir:: PathSegment < ' tcx > ] ,
1503
1503
new_path_span : rustc_span:: Span ,
1504
1504
) -> Path {
1505
- use std:: mem:: transmute;
1506
-
1507
1505
// In here we need to play with the path data one last time to provide it the
1508
1506
// missing `args` and `res` of the final `Path` we get, which, since it comes
1509
1507
// from a re-export, doesn't have the generics that were originally there, so
1510
1508
// we add them by hand.
1511
1509
if let Some ( last) = new_path_segments. last_mut ( ) {
1512
- // `transmute` is needed because we are using a wrong lifetime. Since
1513
- // `segments` will be dropped at the end of this block, it's fine.
1514
- last. args = unsafe { transmute ( path. segments . last ( ) . as_ref ( ) . unwrap ( ) . args . clone ( ) ) } ;
1510
+ last. args = path. segments . last ( ) . as_ref ( ) . unwrap ( ) . args . clone ( ) ;
1515
1511
last. res = path. res ;
1516
1512
}
1517
- // `transmute` is needed because we are using a wrong lifetime. Since
1518
- // `segments` will be dropped at the end of this block, it's fine.
1519
- let path = unsafe {
1520
- hir:: Path {
1521
- segments : transmute ( new_path_segments. as_slice ( ) ) ,
1522
- res : path. res ,
1523
- span : new_path_span,
1524
- }
1525
- } ;
1513
+ let path = hir:: Path { segments : new_path_segments, res : path. res , span : new_path_span } ;
1526
1514
clean_path ( & path, cx)
1527
1515
}
1528
1516
@@ -1541,8 +1529,9 @@ fn first_non_private<'tcx>(
1541
1529
. updated_qpath
1542
1530
. borrow ( )
1543
1531
. get ( & use_id)
1544
- . map ( |saved_path| ( saved_path. segments . to_vec ( ) , saved_path. span ) ) ;
1532
+ . map ( |saved_path| ( saved_path. segments , saved_path. span ) ) ;
1545
1533
if let Some ( ( segments, span) ) = saved_path {
1534
+ let segments = cx. tcx . arena . alloc_slice ( segments) ;
1546
1535
return Some ( first_non_private_clean_path ( cx, path, segments, span) ) ;
1547
1536
}
1548
1537
let ( parent_def_id, ident) = match & path. segments [ ..] {
@@ -1611,8 +1600,8 @@ fn first_non_private<'tcx>(
1611
1600
// 2. We didn't find a public reexport so it's the "end type" path.
1612
1601
if let Some ( ( new_path, _) ) = last_path_res {
1613
1602
cx. updated_qpath . borrow_mut ( ) . insert ( use_id, new_path. clone ( ) ) ;
1614
- let new_path_segments = new_path . segments . to_vec ( ) ;
1615
- return Some ( first_non_private_clean_path ( cx, path, new_path_segments , new_path. span ) ) ;
1603
+ let segments = cx . tcx . arena . alloc_slice ( new_path . segments ) ;
1604
+ return Some ( first_non_private_clean_path ( cx, path, segments , new_path. span ) ) ;
1616
1605
}
1617
1606
// If `last_path_res` is `None`, it can mean two things:
1618
1607
//
0 commit comments