@@ -25,7 +25,7 @@ use compile;
2525use install;
2626use dist;
2727use util:: { exe, libdir, add_lib_path} ;
28- use { Build , Mode } ;
28+ use { Build , Mode , DocTests } ;
2929use cache:: { INTERNER , Interned , Cache } ;
3030use check;
3131use test;
@@ -323,15 +323,15 @@ impl<'a> Builder<'a> {
323323 test:: Cargotest , test:: Cargo , test:: Rls , test:: ErrorIndex , test:: Distcheck ,
324324 test:: RunMakeFullDeps ,
325325 test:: Nomicon , test:: Reference , test:: RustdocBook , test:: RustByExample ,
326- test:: TheBook , test:: UnstableBook ,
326+ test:: TheBook , test:: UnstableBook , test :: RustcBook ,
327327 test:: Rustfmt , test:: Miri , test:: Clippy , test:: RustdocJS , test:: RustdocTheme ,
328328 // Run run-make last, since these won't pass without make on Windows
329329 test:: RunMake , test:: RustdocUi ) ,
330330 Kind :: Bench => describe ! ( test:: Crate , test:: CrateLibrustc ) ,
331331 Kind :: Doc => describe ! ( doc:: UnstableBook , doc:: UnstableBookGen , doc:: TheBook ,
332332 doc:: Standalone , doc:: Std , doc:: Test , doc:: WhitelistedRustc , doc:: Rustc ,
333333 doc:: ErrorIndex , doc:: Nomicon , doc:: Reference , doc:: Rustdoc , doc:: RustByExample ,
334- doc:: CargoBook ) ,
334+ doc:: RustcBook , doc :: CargoBook ) ,
335335 Kind :: Dist => describe ! ( dist:: Docs , dist:: RustcDocs , dist:: Mingw , dist:: Rustc ,
336336 dist:: DebuggerScripts , dist:: Std , dist:: Analysis , dist:: Src ,
337337 dist:: PlainSourceTarball , dist:: Cargo , dist:: Rls , dist:: Rustfmt , dist:: Extended ,
@@ -591,6 +591,8 @@ impl<'a> Builder<'a> {
591591 format ! ( "{} {}" , env:: var( "RUSTFLAGS" ) . unwrap_or_default( ) , extra_args) ) ;
592592 }
593593
594+ let want_rustdoc = self . doc_tests != DocTests :: No ;
595+
594596 // Customize the compiler we're running. Specify the compiler to cargo
595597 // as our shim and then pass it some various options used to configure
596598 // how the actual compiler itself is called.
@@ -607,7 +609,7 @@ impl<'a> Builder<'a> {
607609 . env ( "RUSTC_LIBDIR" , self . rustc_libdir ( compiler) )
608610 . env ( "RUSTC_RPATH" , self . config . rust_rpath . to_string ( ) )
609611 . env ( "RUSTDOC" , self . out . join ( "bootstrap/debug/rustdoc" ) )
610- . env ( "RUSTDOC_REAL" , if cmd == "doc" || cmd == "test" {
612+ . env ( "RUSTDOC_REAL" , if cmd == "doc" || ( cmd == "test" && want_rustdoc ) {
611613 self . rustdoc ( compiler. host )
612614 } else {
613615 PathBuf :: from ( "/path/to/nowhere/rustdoc/not/required" )
@@ -624,7 +626,7 @@ impl<'a> Builder<'a> {
624626 if let Some ( ref error_format) = self . config . rustc_error_format {
625627 cargo. env ( "RUSTC_ERROR_FORMAT" , error_format) ;
626628 }
627- if cmd != "build" && cmd != "check" {
629+ if cmd != "build" && cmd != "check" && want_rustdoc {
628630 cargo. env ( "RUSTDOC_LIBDIR" , self . rustc_libdir ( self . compiler ( 2 , self . config . build ) ) ) ;
629631 }
630632
@@ -706,6 +708,10 @@ impl<'a> Builder<'a> {
706708 cargo. env ( "RUSTC_PRINT_STEP_TIMINGS" , "1" ) ;
707709 }
708710
711+ if self . config . backtrace_on_ice {
712+ cargo. env ( "RUSTC_BACKTRACE_ON_ICE" , "1" ) ;
713+ }
714+
709715 cargo. env ( "RUSTC_VERBOSE" , format ! ( "{}" , self . verbosity) ) ;
710716
711717 // in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.
@@ -1403,4 +1409,39 @@ mod __test {
14031409 } ,
14041410 ] ) ;
14051411 }
1412+
1413+ #[ test]
1414+ fn test_with_no_doc_stage0 ( ) {
1415+ let mut config = configure ( & [ ] , & [ ] ) ;
1416+ config. stage = Some ( 0 ) ;
1417+ config. cmd = Subcommand :: Test {
1418+ paths : vec ! [ "src/libstd" . into( ) ] ,
1419+ test_args : vec ! [ ] ,
1420+ rustc_args : vec ! [ ] ,
1421+ fail_fast : true ,
1422+ doc_tests : DocTests :: No ,
1423+ } ;
1424+
1425+ let build = Build :: new ( config) ;
1426+ let mut builder = Builder :: new ( & build) ;
1427+
1428+ let host = INTERNER . intern_str ( "A" ) ;
1429+
1430+ builder. run_step_descriptions (
1431+ & [ StepDescription :: from :: < test:: Crate > ( ) ] ,
1432+ & [ "src/libstd" . into ( ) ] ,
1433+ ) ;
1434+
1435+ // Ensure we don't build any compiler artifacts.
1436+ assert ! ( builder. cache. all:: <compile:: Rustc >( ) . is_empty( ) ) ;
1437+ assert_eq ! ( first( builder. cache. all:: <test:: Crate >( ) ) , & [
1438+ test:: Crate {
1439+ compiler: Compiler { host, stage: 0 } ,
1440+ target: host,
1441+ mode: Mode :: Libstd ,
1442+ test_kind: test:: TestKind :: Test ,
1443+ krate: INTERNER . intern_str( "std" ) ,
1444+ } ,
1445+ ] ) ;
1446+ }
14061447}
0 commit comments