@@ -6,7 +6,7 @@ use rustc_middle::middle::privacy::AccessLevels;
6
6
use rustc_middle:: ty:: TyCtxt ;
7
7
use rustc_span:: symbol:: sym;
8
8
9
- use crate :: clean:: { self , ItemId , PrimitiveType } ;
9
+ use crate :: clean:: { self , ExternalCrate , ItemId , PrimitiveType } ;
10
10
use crate :: config:: RenderOptions ;
11
11
use crate :: core:: DocContext ;
12
12
use crate :: fold:: DocFolder ;
@@ -15,6 +15,7 @@ use crate::formats::Impl;
15
15
use crate :: html:: markdown:: short_markdown_summary;
16
16
use crate :: html:: render:: cache:: { get_index_search_type, ExternalLocation } ;
17
17
use crate :: html:: render:: IndexItem ;
18
+ use crate :: visit_lib:: LibEmbargoVisitor ;
18
19
19
20
/// This cache is used to store information about the [`clean::Crate`] being
20
21
/// rendered in order to provide more useful documentation. This contains
@@ -139,19 +140,27 @@ impl Cache {
139
140
/// in `krate` due to the data being moved into the `Cache`.
140
141
crate fn populate ( cx : & mut DocContext < ' _ > , mut krate : clean:: Crate ) -> clean:: Crate {
141
142
let tcx = cx. tcx ;
142
- let render_options = & cx. render_options ;
143
143
144
144
// Crawl the crate to build various caches used for the output
145
145
debug ! ( ?cx. cache. crate_version) ;
146
146
cx. cache . traits = krate. external_traits . take ( ) ;
147
- let RenderOptions { extern_html_root_takes_precedence, output : dst, .. } = render_options;
147
+
148
+ let mut externs = Vec :: new ( ) ;
149
+ for & cnum in cx. tcx . crates ( ( ) ) {
150
+ externs. push ( ExternalCrate { crate_num : cnum } ) ;
151
+ // Analyze doc-reachability for extern items
152
+ LibEmbargoVisitor :: new ( cx) . visit_lib ( cnum) ;
153
+ }
154
+
155
+ let RenderOptions { extern_html_root_takes_precedence, output : dst, .. } =
156
+ & cx. render_options ;
148
157
149
158
// Cache where all our extern crates are located
150
159
// FIXME: this part is specific to HTML so it'd be nice to remove it from the common code
151
- for & e in & krate . externs {
160
+ for e in externs {
152
161
let name = e. name ( tcx) ;
153
162
let extern_url =
154
- render_options. extern_html_root_urls . get ( & * name. as_str ( ) ) . map ( |u| & * * u) ;
163
+ cx . render_options . extern_html_root_urls . get ( & * name. as_str ( ) ) . map ( |u| & * * u) ;
155
164
let location = e. location ( extern_url, * extern_html_root_takes_precedence, dst, tcx) ;
156
165
cx. cache . extern_locations . insert ( e. crate_num , location) ;
157
166
cx. cache . external_paths . insert ( e. def_id ( ) , ( vec ! [ name. to_string( ) ] , ItemType :: Module ) ) ;
0 commit comments