Skip to content

Commit

Permalink
Hint upgrading for future edition keys
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Apr 17, 2020
1 parent f9047dc commit f57c4c9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ impl FromStr for Edition {
match s {
"2015" => Ok(Edition::Edition2015),
"2018" => Ok(Edition::Edition2018),
s if s.parse().map_or(false, |y: u16| y > 2020 && y < 2050) => bail!(
"this version of Cargo is older than the `{}` edition, \
and only supports `2015` and `2018` editions.",
s
),
s => bail!(
"supported edition values are `2015` or `2018`, but `{}` \
is unknown",
Expand Down
32 changes: 32 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,38 @@ Caused by:
.run();
}

#[cargo_test]
fn test_edition_from_the_future() {
let p = project()
.file(
"Cargo.toml",
r#"[package]
edition = "2038"
name = "foo"
version = "99.99.99"
authors = []
"#,
)
.file("src/main.rs", r#""#)
.build();

p.cargo("build")
.with_status(101)
.with_stderr(
"\
error: failed to parse manifest at `[..]`
Caused by:
failed to parse the `edition` key
Caused by:
this version of Cargo is older than the `2038` edition, and only supports `2015` and `2018` editions.
"
.to_string(),
)
.run();
}

#[cargo_test]
fn do_not_package_if_src_was_modified() {
let p = project()
Expand Down

0 comments on commit f57c4c9

Please sign in to comment.