@@ -195,9 +195,9 @@ impl FromStr for Bound {
195195}
196196
197197impl Bound {
198- fn sha ( self ) -> Result < String , Error > {
198+ fn sha ( & self ) -> Result < String , Error > {
199199 match self {
200- Bound :: Commit ( commit) => Ok ( commit) ,
200+ Bound :: Commit ( commit) => Ok ( commit. clone ( ) ) ,
201201 Bound :: Date ( date) => {
202202 let date_str = date. format ( YYYY_MM_DD ) ;
203203 let url = format ! (
@@ -220,7 +220,7 @@ impl Bound {
220220 }
221221 }
222222
223- fn as_commit ( self ) -> Result < Self , Error > {
223+ fn as_commit ( & self ) -> Result < Self , Error > {
224224 self . sha ( ) . map ( Bound :: Commit )
225225 }
226226}
@@ -253,31 +253,29 @@ impl Config {
253253
254254 let saw_ice = || -> bool { stderr_utf8. contains ( "error: internal compiler error" ) } ;
255255
256- let input = ( self . output_processing_mode ( ) , status. success ( ) ) ;
256+ let input = ( self . regress_on ( ) , status. success ( ) ) ;
257257 let result = match input {
258- ( OutputProcessingMode :: RegressOnErrorStatus , true ) => TestOutcome :: Baseline ,
259- ( OutputProcessingMode :: RegressOnErrorStatus , false ) => TestOutcome :: Regressed ,
260-
261- ( OutputProcessingMode :: RegressOnSuccessStatus , true ) => TestOutcome :: Regressed ,
262- ( OutputProcessingMode :: RegressOnSuccessStatus , false ) => TestOutcome :: Baseline ,
263-
264- ( OutputProcessingMode :: RegressOnIceAlone , _) => {
258+ ( RegressOn :: ErrorStatus , true ) => TestOutcome :: Baseline ,
259+ ( RegressOn :: ErrorStatus , false ) => TestOutcome :: Regressed ,
260+ ( RegressOn :: SuccessStatus , true ) => TestOutcome :: Regressed ,
261+ ( RegressOn :: SuccessStatus , false ) => TestOutcome :: Baseline ,
262+ ( RegressOn :: IceAlone , _) => {
265263 if saw_ice ( ) {
266264 TestOutcome :: Regressed
267265 } else {
268266 TestOutcome :: Baseline
269267 }
270268 }
271- ( OutputProcessingMode :: RegressOnNotIce , _) => {
269+ ( RegressOn :: NotIce , _) => {
272270 if saw_ice ( ) {
273271 TestOutcome :: Baseline
274272 } else {
275273 TestOutcome :: Regressed
276274 }
277275 }
278276
279- ( OutputProcessingMode :: RegressOnNonCleanError , true ) => TestOutcome :: Regressed ,
280- ( OutputProcessingMode :: RegressOnNonCleanError , false ) => {
277+ ( RegressOn :: NonCleanError , true ) => TestOutcome :: Regressed ,
278+ ( RegressOn :: NonCleanError , false ) => {
281279 if saw_ice ( ) {
282280 TestOutcome :: Regressed
283281 } else {
@@ -292,22 +290,22 @@ impl Config {
292290 result
293291 }
294292
295- fn output_processing_mode ( & self ) -> OutputProcessingMode {
293+ fn regress_on ( & self ) -> RegressOn {
296294 match self . args . regress . as_str ( ) {
297- "error" => OutputProcessingMode :: RegressOnErrorStatus ,
298- "non-error" => OutputProcessingMode :: RegressOnNonCleanError ,
299- "ice" => OutputProcessingMode :: RegressOnIceAlone ,
300- "non-ice" => OutputProcessingMode :: RegressOnNotIce ,
301- "success" => OutputProcessingMode :: RegressOnSuccessStatus ,
295+ "error" => RegressOn :: ErrorStatus ,
296+ "non-error" => RegressOn :: NonCleanError ,
297+ "ice" => RegressOn :: IceAlone ,
298+ "non-ice" => RegressOn :: NotIce ,
299+ "success" => RegressOn :: SuccessStatus ,
302300 setting => panic ! ( "Unknown --regress setting: {:?}" , setting) ,
303301 }
304302 }
305303}
306304
307305#[ derive( Copy , Clone , PartialEq , Eq , Debug , StructOpt ) ]
308306/// Customize what is treated as regression.
309- enum OutputProcessingMode {
310- /// `RegressOnErrorStatus `: Marks test outcome as `Regressed` if and only if
307+ enum RegressOn {
308+ /// `ErrorStatus `: Marks test outcome as `Regressed` if and only if
311309 /// the `rustc` process reports a non-success status. This corresponds to
312310 /// when `rustc` has an internal compiler error (ICE) or when it detects an
313311 /// error in the input program.
@@ -316,58 +314,54 @@ enum OutputProcessingMode {
316314 /// thus the default setting.
317315 ///
318316 /// You explicitly opt into this seting via `--regress=error`.
319- RegressOnErrorStatus ,
317+ ErrorStatus ,
320318
321- /// `RegressOnSuccessStatus `: Marks test outcome as `Regressed` if and only
319+ /// `SuccessStatus `: Marks test outcome as `Regressed` if and only
322320 /// if the `rustc` process reports a success status. This corresponds to
323321 /// when `rustc` believes it has successfully compiled the program. This
324322 /// covers the use case for when you want to bisect to see when a bug was
325323 /// fixed.
326324 ///
327325 /// You explicitly opt into this seting via `--regress=success`.
328- RegressOnSuccessStatus ,
326+ SuccessStatus ,
329327
330- /// `RegressOnIceAlone `: Marks test outcome as `Regressed` if and only if
328+ /// `IceAlone `: Marks test outcome as `Regressed` if and only if
331329 /// the `rustc` process issues a diagnostic indicating that an internal
332330 /// compiler error (ICE) occurred. This covers the use case for when you
333331 /// want to bisect to see when an ICE was introduced pon a codebase that is
334332 /// meant to produce a clean error.
335333 ///
336334 /// You explicitly opt into this seting via `--regress=ice`.
337- RegressOnIceAlone ,
335+ IceAlone ,
338336
339- /// `RegressOnNotIce `: Marks test outcome as `Regressed` if and only if
337+ /// `NotIce `: Marks test outcome as `Regressed` if and only if
340338 /// the `rustc` process does not issue a diagnostic indicating that an
341339 /// internal compiler error (ICE) occurred. This covers the use case for
342340 /// when you want to bisect to see when an ICE was fixed.
343341 ///
344342 /// You explicitly opt into this setting via `--regress=non-ice`
345- RegressOnNotIce ,
343+ NotIce ,
346344
347- /// `RegressOnNonCleanError `: Marks test outcome as `Baseline` if and only
345+ /// `NonCleanError `: Marks test outcome as `Baseline` if and only
348346 /// if the `rustc` process reports error status and does not issue any
349347 /// diagnostic indicating that an internal compiler error (ICE) occurred.
350348 /// This is the use case if the regression is a case where an ill-formed
351349 /// program has stopped being properly rejected by the compiler.
352350 ///
353- /// (The main difference between this case and `RegressOnSuccessStatus ` is
354- /// the handling of ICE: `RegressOnSuccessStatus ` assumes that ICE should be
355- /// considered baseline; `RegressOnNonCleanError ` assumes ICE should be
351+ /// (The main difference between this case and `SuccessStatus ` is
352+ /// the handling of ICE: `SuccessStatus ` assumes that ICE should be
353+ /// considered baseline; `NonCleanError ` assumes ICE should be
356354 /// considered a sign of a regression.)
357355 ///
358356 /// You explicitly opt into this seting via `--regress=non-error`.
359- RegressOnNonCleanError ,
357+ NonCleanError ,
360358}
361359
362- impl OutputProcessingMode {
360+ impl RegressOn {
363361 fn must_process_stderr ( & self ) -> bool {
364362 match self {
365- OutputProcessingMode :: RegressOnErrorStatus
366- | OutputProcessingMode :: RegressOnSuccessStatus => false ,
367-
368- OutputProcessingMode :: RegressOnNonCleanError
369- | OutputProcessingMode :: RegressOnIceAlone
370- | OutputProcessingMode :: RegressOnNotIce => true ,
363+ RegressOn :: ErrorStatus | RegressOn :: SuccessStatus => false ,
364+ RegressOn :: NonCleanError | RegressOn :: IceAlone | RegressOn :: NotIce => true ,
371365 }
372366 }
373367}
@@ -393,7 +387,7 @@ impl CommandTemplate {
393387 assert ! ( !self . 0 . is_empty( ) ) ;
394388 let mut s = self . 0 [ 0 ] . to_string ( ) ;
395389 for arg in & self . 0 [ 1 ..] {
396- s. push_str ( " " ) ;
390+ s. push ( ' ' ) ;
397391 s. push_str ( arg) ;
398392 }
399393 s
@@ -497,7 +491,7 @@ impl Config {
497491 }
498492
499493 let repo_access: Box < dyn RustRepositoryAccessor > ;
500- repo_access = match args. access . as_ref ( ) . map ( |x| x . as_str ( ) ) {
494+ repo_access = match args. access . as_deref ( ) {
501495 None | Some ( "checkout" ) => Box :: new ( AccessViaLocalGit ) ,
502496 Some ( "github" ) => Box :: new ( AccessViaGithub ) ,
503497 Some ( other) => bail ! ( "unknown access argument: {}" , other) ,
@@ -632,7 +626,7 @@ fn bisect(cfg: &Config, client: &Client) -> Result<(), Error> {
632626
633627fn searched_range (
634628 cfg : & Config ,
635- searched_toolchains : & Vec < Toolchain > ,
629+ searched_toolchains : & [ Toolchain ] ,
636630) -> ( ToolchainSpec , ToolchainSpec ) {
637631 let first_toolchain = searched_toolchains. first ( ) . unwrap ( ) . spec . clone ( ) ;
638632 let last_toolchain = searched_toolchains. last ( ) . unwrap ( ) . spec . clone ( ) ;
@@ -919,14 +913,13 @@ fn bisect_to_regression(
919913 cfg : & Config ,
920914 client : & Client ,
921915 dl_spec : & DownloadParams ,
922- ) -> Result < usize , InstallError > {
923- let found = least_satisfying ( & toolchains, |t| {
916+ ) -> usize {
917+ least_satisfying ( & toolchains, |t| {
924918 match install_and_test ( & t, & cfg, & client, & dl_spec) {
925919 Ok ( r) => r,
926920 Err ( _) => Satisfies :: Unknown ,
927921 }
928- } ) ;
929- Ok ( found)
922+ } )
930923}
931924
932925fn get_start_date ( cfg : & Config ) -> chrono:: Date < Utc > {
@@ -940,12 +933,10 @@ fn get_start_date(cfg: &Config) -> chrono::Date<Utc> {
940933fn get_end_date ( cfg : & Config ) -> chrono:: Date < Utc > {
941934 if let Some ( Bound :: Date ( date) ) = cfg. args . end {
942935 date
936+ } else if let Some ( date) = Toolchain :: default_nightly ( ) {
937+ date
943938 } else {
944- if let Some ( date) = Toolchain :: default_nightly ( ) {
945- date
946- } else {
947- chrono:: Utc :: now ( ) . date ( )
948- }
939+ chrono:: Utc :: now ( ) . date ( )
949940 }
950941}
951942
@@ -1050,7 +1041,8 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
10501041 }
10511042 }
10521043
1053- let first_success = first_success. ok_or ( format_err ! ( "could not find a nightly that built" ) ) ?;
1044+ let first_success =
1045+ first_success. ok_or_else ( || format_err ! ( "could not find a nightly that built" ) ) ?;
10541046
10551047 // confirm that the end of the date range has the regression
10561048 let mut t_end = Toolchain {
@@ -1083,7 +1075,7 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
10831075 ToolchainSpec :: Nightly { date : last_failure } ,
10841076 ) ;
10851077
1086- let found = bisect_to_regression ( & toolchains, & cfg, client, & dl_spec) ? ;
1078+ let found = bisect_to_regression ( & toolchains, & cfg, client, & dl_spec) ;
10871079
10881080 Ok ( BisectionResult {
10891081 dl_spec,
@@ -1165,7 +1157,7 @@ fn bisect_ci_via(
11651157 " commit[{}] {}: {}" ,
11661158 j,
11671159 commit. date. date( ) ,
1168- commit. summary. split( " \n " ) . next( ) . unwrap( )
1160+ commit. summary. split( '\n' ) . next( ) . unwrap( )
11691161 )
11701162 }
11711163
@@ -1249,7 +1241,7 @@ fn bisect_ci_in_commits(
12491241 }
12501242 }
12511243
1252- let found = bisect_to_regression ( & toolchains, & cfg, client, & dl_spec) ? ;
1244+ let found = bisect_to_regression ( & toolchains, & cfg, client, & dl_spec) ;
12531245
12541246 Ok ( BisectionResult {
12551247 searched : toolchains,
0 commit comments