@@ -2,7 +2,6 @@ use std::collections::{BTreeSet, HashMap, HashSet};
22use std:: env;
33use std:: ffi:: OsStr ;
44use std:: path:: PathBuf ;
5- use std:: rc:: Rc ;
65
76use semver:: Version ;
87
@@ -76,7 +75,7 @@ pub struct Compilation<'cfg> {
7675 primary_unit_rustc_process : Option < ProcessBuilder > ,
7776
7877 target_runner : Option < ( PathBuf , Vec < String > ) > ,
79- rustc : Rc < Rustc > ,
78+ supports_rustdoc_crate_type : bool ,
8079}
8180
8281impl < ' cfg > Compilation < ' cfg > {
@@ -113,7 +112,7 @@ impl<'cfg> Compilation<'cfg> {
113112 host : bcx. host_triple ( ) . to_string ( ) ,
114113 target : bcx. target_triple ( ) . to_string ( ) ,
115114 target_runner : target_runner ( bcx) ?,
116- rustc : bcx. rustc . clone ( ) ,
115+ supports_rustdoc_crate_type : supports_rustdoc_crate_type ( bcx. config , & bcx . rustc ) ? ,
117116 } )
118117 }
119118
@@ -139,25 +138,14 @@ impl<'cfg> Compilation<'cfg> {
139138 Ok ( p)
140139 }
141140
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-
153141 /// See `process`.
154142 pub fn rustdoc_process ( & self , pkg : & Package , target : & Target ) -> CargoResult < ProcessBuilder > {
155143 let mut p = self . fill_env ( process ( & * self . config . rustdoc ( ) ?) , pkg, false ) ?;
156144 if target. edition ( ) != Edition :: Edition2015 {
157145 p. arg ( format ! ( "--edition={}" , target. edition( ) ) ) ;
158146 }
159147
160- if self . supports_rustdoc_crate_type ( ) ? {
148+ if self . supports_rustdoc_crate_type {
161149 for crate_type in target. rustc_crate_types ( ) {
162150 p. arg ( "--crate-type" ) . arg ( crate_type) ;
163151 }
@@ -331,3 +319,14 @@ fn target_runner(bcx: &BuildContext<'_, '_>) -> CargoResult<Option<(PathBuf, Vec
331319
332320 Ok ( None )
333321}
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