Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolver did not set to 2 by default in workspaces #9956

Closed
harrier-lcc opened this issue Oct 4, 2021 · 1 comment · Fixed by rust-lang/edition-guide#267
Closed

Resolver did not set to 2 by default in workspaces #9956

harrier-lcc opened this issue Oct 4, 2021 · 1 comment · Fixed by rust-lang/edition-guide#267
Assignees
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-bug Category: bug

Comments

@harrier-lcc
Copy link

Problem
I have a cargo workspace with 2 packages, all set to edition = "2021". However, this do not set to use the resolver 2 by default, which is misleading.

This can be solved by setting resolver = "2" in workspace Cargo.toml (not in the package Cargo.toml) manually, but this is misleading as one would expect using edition = "2021" will set resolver default to be 2.

setting resolver = "2" directly in the package does generate an warning:
warning: resolver for the non root package will be ignored, specify resolver at the workspace root:.

The rust 2021 edition guide says:
edition = "2021" implies resolver = "2" in Cargo.toml., but this is simply not true in the case of workspace; and edition do not work in workspace Cargo.toml as well.

Steps

  1. Setup an cargo workspace with one package

Cargo.toml:

[workspace]

members = [
   "dev-resolver"
]

dev-resolver/Cargo.toml

[package]
name = "dev-resolver"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
p256 = { version = "0.9.0", features = ["ecdsa"], default-features = false }

[dev-dependencies]
rand_core = { version = "0.6.3", features = ["getrandom"] }
  1. cargo build. getrandom is compiled.

  2. Set resolver = "2" in workspace Cargo.toml then cargo build, getrandom is not compiled.

Possible Solution(s)

This have to be add in the documentation.

For rust 2021 (and thus nightly), I suggest to set this automatically (i.e. workspace resolver by default uses resolver 2).

Notes

Output of cargo version:
cargo 1.57.0-nightly (0121d66aa 2021-09-22)

@ehuss
Copy link
Contributor

ehuss commented Oct 4, 2021

Thanks for the report! I have posted rust-lang/edition-guide#267 to try to clarify how this works.

Cargo currently doesn't allow setting a global edition for a virtual workspace. That is tracked in #5784.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants