@@ -1499,31 +1499,25 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
14991499fn first_non_private_clean_path < ' tcx > (
15001500 cx : & mut DocContext < ' tcx > ,
15011501 path : & hir:: Path < ' tcx > ,
1502- mut new_path_segments : Vec < hir:: PathSegment < ' tcx > > ,
1502+ new_path_segments : & ' tcx [ hir:: PathSegment < ' tcx > ] ,
15031503 new_path_span : rustc_span:: Span ,
15041504) -> 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) ;
15071508 // In here we need to play with the path data one last time to provide it the
15081509 // missing `args` and `res` of the final `Path` we get, which, since it comes
15091510 // from a re-export, doesn't have the generics that were originally there, so
15101511 // 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) ;
15161519 }
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
15271521}
15281522
15291523/// 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>(
15351529 hir_id : hir:: HirId ,
15361530 path : & hir:: Path < ' tcx > ,
15371531) -> Option < Path > {
1538- let use_id = path. segments . last ( ) . map ( |seg| seg. hir_id ) ?;
15391532 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- }
15481533 let ( parent_def_id, ident) = match & path. segments [ ..] {
15491534 [ ] => return None ,
15501535 // Relative paths are available in the same scope as the owner.
@@ -1611,9 +1596,7 @@ fn first_non_private<'tcx>(
16111596 // 1. We found a public reexport.
16121597 // 2. We didn't find a public reexport so it's the "end type" path.
16131598 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 ) ) ;
16171600 }
16181601 // If `last_path_res` is `None`, it can mean two things:
16191602 //
0 commit comments