@@ -69,6 +69,16 @@ const ESSENTIAL_FILES_UNVERSIONED: &[&str] = &[
69
69
const DUMMY_CRATE_NAME : & str = "empty-library" ;
70
70
const DUMMY_CRATE_VERSION : & str = "1.0.0" ;
71
71
72
+ // This macro exists because of lifetimes issues surrounding the `Command::process_lines` method:
73
+ // it expects a mutable reference to a closure, in which we capture a variable in order to store
74
+ // the JSON output. Unfortunately, we *need* to create the command in the same scope level otherwise
75
+ // rustc becomes very grumpy about the fact that the variable needs to be static because it is
76
+ // captured in a mutably referenced closure.
77
+ //
78
+ // So either you create a function with a callback in which you pass the `Command` as an argument,
79
+ // or you create a function returning a `Command`, it's very unhappy in both cases.
80
+ //
81
+ // TODO: make `Command::process_lines` take the closure by value rather than a mutable reference.
72
82
macro_rules! config_command {
73
83
( $obj: ident, $build: expr, $target: expr, $metadata: expr, $limits: expr, $rustdoc_flags_extras: expr, $( $extra: tt) +) => { {
74
84
let mut cargo_args = vec![ "doc" , "--lib" , "--no-deps" ] ;
@@ -109,6 +119,11 @@ macro_rules! config_command {
109
119
"--cap-lints" . to_string( ) ,
110
120
"warn" . to_string( ) ,
111
121
] ;
122
+
123
+ if let Some ( package_rustdoc_args) = & $metadata. rustdoc_args {
124
+ rustdoc_flags. append( & mut package_rustdoc_args. clone( ) ) ;
125
+ }
126
+
112
127
rustdoc_flags. extend( $rustdoc_flags_extras) ;
113
128
114
129
$build
@@ -603,9 +618,6 @@ impl RustwideBuilder {
603
618
dep. version
604
619
) ) ;
605
620
}
606
- if let Some ( package_rustdoc_args) = & metadata. rustdoc_args {
607
- rustdoc_flags. append ( & mut package_rustdoc_args. iter ( ) . map ( |s| s. to_owned ( ) ) . collect ( ) ) ;
608
- }
609
621
610
622
rustdoc_flags. extend ( vec ! [
611
623
"--resource-suffix" . to_string( ) ,
0 commit comments