Skip to content

Commit 8413008

Browse files
committed
Rename the rust manifest key to edition
This'll hopefully jive better with the terminology of "edition" throughout the rest of Rust!
1 parent 4dc5db2 commit 8413008

File tree

8 files changed

+27
-22
lines changed

8 files changed

+27
-22
lines changed

src/cargo/core/features.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ use std::env;
4949
use std::fmt;
5050
use std::str::FromStr;
5151

52+
use failure::Error;
53+
5254
use util::errors::CargoResult;
5355

5456
/// The edition of the compiler (RFC 2052)
@@ -69,12 +71,15 @@ impl fmt::Display for Edition {
6971
}
7072
}
7173
impl FromStr for Edition {
72-
type Err = ();
73-
fn from_str(s: &str) -> Result<Self, ()> {
74+
type Err = Error;
75+
fn from_str(s: &str) -> Result<Self, Error> {
7476
match s {
7577
"2015" => Ok(Edition::Edition2015),
7678
"2018" => Ok(Edition::Edition2018),
77-
_ => Err(()),
79+
s => {
80+
bail!("supported edition values are `2015` or `2018`, but `{}` \
81+
is unknown", s)
82+
}
7883
}
7984
}
8085
}

src/cargo/util/toml/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ pub struct TomlProject {
558558
license_file: Option<String>,
559559
repository: Option<String>,
560560
metadata: Option<toml::Value>,
561-
rust: Option<String>,
561+
edition: Option<String>,
562562
}
563563

564564
#[derive(Debug, Deserialize, Serialize)]
@@ -719,15 +719,12 @@ impl TomlManifest {
719719

720720
let pkgid = project.to_package_id(source_id)?;
721721

722-
let edition = if let Some(ref edition) = project.rust {
722+
let edition = if let Some(ref edition) = project.edition {
723723
features
724724
.require(Feature::edition())
725725
.chain_err(|| "editions are unstable")?;
726-
if let Ok(edition) = edition.parse() {
727-
edition
728-
} else {
729-
bail!("the `rust` key must be one of: `2015`, `2018`")
730-
}
726+
edition.parse()
727+
.chain_err(|| "failed to parse the `edition` key")?
731728
} else {
732729
Edition::Edition2015
733730
};

src/doc/src/reference/unstable.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,16 @@ cargo +nightly build --out-dir=out -Z unstable-options
181181
* Tracking Issue: [rust-lang/rust#44581](https://github.com/rust-lang/rust/issues/44581)
182182
* RFC: [#2052](https://github.com/rust-lang/rfcs/blob/master/text/2052-epochs.md)
183183

184-
You can opt in to a specific Rust Edition for your package with the `rust` key
185-
in `Cargo.toml`. If you don't specify the edition, it will default to 2015.
186-
You need to include the appropriate `cargo-features`:
184+
You can opt in to a specific Rust Edition for your package with the `edition`
185+
key in `Cargo.toml`. If you don't specify the edition, it will default to
186+
2015. You need to include the appropriate `cargo-features`:
187187

188188
```toml
189189
cargo-features = ["edition"]
190190

191191
[package]
192192
...
193-
rust = "2018"
193+
edition = "2018"
194194
```
195195

196196

tests/testsuite/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ fn bench_autodiscover_2015() {
713713
name = "foo"
714714
version = "0.0.1"
715715
authors = []
716-
rust = "2015"
716+
edition = "2015"
717717
718718
[[bench]]
719719
name = "bench_magic"

tests/testsuite/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ fn doc_edition() {
14961496
name = "foo"
14971497
version = "0.0.1"
14981498
authors = []
1499-
rust = "2018"
1499+
edition = "2018"
15001500
"#,
15011501
)
15021502
.file("src/lib.rs", "")

tests/testsuite/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ fn installs_from_cwd_with_2018_warnings() {
10381038
name = "foo"
10391039
version = "0.1.0"
10401040
authors = []
1041-
rust = "2018"
1041+
edition = "2018"
10421042
"#,
10431043
)
10441044
.file("src/main.rs", "fn main() {}")

tests/testsuite/package.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ fn test_edition() {
11101110
name = "foo"
11111111
version = "0.0.1"
11121112
authors = []
1113-
rust = "2018"
1113+
edition = "2018"
11141114
"#,
11151115
)
11161116
.file("src/lib.rs", r#" "#)
@@ -1178,7 +1178,7 @@ fn test_edition_malformed() {
11781178
name = "foo"
11791179
version = "0.0.1"
11801180
authors = []
1181-
rust = "chicken"
1181+
edition = "chicken"
11821182
"#,
11831183
)
11841184
.file("src/lib.rs", r#" "#)
@@ -1191,7 +1191,10 @@ fn test_edition_malformed() {
11911191
error: failed to parse manifest at `[..]`
11921192
11931193
Caused by:
1194-
the `rust` key must be one of: `2015`, `2018`
1194+
failed to parse the `edition` key
1195+
1196+
Caused by:
1197+
supported edition values are `2015` or `2018`, but `chicken` is unknown
11951198
"
11961199
)),
11971200
);
@@ -1207,7 +1210,7 @@ fn test_edition_nightly() {
12071210
name = "foo"
12081211
version = "0.0.1"
12091212
authors = []
1210-
rust = "2015"
1213+
edition = "2015"
12111214
"#,
12121215
)
12131216
.file("src/lib.rs", r#" "#)

tests/testsuite/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ fn autodiscover_examples_project(rust_edition: &str, autoexamples: Option<bool>)
403403
name = "foo"
404404
version = "0.0.1"
405405
authors = []
406-
rust = "{rust_edition}"
406+
edition = "{rust_edition}"
407407
{autoexamples}
408408
409409
[features]

0 commit comments

Comments
 (0)