@@ -29,7 +29,7 @@ use rustc_span::symbol::sym;
2929use tracing:: { debug, info} ;
3030
3131use crate :: clean:: inline:: build_trait;
32- use crate :: clean:: { self , ItemId } ;
32+ use crate :: clean:: { self , ItemId , NestedAttributesExt } ;
3333use crate :: config:: { Options as RustdocOptions , OutputFormat , RenderOptions } ;
3434use crate :: formats:: cache:: Cache ;
3535use crate :: html:: macro_expansion:: { ExpandedCode , source_macro_expansion} ;
@@ -62,8 +62,6 @@ pub(crate) struct DocContext<'tcx> {
6262 // FIXME(eddyb) make this a `ty::TraitRef<'tcx>` set.
6363 pub ( crate ) generated_synthetics : FxHashSet < ( Ty < ' tcx > , DefId ) > ,
6464 pub ( crate ) auto_traits : Vec < DefId > ,
65- /// The options given to rustdoc that could be relevant to a pass.
66- pub ( crate ) render_options : RenderOptions ,
6765 /// This same cache is used throughout rustdoc, including in [`crate::html::render`].
6866 pub ( crate ) cache : Cache ,
6967 /// Used by [`clean::inline`] to tell if an item has already been inlined.
@@ -139,6 +137,16 @@ impl<'tcx> DocContext<'tcx> {
139137 pub ( crate ) fn is_json_output ( & self ) -> bool {
140138 self . output_format . is_json ( ) && !self . show_coverage
141139 }
140+
141+ /// If `--document-private-items` was passed to rustdoc.
142+ pub ( crate ) fn document_private ( & self ) -> bool {
143+ self . cache . document_private
144+ }
145+
146+ /// If `--document-hidden-items` was passed to rustdoc.
147+ pub ( crate ) fn document_hidden ( & self ) -> bool {
148+ self . cache . document_hidden
149+ }
142150}
143151
144152/// Creates a new `DiagCtxt` that can be used to emit warnings and errors.
@@ -379,7 +387,6 @@ pub(crate) fn run_global_ctxt(
379387 cache : Cache :: new ( render_options. document_private , render_options. document_hidden ) ,
380388 inlined : FxHashSet :: default ( ) ,
381389 output_format,
382- render_options,
383390 show_coverage,
384391 } ;
385392
@@ -424,9 +431,9 @@ pub(crate) fn run_global_ctxt(
424431 for p in passes:: defaults ( show_coverage) {
425432 let run = match p. condition {
426433 Always => true ,
427- WhenDocumentPrivate => ctxt. render_options . document_private ,
428- WhenNotDocumentPrivate => !ctxt. render_options . document_private ,
429- WhenNotDocumentHidden => !ctxt. render_options . document_hidden ,
434+ WhenDocumentPrivate => ctxt. document_private ( ) ,
435+ WhenNotDocumentPrivate => !ctxt. document_private ( ) ,
436+ WhenNotDocumentHidden => !ctxt. document_hidden ( ) ,
430437 } ;
431438 if run {
432439 debug ! ( "running pass {}" , p. pass. name) ;
@@ -444,15 +451,16 @@ pub(crate) fn run_global_ctxt(
444451
445452 tcx. sess . time ( "check_lint_expectations" , || tcx. check_expectations ( Some ( sym:: rustdoc) ) ) ;
446453
447- krate = tcx. sess . time ( "create_format_cache" , || Cache :: populate ( & mut ctxt, krate) ) ;
454+ krate =
455+ tcx. sess . time ( "create_format_cache" , || Cache :: populate ( & mut ctxt, krate, & render_options) ) ;
448456
449457 let mut collector =
450458 LinkCollector { cx : & mut ctxt, visited_links : visited, ambiguous_links : ambiguous } ;
451459 collector. resolve_ambiguities ( ) ;
452460
453461 tcx. dcx ( ) . abort_if_errors ( ) ;
454462
455- ( krate, ctxt . render_options , ctxt. cache , expanded_macros)
463+ ( krate, render_options, ctxt. cache , expanded_macros)
456464}
457465
458466/// Due to <https://github.com/rust-lang/rust/pull/73566>,
0 commit comments