@@ -557,15 +557,8 @@ impl FixArgs {
557
557
if edition == "2018" { cmd. arg ( "-Wrust-2018-idioms" ) ; }
558
558
}
559
559
}
560
- match & self . prepare_for_edition {
561
- PrepareFor :: Edition ( edition) => {
562
- cmd. arg ( "-W" ) . arg ( format ! ( "rust-{}-compatibility" , edition) ) ;
563
- }
564
- PrepareFor :: Next => {
565
- let edition = self . next_edition ( ) ;
566
- cmd. arg ( "-W" ) . arg ( format ! ( "rust-{}-compatibility" , edition) ) ;
567
- }
568
- PrepareFor :: None => { }
560
+ if let Some ( edition) = self . prepare_for_edition_resolve ( ) {
561
+ cmd. arg ( "-W" ) . arg ( format ! ( "rust-{}-compatibility" , edition) ) ;
569
562
}
570
563
}
571
564
@@ -577,10 +570,9 @@ impl FixArgs {
577
570
/// actually be able to fix anything! If it looks like this is happening
578
571
/// then yield an error to the user, indicating that this is happening.
579
572
fn verify_not_preparing_for_enabled_edition ( & self ) -> CargoResult < ( ) > {
580
- let edition = match & self . prepare_for_edition {
581
- PrepareFor :: Edition ( s) => s,
582
- PrepareFor :: Next => self . next_edition ( ) ,
583
- PrepareFor :: None => return Ok ( ( ) ) ,
573
+ let edition = match self . prepare_for_edition_resolve ( ) {
574
+ Some ( s) => s,
575
+ None => return Ok ( ( ) ) ,
584
576
} ;
585
577
let enabled = match & self . enabled_edition {
586
578
Some ( s) => s,
@@ -609,10 +601,9 @@ impl FixArgs {
609
601
///
610
602
/// If this is the case, issue a warning.
611
603
fn warn_if_preparing_probably_inert ( & self ) -> CargoResult < ( ) > {
612
- let edition = match & self . prepare_for_edition {
613
- PrepareFor :: Edition ( s) => s,
614
- PrepareFor :: Next => self . next_edition ( ) ,
615
- PrepareFor :: None => return Ok ( ( ) ) ,
604
+ let edition = match self . prepare_for_edition_resolve ( ) {
605
+ Some ( s) => s,
606
+ None => return Ok ( ( ) ) ,
616
607
} ;
617
608
let path = match & self . file {
618
609
Some ( s) => s,
@@ -635,6 +626,14 @@ impl FixArgs {
635
626
Ok ( ( ) )
636
627
}
637
628
629
+ fn prepare_for_edition_resolve ( & self ) -> Option < & str > {
630
+ match & self . prepare_for_edition {
631
+ PrepareFor :: Edition ( s) => Some ( s) ,
632
+ PrepareFor :: Next => Some ( self . next_edition ( ) ) ,
633
+ PrepareFor :: None => None ,
634
+ }
635
+ }
636
+
638
637
fn next_edition ( & self ) -> & str {
639
638
match self . enabled_edition . as_ref ( ) . map ( |s| & * * s) {
640
639
// 2015 -> 2018,
0 commit comments