bindeps failing build fix by enthropy7 · Pull Request #3111 · rust-lang/docs.rs

syphar

@enthropy7

This commit adds tests that demonstrate the problem: crates using
unstable cargo features like `-Zbindeps` fail to build because the
unstable flags from `cargo-args` are not passed to `cargo metadata`
and `cargo fetch` commands.

- Add test_bindeps_cargo_args_parsing() to verify cargo-args parsing
- Add test_bindeps_separate_args_parsing() for -Z bindeps style
- Add test_bindeps_crate_fails_without_unstable_flags() integration test
  that EXPECTS FAILURE (demonstrates the issue)
- Add test_load_metadata_signature_doesnt_accept_unstable_flags() to document the issue
- Add test crate tests/crates/bindeps-test/ with bindeps configuration

These tests demonstrate the issue:
1. load_metadata_from_rustwide() doesn't accept unstable flags parameter
2. cargo metadata/fetch are called without -Z flags from cargo-args
3. This causes builds to fail for crates using bindeps

See: rust-lang#2710

@enthropy7

This commit fixes issue rust-lang#2710 by ensuring that unstable cargo flags
(e.g., `-Zbindeps`) from `cargo-args` are passed to ALL cargo
commands, not just `cargo rustdoc`.

Changes:
- Add `Metadata::unstable_cargo_flags()` method to extract `-Z*` flags
  from `cargo-args`
- Update `load_metadata_from_rustwide()` to accept `unstable_flags`
  parameter and pass them to `cargo metadata`
- Update `build_local_package()` to read metadata and pass unstable flags
- Update `execute_build()` to pass unstable flags to `cargo metadata`
- Update fallback path (`cargo generate-lockfile`, `cargo fetch`) to
  pass unstable flags
- Remove unused `.peekable()` in `unstable_cargo_flags()` method
- Apply rustfmt formatting
- Update test to expect success (with fix)

syphar