mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #5908 - orium:fix-package-cargo-toml, r=alexcrichton
Fix serialization bug in `edition` field of `TomlProject`. Fixes #5906.
This commit is contained in:
commit
cc88d01166
@ -568,8 +568,15 @@ impl<'de> de::Deserialize<'de> for VecStringOrBool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the `package`/`project` sections of a `Cargo.toml`.
|
||||
///
|
||||
/// Note that the order of the fields matters, since this is the order they
|
||||
/// are serialized to a TOML file. For example, you cannot have values after
|
||||
/// the field `metadata`, since it is a table and values cannot appear after
|
||||
/// tables.
|
||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||
pub struct TomlProject {
|
||||
edition: Option<String>,
|
||||
name: String,
|
||||
version: semver::Version,
|
||||
authors: Option<Vec<String>>,
|
||||
@ -604,7 +611,6 @@ pub struct TomlProject {
|
||||
license_file: Option<String>,
|
||||
repository: Option<String>,
|
||||
metadata: Option<toml::Value>,
|
||||
edition: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
@ -965,6 +965,32 @@ fn test_edition() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edition_with_metadata() {
|
||||
if !is_nightly() { // --edition is nightly-only
|
||||
return;
|
||||
}
|
||||
|
||||
let p = project()
|
||||
.file("Cargo.toml", r#"
|
||||
cargo-features = ["edition"]
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
edition = "2018"
|
||||
[package.metadata.docs.rs]
|
||||
features = ["foobar"]
|
||||
"#)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
assert_that(
|
||||
p.cargo("package").masquerade_as_nightly_cargo(),
|
||||
execs(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edition_missing() {
|
||||
// no edition = 2015
|
||||
|
Loading…
x
Reference in New Issue
Block a user