@@ -965,7 +965,7 @@ macro_rules! tool_doc {
965965 (
966966 $tool: ident,
967967 $path: literal,
968- $ ( rustc_private_tool = $rustc_private_tool : literal , ) ?
968+ mode = $mode : expr ,
969969 $( is_library = $is_library: expr, ) ?
970970 $( crates = $crates: expr) ?
971971 ) => {
@@ -988,20 +988,29 @@ macro_rules! tool_doc {
988988
989989 fn make_run( run: RunConfig <' _>) {
990990 let target = run. target;
991- let ( build_compiler, mode) = if true $( && $rustc_private_tool) ? {
992- // Rustdoc needs the rustc sysroot available to build.
993- let compilers = RustcPrivateCompilers :: new( run. builder, run. builder. top_stage, target) ;
994-
995- // Build rustc docs so that we generate relative links.
996- run. builder. ensure( Rustc :: from_build_compiler( run. builder, compilers. build_compiler( ) , target) ) ;
997-
998- ( compilers. build_compiler( ) , Mode :: ToolRustcPrivate )
999- } else {
1000- // bootstrap/host tools have to be documented with the stage 0 compiler
1001- ( prepare_doc_compiler( run. builder, run. builder. host_target, 1 ) , Mode :: ToolBootstrap )
991+ let build_compiler = match $mode {
992+ Mode :: ToolRustcPrivate => {
993+ // Rustdoc needs the rustc sysroot available to build.
994+ let compilers = RustcPrivateCompilers :: new( run. builder, run. builder. top_stage, target) ;
995+
996+ // Build rustc docs so that we generate relative links.
997+ run. builder. ensure( Rustc :: from_build_compiler( run. builder, compilers. build_compiler( ) , target) ) ;
998+ compilers. build_compiler( )
999+ }
1000+ Mode :: ToolBootstrap => {
1001+ // bootstrap/host tools should be documented with the stage 0 compiler
1002+ prepare_doc_compiler( run. builder, run. builder. host_target, 1 )
1003+ }
1004+ Mode :: ToolTarget => {
1005+ // target tools should be documented with the in-tree compiler
1006+ prepare_doc_compiler( run. builder, run. builder. host_target, 2 )
1007+ }
1008+ _ => {
1009+ panic!( "Unexpected tool mode for documenting: {:?}" , $mode) ;
1010+ }
10021011 } ;
10031012
1004- run. builder. ensure( $tool { build_compiler, mode, target } ) ;
1013+ run. builder. ensure( $tool { build_compiler, mode: $mode , target } ) ;
10051014 }
10061015
10071016 /// Generates documentation for a tool.
@@ -1087,18 +1096,33 @@ macro_rules! tool_doc {
10871096tool_doc ! (
10881097 BuildHelper ,
10891098 "src/build_helper" ,
1090- rustc_private_tool = false ,
1099+ mode = Mode :: ToolBootstrap ,
10911100 is_library = true ,
10921101 crates = [ "build_helper" ]
10931102) ;
1094- tool_doc ! ( Rustdoc , "src/tools/rustdoc" , crates = [ "rustdoc" , "rustdoc-json-types" ] ) ;
1095- tool_doc ! ( Rustfmt , "src/tools/rustfmt" , crates = [ "rustfmt-nightly" , "rustfmt-config_proc_macro" ] ) ;
1096- tool_doc ! ( Clippy , "src/tools/clippy" , crates = [ "clippy_config" , "clippy_utils" ] ) ;
1097- tool_doc ! ( Miri , "src/tools/miri" , crates = [ "miri" ] ) ;
1103+ tool_doc ! (
1104+ Rustdoc ,
1105+ "src/tools/rustdoc" ,
1106+ mode = Mode :: ToolRustcPrivate ,
1107+ crates = [ "rustdoc" , "rustdoc-json-types" ]
1108+ ) ;
1109+ tool_doc ! (
1110+ Rustfmt ,
1111+ "src/tools/rustfmt" ,
1112+ mode = Mode :: ToolRustcPrivate ,
1113+ crates = [ "rustfmt-nightly" , "rustfmt-config_proc_macro" ]
1114+ ) ;
1115+ tool_doc ! (
1116+ Clippy ,
1117+ "src/tools/clippy" ,
1118+ mode = Mode :: ToolRustcPrivate ,
1119+ crates = [ "clippy_config" , "clippy_utils" ]
1120+ ) ;
1121+ tool_doc ! ( Miri , "src/tools/miri" , mode = Mode :: ToolRustcPrivate , crates = [ "miri" ] ) ;
10981122tool_doc ! (
10991123 Cargo ,
11001124 "src/tools/cargo" ,
1101- rustc_private_tool = false ,
1125+ mode = Mode :: ToolTarget ,
11021126 crates = [
11031127 "cargo" ,
11041128 "cargo-credential" ,
@@ -1112,25 +1136,25 @@ tool_doc!(
11121136 "rustfix" ,
11131137 ]
11141138) ;
1115- tool_doc ! ( Tidy , "src/tools/tidy" , rustc_private_tool = false , crates = [ "tidy" ] ) ;
1139+ tool_doc ! ( Tidy , "src/tools/tidy" , mode = Mode :: ToolBootstrap , crates = [ "tidy" ] ) ;
11161140tool_doc ! (
11171141 Bootstrap ,
11181142 "src/bootstrap" ,
1119- rustc_private_tool = false ,
1143+ mode = Mode :: ToolBootstrap ,
11201144 is_library = true ,
11211145 crates = [ "bootstrap" ]
11221146) ;
11231147tool_doc ! (
11241148 RunMakeSupport ,
11251149 "src/tools/run-make-support" ,
1126- rustc_private_tool = false ,
1150+ mode = Mode :: ToolBootstrap ,
11271151 is_library = true ,
11281152 crates = [ "run_make_support" ]
11291153) ;
11301154tool_doc ! (
11311155 Compiletest ,
11321156 "src/tools/compiletest" ,
1133- rustc_private_tool = false ,
1157+ mode = Mode :: ToolBootstrap ,
11341158 is_library = true ,
11351159 crates = [ "compiletest" ]
11361160) ;
0 commit comments