@@ -188,9 +188,9 @@ impl FromStr for Bound {
188188}
189189
190190impl Bound {
191- fn sha ( self ) -> Result < String , Error > {
191+ fn sha ( & self ) -> Result < String , Error > {
192192 match self {
193- Bound :: Commit ( commit) => Ok ( commit) ,
193+ Bound :: Commit ( commit) => Ok ( commit. clone ( ) ) ,
194194 Bound :: Date ( date) => {
195195 let date_str = date. format ( YYYY_MM_DD ) ;
196196 let url = format ! (
@@ -213,7 +213,7 @@ impl Bound {
213213 }
214214 }
215215
216- fn as_commit ( self ) -> Result < Self , Error > {
216+ fn as_commit ( & self ) -> Result < Self , Error > {
217217 self . sha ( ) . map ( Bound :: Commit )
218218 }
219219}
@@ -246,31 +246,29 @@ impl Config {
246246
247247 let saw_ice = || -> bool { stderr_utf8. contains ( "error: internal compiler error" ) } ;
248248
249- let input = ( self . output_processing_mode ( ) , status. success ( ) ) ;
249+ let input = ( self . regress_on ( ) , status. success ( ) ) ;
250250 let result = match input {
251- ( OutputProcessingMode :: RegressOnErrorStatus , true ) => TestOutcome :: Baseline ,
252- ( OutputProcessingMode :: RegressOnErrorStatus , false ) => TestOutcome :: Regressed ,
253-
254- ( OutputProcessingMode :: RegressOnSuccessStatus , true ) => TestOutcome :: Regressed ,
255- ( OutputProcessingMode :: RegressOnSuccessStatus , false ) => TestOutcome :: Baseline ,
256-
257- ( OutputProcessingMode :: RegressOnIceAlone , _) => {
251+ ( RegressOn :: ErrorStatus , true ) => TestOutcome :: Baseline ,
252+ ( RegressOn :: ErrorStatus , false ) => TestOutcome :: Regressed ,
253+ ( RegressOn :: SuccessStatus , true ) => TestOutcome :: Regressed ,
254+ ( RegressOn :: SuccessStatus , false ) => TestOutcome :: Baseline ,
255+ ( RegressOn :: IceAlone , _) => {
258256 if saw_ice ( ) {
259257 TestOutcome :: Regressed
260258 } else {
261259 TestOutcome :: Baseline
262260 }
263261 }
264- ( OutputProcessingMode :: RegressOnNotIce , _) => {
262+ ( RegressOn :: NotIce , _) => {
265263 if saw_ice ( ) {
266264 TestOutcome :: Baseline
267265 } else {
268266 TestOutcome :: Regressed
269267 }
270268 }
271269
272- ( OutputProcessingMode :: RegressOnNonCleanError , true ) => TestOutcome :: Regressed ,
273- ( OutputProcessingMode :: RegressOnNonCleanError , false ) => {
270+ ( RegressOn :: NonCleanError , true ) => TestOutcome :: Regressed ,
271+ ( RegressOn :: NonCleanError , false ) => {
274272 if saw_ice ( ) {
275273 TestOutcome :: Regressed
276274 } else {
@@ -285,22 +283,22 @@ impl Config {
285283 result
286284 }
287285
288- fn output_processing_mode ( & self ) -> OutputProcessingMode {
286+ fn regress_on ( & self ) -> RegressOn {
289287 match self . args . regress . as_str ( ) {
290- "error" => OutputProcessingMode :: RegressOnErrorStatus ,
291- "non-error" => OutputProcessingMode :: RegressOnNonCleanError ,
292- "ice" => OutputProcessingMode :: RegressOnIceAlone ,
293- "non-ice" => OutputProcessingMode :: RegressOnNotIce ,
294- "success" => OutputProcessingMode :: RegressOnSuccessStatus ,
288+ "error" => RegressOn :: ErrorStatus ,
289+ "non-error" => RegressOn :: NonCleanError ,
290+ "ice" => RegressOn :: IceAlone ,
291+ "non-ice" => RegressOn :: NotIce ,
292+ "success" => RegressOn :: SuccessStatus ,
295293 setting => panic ! ( "Unknown --regress setting: {:?}" , setting) ,
296294 }
297295 }
298296}
299297
300298#[ derive( Copy , Clone , PartialEq , Eq , Debug , StructOpt ) ]
301299/// Customize what is treated as regression.
302- enum OutputProcessingMode {
303- /// `RegressOnErrorStatus `: Marks test outcome as `Regressed` if and only if
300+ enum RegressOn {
301+ /// `ErrorStatus `: Marks test outcome as `Regressed` if and only if
304302 /// the `rustc` process reports a non-success status. This corresponds to
305303 /// when `rustc` has an internal compiler error (ICE) or when it detects an
306304 /// error in the input program.
@@ -309,58 +307,54 @@ enum OutputProcessingMode {
309307 /// thus the default setting.
310308 ///
311309 /// You explicitly opt into this seting via `--regress=error`.
312- RegressOnErrorStatus ,
310+ ErrorStatus ,
313311
314- /// `RegressOnSuccessStatus `: Marks test outcome as `Regressed` if and only
312+ /// `SuccessStatus `: Marks test outcome as `Regressed` if and only
315313 /// if the `rustc` process reports a success status. This corresponds to
316314 /// when `rustc` believes it has successfully compiled the program. This
317315 /// covers the use case for when you want to bisect to see when a bug was
318316 /// fixed.
319317 ///
320318 /// You explicitly opt into this seting via `--regress=success`.
321- RegressOnSuccessStatus ,
319+ SuccessStatus ,
322320
323- /// `RegressOnIceAlone `: Marks test outcome as `Regressed` if and only if
321+ /// `IceAlone `: Marks test outcome as `Regressed` if and only if
324322 /// the `rustc` process issues a diagnostic indicating that an internal
325323 /// compiler error (ICE) occurred. This covers the use case for when you
326324 /// want to bisect to see when an ICE was introduced pon a codebase that is
327325 /// meant to produce a clean error.
328326 ///
329327 /// You explicitly opt into this seting via `--regress=ice`.
330- RegressOnIceAlone ,
328+ IceAlone ,
331329
332- /// `RegressOnNotIce `: Marks test outcome as `Regressed` if and only if
330+ /// `NotIce `: Marks test outcome as `Regressed` if and only if
333331 /// the `rustc` process does not issue a diagnostic indicating that an
334332 /// internal compiler error (ICE) occurred. This covers the use case for
335333 /// when you want to bisect to see when an ICE was fixed.
336334 ///
337335 /// You explicitly opt into this setting via `--regress=non-ice`
338- RegressOnNotIce ,
336+ NotIce ,
339337
340- /// `RegressOnNonCleanError `: Marks test outcome as `Baseline` if and only
338+ /// `NonCleanError `: Marks test outcome as `Baseline` if and only
341339 /// if the `rustc` process reports error status and does not issue any
342340 /// diagnostic indicating that an internal compiler error (ICE) occurred.
343341 /// This is the use case if the regression is a case where an ill-formed
344342 /// program has stopped being properly rejected by the compiler.
345343 ///
346- /// (The main difference between this case and `RegressOnSuccessStatus ` is
347- /// the handling of ICE: `RegressOnSuccessStatus ` assumes that ICE should be
348- /// considered baseline; `RegressOnNonCleanError ` assumes ICE should be
344+ /// (The main difference between this case and `SuccessStatus ` is
345+ /// the handling of ICE: `SuccessStatus ` assumes that ICE should be
346+ /// considered baseline; `NonCleanError ` assumes ICE should be
349347 /// considered a sign of a regression.)
350348 ///
351349 /// You explicitly opt into this seting via `--regress=non-error`.
352- RegressOnNonCleanError ,
350+ NonCleanError ,
353351}
354352
355- impl OutputProcessingMode {
353+ impl RegressOn {
356354 fn must_process_stderr ( & self ) -> bool {
357355 match self {
358- OutputProcessingMode :: RegressOnErrorStatus
359- | OutputProcessingMode :: RegressOnSuccessStatus => false ,
360-
361- OutputProcessingMode :: RegressOnNonCleanError
362- | OutputProcessingMode :: RegressOnIceAlone
363- | OutputProcessingMode :: RegressOnNotIce => true ,
356+ RegressOn :: ErrorStatus | RegressOn :: SuccessStatus => false ,
357+ RegressOn :: NonCleanError | RegressOn :: IceAlone | RegressOn :: NotIce => true ,
364358 }
365359 }
366360}
@@ -386,7 +380,7 @@ impl CommandTemplate {
386380 assert ! ( !self . 0 . is_empty( ) ) ;
387381 let mut s = self . 0 [ 0 ] . to_string ( ) ;
388382 for arg in & self . 0 [ 1 ..] {
389- s. push_str ( " " ) ;
383+ s. push ( ' ' ) ;
390384 s. push_str ( arg) ;
391385 }
392386 s
@@ -490,7 +484,7 @@ impl Config {
490484 }
491485
492486 let repo_access: Box < dyn RustRepositoryAccessor > ;
493- repo_access = match args. access . as_ref ( ) . map ( |x| x . as_str ( ) ) {
487+ repo_access = match args. access . as_deref ( ) {
494488 None | Some ( "checkout" ) => Box :: new ( AccessViaLocalGit ) ,
495489 Some ( "github" ) => Box :: new ( AccessViaGithub ) ,
496490 Some ( other) => bail ! ( "unknown access argument: {}" , other) ,
@@ -625,7 +619,7 @@ fn bisect(cfg: &Config, client: &Client) -> Result<(), Error> {
625619
626620fn searched_range (
627621 cfg : & Config ,
628- searched_toolchains : & Vec < Toolchain > ,
622+ searched_toolchains : & [ Toolchain ] ,
629623) -> ( ToolchainSpec , ToolchainSpec ) {
630624 let first_toolchain = searched_toolchains. first ( ) . unwrap ( ) . spec . clone ( ) ;
631625 let last_toolchain = searched_toolchains. last ( ) . unwrap ( ) . spec . clone ( ) ;
@@ -912,14 +906,13 @@ fn bisect_to_regression(
912906 cfg : & Config ,
913907 client : & Client ,
914908 dl_spec : & DownloadParams ,
915- ) -> Result < usize , InstallError > {
916- let found = least_satisfying ( & toolchains, |t| {
909+ ) -> usize {
910+ least_satisfying ( & toolchains, |t| {
917911 match install_and_test ( & t, & cfg, & client, & dl_spec) {
918912 Ok ( r) => r,
919913 Err ( _) => Satisfies :: Unknown ,
920914 }
921- } ) ;
922- Ok ( found)
915+ } )
923916}
924917
925918fn get_start_date ( cfg : & Config ) -> chrono:: Date < Utc > {
@@ -933,12 +926,10 @@ fn get_start_date(cfg: &Config) -> chrono::Date<Utc> {
933926fn get_end_date ( cfg : & Config ) -> chrono:: Date < Utc > {
934927 if let Some ( Bound :: Date ( date) ) = cfg. args . end {
935928 date
929+ } else if let Some ( date) = Toolchain :: default_nightly ( ) {
930+ date
936931 } else {
937- if let Some ( date) = Toolchain :: default_nightly ( ) {
938- date
939- } else {
940- chrono:: Utc :: now ( ) . date ( )
941- }
932+ chrono:: Utc :: now ( ) . date ( )
942933 }
943934}
944935
@@ -1043,7 +1034,8 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
10431034 }
10441035 }
10451036
1046- let first_success = first_success. ok_or ( format_err ! ( "could not find a nightly that built" ) ) ?;
1037+ let first_success =
1038+ first_success. ok_or_else ( || format_err ! ( "could not find a nightly that built" ) ) ?;
10471039
10481040 // confirm that the end of the date range has the regression
10491041 let mut t_end = Toolchain {
@@ -1076,7 +1068,7 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
10761068 ToolchainSpec :: Nightly { date : last_failure } ,
10771069 ) ;
10781070
1079- let found = bisect_to_regression ( & toolchains, & cfg, client, & dl_spec) ? ;
1071+ let found = bisect_to_regression ( & toolchains, & cfg, client, & dl_spec) ;
10801072
10811073 Ok ( BisectionResult {
10821074 dl_spec,
@@ -1158,7 +1150,7 @@ fn bisect_ci_via(
11581150 " commit[{}] {}: {}" ,
11591151 j,
11601152 commit. date. date( ) ,
1161- commit. summary. split( " \n " ) . next( ) . unwrap( )
1153+ commit. summary. split( '\n' ) . next( ) . unwrap( )
11621154 )
11631155 }
11641156
@@ -1242,7 +1234,7 @@ fn bisect_ci_in_commits(
12421234 }
12431235 }
12441236
1245- let found = bisect_to_regression ( & toolchains, & cfg, client, & dl_spec) ? ;
1237+ let found = bisect_to_regression ( & toolchains, & cfg, client, & dl_spec) ;
12461238
12471239 Ok ( BisectionResult {
12481240 searched : toolchains,
0 commit comments