@@ -35,6 +35,12 @@ crate enum OutputFormat {
3535 Html ,
3636}
3737
38+ impl Default for OutputFormat {
39+ fn default ( ) -> OutputFormat {
40+ OutputFormat :: Html
41+ }
42+ }
43+
3844impl OutputFormat {
3945 crate fn is_json ( & self ) -> bool {
4046 matches ! ( self , OutputFormat :: Json )
@@ -118,7 +124,7 @@ crate struct Options {
118124 crate enable_per_target_ignores : bool ,
119125
120126 /// The path to a rustc-like binary to build tests with. If not set, we
121- /// default to loading from $sysroot/bin/rustc.
127+ /// default to loading from ` $sysroot/bin/rustc` .
122128 crate test_builder : Option < PathBuf > ,
123129
124130 // Options that affect the documentation process
@@ -142,8 +148,10 @@ crate struct Options {
142148 crate crate_version : Option < String > ,
143149 /// Collected options specific to outputting final pages.
144150 crate render_options : RenderOptions ,
145- /// Output format rendering (used only for "show-coverage" option for the moment)
146- crate output_format : Option < OutputFormat > ,
151+ /// The format that we output when rendering.
152+ ///
153+ /// Currently used only for the `--show-coverage` option.
154+ crate output_format : OutputFormat ,
147155 /// If this option is set to `true`, rustdoc will only run checks and not generate
148156 /// documentation.
149157 crate run_check : bool ,
@@ -271,7 +279,7 @@ crate struct RenderInfo {
271279 crate deref_trait_did : Option < DefId > ,
272280 crate deref_mut_trait_did : Option < DefId > ,
273281 crate owned_box_did : Option < DefId > ,
274- crate output_format : Option < OutputFormat > ,
282+ crate output_format : OutputFormat ,
275283}
276284
277285impl Options {
@@ -537,28 +545,28 @@ impl Options {
537545
538546 let output_format = match matches. opt_str ( "output-format" ) {
539547 Some ( s) => match OutputFormat :: try_from ( s. as_str ( ) ) {
540- Ok ( o ) => {
541- if o . is_json ( )
548+ Ok ( out_fmt ) => {
549+ if out_fmt . is_json ( )
542550 && !( show_coverage || nightly_options:: match_is_nightly_build ( matches) )
543551 {
544552 diag. struct_err ( "json output format isn't supported for doc generation" )
545553 . emit ( ) ;
546554 return Err ( 1 ) ;
547- } else if !o . is_json ( ) && show_coverage {
555+ } else if !out_fmt . is_json ( ) && show_coverage {
548556 diag. struct_err (
549557 "html output format isn't supported for the --show-coverage option" ,
550558 )
551559 . emit ( ) ;
552560 return Err ( 1 ) ;
553561 }
554- Some ( o )
562+ out_fmt
555563 }
556564 Err ( e) => {
557565 diag. struct_err ( & e) . emit ( ) ;
558566 return Err ( 1 ) ;
559567 }
560568 } ,
561- None => None ,
569+ None => OutputFormat :: default ( ) ,
562570 } ;
563571 let crate_name = matches. opt_str ( "crate-name" ) ;
564572 let proc_macro_crate = crate_types. contains ( & CrateType :: ProcMacro ) ;
0 commit comments