@@ -45,7 +45,7 @@ use crate::util::interning::InternedString;
4545use crate :: util:: restricted_names:: is_glob_pattern;
4646use crate :: util:: { closest_msg, profile, CargoResult , StableHasher } ;
4747
48- use anyhow:: Context as _;
48+ use anyhow:: { bail , Context as _} ;
4949
5050/// Contains information about how a package should be compiled.
5151///
@@ -76,9 +76,6 @@ pub struct CompileOptions {
7676 /// Whether the `--document-private-items` flags was specified and should
7777 /// be forwarded to `rustdoc`.
7878 pub rustdoc_document_private_items : bool ,
79- /// Whether the `--scrape-examples` flag was specified and build flags for
80- /// examples should be forwarded to `rustdoc`.
81- pub rustdoc_scrape_examples : Option < CompileFilter > ,
8279 /// Whether the build process should check the minimum Rust version
8380 /// defined in the cargo metadata for a crate.
8481 pub honor_rust_version : bool ,
@@ -97,7 +94,6 @@ impl<'a> CompileOptions {
9794 target_rustc_args : None ,
9895 local_rustdoc_args : None ,
9996 rustdoc_document_private_items : false ,
100- rustdoc_scrape_examples : None ,
10197 honor_rust_version : true ,
10298 } )
10399 }
@@ -338,7 +334,6 @@ pub fn create_bcx<'a, 'cfg>(
338334 ref target_rustc_args,
339335 ref local_rustdoc_args,
340336 rustdoc_document_private_items,
341- ref rustdoc_scrape_examples,
342337 honor_rust_version,
343338 } = * options;
344339 let config = ws. config ( ) ;
@@ -369,6 +364,7 @@ pub fn create_bcx<'a, 'cfg>(
369364 let target_data = RustcTargetData :: new ( ws, & build_config. requested_kinds ) ?;
370365
371366 let all_packages = & Packages :: All ;
367+ let rustdoc_scrape_examples = & config. cli_unstable ( ) . rustdoc_scrape_examples ;
372368 let need_reverse_dependencies = rustdoc_scrape_examples. is_some ( ) ;
373369 let full_specs = if need_reverse_dependencies {
374370 all_packages
@@ -506,15 +502,30 @@ pub fn create_bcx<'a, 'cfg>(
506502 ) ?;
507503
508504 let mut scrape_units = match rustdoc_scrape_examples {
509- Some ( scrape_filter) => {
505+ Some ( arg) => {
506+ let filter = match arg. as_str ( ) {
507+ "all" => CompileFilter :: new_all_targets ( ) ,
508+ "examples" => CompileFilter :: new (
509+ LibRule :: False ,
510+ FilterRule :: none ( ) ,
511+ FilterRule :: none ( ) ,
512+ FilterRule :: All ,
513+ FilterRule :: none ( ) ,
514+ ) ,
515+ _ => {
516+ bail ! (
517+ r#"-Z rustdoc-scrape-examples must take "all" or "examples" as an argument"#
518+ )
519+ }
520+ } ;
510521 let to_build_ids = resolve. specs_to_ids ( & resolve_specs) ?;
511522 let to_builds = pkg_set. get_many ( to_build_ids) ?;
512523 let mode = CompileMode :: Docscrape ;
513524
514525 generate_targets (
515526 ws,
516527 & to_builds,
517- scrape_filter ,
528+ & filter ,
518529 & build_config. requested_kinds ,
519530 explicit_host_kind,
520531 mode,
0 commit comments