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 @@ -734,6 +734,18 @@ impl CliOptions for GetOptsOptions {
734734 fn config_path ( & self ) -> Option < & Path > {
735735 self . config_path . as_deref ( )
736736 }
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+ }
737749}
738750
739751fn 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>(
376376 file_path : Option < & Path > ,
377377 options : Option < O > ,
378378) -> 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 ) ,
382386 } ;
383387
384388 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 {
419419 /// It is ok if the returned path doesn't exist or is not canonicalized
420420 /// (i.e. the callers are expected to handle such cases).
421421 fn config_path ( & self ) -> Option < & Path > ;
422+ fn edition ( & self ) -> Option < Edition > ;
423+ fn style_edition ( & self ) -> Option < StyleEdition > ;
422424}
423425
424426/// 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 {
8989 fn config_path ( & self ) -> Option < & Path > {
9090 unreachable ! ( ) ;
9191 }
92+ fn edition ( & self ) -> Option < rustfmt_nightly:: Edition > {
93+ unreachable ! ( ) ;
94+ }
95+ fn style_edition ( & self ) -> Option < rustfmt_nightly:: StyleEdition > {
96+ unreachable ! ( ) ;
97+ }
9298}
9399
94100fn uncommitted_files ( ) -> Vec < String > {
You can’t perform that action at this time.
0 commit comments