diff --git a/pkgs/build-support/rust/build-rust-crate/lib.sh b/pkgs/build-support/rust/build-rust-crate/lib.sh index 7f98701b5409..0181ae432c85 100644 --- a/pkgs/build-support/rust/build-rust-crate/lib.sh +++ b/pkgs/build-support/rust/build-rust-crate/lib.sh @@ -78,6 +78,10 @@ build_bin_test() { build_bin_test_file() { local file="$1" local derived_crate_name="${file//\//_}" + # Make sure to strip the top level `tests` directory: see #204051. Note that + # a forward slash has now become an underscore due to the substitution + # above. + derived_crate_name=${derived_crate_name#"tests_"} derived_crate_name="${derived_crate_name%.rs}" build_bin_test "$derived_crate_name" "$file" }