File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 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 {
8181
8282 let mut opts = args. compile_options ( gctx, mode, Some ( & ws) , ProfileChecking :: LegacyTestOnly ) ?;
8383
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
8689 opts. filter = ops:: CompileFilter :: new_all_targets ( ) ;
8790 }
8891
Original file line number Diff line number Diff line change @@ -805,7 +805,7 @@ fn does_not_warn_about_dirty_ignored_files() {
805805}
806806
807807#[ cargo_test]
808- fn fix_all_targets_by_default ( ) {
808+ fn do_not_fix_tests_by_default ( ) {
809809 let p = project ( )
810810 . file ( "src/lib.rs" , "pub fn foo() { let mut x = 3; let _ = x; }" )
811811 . file ( "tests/foo.rs" , "pub fn foo() { let mut x = 3; let _ = x; }" )
@@ -814,7 +814,7 @@ fn fix_all_targets_by_default() {
814814 . env ( "__CARGO_FIX_YOLO" , "1" )
815815 . run ( ) ;
816816 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" ) ) ;
818818}
819819
820820#[ cargo_test]
@@ -1424,7 +1424,7 @@ fn fix_to_broken_code() {
14241424 p. cargo ( "build" ) . cwd ( "foo" ) . run ( ) ;
14251425
14261426 // 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" )
14281428 . cwd ( "bar" )
14291429 . env ( "RUSTC" , p. root ( ) . join ( "foo/target/debug/foo" ) )
14301430 . with_status ( 101 )
You can’t perform that action at this time.
0 commit comments