File tree Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -733,6 +733,18 @@ impl CliOptions for GetOptsOptions {
733
733
fn config_path ( & self ) -> Option < & Path > {
734
734
self . config_path . as_deref ( )
735
735
}
736
+
737
+ fn edition ( & self ) -> Option < Edition > {
738
+ self . inline_config
739
+ . get ( "edition" )
740
+ . map_or ( self . edition , |e| Edition :: from_str ( e) . ok ( ) )
741
+ }
742
+
743
+ fn style_edition ( & self ) -> Option < StyleEdition > {
744
+ self . inline_config
745
+ . get ( "style_edition" )
746
+ . map_or ( self . style_edition , |se| StyleEdition :: from_str ( se) . ok ( ) )
747
+ }
736
748
}
737
749
738
750
fn edition_from_edition_str ( edition_str : & str ) -> Result < Edition > {
Original file line number Diff line number Diff line change @@ -376,9 +376,13 @@ pub fn load_config<O: CliOptions>(
376
376
file_path : Option < & Path > ,
377
377
options : Option < O > ,
378
378
) -> Result < ( Config , Option < PathBuf > ) , Error > {
379
- let over_ride = match options {
380
- Some ( ref opts) => config_path ( opts) ?,
381
- None => None ,
379
+ let ( over_ride, _edition, _style_edition) = match options {
380
+ Some ( ref opts) => (
381
+ config_path ( opts) ?,
382
+ opts. edition ( ) ,
383
+ opts. style_edition ( ) ,
384
+ ) ,
385
+ None => ( None , None , None ) ,
382
386
} ;
383
387
384
388
let result = if let Some ( over_ride) = over_ride {
Original file line number Diff line number Diff line change @@ -416,6 +416,8 @@ impl FromStr for IgnoreList {
416
416
pub trait CliOptions {
417
417
fn apply_to ( self , config : & mut Config ) ;
418
418
fn config_path ( & self ) -> Option < & Path > ;
419
+ fn edition ( & self ) -> Option < Edition > ;
420
+ fn style_edition ( & self ) -> Option < StyleEdition > ;
419
421
}
420
422
421
423
/// The edition of the syntax and semantics of code (RFC 2052).
Original file line number Diff line number Diff line change @@ -85,6 +85,12 @@ impl CliOptions for NullOptions {
85
85
fn config_path ( & self ) -> Option < & Path > {
86
86
unreachable ! ( ) ;
87
87
}
88
+ fn edition ( & self ) -> Option < rustfmt_nightly:: Edition > {
89
+ unreachable ! ( ) ;
90
+ }
91
+ fn style_edition ( & self ) -> Option < rustfmt_nightly:: StyleEdition > {
92
+ unreachable ! ( ) ;
93
+ }
88
94
}
89
95
90
96
fn uncommitted_files ( ) -> Vec < String > {
You can’t perform that action at this time.
0 commit comments