@@ -330,7 +330,7 @@ pub fn fix_maybe_exec_rustc(config: &Config) -> CargoResult<bool> {
330330 // that we have to back it all out.
331331 if !fixes. files . is_empty ( ) {
332332 let mut cmd = rustc. build_command ( ) ;
333- args. apply ( & mut cmd) ;
333+ args. apply ( & mut cmd, config ) ;
334334 cmd. arg ( "--error-format=json" ) ;
335335 let output = cmd. output ( ) . context ( "failed to spawn rustc" ) ?;
336336
@@ -369,7 +369,7 @@ pub fn fix_maybe_exec_rustc(config: &Config) -> CargoResult<bool> {
369369 // - If `--broken-code`, show the error messages.
370370 // - If the fix succeeded, show any remaining warnings.
371371 let mut cmd = rustc. build_command ( ) ;
372- args. apply ( & mut cmd) ;
372+ args. apply ( & mut cmd, config ) ;
373373 for arg in args. format_args {
374374 // Add any json/error format arguments that Cargo wants. This allows
375375 // things like colored output to work correctly.
@@ -457,7 +457,7 @@ fn rustfix_crate(
457457 // We'll generate new errors below.
458458 file. errors_applying_fixes . clear ( ) ;
459459 }
460- rustfix_and_fix ( & mut fixes, rustc, filename, args) ?;
460+ rustfix_and_fix ( & mut fixes, rustc, filename, args, config ) ?;
461461 let mut progress_yet_to_be_made = false ;
462462 for ( path, file) in fixes. files . iter_mut ( ) {
463463 if file. errors_applying_fixes . is_empty ( ) {
@@ -499,14 +499,15 @@ fn rustfix_and_fix(
499499 rustc : & ProcessBuilder ,
500500 filename : & Path ,
501501 args : & FixArgs ,
502+ config : & Config ,
502503) -> Result < ( ) , Error > {
503504 // If not empty, filter by these lints.
504505 // TODO: implement a way to specify this.
505506 let only = HashSet :: new ( ) ;
506507
507508 let mut cmd = rustc. build_command ( ) ;
508509 cmd. arg ( "--error-format=json" ) ;
509- args. apply ( & mut cmd) ;
510+ args. apply ( & mut cmd, config ) ;
510511 let output = cmd. output ( ) . with_context ( || {
511512 format ! (
512513 "failed to execute `{}`" ,
@@ -763,7 +764,7 @@ impl FixArgs {
763764 } )
764765 }
765766
766- fn apply ( & self , cmd : & mut Command ) {
767+ fn apply ( & self , cmd : & mut Command , config : & Config ) {
767768 cmd. arg ( & self . file ) ;
768769 cmd. args ( & self . other ) . arg ( "--cap-lints=warn" ) ;
769770 if let Some ( edition) = self . enabled_edition {
@@ -775,7 +776,13 @@ impl FixArgs {
775776
776777 if let Some ( edition) = self . prepare_for_edition {
777778 if edition. supports_compat_lint ( ) {
778- cmd. arg ( "-W" ) . arg ( format ! ( "rust-{}-compatibility" , edition) ) ;
779+ if config. nightly_features_allowed {
780+ cmd. arg ( "--force-warns" )
781+ . arg ( format ! ( "rust-{}-compatibility" , edition) )
782+ . arg ( "-Zunstable-options" ) ;
783+ } else {
784+ cmd. arg ( "-W" ) . arg ( format ! ( "rust-{}-compatibility" , edition) ) ;
785+ }
779786 }
780787 }
781788 }
0 commit comments