Skip to content

Conversation

@bonzini
Copy link
Collaborator

@bonzini bonzini commented Nov 28, 2025

A couple fixes found while porting libblkio to use rust.workspace().

A minor one is that cfg(test) was causing warnings.

The more important one is that rustix failed to build because it attempted to load rustc-std-workspace-alloc. To fix this, handle the implicit feature for optional dependencies at the time of Manifest.from_raw, instead of doing so at interpretation time.

It should be added even if unexpected_cfgs is not part of Cargo.toml.

Signed-off-by: Paolo Bonzini <[email protected]>
@bonzini bonzini added bug dependencies:cargo Issues related to using cargo subprojects labels Nov 28, 2025
@bonzini bonzini added this to the 1.11 milestone Nov 28, 2025
Make the implicit `xyz = ["dep:xyz"]` declaration explicit in the Manifest.
This also makes it possible to implement correctly the part of the spec where
"If you specify the optional dependency with the dep: prefix anywhere in
the [features] table, that disables the implicit feature."

Unfortunately, this can only be done after target-specific configurations
are resolved, which makes it hard to write a unit test for this.  Rustix
requires it, though; without this patch, something like

        [package]
        name = "rustix"
        edition = "2021"
        rust-version = "1.63"
        version = "0.38.34"

        [dependencies]
        alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" }
        libc = { version = "0.2.0", optional = true, package = "libc" }
        libc_errno = { version = "0.3.8", optional = true, package = "errno" }

        [features]
        alloc = []
        default = ["std"]
        rustc-dep-of-std = ["dep:alloc"]
        std = ["alloc"]
        use-libc = ["libc_errno", "libc"]

would incorrectly request the rustc-std-workspace-alloc crate via the
chain default->std->alloc.  The patch blocks it because it finds the
"dep:alloc" dependency of feature rustc-dep-of-std.

Signed-off-by: Paolo Bonzini <[email protected]>
@bonzini bonzini marked this pull request as ready for review November 28, 2025 19:12
@bonzini bonzini requested a review from jpakkane as a code owner November 28, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug dependencies:cargo Issues related to using cargo subprojects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant