File tree 2 files changed +42
-3
lines changed
2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -211,16 +211,24 @@ impl RustdocScrapeExamples {
211
211
}
212
212
213
213
impl 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
215
223
pub fn scrape_units_have_dep_on < ' a > ( & ' a self , unit : & ' a Unit ) -> Vec < & ' a Unit > {
216
224
self . scrape_units
217
225
. iter ( )
218
226
. filter ( |scrape_unit| {
219
227
self . unit_graph [ scrape_unit]
220
228
. iter ( )
221
- . any ( |dep| & dep. unit == unit)
229
+ . any ( |dep| & dep. unit == unit && !dep . unit . mode . is_run_custom_build ( ) )
222
230
} )
223
- . collect :: < Vec < _ > > ( )
231
+ . collect ( )
224
232
}
225
233
226
234
/// 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
366
366
. run ( ) ;
367
367
}
368
368
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
+
369
400
#[ cargo_test( nightly, reason = "rustdoc scrape examples flags are unstable" ) ]
370
401
fn no_fail_bad_example ( ) {
371
402
let p = project ( )
You can’t perform that action at this time.
0 commit comments