How do I "ignore" a member in a Cargo workspace?

⚓ Rust    📅 2025-08-28    👤 surdeus    👁️ 2      

surdeus

I have a workspace with 2 members:

  • foo which must build on 1.75 and uses Edition 2021
  • foo_tests which is a separate crate for tests. foo_test uses nightly and importantly uses Edition 2024

In my CI, I want to guarantee that foo can be built using:

cargo +1.75 build --package foo

The above command raises this error:

error: failed to load manifest for workspace member `foo_tests`

Caused by:
  failed to parse manifest at `foo_tests/Cargo.toml`

Caused by:
  feature `edition2024` is required

  The package requires the Cargo feature called `edition2024`, but
  that feature is not stabilized in this version of Cargo
  (1.75.0 (1d8b05cdd 2023-11-20)).

Because foo_tests uses Edition 2024 (which wasn't stabilized until 1.85) i cannot compile foo using Rust 1.75. However, I'd like to essentially completely ignore the foo_tests member.

What should I do if I want to continue using nightly and Edition 2024 for foo_tests, but also be able to compile foo with Rust 1.75 and Edition 2021?

I want to use Edition 2024 in foo_tests to be able to use let chains

Workspace

  • Cargo.toml:

    [workspace]
    members = [
      "foo",
      "foo_tests"
    ]
    
  • foo/Cargo.toml:

    [package]
    name = "foo"
    version = "0.1.0"
    edition = "2021"
    rust-version = "1.75.0"
    
  • foo_tests/Cargo.toml:

    [package]
    name = "foo_tests"
    version = "0.1.0"
    edition = "2024"
    

Things I have tried

  • Using the --exclude flag. Error: it can only be used with --workspace
  • Using --workspace --exclude foo_tests, but the same error is raised as in the original post

2 posts - 2 participants

Read full topic

🏷️ Rust_feed