File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838 - name : Build and Test
3939 env :
4040 RUSTFLAGS : -D warnings
41+ CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT : true
4142 run : cargo run --manifest-path ci/Cargo.toml build-and-test
Original file line number Diff line number Diff line change 3434 - name : Build and Test
3535 env :
3636 RUSTFLAGS : -D warnings
37+ CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT : true
3738 run : cargo run --manifest-path ci/Cargo.toml build-and-test
Original file line number Diff line number Diff line change 6060 - name : Build and Test
6161 env :
6262 RUSTFLAGS : -D warnings
63+ CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT : true
6364 run : cargo run --manifest-path ci/Cargo.toml build-and-test
Original file line number Diff line number Diff line change @@ -1130,8 +1130,23 @@ fn rustfmt() -> PathBuf {
11301130 let mut me = env:: current_exe ( ) . expect ( "failed to get current executable" ) ;
11311131 // Chop of the test name.
11321132 me. pop ( ) ;
1133- // Chop off `deps`.
1134- me. pop ( ) ;
1133+
1134+ // Handle Cargo's old and new filesystem layouts
1135+ // * v1: `target/<profile>/deps/test-bin-[HASH][EXE]`
1136+ // * v2: `target/<profile>/build/<pkgname>/[HASH]/out/test-bin-[HASH][EXE]`
1137+ if me. ends_with ( "deps" ) {
1138+ // Chop off `deps`.
1139+ me. pop ( ) ;
1140+ } else if me. ends_with ( "out" ) {
1141+ // Chop off `out`.
1142+ me. pop ( ) ;
1143+ // Chop off `<hash>`.
1144+ me. pop ( ) ;
1145+ // Chop off `<pkgname>`.
1146+ me. pop ( ) ;
1147+ // Chop off `build`.
1148+ me. pop ( ) ;
1149+ }
11351150
11361151 me. push ( "rustfmt" ) ;
11371152 assert ! (
Original file line number Diff line number Diff line change @@ -10,8 +10,17 @@ use rustfmt_config_proc_macro::rustfmt_only_ci_test;
1010fn cargo_fmt ( args : & [ & str ] ) -> ( String , String ) {
1111 let mut bin_dir = env:: current_exe ( ) . unwrap ( ) ;
1212 bin_dir. pop ( ) ; // chop off test exe name
13+
14+ // Handle Cargo's old and new filesystem layouts
15+ // * v1: `target/<profile>/deps/test-bin-[HASH][EXE]`
16+ // * v2: `target/<profile>/build/<pkgname>/[HASH]/out/test-bin-[HASH][EXE]`
1317 if bin_dir. ends_with ( "deps" ) {
1418 bin_dir. pop ( ) ;
19+ } else if bin_dir. ends_with ( "out" ) {
20+ bin_dir. pop ( ) ; // chop off `out`
21+ bin_dir. pop ( ) ; // chop off `<hash>`
22+ bin_dir. pop ( ) ; // chop off `<pkgname>`
23+ bin_dir. pop ( ) ; // chop off `build`
1524 }
1625 let cmd = bin_dir. join ( format ! ( "cargo-fmt{}" , env:: consts:: EXE_SUFFIX ) ) ;
1726
You can’t perform that action at this time.
0 commit comments