Bug 2152697

Summary: rust2rpm / rust-packaging doesn't support Rust 1.60+ features for optional and conditional dependencies
Product: [Fedora] Fedora Reporter: Fabio Valentini <decathorpe>
Component: rust-packagingAssignee: Rust SIG <rust-sig>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 38CC: decathorpe, fge, igor.raits, rust-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rust-packaging-24-1.fc39 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-02-16 18:43:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2169233    
Bug Blocks: 2117147, 2119164, 2125013, 2126224, 2136580, 2137029, 2137245, 2140158, 2140269, 2148310, 2166384, 2167496    

Description Fabio Valentini 2022-12-12 17:54:22 UTC
Cargo 1.60 introduced new syntax for specifying feature dependencies ("dep:foo" or "dep?/foo", for "optional dependencies" and "dependency features", respectively). rust2rpm, rust-packaging, and Rust RPM macros don't support this syntax, and packages can't be updated to versions of crates that start to use these features.

Tracked upstream here:
https://pagure.io/fedora-rust/rust2rpm/issue/186

Filed as tracking bug, so updates that are blocked by this missing feature can be marked appropriately.

Comment 1 Fabio Valentini 2023-01-16 20:25:32 UTC
*** Bug 2161128 has been marked as a duplicate of this bug. ***

Comment 2 Gris Ge 2023-01-20 07:44:34 UTC
Hi Fabio,

In case you didn't noticed, currently rust packaging tool is treating __every__ dependency as a internal feature.

For example, the rust-rtnetlink has Cargo.toml

[features]
test_as_root = []
default = ["tokio_socket"]
tokio_socket = ["netlink-proto/tokio_socket", "tokio"]
smol_socket = ["netlink-proto/smol_socket", "async-global-executor"]


Then fedora packaging tool is treating `tokio` as a feature: `rust-rtnetlink+tokio-devel.noarch`.

A lot rust crate package is impacted on this.

Comment 3 Fabio Valentini 2023-01-20 12:26:13 UTC
Hi Gris - it looks like there's a misunderstanding here.
I am well aware about how our rust packaging works, and the behaviour is correct. :)

In cargo, optional dependencies *are* features. And up until Rust 1.60, there was no way to discriminate between optional dependencies that are supposed to be "internal" (i.e. implenentation details) or "public".

In your example, "tokio" is indeed an optional dependency, which is turned into a feature by cargo.

Now, what's new with Rust 1.60 is that you can actually mark optional dependencies as "private", in your example, that would look like using
tokio_socket = ["netlink-proto/tokio_socket", "dep:tokio"]
instead of
tokio_socket = ["netlink-proto/tokio_socket", "tokio"]
as cargo now no longer generates implicit features for optional dependencies if they are referenced like "dep:foo".

This new syntax is what our tools don't understand yet. But for packages that *don't* use this syntax, the generated feature subpackages *are correct* and match upstream cargo behaviour.

Comment 4 Ben Cotton 2023-02-07 15:00:40 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 5 Fedora Update System 2023-02-16 18:41:21 UTC
FEDORA-2023-77a65a092d has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-77a65a092d

Comment 6 Fedora Update System 2023-02-16 18:43:10 UTC
FEDORA-2023-77a65a092d has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.