Skip to content

Commit e52a9d9

Browse files
committed
Add comments and todos
1 parent 8b06a0f commit e52a9d9

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/bin/cargo/commands/doc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
5555
let mut compile_opts =
5656
args.compile_options(config, mode, Some(&ws), ProfileChecking::Custom)?;
5757
compile_opts.rustdoc_document_private_items = args.is_present("document-private-items");
58+
59+
// TODO(wcrichto): move scrape example configuration into Cargo.toml before stabilization
60+
// See: https://github.com/rust-lang/cargo/pull/9525#discussion_r728470927
5861
compile_opts.rustdoc_scrape_examples = match args.value_of("scrape-examples") {
5962
Some(s) => Some(match s {
6063
"all" => CompileFilter::new_all_targets(),

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
418418
vec![]
419419
}
420420
CompileMode::Docscrape => {
421-
// FIXME(wcrichto): should this include the *.examples files?
421+
// Docscrape only generates temporary *.examples files to pass to rustdoc
422+
// so they're not important to track
422423
vec![]
423424
}
424425
CompileMode::Test

src/cargo/core/compiler/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,9 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Work> {
696696
rustdoc.arg("--scrape-examples-target-crate").arg(pkg);
697697
}
698698
} else if cx.bcx.scrape_units.len() > 0 && cx.bcx.roots.contains(unit) {
699+
// We only pass scraped examples to packages in the workspace (bcx.roots)
700+
// since examples are only coming from reverse-dependencies of workspace packages
701+
699702
rustdoc.arg("-Zunstable-options");
700703

701704
for scrape_unit in &cx.bcx.scrape_units {

src/cargo/ops/cargo_compile.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -780,22 +780,20 @@ impl CompileFilter {
780780

781781
pub fn need_dev_deps(&self, mode: CompileMode) -> bool {
782782
match mode {
783-
CompileMode::Test
784-
| CompileMode::Doctest
785-
| CompileMode::Bench
786-
| CompileMode::Docscrape => true,
783+
CompileMode::Test | CompileMode::Doctest | CompileMode::Bench => true,
787784
CompileMode::Check { test: true } => true,
788-
CompileMode::Build | CompileMode::Doc { .. } | CompileMode::Check { test: false } => {
789-
match *self {
790-
CompileFilter::Default { .. } => false,
791-
CompileFilter::Only {
792-
ref examples,
793-
ref tests,
794-
ref benches,
795-
..
796-
} => examples.is_specific() || tests.is_specific() || benches.is_specific(),
797-
}
798-
}
785+
CompileMode::Build
786+
| CompileMode::Doc { .. }
787+
| CompileMode::Docscrape
788+
| CompileMode::Check { test: false } => match *self {
789+
CompileFilter::Default { .. } => false,
790+
CompileFilter::Only {
791+
ref examples,
792+
ref tests,
793+
ref benches,
794+
..
795+
} => examples.is_specific() || tests.is_specific() || benches.is_specific(),
796+
},
799797
CompileMode::RunCustomBuild => panic!("Invalid mode"),
800798
}
801799
}

0 commit comments

Comments
 (0)