@@ -35,6 +35,12 @@ crate enum OutputFormat {
35
35
Html ,
36
36
}
37
37
38
+ impl Default for OutputFormat {
39
+ fn default ( ) -> OutputFormat {
40
+ OutputFormat :: Html
41
+ }
42
+ }
43
+
38
44
impl OutputFormat {
39
45
crate fn is_json ( & self ) -> bool {
40
46
matches ! ( self , OutputFormat :: Json )
@@ -118,7 +124,7 @@ crate struct Options {
118
124
crate enable_per_target_ignores : bool ,
119
125
120
126
/// 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` .
122
128
crate test_builder : Option < PathBuf > ,
123
129
124
130
// Options that affect the documentation process
@@ -142,8 +148,10 @@ crate struct Options {
142
148
crate crate_version : Option < String > ,
143
149
/// Collected options specific to outputting final pages.
144
150
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 ,
147
155
/// If this option is set to `true`, rustdoc will only run checks and not generate
148
156
/// documentation.
149
157
crate run_check : bool ,
@@ -271,7 +279,7 @@ crate struct RenderInfo {
271
279
crate deref_trait_did : Option < DefId > ,
272
280
crate deref_mut_trait_did : Option < DefId > ,
273
281
crate owned_box_did : Option < DefId > ,
274
- crate output_format : Option < OutputFormat > ,
282
+ crate output_format : OutputFormat ,
275
283
}
276
284
277
285
impl Options {
@@ -537,28 +545,28 @@ impl Options {
537
545
538
546
let output_format = match matches. opt_str ( "output-format" ) {
539
547
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 ( )
542
550
&& !( show_coverage || nightly_options:: match_is_nightly_build ( matches) )
543
551
{
544
552
diag. struct_err ( "json output format isn't supported for doc generation" )
545
553
. emit ( ) ;
546
554
return Err ( 1 ) ;
547
- } else if !o . is_json ( ) && show_coverage {
555
+ } else if !out_fmt . is_json ( ) && show_coverage {
548
556
diag. struct_err (
549
557
"html output format isn't supported for the --show-coverage option" ,
550
558
)
551
559
. emit ( ) ;
552
560
return Err ( 1 ) ;
553
561
}
554
- Some ( o )
562
+ out_fmt
555
563
}
556
564
Err ( e) => {
557
565
diag. struct_err ( & e) . emit ( ) ;
558
566
return Err ( 1 ) ;
559
567
}
560
568
} ,
561
- None => None ,
569
+ None => OutputFormat :: default ( ) ,
562
570
} ;
563
571
let crate_name = matches. opt_str ( "crate-name" ) ;
564
572
let proc_macro_crate = crate_types. contains ( & CrateType :: ProcMacro ) ;
0 commit comments