@@ -220,9 +220,17 @@ fn panic(_: &core::panic::PanicInfo) -> ! {
220220 Some ( target_dir) => target_dir,
221221 } ;
222222
223- let profile = match profile {
224- OptimisationProfile :: Release => "release" . to_string ( ) ,
225- OptimisationProfile :: Debug => "debug" . to_string ( ) ,
223+ // https://doc.rust-lang.org/cargo/guide/build-cache.html
224+ // > For historical reasons, the `dev` and `test` profiles are stored
225+ // > in the `debug` directory, and the `release` and `bench` profiles are
226+ // > stored in the `release` directory. User-defined profiles are
227+ // > stored in a directory with the same name as the profile.
228+
229+ let profile_dir = match & profile {
230+ OptimisationProfile :: Release => "release" ,
231+ OptimisationProfile :: Debug => "debug" ,
232+ OptimisationProfile :: Other ( profile) if profile == "bench" => "release" ,
233+ OptimisationProfile :: Other ( profile) if profile == "dev" || profile == "test" => "debug" ,
226234 OptimisationProfile :: Other ( custom_profile) => custom_profile,
227235 } ;
228236
@@ -234,7 +242,7 @@ fn panic(_: &core::panic::PanicInfo) -> ! {
234242 . collect ( )
235243 } )
236244 . iter ( )
237- . map ( |path| path. join ( & profile ) )
245+ . map ( |path| path. join ( profile_dir ) )
238246 . collect ( ) ;
239247
240248 for manifest in & self . manifests {
0 commit comments