@@ -643,7 +643,7 @@ impl Step for Rustc {
643
643
}
644
644
645
645
macro_rules! tool_doc {
646
- ( $tool: ident, $should_run: literal, $path: literal, [ $( $krate: literal) ,+ $( , ) ?] $( , ) ?) => {
646
+ ( $tool: ident, $should_run: literal, $path: literal, [ $( $krate: literal) ,+ $( , ) ?] , in_tree = $in_tree : expr $( , ) ?) => {
647
647
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
648
648
pub struct $tool {
649
649
target: TargetSelection ,
@@ -699,6 +699,12 @@ macro_rules! tool_doc {
699
699
t!( fs:: create_dir_all( & out_dir) ) ;
700
700
t!( symlink_dir_force( & builder. config, & out, & out_dir) ) ;
701
701
702
+ let source_type = if $in_tree == true {
703
+ SourceType :: InTree
704
+ } else {
705
+ SourceType :: Submodule
706
+ } ;
707
+
702
708
// Build cargo command.
703
709
let mut cargo = prepare_tool_cargo(
704
710
builder,
@@ -707,7 +713,7 @@ macro_rules! tool_doc {
707
713
target,
708
714
"doc" ,
709
715
$path,
710
- SourceType :: InTree ,
716
+ source_type ,
711
717
& [ ] ,
712
718
) ;
713
719
@@ -723,20 +729,38 @@ macro_rules! tool_doc {
723
729
cargo. rustdocflag( "--show-type-layout" ) ;
724
730
cargo. rustdocflag( "--generate-link-to-definition" ) ;
725
731
cargo. rustdocflag( "-Zunstable-options" ) ;
726
- builder. run( & mut cargo. into( ) ) ;
732
+ if $in_tree == true {
733
+ builder. run( & mut cargo. into( ) ) ;
734
+ } else {
735
+ // Allow out-of-tree docs to fail (since the tool might be in a broken state).
736
+ if !builder. try_run( & mut cargo. into( ) ) {
737
+ builder. info( & format!(
738
+ "WARNING: tool {} failed to document; ignoring failure because it is an out-of-tree tool" ,
739
+ stringify!( $tool) . to_lowercase( ) ,
740
+ ) ) ;
741
+ }
742
+ }
727
743
}
728
744
}
729
745
}
730
746
}
731
747
732
- tool_doc ! ( Rustdoc , "rustdoc-tool" , "src/tools/rustdoc" , [ "rustdoc" , "rustdoc-json-types" ] ) ;
748
+ tool_doc ! (
749
+ Rustdoc ,
750
+ "rustdoc-tool" ,
751
+ "src/tools/rustdoc" ,
752
+ [ "rustdoc" , "rustdoc-json-types" ] ,
753
+ in_tree = true
754
+ ) ;
733
755
tool_doc ! (
734
756
Rustfmt ,
735
757
"rustfmt-nightly" ,
736
758
"src/tools/rustfmt" ,
737
759
[ "rustfmt-nightly" , "rustfmt-config_proc_macro" ] ,
760
+ in_tree = true
738
761
) ;
739
- tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , [ "clippy_utils" ] ) ;
762
+ tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , [ "clippy_utils" ] , in_tree = true ) ;
763
+ tool_doc ! ( Miri , "miri" , "src/tools/miri" , [ "miri" ] , in_tree = false ) ;
740
764
741
765
#[ derive( Ord , PartialOrd , Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
742
766
pub struct ErrorIndex {
0 commit comments