Problem
There are multiple Patch [...] was not used in the crate graph warnings when building a project using -Zbuild-std and -Zbuild-std-features=compiler-builtins-mem on nightly:
Warning output
warning: Patch
gimli v0.23.0 (/home/philipp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/vendor/gimli)was not used in the crate graph.
Patchobject v0.22.0 (/home/philipp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/vendor/object)was not used in the crate graph.
Patchadler v0.2.3 (/home/philipp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/vendor/adler)was not used in the crate graph.
Patchaddr2line v0.14.0 (/home/philipp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/vendor/addr2line)was not used in the crate graph.
Patchminiz_oxide v0.4.0 (/home/philipp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/vendor/miniz_oxide)was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, runcargo updateto use the new
version. This may also occur with an optional dependency that is not enabled.
Steps
cargo new --lib example && cd exampleecho "#![no_std]" > src/lib.rscargo +nightly check --target x86_64-unknown-linux-gnu -Z build-std=core -Zbuild-std-features=compiler-builtins-mem(The actual target doesn't seem to matter, the build-std feature just requires that we pass a --target argument.)
Notes
These warnings appeared between https://github.com/rust-lang/cargo/compare/d5556aeb8...2af662e22. My guess is that https://github.com/rust-lang/cargo/pull/8834 introduced them. They still happen on the latest nightly.
Output of cargo version:
cargo 1.50.0-nightly (d274fcf86 2020-12-07)
release: 1.50.0
commit-hash: d274fcf862b89264fa2c6b917b15230705257317
commit-date: 2020-12-07
Ah yes this is indeed caused by #8834. There's some discussion on https://github.com/rust-lang/cargo/issues/8962 about the impact of that PR and how we may back it out.
Are there currently any workarounds for this?
Oh this was actually fixed in https://github.com/rust-lang/cargo/pull/8968, and now it's just updating the Cargo submodule in rust-lang/rust. In the meantime there are no workarounds.
Most helpful comment
Ah yes this is indeed caused by #8834. There's some discussion on https://github.com/rust-lang/cargo/issues/8962 about the impact of that PR and how we may back it out.