@@ -13,6 +13,7 @@ use ::serde::{Deserialize, Serialize};
1313use rustc_ast:: join_path_syms;
1414use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
1515use rustc_data_structures:: thin_vec:: ThinVec ;
16+ use rustc_hir:: def_id:: LOCAL_CRATE ;
1617use rustc_hir:: find_attr;
1718use rustc_middle:: ty:: TyCtxt ;
1819use rustc_span:: def_id:: DefId ;
@@ -22,7 +23,7 @@ use stringdex::internals as stringdex_internals;
2223use tracing:: instrument;
2324
2425use crate :: clean:: types:: { Function , Generics , ItemId , Type , WherePredicate } ;
25- use crate :: clean:: { self , utils} ;
26+ use crate :: clean:: { self , ExternalLocation , utils} ;
2627use crate :: config:: ShouldMerge ;
2728use crate :: error:: Error ;
2829use crate :: formats:: cache:: { Cache , OrphanImplItem } ;
@@ -616,7 +617,8 @@ impl SerializedSearchIndex {
616617 trait_parent,
617618 deprecated,
618619 unstable,
619- associated_item_disambiguator,
620+ associated_item_disambiguator_or_extern_crate_url :
621+ associated_item_disambiguator,
620622 } | EntryData {
621623 krate : * map. get ( krate) . unwrap ( ) ,
622624 ty : * ty,
@@ -627,7 +629,8 @@ impl SerializedSearchIndex {
627629 trait_parent : trait_parent. and_then ( |path_id| map. get ( & path_id) . copied ( ) ) ,
628630 deprecated : * deprecated,
629631 unstable : * unstable,
630- associated_item_disambiguator : associated_item_disambiguator. clone ( ) ,
632+ associated_item_disambiguator_or_extern_crate_url :
633+ associated_item_disambiguator. clone ( ) ,
631634 } ,
632635 ) ,
633636 self . descs [ id] . clone ( ) ,
@@ -898,7 +901,7 @@ struct EntryData {
898901 trait_parent : Option < usize > ,
899902 deprecated : bool ,
900903 unstable : bool ,
901- associated_item_disambiguator : Option < String > ,
904+ associated_item_disambiguator_or_extern_crate_url : Option < String > ,
902905}
903906
904907impl Serialize for EntryData {
@@ -915,7 +918,7 @@ impl Serialize for EntryData {
915918 seq. serialize_element ( & self . trait_parent . map ( |id| id + 1 ) . unwrap_or ( 0 ) ) ?;
916919 seq. serialize_element ( & if self . deprecated { 1 } else { 0 } ) ?;
917920 seq. serialize_element ( & if self . unstable { 1 } else { 0 } ) ?;
918- if let Some ( disambig) = & self . associated_item_disambiguator {
921+ if let Some ( disambig) = & self . associated_item_disambiguator_or_extern_crate_url {
919922 seq. serialize_element ( & disambig) ?;
920923 }
921924 seq. end ( )
@@ -961,7 +964,8 @@ impl<'de> Deserialize<'de> for EntryData {
961964 trait_parent : Option :: < i32 > :: from ( trait_parent) . map ( |path| path as usize ) ,
962965 deprecated : deprecated != 0 ,
963966 unstable : unstable != 0 ,
964- associated_item_disambiguator,
967+ associated_item_disambiguator_or_extern_crate_url :
968+ associated_item_disambiguator,
965969 } )
966970 }
967971 }
@@ -1389,7 +1393,7 @@ pub(crate) fn build_index(
13891393 trait_parent : None ,
13901394 deprecated : false ,
13911395 unstable : false ,
1392- associated_item_disambiguator : None ,
1396+ associated_item_disambiguator_or_extern_crate_url : None ,
13931397 } ) ,
13941398 crate_doc,
13951399 None ,
@@ -1528,7 +1532,8 @@ pub(crate) fn build_index(
15281532 exact_module_path,
15291533 deprecated : item. is_deprecated ,
15301534 unstable : item. is_unstable ,
1531- associated_item_disambiguator : if let Some ( impl_id) = item. impl_id
1535+ associated_item_disambiguator_or_extern_crate_url : if let Some ( impl_id) =
1536+ item. impl_id
15321537 && let Some ( parent_idx) = item. parent_idx
15331538 && associated_item_duplicates
15341539 . get ( & ( parent_idx, item. ty , item. name ) )
@@ -1537,6 +1542,14 @@ pub(crate) fn build_index(
15371542 > 1
15381543 {
15391544 Some ( render:: get_id_for_impl ( tcx, ItemId :: DefId ( impl_id) ) )
1545+ } else if item. ty == ItemType :: ExternCrate
1546+ && let Some ( local_def_id) = item. defid . and_then ( |def_id| def_id. as_local ( ) )
1547+ && let cnum = tcx. extern_mod_stmt_cnum ( local_def_id) . unwrap_or ( LOCAL_CRATE )
1548+ && let Some ( ExternalLocation :: Remote { url, is_absolute } ) =
1549+ cache. extern_locations . get ( & cnum)
1550+ && * is_absolute
1551+ {
1552+ Some ( format ! ( "{}{}" , url, tcx. crate_name( cnum) . as_str( ) ) )
15401553 } else {
15411554 None
15421555 } ,
0 commit comments