@@ -1499,31 +1499,25 @@ 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 [ hir:: PathSegment < ' tcx > ] ,
1503
1503
new_path_span : rustc_span:: Span ,
1504
1504
) -> Path {
1505
- use std:: mem:: transmute;
1506
-
1505
+ let new_hir_path =
1506
+ hir:: Path { segments : new_path_segments, res : path. res , span : new_path_span } ;
1507
+ let mut new_clean_path = clean_path ( & new_hir_path, cx) ;
1507
1508
// In here we need to play with the path data one last time to provide it the
1508
1509
// missing `args` and `res` of the final `Path` we get, which, since it comes
1509
1510
// from a re-export, doesn't have the generics that were originally there, so
1510
1511
// we add them by hand.
1511
- 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 ( ) ) } ;
1515
- last. res = path. res ;
1512
+ if let Some ( path_last) = path. segments . last ( ) . as_ref ( )
1513
+ && let Some ( new_path_last) = new_clean_path. segments [ ..] . last_mut ( )
1514
+ && let Some ( path_last_args) = path_last. args . as_ref ( )
1515
+ && path_last. args . is_some ( )
1516
+ {
1517
+ assert ! ( new_path_last. args. is_empty( ) ) ;
1518
+ new_path_last. args = clean_generic_args ( path_last_args, cx) ;
1516
1519
}
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
- } ;
1526
- clean_path ( & path, cx)
1520
+ new_clean_path
1527
1521
}
1528
1522
1529
1523
/// The goal of this function is to return the first `Path` which is not private (ie not private
@@ -1535,16 +1529,7 @@ fn first_non_private<'tcx>(
1535
1529
hir_id : hir:: HirId ,
1536
1530
path : & hir:: Path < ' tcx > ,
1537
1531
) -> Option < Path > {
1538
- let use_id = path. segments . last ( ) . map ( |seg| seg. hir_id ) ?;
1539
1532
let target_def_id = path. res . opt_def_id ( ) ?;
1540
- let saved_path = cx
1541
- . updated_qpath
1542
- . borrow ( )
1543
- . get ( & use_id)
1544
- . map ( |saved_path| ( saved_path. segments . to_vec ( ) , saved_path. span ) ) ;
1545
- if let Some ( ( segments, span) ) = saved_path {
1546
- return Some ( first_non_private_clean_path ( cx, path, segments, span) ) ;
1547
- }
1548
1533
let ( parent_def_id, ident) = match & path. segments [ ..] {
1549
1534
[ ] => return None ,
1550
1535
// Relative paths are available in the same scope as the owner.
@@ -1611,9 +1596,7 @@ fn first_non_private<'tcx>(
1611
1596
// 1. We found a public reexport.
1612
1597
// 2. We didn't find a public reexport so it's the "end type" path.
1613
1598
if let Some ( ( new_path, _) ) = last_path_res {
1614
- cx. updated_qpath . borrow_mut ( ) . insert ( use_id, new_path. clone ( ) ) ;
1615
- let new_path_segments = new_path. segments . to_vec ( ) ;
1616
- return Some ( first_non_private_clean_path ( cx, path, new_path_segments, new_path. span ) ) ;
1599
+ return Some ( first_non_private_clean_path ( cx, path, new_path. segments , new_path. span ) ) ;
1617
1600
}
1618
1601
// If `last_path_res` is `None`, it can mean two things:
1619
1602
//
0 commit comments