Skip to content

Commit a3a2559

Browse files
add a coverage mode for private items
1 parent 5eb1ab5 commit a3a2559

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/librustdoc/config.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ impl Options {
232232
for &name in passes::DEFAULT_COVERAGE_PASSES {
233233
println!("{:>20}", name);
234234
}
235+
println!("\nPasses run with `--show-coverage --document-private-items`:");
236+
for &name in passes::PRIVATE_COVERAGE_PASSES {
237+
println!("{:>20}", name);
238+
}
235239
return Err(0);
236240
}
237241

@@ -421,17 +425,21 @@ impl Options {
421425
}
422426
});
423427

428+
let show_coverage = matches.opt_present("show-coverage");
429+
let document_private = matches.opt_present("document-private-items");
430+
424431
let default_passes = if matches.opt_present("no-defaults") {
425432
passes::DefaultPassOption::None
426-
} else if matches.opt_present("show-coverage") {
433+
} else if show_coverage && document_private {
434+
passes::DefaultPassOption::PrivateCoverage
435+
} else if show_coverage {
427436
passes::DefaultPassOption::Coverage
428-
} else if matches.opt_present("document-private-items") {
437+
} else if document_private {
429438
passes::DefaultPassOption::Private
430439
} else {
431440
passes::DefaultPassOption::Default
432441
};
433442
let manual_passes = matches.opt_strs("passes");
434-
let show_coverage = matches.opt_present("show-coverage");
435443

436444
let crate_name = matches.opt_str("crate-name");
437445
let playground_url = matches.opt_str("playground-url");

src/librustdoc/passes/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,21 @@ pub const DEFAULT_COVERAGE_PASSES: &'static [&'static str] = &[
106106
"calculate-doc-coverage",
107107
];
108108

109+
/// The list of default passes run when `--doc-coverage --document-private-items` is passed to
110+
/// rustdoc.
111+
pub const PRIVATE_COVERAGE_PASSES: &'static [&'static str] = &[
112+
"collect-trait-impls",
113+
"calculate-doc-coverage",
114+
];
115+
109116
/// A shorthand way to refer to which set of passes to use, based on the presence of
110117
/// `--no-defaults` or `--document-private-items`.
111118
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
112119
pub enum DefaultPassOption {
113120
Default,
114121
Private,
115122
Coverage,
123+
PrivateCoverage,
116124
None,
117125
}
118126

@@ -122,6 +130,7 @@ pub fn defaults(default_set: DefaultPassOption) -> &'static [&'static str] {
122130
DefaultPassOption::Default => DEFAULT_PASSES,
123131
DefaultPassOption::Private => DEFAULT_PRIVATE_PASSES,
124132
DefaultPassOption::Coverage => DEFAULT_COVERAGE_PASSES,
133+
DefaultPassOption::PrivateCoverage => PRIVATE_COVERAGE_PASSES,
125134
DefaultPassOption::None => &[],
126135
}
127136
}

0 commit comments

Comments
 (0)