File tree 4 files changed +27
-3
lines changed
4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -734,6 +734,18 @@ impl CliOptions for GetOptsOptions {
734
734
fn config_path ( & self ) -> Option < & Path > {
735
735
self . config_path . as_deref ( )
736
736
}
737
+
738
+ fn edition ( & self ) -> Option < Edition > {
739
+ self . inline_config
740
+ . get ( "edition" )
741
+ . map_or ( self . edition , |e| Edition :: from_str ( e) . ok ( ) )
742
+ }
743
+
744
+ fn style_edition ( & self ) -> Option < StyleEdition > {
745
+ self . inline_config
746
+ . get ( "style_edition" )
747
+ . map_or ( self . style_edition , |se| StyleEdition :: from_str ( se) . ok ( ) )
748
+ }
737
749
}
738
750
739
751
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 @@ -419,6 +419,8 @@ pub trait CliOptions {
419
419
/// It is ok if the returned path doesn't exist or is not canonicalized
420
420
/// (i.e. the callers are expected to handle such cases).
421
421
fn config_path ( & self ) -> Option < & Path > ;
422
+ fn edition ( & self ) -> Option < Edition > ;
423
+ fn style_edition ( & self ) -> Option < StyleEdition > ;
422
424
}
423
425
424
426
/// The edition of the syntax and semantics of code (RFC 2052).
Original file line number Diff line number Diff line change @@ -89,6 +89,12 @@ impl CliOptions for NullOptions {
89
89
fn config_path ( & self ) -> Option < & Path > {
90
90
unreachable ! ( ) ;
91
91
}
92
+ fn edition ( & self ) -> Option < rustfmt_nightly:: Edition > {
93
+ unreachable ! ( ) ;
94
+ }
95
+ fn style_edition ( & self ) -> Option < rustfmt_nightly:: StyleEdition > {
96
+ unreachable ! ( ) ;
97
+ }
92
98
}
93
99
94
100
fn uncommitted_files ( ) -> Vec < String > {
You can’t perform that action at this time.
0 commit comments