Skip to content

Conversation

@enthropy7
Copy link
Contributor

fixed #2710 by ensuring unstable cargo flags (e.g., -Zbindeps) from [package.metadata.docs.rs] cargo-args are passed to all cargo commands, before it was only rustdoc. Added Metadata::unstable_cargo_flags() to extract -Z* flags and updated load_metadata_from_rustwide() and all cargo invocations (metadata, fetch, generate-lockfile, rustdoc) to accept and forward these flags. This lets crates using unstable features build on docs.rs. change is minimal, backward compatible, and follows existing patterns, covering all cargo commands to prevent failures at any stage. all tests added in 2 commits. 1-st demonstrate how it was before, 2-nd - how it works now (well).

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
- 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 will fail without the fix because:
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
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

This ensures that crates using unstable features like `bindeps` can
build successfully on docs.rs, as the required `-Z` flags are now
passed to all cargo invocations.

Tests:
- Update existing tests to verify `unstable_cargo_flags()` works correctly
- Update integration tests to verify the fix works end-to-end

Fixes: rust-lang#2710
@enthropy7 enthropy7 requested a review from a team as a code owner January 1, 2026 20:09
@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Jan 1, 2026
The peekable() iterator adapter was not being used (we never call peek()),
so it was flagged by lint-dependencies. Simplified to use a regular iterator
and call next() twice, which works the same way.
@enthropy7
Copy link
Contributor Author

r? @syphar take a look please if you have time :>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crates using unstable cargo feature bindeps are not buildable in docs.rs

2 participants