@@ -146,7 +146,7 @@ impl Profiler {
146
146
147
147
// What cargo subcommand do we need to run for this profiler? If not
148
148
// `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 > {
150
150
match self {
151
151
Profiler :: PerfStat
152
152
| Profiler :: PerfStatSelfProfile
@@ -158,27 +158,14 @@ impl Profiler {
158
158
| Profiler :: Callgrind
159
159
| Profiler :: DHAT
160
160
| 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
+ } ,
179
166
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 ,
182
169
}
183
170
}
184
171
}
@@ -268,23 +255,19 @@ impl<'a> CargoProcess<'a> {
268
255
// machinery works).
269
256
let subcommand = if let Some ( ( ref mut processor, run_kind, ..) ) = self . processor_etc {
270
257
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
- }
277
258
if !profiler. is_run_kind_allowed ( run_kind) {
278
259
return Err ( anyhow:: anyhow!(
279
260
"this profiler doesn't support {:?} runs" ,
280
261
run_kind
281
262
) ) ;
282
263
}
283
264
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,
288
271
}
289
272
} else {
290
273
"rustc"
0 commit comments