@@ -249,15 +249,15 @@ pub(crate) struct RenderOptions {
249249 /// A map of crate names to the URL to use instead of querying the crate's `html_root_url`.
250250 pub ( crate ) extern_html_root_urls : BTreeMap < String , String > ,
251251 /// Whether to give precedence to `html_root_url` or `--extern-html-root-url`.
252- pub ( crate ) extern_html_root_takes_precedence : bool ,
252+ pub ( crate ) extern_html_root_takes_precedence : ExternHtmlRootTakesPrecedence ,
253253 /// A map of the default settings (values are as for DOM storage API). Keys should lack the
254254 /// `rustdoc-` prefix.
255255 pub ( crate ) default_settings : FxIndexMap < String , String > ,
256256 /// If present, suffix added to CSS/JavaScript files when referencing them in generated pages.
257257 pub ( crate ) resource_suffix : String ,
258258 /// Whether to create an index page in the root of the output directory. If this is true but
259259 /// `enable_index_page` is None, generate a static listing of crates instead.
260- pub ( crate ) enable_index_page : bool ,
260+ pub ( crate ) enable_index_page : EnableIndexPage ,
261261 /// A file to use as the index page at the root of the output directory. Overrides
262262 /// `enable_index_page` to be true if set.
263263 pub ( crate ) index_page : Option < PathBuf > ,
@@ -268,47 +268,86 @@ pub(crate) struct RenderOptions {
268268 // Options specific to reading standalone Markdown files
269269 /// Whether to generate a table of contents on the output file when reading a standalone
270270 /// Markdown file.
271- pub ( crate ) markdown_no_toc : bool ,
271+ pub ( crate ) markdown_no_toc : MarkdownNoToc ,
272272 /// Additional CSS files to link in pages generated from standalone Markdown files.
273273 pub ( crate ) markdown_css : Vec < String > ,
274274 /// If present, playground URL to use in the "Run" button added to code samples generated from
275275 /// standalone Markdown files. If not present, `playground_url` is used.
276276 pub ( crate ) markdown_playground_url : Option < String > ,
277277 /// Document items that have lower than `pub` visibility.
278- pub ( crate ) document_private : bool ,
278+ pub ( crate ) document_private : DocumentPrivate ,
279279 /// Document items that have `doc(hidden)`.
280- pub ( crate ) document_hidden : bool ,
280+ pub ( crate ) document_hidden : DocumentHidden ,
281281 /// If `true`, generate a JSON file in the crate folder instead of HTML redirection files.
282- pub ( crate ) generate_redirect_map : bool ,
282+ pub ( crate ) generate_redirect_map : GenerateRedirectMap ,
283283 /// Show the memory layout of types in the docs.
284- pub ( crate ) show_type_layout : bool ,
284+ pub ( crate ) show_type_layout : ShowTypeLayout ,
285285 /// Note: this field is duplicated in `Options` because it's useful to have
286286 /// it in both places.
287287 pub ( crate ) unstable_features : rustc_feature:: UnstableFeatures ,
288288 pub ( crate ) emit : Vec < EmitType > ,
289289 /// If `true`, HTML source pages will generate links for items to their definition.
290- pub ( crate ) generate_link_to_definition : bool ,
290+ pub ( crate ) generate_link_to_definition : GenerateLinkToDefinition ,
291291 /// Set of function-call locations to include as examples
292292 pub ( crate ) call_locations : AllCallLocations ,
293293 /// If `true`, Context::init will not emit shared files.
294- pub ( crate ) no_emit_shared : bool ,
294+ pub ( crate ) no_emit_shared : NoEmitShared ,
295295 /// If `true`, HTML source code pages won't be generated.
296- pub ( crate ) html_no_source : bool ,
296+ pub ( crate ) html_no_source : HtmlNoSource ,
297297 /// This field is only used for the JSON output. If it's set to true, no file will be created
298298 /// and content will be displayed in stdout directly.
299- pub ( crate ) output_to_stdout : bool ,
299+ pub ( crate ) output_to_stdout : OutputToStdout ,
300300 /// Whether we should read or write rendered cross-crate info in the doc root.
301301 pub ( crate ) should_merge : ShouldMerge ,
302302 /// Path to crate-info for external crates.
303303 pub ( crate ) include_parts_dir : Vec < PathToParts > ,
304304 /// Where to write crate-info
305305 pub ( crate ) parts_out_dir : Option < PathToParts > ,
306306 /// disable minification of CSS/JS
307- pub ( crate ) disable_minification : bool ,
307+ pub ( crate ) disable_minification : DisableMinification ,
308308 /// If `true`, HTML source pages will generate the possibility to expand macros.
309- pub ( crate ) generate_macro_expansion : bool ,
309+ pub ( crate ) generate_macro_expansion : GenerateMacroExpansion ,
310310}
311311
312+ #[ derive( Clone , Copy , Debug , Default ) ]
313+ pub ( crate ) struct ExternHtmlRootTakesPrecedence ( pub ( crate ) bool ) ;
314+
315+ #[ derive( Clone , Copy , Debug , Default ) ]
316+ pub ( crate ) struct EnableIndexPage ( pub ( crate ) bool ) ;
317+
318+ #[ derive( Clone , Copy , Debug , Default ) ]
319+ pub ( crate ) struct MarkdownNoToc ( pub ( crate ) bool ) ;
320+
321+ #[ derive( Clone , Copy , Debug , Default ) ]
322+ pub ( crate ) struct DocumentPrivate ( pub ( crate ) bool ) ;
323+
324+ #[ derive( Clone , Copy , Debug , Default ) ]
325+ pub ( crate ) struct DocumentHidden ( pub ( crate ) bool ) ;
326+
327+ #[ derive( Clone , Copy , Debug , Default ) ]
328+ pub ( crate ) struct GenerateRedirectMap ( pub ( crate ) bool ) ;
329+
330+ #[ derive( Clone , Copy , Debug , Default ) ]
331+ pub ( crate ) struct ShowTypeLayout ( pub ( crate ) bool ) ;
332+
333+ #[ derive( Clone , Copy , Debug , Default ) ]
334+ pub ( crate ) struct GenerateLinkToDefinition ( pub ( crate ) bool ) ;
335+
336+ #[ derive( Clone , Copy , Debug , Default ) ]
337+ pub ( crate ) struct NoEmitShared ( pub ( crate ) bool ) ;
338+
339+ #[ derive( Clone , Copy , Debug , Default ) ]
340+ pub ( crate ) struct HtmlNoSource ( pub ( crate ) bool ) ;
341+
342+ #[ derive( Clone , Copy , Debug , Default ) ]
343+ pub ( crate ) struct OutputToStdout ( pub ( crate ) bool ) ;
344+
345+ #[ derive( Clone , Copy , Debug , Default ) ]
346+ pub ( crate ) struct DisableMinification ( pub ( crate ) bool ) ;
347+
348+ #[ derive( Clone , Copy , Debug , Default ) ]
349+ pub ( crate ) struct GenerateMacroExpansion ( pub ( crate ) bool ) ;
350+
312351#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
313352pub ( crate ) enum ModuleSorting {
314353 DeclarationOrder ,
@@ -633,15 +672,15 @@ impl Options {
633672 dcx. fatal ( "the `--test` flag must be passed to enable `--no-run`" ) ;
634673 }
635674
636- let mut output_to_stdout = false ;
675+ let mut output_to_stdout = OutputToStdout ( false ) ;
637676 let test_builder_wrappers =
638677 matches. opt_strs ( "test-builder-wrapper" ) . iter ( ) . map ( PathBuf :: from) . collect ( ) ;
639678 let output = match ( matches. opt_str ( "out-dir" ) , matches. opt_str ( "output" ) ) {
640679 ( Some ( _) , Some ( _) ) => {
641680 dcx. fatal ( "cannot use both 'out-dir' and 'output' at once" ) ;
642681 }
643682 ( Some ( out_dir) , None ) | ( None , Some ( out_dir) ) => {
644- output_to_stdout = out_dir == "-" ;
683+ output_to_stdout. 0 = out_dir == "-" ;
645684 PathBuf :: from ( out_dir)
646685 }
647686 ( None , None ) => PathBuf :: from ( "doc" ) ,
@@ -773,11 +812,11 @@ impl Options {
773812 ModuleSorting :: Alphabetical
774813 } ;
775814 let resource_suffix = matches. opt_str ( "resource-suffix" ) . unwrap_or_default ( ) ;
776- let markdown_no_toc = matches. opt_present ( "markdown-no-toc" ) ;
815+ let markdown_no_toc = MarkdownNoToc ( matches. opt_present ( "markdown-no-toc" ) ) ;
777816 let markdown_css = matches. opt_strs ( "markdown-css" ) ;
778817 let markdown_playground_url = matches. opt_str ( "markdown-playground-url" ) ;
779818 let crate_version = matches. opt_str ( "crate-version" ) ;
780- let enable_index_page = matches. opt_present ( "enable-index-page" ) || index_page. is_some ( ) ;
819+ let enable_index_page = EnableIndexPage ( matches. opt_present ( "enable-index-page" ) || index_page. is_some ( ) ) ;
781820 let static_root_path = matches. opt_str ( "static-root-path" ) ;
782821 let test_run_directory = matches. opt_str ( "test-run-directory" ) . map ( PathBuf :: from) ;
783822 let persist_doctests = matches. opt_str ( "persist-doctests" ) . map ( PathBuf :: from) ;
@@ -788,30 +827,30 @@ impl Options {
788827 let extern_strs = matches. opt_strs ( "extern" ) ;
789828 let test_runtool = matches. opt_str ( "test-runtool" ) ;
790829 let test_runtool_args = matches. opt_strs ( "test-runtool-arg" ) ;
791- let document_private = matches. opt_present ( "document-private-items" ) ;
792- let document_hidden = matches. opt_present ( "document-hidden-items" ) ;
830+ let document_private = DocumentPrivate ( matches. opt_present ( "document-private-items" ) ) ;
831+ let document_hidden = DocumentHidden ( matches. opt_present ( "document-hidden-items" ) ) ;
793832 let run_check = matches. opt_present ( "check" ) ;
794- let generate_redirect_map = matches. opt_present ( "generate-redirect-map" ) ;
795- let show_type_layout = matches. opt_present ( "show-type-layout" ) ;
833+ let generate_redirect_map = GenerateRedirectMap ( matches. opt_present ( "generate-redirect-map" ) ) ;
834+ let show_type_layout = ShowTypeLayout ( matches. opt_present ( "show-type-layout" ) ) ;
796835 let nocapture = matches. opt_present ( "nocapture" ) ;
797- let generate_link_to_definition = matches. opt_present ( "generate-link-to-definition" ) ;
798- let generate_macro_expansion = matches. opt_present ( "generate-macro-expansion" ) ;
836+ let generate_link_to_definition = GenerateLinkToDefinition ( matches. opt_present ( "generate-link-to-definition" ) ) ;
837+ let generate_macro_expansion = GenerateMacroExpansion ( matches. opt_present ( "generate-macro-expansion" ) ) ;
799838 let extern_html_root_takes_precedence =
800- matches. opt_present ( "extern-html-root-takes-precedence" ) ;
801- let html_no_source = matches. opt_present ( "html-no-source" ) ;
839+ ExternHtmlRootTakesPrecedence ( matches. opt_present ( "extern-html-root-takes-precedence" ) ) ;
840+ let html_no_source = HtmlNoSource ( matches. opt_present ( "html-no-source" ) ) ;
802841 let should_merge = match parse_merge ( matches) {
803842 Ok ( result) => result,
804843 Err ( e) => dcx. fatal ( format ! ( "--merge option error: {e}" ) ) ,
805844 } ;
806845
807- if generate_link_to_definition && ( show_coverage || output_format != OutputFormat :: Html ) {
846+ if generate_link_to_definition. 0 && ( show_coverage || output_format != OutputFormat :: Html ) {
808847 dcx. struct_warn (
809848 "`--generate-link-to-definition` option can only be used with HTML output format" ,
810849 )
811850 . with_note ( "`--generate-link-to-definition` option will be ignored" )
812851 . emit ( ) ;
813852 }
814- if generate_macro_expansion && ( show_coverage || output_format != OutputFormat :: Html ) {
853+ if generate_macro_expansion. 0 && ( show_coverage || output_format != OutputFormat :: Html ) {
815854 dcx. struct_warn (
816855 "`--generate-macro-expansion` option can only be used with HTML output format" ,
817856 )
@@ -828,7 +867,7 @@ impl Options {
828867 let unstable_features =
829868 rustc_feature:: UnstableFeatures :: from_environment ( crate_name. as_deref ( ) ) ;
830869
831- let disable_minification = matches. opt_present ( "disable-minification" ) ;
870+ let disable_minification = DisableMinification ( matches. opt_present ( "disable-minification" ) ) ;
832871
833872 let options = Options {
834873 bin_crate,
@@ -901,7 +940,7 @@ impl Options {
901940 generate_link_to_definition,
902941 generate_macro_expansion,
903942 call_locations,
904- no_emit_shared : false ,
943+ no_emit_shared : NoEmitShared ( false ) ,
905944 html_no_source,
906945 output_to_stdout,
907946 should_merge,
0 commit comments