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

[beta] Fix publication of packages with metadata and resolver #9304

Merged
merged 1 commit into from
Mar 26, 2021
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
10 changes: 8 additions & 2 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,11 @@ pub struct TomlProject {
license: Option<String>,
license_file: Option<String>,
repository: Option<String>,
metadata: Option<toml::Value>,
resolver: Option<String>,

// Note that this field must come last due to the way toml serialization
// works which requires tables to be emitted after all values.
metadata: Option<toml::Value>,
}

#[derive(Debug, Deserialize, Serialize)]
Expand All @@ -899,8 +902,11 @@ pub struct TomlWorkspace {
#[serde(rename = "default-members")]
default_members: Option<Vec<String>>,
exclude: Option<Vec<String>>,
metadata: Option<toml::Value>,
resolver: Option<String>,

// Note that this field must come last due to the way toml serialization
// works which requires tables to be emitted after all values.
metadata: Option<toml::Value>,
}

impl TomlProject {
Expand Down
22 changes: 22 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1954,3 +1954,25 @@ fn reproducible_output() {
assert_eq!(header.groupname().unwrap().unwrap(), "");
}
}

#[cargo_test]
fn package_with_resolver_and_metadata() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
resolver = '2'

[package.metadata.docs.rs]
all-features = true
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("package").run();
}