@@ -1505,6 +1505,8 @@ fn first_non_private(
1505
1505
hir_id : hir:: HirId ,
1506
1506
path : & hir:: Path < ' _ > ,
1507
1507
) -> Option < Path > {
1508
+ use std:: mem:: transmute;
1509
+
1508
1510
let ( parent_def_id, mut ident) = match & path. segments [ ..] {
1509
1511
[ ] => return None ,
1510
1512
// Relative paths are available in the same scope as the owner.
@@ -1574,9 +1576,27 @@ fn first_non_private(
1574
1576
//
1575
1577
// 1. We found a public reexport.
1576
1578
// 2. We didn't find a public reexport so it's the "end type" path.
1577
- if let Some ( ( path, res) ) = last_path_res {
1578
- let path = hir:: Path { segments : path. segments , res : * res, span : path. span } ;
1579
- return Some ( clean_path ( & path, cx) ) ;
1579
+ if let Some ( ( new_path, _) ) = last_path_res {
1580
+ // In here we need to play with the path data one last time to provide it the
1581
+ // missing `args` and `res` of the final `Path` we get, which, since it comes
1582
+ // from a re-export, doesn't have the generics that were originally there, so
1583
+ // we add them by hand.
1584
+ let mut segments = new_path. segments . to_vec ( ) ;
1585
+ if let Some ( last) = segments. last_mut ( ) {
1586
+ // `transmute` is needed because we are using a wrong lifetime. Since
1587
+ // `segments` will be dropped at the end of this block, it's fine.
1588
+ last. args = unsafe {
1589
+ transmute (
1590
+ path. segments . last ( ) . as_ref ( ) . unwrap ( ) . args . clone ( ) ,
1591
+ )
1592
+ } ;
1593
+ last. res = path. res ;
1594
+ }
1595
+ // `transmute` is needed because we are using a wrong lifetime. Since
1596
+ // `segments` will be dropped at the end of this block, it's fine.
1597
+ let segments = unsafe { transmute ( segments. as_slice ( ) ) } ;
1598
+ let new_path = hir:: Path { segments, res : path. res , span : new_path. span } ;
1599
+ return Some ( clean_path ( & new_path, cx) ) ;
1580
1600
}
1581
1601
// If `last_path_res` is `None`, it can mean two things:
1582
1602
//
0 commit comments