@@ -965,7 +965,7 @@ macro_rules! tool_doc {
965
965
(
966
966
$tool: ident,
967
967
$path: literal,
968
- $ ( rustc_private_tool = $rustc_private_tool : literal , ) ?
968
+ mode = $mode : expr ,
969
969
$( is_library = $is_library: expr, ) ?
970
970
$( crates = $crates: expr) ?
971
971
) => {
@@ -988,20 +988,29 @@ macro_rules! tool_doc {
988
988
989
989
fn make_run( run: RunConfig <' _>) {
990
990
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
+ }
1002
1011
} ;
1003
1012
1004
- run. builder. ensure( $tool { build_compiler, mode, target } ) ;
1013
+ run. builder. ensure( $tool { build_compiler, mode: $mode , target } ) ;
1005
1014
}
1006
1015
1007
1016
/// Generates documentation for a tool.
@@ -1087,18 +1096,33 @@ macro_rules! tool_doc {
1087
1096
tool_doc ! (
1088
1097
BuildHelper ,
1089
1098
"src/build_helper" ,
1090
- rustc_private_tool = false ,
1099
+ mode = Mode :: ToolBootstrap ,
1091
1100
is_library = true ,
1092
1101
crates = [ "build_helper" ]
1093
1102
) ;
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" ] ) ;
1098
1122
tool_doc ! (
1099
1123
Cargo ,
1100
1124
"src/tools/cargo" ,
1101
- rustc_private_tool = false ,
1125
+ mode = Mode :: ToolTarget ,
1102
1126
crates = [
1103
1127
"cargo" ,
1104
1128
"cargo-credential" ,
@@ -1112,25 +1136,25 @@ tool_doc!(
1112
1136
"rustfix" ,
1113
1137
]
1114
1138
) ;
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" ] ) ;
1116
1140
tool_doc ! (
1117
1141
Bootstrap ,
1118
1142
"src/bootstrap" ,
1119
- rustc_private_tool = false ,
1143
+ mode = Mode :: ToolBootstrap ,
1120
1144
is_library = true ,
1121
1145
crates = [ "bootstrap" ]
1122
1146
) ;
1123
1147
tool_doc ! (
1124
1148
RunMakeSupport ,
1125
1149
"src/tools/run-make-support" ,
1126
- rustc_private_tool = false ,
1150
+ mode = Mode :: ToolBootstrap ,
1127
1151
is_library = true ,
1128
1152
crates = [ "run_make_support" ]
1129
1153
) ;
1130
1154
tool_doc ! (
1131
1155
Compiletest ,
1132
1156
"src/tools/compiletest" ,
1133
- rustc_private_tool = false ,
1157
+ mode = Mode :: ToolBootstrap ,
1134
1158
is_library = true ,
1135
1159
crates = [ "compiletest" ]
1136
1160
) ;
0 commit comments