@@ -146,7 +146,7 @@ impl Profiler {
146146
147147 // What cargo subcommand do we need to run for this profiler? If not
148148 // `rustc`, must be a subcommand that itself invokes `rustc`.
149- fn subcommand ( & self ) -> & ' static str {
149+ fn subcommand ( & self , build_kind : BuildKind ) -> Option < & ' static str > {
150150 match self {
151151 Profiler :: PerfStat
152152 | Profiler :: PerfStatSelfProfile
@@ -158,27 +158,14 @@ impl Profiler {
158158 | Profiler :: Callgrind
159159 | Profiler :: DHAT
160160 | Profiler :: Massif
161- | Profiler :: Eprintln => "rustc" ,
162- Profiler :: LlvmLines => "llvm-lines" ,
163- }
164- }
165-
166- fn is_build_kind_allowed ( & self , build_kind : BuildKind ) -> bool {
167- match self {
168- Profiler :: PerfStat
169- | Profiler :: PerfStatSelfProfile
170- | Profiler :: SelfProfile
171- | Profiler :: TimePasses
172- | Profiler :: PerfRecord
173- | Profiler :: OProfile
174- | Profiler :: Cachegrind
175- | Profiler :: Callgrind
176- | Profiler :: DHAT
177- | Profiler :: Massif
178- | Profiler :: Eprintln => true ,
161+ | Profiler :: Eprintln => if build_kind == BuildKind :: Doc {
162+ Some ( "rustdoc" )
163+ } else {
164+ Some ( "rustc" )
165+ } ,
179166 Profiler :: LlvmLines => match build_kind {
180- BuildKind :: Debug | BuildKind :: Opt => true ,
181- BuildKind :: Check | BuildKind :: Doc => false ,
167+ BuildKind :: Debug | BuildKind :: Opt => Some ( "rustc" ) ,
168+ BuildKind :: Check | BuildKind :: Doc => None ,
182169 }
183170 }
184171 }
@@ -268,23 +255,19 @@ impl<'a> CargoProcess<'a> {
268255 // machinery works).
269256 let subcommand = if let Some ( ( ref mut processor, run_kind, ..) ) = self . processor_etc {
270257 let profiler = processor. profiler ( ) ;
271- if !profiler. is_build_kind_allowed ( self . build_kind ) {
272- return Err ( anyhow:: anyhow!(
273- "this profiler doesn't support {:?} builds" ,
274- self . build_kind
275- ) ) ;
276- }
277258 if !profiler. is_run_kind_allowed ( run_kind) {
278259 return Err ( anyhow:: anyhow!(
279260 "this profiler doesn't support {:?} runs" ,
280261 run_kind
281262 ) ) ;
282263 }
283264
284- if self . build_kind == BuildKind :: Doc {
285- "rustdoc"
286- } else {
287- profiler. subcommand ( )
265+ match profiler. subcommand ( self . build_kind ) {
266+ None => return Err ( anyhow:: anyhow!(
267+ "this profiler doesn't support {:?} builds" ,
268+ self . build_kind
269+ ) ) ,
270+ Some ( sub) => sub,
288271 }
289272 } else {
290273 "rustc"
0 commit comments