@@ -766,10 +766,10 @@ macro_rules! tool_doc {
766766 $should_run: literal,
767767 $path: literal,
768768 $( rustc_tool = $rustc_tool: literal, ) ?
769- $( in_tree = $in_tree: literal, ) ?
770- [ $ ( $extra_arg : literal ) ,+ $ ( , ) ?]
771- $( , ) ?
772- ) => {
769+ $( in_tree = $in_tree: literal , ) ?
770+ $ ( is_library = $is_library : expr , ) ?
771+ $( crates = $crates : expr ) ?
772+ ) => {
773773 #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
774774 pub struct $tool {
775775 target: TargetSelection ,
@@ -828,8 +828,13 @@ macro_rules! tool_doc {
828828 // Cargo uses a different directory for proc macros.
829829 builder. stage_out( compiler, Mode :: ToolRustc ) . join( "doc" ) ,
830830 ] ;
831+
832+ $( for krate in $crates {
833+ let dir_name = krate. replace( "-" , "_" ) ;
834+ t!( fs:: create_dir_all( & out. join( dir_name) ) ) ;
835+ } ) ?
836+
831837 for out_dir in out_dirs {
832- t!( fs:: create_dir_all( & out_dir) ) ;
833838 symlink_dir_force( & builder. config, & out, & out_dir) ;
834839 }
835840
@@ -849,9 +854,13 @@ macro_rules! tool_doc {
849854 // Only include compiler crates, no dependencies of those, such as `libc`.
850855 cargo. arg( "--no-deps" ) ;
851856
852- $(
853- cargo. arg( $extra_arg) ;
854- ) +
857+ if false $( || $is_library) ? {
858+ cargo. arg( "--lib" ) ;
859+ }
860+
861+ $( for krate in $crates {
862+ cargo. arg( "-p" ) . arg( krate) ;
863+ } ) ?
855864
856865 cargo. rustdocflag( "--document-private-items" ) ;
857866 // Since we always pass --document-private-items, there's no need to warn about linking to private items.
@@ -863,60 +872,56 @@ macro_rules! tool_doc {
863872
864873 let _guard = builder. msg_doc( compiler, stringify!( $tool) . to_lowercase( ) , target) ;
865874 builder. run( & mut cargo. into( ) ) ;
875+
876+ if !builder. config. dry_run( ) {
877+ // Sanity check on linked doc directories
878+ $( for krate in $crates {
879+ let dir_name = krate. replace( "-" , "_" ) ;
880+ // Making sure the directory exists and is not empty.
881+ assert!( out. join( & * dir_name) . read_dir( ) . unwrap( ) . next( ) . is_some( ) ) ;
882+ } ) ?
883+ }
866884 }
867885 }
868886 }
869887}
870888
871- tool_doc ! (
872- Rustdoc ,
873- "rustdoc-tool" ,
874- "src/tools/rustdoc" ,
875- [ "-p" , "rustdoc" , "-p" , "rustdoc-json-types" ]
876- ) ;
889+ tool_doc ! ( Rustdoc , "rustdoc-tool" , "src/tools/rustdoc" , crates = [ "rustdoc" , "rustdoc-json-types" ] ) ;
877890tool_doc ! (
878891 Rustfmt ,
879892 "rustfmt-nightly" ,
880893 "src/tools/rustfmt" ,
881- [ "-p" , " rustfmt-nightly", "-p" , " rustfmt-config_proc_macro"] ,
894+ crates = [ " rustfmt-nightly", "rustfmt-config_proc_macro" ]
882895) ;
883- tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , [ "-p" , "clippy_utils" ] ) ;
884- tool_doc ! ( Miri , "miri" , "src/tools/miri" , [ "-p" , "miri" ] ) ;
896+ tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , crates = [ "clippy_utils" ] ) ;
897+ tool_doc ! ( Miri , "miri" , "src/tools/miri" , crates = [ "miri" ] ) ;
885898tool_doc ! (
886899 Cargo ,
887900 "cargo" ,
888901 "src/tools/cargo" ,
889902 rustc_tool = false ,
890903 in_tree = false ,
891- [
892- "-p" ,
904+ crates = [
893905 "cargo" ,
894- "-p" ,
895906 "cargo-platform" ,
896- "-p" ,
897907 "cargo-util" ,
898- "-p" ,
899908 "crates-io" ,
900- "-p" ,
901909 "cargo-test-macro" ,
902- "-p" ,
903910 "cargo-test-support" ,
904- "-p" ,
905911 "cargo-credential" ,
906- "-p" ,
907912 "mdman" ,
908913 // FIXME: this trips a license check in tidy.
909- // "-p",
910914 // "resolver-tests",
911915 ]
912916) ;
913- tool_doc ! ( Tidy , "tidy" , "src/tools/tidy" , rustc_tool = false , [ "-p" , "tidy" ] ) ;
917+ tool_doc ! ( Tidy , "tidy" , "src/tools/tidy" , rustc_tool = false , crates = [ "tidy" ] ) ;
914918tool_doc ! (
915919 Bootstrap ,
916920 "bootstrap" ,
917921 "src/bootstrap" ,
918922 rustc_tool = false ,
919- [ "--lib" , "-p" , "bootstrap" ]
923+ is_library = true ,
924+ crates = [ "bootstrap" ]
920925) ;
921926
922927#[ derive( Ord , PartialOrd , Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
0 commit comments