@@ -217,9 +217,37 @@ impl PartialConfig {
217
217
218
218
:: toml:: to_string ( & cloned) . map_err ( ToTomlError )
219
219
}
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
+ }
220
233
}
221
234
222
235
impl 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
+
223
251
pub ( crate ) fn version_meets_requirement ( & self ) -> bool {
224
252
if self . was_set ( ) . required_version ( ) {
225
253
let version = env ! ( "CARGO_PKG_VERSION" ) ;
@@ -324,12 +352,13 @@ impl Config {
324
352
err. push_str ( msg)
325
353
}
326
354
}
327
- match parsed. try_into ( ) {
355
+
356
+ match parsed. try_into :: < PartialConfig > ( ) {
328
357
Ok ( parsed_config) => {
329
358
if !err. is_empty ( ) {
330
359
eprint ! ( "{err}" ) ;
331
360
}
332
- Ok ( Config :: default ( ) . fill_from_parsed_config ( parsed_config , dir) )
361
+ Ok ( parsed_config . to_parsed_config ( None , None , dir) )
333
362
}
334
363
Err ( e) => {
335
364
err. push_str ( "Error: Decoding config file failed:\n " ) ;
0 commit comments