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
- 2026 - Microsoft Office 365
- [Ubuntu] `ubuntu-latest` label will use Ubuntu 26.04 in November 2026
- Gamut mapping
- [Codex Desktop] Editing and resending a queued message triggers "App-server queued follow-up no longer exists"
- [Windows] ChatGPT 26.820.60940 fails with "invalid transport in mcp_servers.codex_app"; Beta 26.727.40816 works
- [BUG]: infinite loading of videos
Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments
github (SaaS)
2026 - Microsoft Office 365
[Ubuntu] `ubuntu-latest` label will use Ubuntu 26.04 in November 2026
Gamut mapping
[Codex Desktop] Editing and resending a queued message triggers "App-server queued follow-up no longer exists"
[Windows] ChatGPT 26.820.60940 fails with "invalid transport in mcp_servers.codex_app"; Beta 26.727.40816 works
[BUG]: infinite loading of videos
Restore GPT-5.6 Sol’s 372k Codex context window, or provide an opt-in setting
Codex Desktop for macOS repeatedly triggers `syspolicyd` / `trustd` CPU and memory runaway
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
Comments (0)
No comments yet. Start the discussion.