11use std:: collections:: BTreeMap ;
2- use std:: path:: Path ;
32
4- use rustc_ast:: ast;
53use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
64use rustc_middle:: ty:: TyCtxt ;
7- use rustc_span:: symbol:: { sym , Symbol } ;
5+ use rustc_span:: symbol:: Symbol ;
86use serde:: ser:: { Serialize , SerializeStruct , Serializer } ;
97
108use crate :: clean;
119use crate :: clean:: types:: {
12- AttributesExt , FnDecl , FnRetTy , GenericBound , Generics , GetDefId , Type , WherePredicate ,
10+ FnDecl , FnRetTy , GenericBound , Generics , GetDefId , Type , WherePredicate ,
1311} ;
1412use crate :: formats:: cache:: Cache ;
1513use crate :: formats:: item_type:: ItemType ;
@@ -26,47 +24,6 @@ crate enum ExternalLocation {
2624 Unknown ,
2725}
2826
29- /// Attempts to find where an external crate is located, given that we're
30- /// rendering in to the specified source destination.
31- crate fn extern_location (
32- e : & clean:: ExternalCrate ,
33- extern_url : Option < & str > ,
34- ast_attrs : & [ ast:: Attribute ] ,
35- dst : & Path ,
36- tcx : TyCtxt < ' _ > ,
37- ) -> ExternalLocation {
38- use ExternalLocation :: * ;
39- // See if there's documentation generated into the local directory
40- let local_location = dst. join ( & * e. name ( tcx) . as_str ( ) ) ;
41- if local_location. is_dir ( ) {
42- return Local ;
43- }
44-
45- if let Some ( url) = extern_url {
46- let mut url = url. to_string ( ) ;
47- if !url. ends_with ( '/' ) {
48- url. push ( '/' ) ;
49- }
50- return Remote ( url) ;
51- }
52-
53- // Failing that, see if there's an attribute specifying where to find this
54- // external crate
55- ast_attrs
56- . lists ( sym:: doc)
57- . filter ( |a| a. has_name ( sym:: html_root_url) )
58- . filter_map ( |a| a. value_str ( ) )
59- . map ( |url| {
60- let mut url = url. to_string ( ) ;
61- if !url. ends_with ( '/' ) {
62- url. push ( '/' )
63- }
64- Remote ( url)
65- } )
66- . next ( )
67- . unwrap_or ( Unknown ) // Well, at least we tried.
68- }
69-
7027/// Builds the search index from the collected metadata
7128crate fn build_index < ' tcx > ( krate : & clean:: Crate , cache : & mut Cache , tcx : TyCtxt < ' tcx > ) -> String {
7229 let mut defid_to_pathid = FxHashMap :: default ( ) ;
0 commit comments