IssueRaiser

Disabled optional weak dependencies end up in `Cargo.lock`

### Problem Lets say I have two crates, with these contents of `Cargo.toml`. The Rust code does not matter here. ```toml # foo/Cargo.toml [dependencies] serde = {version = "1.0.133", optional = true, default-features = false} time = {version = "=0.3.10", optional = true, default-features = false} chrono = {version = "=0.4.18", optional = true, default-features = false} [features] serialization = ["dep:serde", "time?/serde-well-known"] ``` ```toml # bar/Cargo.toml [dependencies] foo.features = ["serialization"] foo.path = "../foo" # time = "=0.3.11" # chrono = "=0.4.19" ``` As you can see, `bar` depends on `foo` and enables the `serialization` feature, but it does not enable the `time` nor the `chrono` feature. This results in the following `bar/Cargo.lock` file: <details> <summary><code>bar/Cargo.lock</code></summary> ```toml # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "app" version = "0.1.0" dependencies = [ "foo", ] [[package]] name = "foo" version = "0.1.0" dependencies = [ "serde", "time", ] [[package]] name = "itoa" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] name = "libc" version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] na

Posted by jonasbb on Jun 30, 2022, 5:31 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

github (SaaS)

Disabled optional weak dependencies end up in `Cargo.lock`

jonasbbJun 30, 2022, 5:31 PM

### Problem Lets say I have two crates, with these contents of `Cargo.toml`. The Rust code does not matter here. ```toml # foo/Cargo.toml [dependencies] serde = {version = "1.0.133", optional = true, default-features = false} time = {version = "=0.3.10", optional = true, default-features = false} chrono = {version = "=0.4.18", optional = true, default-features = false} [features] serialization = ["dep:serde", "time?/serde-well-known"] ``` ```toml # bar/Cargo.toml [dependencies] foo.features = ["serialization"] foo.path = "../foo" # time = "=0.3.11" # chrono = "=0.4.19" ``` As you can see, `bar` depends on `foo` and enables the `serialization` feature, but it does not enable the `time` nor the `chrono` feature. This results in the following `bar/Cargo.lock` file: <details> <summary><code>bar/Cargo.lock</code></summary> ```toml # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "app" version = "0.1.0" dependencies = [ "foo", ] [[package]] name = "foo" version = "0.1.0" dependencies = [ "serde", "time", ] [[package]] name = "itoa" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] name = "libc" version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] na

Comments (0)

No comments yet. Start the discussion.

Comment on this issue