File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed
Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -211,16 +211,24 @@ impl RustdocScrapeExamples {
211211}
212212
213213impl BuildContext < ' _ , ' _ > {
214- /// Returns the set of Docscrape units that have a direct dependency on `unit`
214+ /// Returns the set of [`Docscrape`] units that have a direct dependency on `unit`.
215+ ///
216+ /// [`RunCustomBuild`] units are excluded because we allow failures
217+ /// from type checks but not build script executions.
218+ /// A plain old `cargo doc` would just die if a build script execution fails,
219+ /// there is no reason for `-Zrustdoc-scrape-examples` to keep going.
220+ ///
221+ /// [`Docscrape`]: crate::core::compiler::CompileMode::Docscrape
222+ /// [`RunCustomBuild`]: crate::core::compiler::CompileMode::Docscrape
215223 pub fn scrape_units_have_dep_on < ' a > ( & ' a self , unit : & ' a Unit ) -> Vec < & ' a Unit > {
216224 self . scrape_units
217225 . iter ( )
218226 . filter ( |scrape_unit| {
219227 self . unit_graph [ scrape_unit]
220228 . iter ( )
221- . any ( |dep| & dep. unit == unit)
229+ . any ( |dep| & dep. unit == unit && !dep . unit . mode . is_run_custom_build ( ) )
222230 } )
223- . collect :: < Vec < _ > > ( )
231+ . collect ( )
224232 }
225233
226234 /// Returns true if this unit is needed for doing doc-scraping and is also
Original file line number Diff line number Diff line change @@ -366,6 +366,37 @@ warning: `foo` (example \"ex2\") generated 1 warning
366366 . run ( ) ;
367367}
368368
369+ #[ cargo_test( nightly, reason = "rustdoc scrape examples flags are unstable" ) ]
370+ fn fail_bad_build_script ( ) {
371+ // See rust-lang/cargo#11623
372+ let p = project ( )
373+ . file (
374+ "Cargo.toml" ,
375+ r#"
376+ [package]
377+ name = "foo"
378+ version = "0.0.1"
379+ "# ,
380+ )
381+ . file ( "src/lib.rs" , "" )
382+ . file ( "build.rs" , "fn main() { panic!(\" You shall not pass\" )}" )
383+ . file ( "examples/ex.rs" , "fn main() {}" )
384+ . build ( ) ;
385+
386+ // `cargo doc` fails
387+ p. cargo ( "doc" )
388+ . with_status ( 101 )
389+ . with_stderr_contains ( "[..]You shall not pass[..]" )
390+ . run ( ) ;
391+
392+ // scrape examples should fail whenever `cargo doc` fails.
393+ p. cargo ( "doc -Zunstable-options -Z rustdoc-scrape-examples" )
394+ . masquerade_as_nightly_cargo ( & [ "rustdoc-scrape-examples" ] )
395+ . with_status ( 101 )
396+ . with_stderr_contains ( "[..]You shall not pass[..]" )
397+ . run ( ) ;
398+ }
399+
369400#[ cargo_test( nightly, reason = "rustdoc scrape examples flags are unstable" ) ]
370401fn no_fail_bad_example ( ) {
371402 let p = project ( )
You can’t perform that action at this time.
0 commit comments