@@ -217,9 +217,37 @@ impl PartialConfig {
217217
218218 :: toml:: to_string ( & cloned) . map_err ( ToTomlError )
219219 }
220+
221+ pub ( super ) fn to_parsed_config (
222+ self ,
223+ style_edition_override : Option < StyleEdition > ,
224+ edition_override : Option < Edition > ,
225+ dir : & Path ,
226+ ) -> Config {
227+ Config :: default_for_possible_style_edition (
228+ style_edition_override. or ( self . style_edition ) ,
229+ edition_override. or ( self . edition ) ,
230+ )
231+ . fill_from_parsed_config ( self , dir)
232+ }
220233}
221234
222235impl Config {
236+ pub fn default_for_possible_style_edition (
237+ style_edition : Option < StyleEdition > ,
238+ edition : Option < Edition > ,
239+ ) -> Config {
240+ style_edition. map_or_else (
241+ || {
242+ edition. map_or_else (
243+ || Config :: default ( ) ,
244+ |e| Self :: default_with_style_edition ( e. into ( ) ) ,
245+ )
246+ } ,
247+ |se| Self :: default_with_style_edition ( se) ,
248+ )
249+ }
250+
223251 pub ( crate ) fn version_meets_requirement ( & self ) -> bool {
224252 if self . was_set ( ) . required_version ( ) {
225253 let version = env ! ( "CARGO_PKG_VERSION" ) ;
@@ -324,12 +352,13 @@ impl Config {
324352 err. push_str ( msg)
325353 }
326354 }
327- match parsed. try_into ( ) {
355+
356+ match parsed. try_into :: < PartialConfig > ( ) {
328357 Ok ( parsed_config) => {
329358 if !err. is_empty ( ) {
330359 eprint ! ( "{err}" ) ;
331360 }
332- Ok ( Config :: default ( ) . fill_from_parsed_config ( parsed_config , dir) )
361+ Ok ( parsed_config . to_parsed_config ( None , None , dir) )
333362 }
334363 Err ( e) => {
335364 err. push_str ( "Error: Decoding config file failed:\n " ) ;
0 commit comments