@@ -2,7 +2,6 @@ use std::collections::{BTreeSet, HashMap, HashSet};
2
2
use std:: env;
3
3
use std:: ffi:: OsStr ;
4
4
use std:: path:: PathBuf ;
5
- use std:: rc:: Rc ;
6
5
7
6
use semver:: Version ;
8
7
@@ -76,7 +75,7 @@ pub struct Compilation<'cfg> {
76
75
primary_unit_rustc_process : Option < ProcessBuilder > ,
77
76
78
77
target_runner : Option < ( PathBuf , Vec < String > ) > ,
79
- rustc : Rc < Rustc > ,
78
+ supports_rustdoc_crate_type : bool ,
80
79
}
81
80
82
81
impl < ' cfg > Compilation < ' cfg > {
@@ -113,7 +112,7 @@ impl<'cfg> Compilation<'cfg> {
113
112
host : bcx. host_triple ( ) . to_string ( ) ,
114
113
target : bcx. target_triple ( ) . to_string ( ) ,
115
114
target_runner : target_runner ( bcx) ?,
116
- rustc : bcx. rustc . clone ( ) ,
115
+ supports_rustdoc_crate_type : supports_rustdoc_crate_type ( bcx. config , & bcx . rustc ) ? ,
117
116
} )
118
117
}
119
118
@@ -139,25 +138,14 @@ impl<'cfg> Compilation<'cfg> {
139
138
Ok ( p)
140
139
}
141
140
142
- fn supports_rustdoc_crate_type ( & self ) -> CargoResult < bool > {
143
- // NOTE: Unconditionally return 'true' once support for
144
- // rustdoc '--crate-type' rides to stable
145
- let mut crate_type_test = process ( self . config . rustdoc ( ) ?) ;
146
- // If '--crate-type' is not supported by rustcoc, this command
147
- // will exit with an error. Otherwise, it will print a help message,
148
- // and exit successfully
149
- crate_type_test. args ( & [ "--crate-type" , "proc-macro" , "--help" ] ) ;
150
- Ok ( self . rustc . cached_output ( & crate_type_test) . is_ok ( ) )
151
- }
152
-
153
141
/// See `process`.
154
142
pub fn rustdoc_process ( & self , pkg : & Package , target : & Target ) -> CargoResult < ProcessBuilder > {
155
143
let mut p = self . fill_env ( process ( & * self . config . rustdoc ( ) ?) , pkg, false ) ?;
156
144
if target. edition ( ) != Edition :: Edition2015 {
157
145
p. arg ( format ! ( "--edition={}" , target. edition( ) ) ) ;
158
146
}
159
147
160
- if self . supports_rustdoc_crate_type ( ) ? {
148
+ if self . supports_rustdoc_crate_type {
161
149
for crate_type in target. rustc_crate_types ( ) {
162
150
p. arg ( "--crate-type" ) . arg ( crate_type) ;
163
151
}
@@ -331,3 +319,14 @@ fn target_runner(bcx: &BuildContext<'_, '_>) -> CargoResult<Option<(PathBuf, Vec
331
319
332
320
Ok ( None )
333
321
}
322
+
323
+ fn supports_rustdoc_crate_type ( config : & Config , rustc : & Rustc ) -> CargoResult < bool > {
324
+ // NOTE: Unconditionally return 'true' once support for
325
+ // rustdoc '--crate-type' rides to stable
326
+ let mut crate_type_test = process ( config. rustdoc ( ) ?) ;
327
+ // If '--crate-type' is not supported by rustcoc, this command
328
+ // will exit with an error. Otherwise, it will print a help message,
329
+ // and exit successfully
330
+ crate_type_test. args ( & [ "--crate-type" , "proc-macro" , "--help" ] ) ;
331
+ Ok ( rustc. cached_output ( & crate_type_test) . is_ok ( ) )
332
+ }
0 commit comments