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

Allow resolver="1" to explicitly use the old resolver behavior. #8857

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cargo/core/resolver/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ pub enum ResolveBehavior {
impl ResolveBehavior {
pub fn from_manifest(resolver: &str) -> CargoResult<ResolveBehavior> {
match resolver {
"1" => Ok(ResolveBehavior::V1),
"2" => Ok(ResolveBehavior::V2),
s => anyhow::bail!(
"`resolver` setting `{}` is not valid, only valid option is \"2\"",
"`resolver` setting `{}` is not valid, valid options are \"1\" or \"2\"",
s
),
}
Expand Down
6 changes: 3 additions & 3 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,9 @@ version = "1.0.0"
resolver = "2"
```

Currently the only allowed value is `"2"`. This declaration enables all of the
new feature behavior of [`-Zfeatures=all`](#features) and
[`-Zpackage-features`](#package-features).
The value `"1"` is the current resolver behavior on the stable channel. A
value of `"2"` enables all of the new feature behavior of
[`-Zfeatures=all`](#features) and [`-Zpackage-features`](#package-features).

This flag is global for a workspace. If using a virtual workspace, the root
definition should be in the `[workspace]` table like this:
Expand Down
59 changes: 57 additions & 2 deletions tests/testsuite/features2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ fn resolver_bad_setting() {
[package]
name = "foo"
version = "0.1.0"
resolver = "1"
resolver = "foo"
"#,
)
.file("src/lib.rs", "")
Expand All @@ -1381,12 +1381,67 @@ fn resolver_bad_setting() {
error: failed to parse manifest at `[..]/foo/Cargo.toml`

Caused by:
`resolver` setting `1` is not valid, only valid option is \"2\"
`resolver` setting `foo` is not valid, valid options are \"1\" or \"2\"
",
)
.run();
}

#[cargo_test]
fn resolver_original() {
// resolver="1" uses old unification behavior.
Package::new("common", "1.0.0")
.feature("f1", &[])
.file(
"src/lib.rs",
r#"
#[cfg(feature = "f1")]
compile_error!("f1 should not activate");
"#,
)
.publish();

Package::new("bar", "1.0.0")
.add_dep(
Dependency::new("common", "1.0")
.target("cfg(whatever)")
.enable_features(&["f1"]),
)
.publish();

let manifest = |resolver| {
format!(
r#"
cargo-features = ["resolver"]
[package]
name = "foo"
version = "0.1.0"
resolver = "{}"

[dependencies]
common = "1.0"
bar = "1.0"
"#,
resolver
)
};

let p = project()
.file("Cargo.toml", &manifest("1"))
.file("src/lib.rs", "")
.build();

p.cargo("check")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr_contains("[..]f1 should not activate[..]")
.run();

p.change_file("Cargo.toml", &manifest("2"));

p.cargo("check").masquerade_as_nightly_cargo().run();
}

#[cargo_test]
fn resolver_not_both() {
// Can't specify resolver in both workspace and package.
Expand Down