File tree 2 files changed +8
-5
lines changed
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,11 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
81
81
82
82
let mut opts = args. compile_options ( gctx, mode, Some ( & ws) , ProfileChecking :: LegacyTestOnly ) ?;
83
83
84
- if !opts. filter . is_specific ( ) {
85
- // cargo fix with no target selection implies `--all-targets`.
84
+ let edition = args. flag ( "edition" ) || args. flag ( "edition-idioms" ) ;
85
+ if !opts. filter . is_specific ( ) && edition {
86
+ // When `cargo fix` is run without specifying targets but with `--edition` or `--edition-idioms`,
87
+ // it should default to fixing all targets.
88
+ // See: https://github.com/rust-lang/cargo/issues/13527
86
89
opts. filter = ops:: CompileFilter :: new_all_targets ( ) ;
87
90
}
88
91
Original file line number Diff line number Diff line change @@ -805,7 +805,7 @@ fn does_not_warn_about_dirty_ignored_files() {
805
805
}
806
806
807
807
#[ cargo_test]
808
- fn fix_all_targets_by_default ( ) {
808
+ fn do_not_fix_tests ( ) {
809
809
let p = project ( )
810
810
. file ( "src/lib.rs" , "pub fn foo() { let mut x = 3; let _ = x; }" )
811
811
. file ( "tests/foo.rs" , "pub fn foo() { let mut x = 3; let _ = x; }" )
@@ -814,7 +814,7 @@ fn fix_all_targets_by_default() {
814
814
. env ( "__CARGO_FIX_YOLO" , "1" )
815
815
. run ( ) ;
816
816
assert ! ( !p. read_file( "src/lib.rs" ) . contains( "let mut x" ) ) ;
817
- assert ! ( ! p. read_file( "tests/foo.rs" ) . contains( "let mut x" ) ) ;
817
+ assert ! ( p. read_file( "tests/foo.rs" ) . contains( "let mut x" ) ) ;
818
818
}
819
819
820
820
#[ cargo_test]
@@ -1424,7 +1424,7 @@ fn fix_to_broken_code() {
1424
1424
p. cargo ( "build" ) . cwd ( "foo" ) . run ( ) ;
1425
1425
1426
1426
// Attempt to fix code, but our shim will always fail the second compile
1427
- p. cargo ( "fix --allow-no-vcs --broken-code" )
1427
+ p. cargo ( "fix --all-targets -- allow-no-vcs --broken-code" )
1428
1428
. cwd ( "bar" )
1429
1429
. env ( "RUSTC" , p. root ( ) . join ( "foo/target/debug/foo" ) )
1430
1430
. with_status ( 101 )
You can’t perform that action at this time.
0 commit comments