Should we always use resolver=2 in workspaces?

The Rust 1.51.0 release blog post explains the benefits of the new resolver.
The edition guide states that the new resolver is automatically enabled for 2021 edition crates.

It also says that it is not automatically enabled for workspaces. This leads me to wonder whether we should in general always enable the new resolver in workspaces. Is there any reason to not do this? Is it good practice to do this?

1 Like

The reason this isn't done by default is because it would be a breaking change. The new resolver behaves different from the old resolver. Of it didn't, we wouldn't have exposed a way to switch between the two in the first place.

I figured this was the reason for not changing the default. My question is whether I in my crates should change the resolver in the same sense that I have interest in setting the edition to 2021 because in general things get better with newer versions, not whether Rust/Cargo should change the default.

I found that edition guide blurb rather confusing.

Anyway, I think the only reason you have to opt-in with resolver = "2" in a virtual workspace is that you can't set edition under [workspace] (and a virtual workspace has no [package] under which to do so either). See the bottom of that issue for some closed-as-dupe issues about this topic.

(I say "only reason" but basically the clash is that edition is (currently) per-crate, and resolver is per-workspace, but the former is being used to determine the default of the latter in the root package of a workspace. No root package, no way to override the default.)

TL;DR: if you would have used edition = "2021" in a non-virtual-workspace crate, set resolver = "2" in your virtual workspace crate.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.