mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Rename the rust
manifest key to edition
This'll hopefully jive better with the terminology of "edition" throughout the rest of Rust!
This commit is contained in:
parent
4dc5db2db5
commit
8413008937
@ -49,6 +49,8 @@ use std::env;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
use failure::Error;
|
||||||
|
|
||||||
use util::errors::CargoResult;
|
use util::errors::CargoResult;
|
||||||
|
|
||||||
/// The edition of the compiler (RFC 2052)
|
/// The edition of the compiler (RFC 2052)
|
||||||
@ -69,12 +71,15 @@ impl fmt::Display for Edition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl FromStr for Edition {
|
impl FromStr for Edition {
|
||||||
type Err = ();
|
type Err = Error;
|
||||||
fn from_str(s: &str) -> Result<Self, ()> {
|
fn from_str(s: &str) -> Result<Self, Error> {
|
||||||
match s {
|
match s {
|
||||||
"2015" => Ok(Edition::Edition2015),
|
"2015" => Ok(Edition::Edition2015),
|
||||||
"2018" => Ok(Edition::Edition2018),
|
"2018" => Ok(Edition::Edition2018),
|
||||||
_ => Err(()),
|
s => {
|
||||||
|
bail!("supported edition values are `2015` or `2018`, but `{}` \
|
||||||
|
is unknown", s)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ pub struct TomlProject {
|
|||||||
license_file: Option<String>,
|
license_file: Option<String>,
|
||||||
repository: Option<String>,
|
repository: Option<String>,
|
||||||
metadata: Option<toml::Value>,
|
metadata: Option<toml::Value>,
|
||||||
rust: Option<String>,
|
edition: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -719,15 +719,12 @@ impl TomlManifest {
|
|||||||
|
|
||||||
let pkgid = project.to_package_id(source_id)?;
|
let pkgid = project.to_package_id(source_id)?;
|
||||||
|
|
||||||
let edition = if let Some(ref edition) = project.rust {
|
let edition = if let Some(ref edition) = project.edition {
|
||||||
features
|
features
|
||||||
.require(Feature::edition())
|
.require(Feature::edition())
|
||||||
.chain_err(|| "editions are unstable")?;
|
.chain_err(|| "editions are unstable")?;
|
||||||
if let Ok(edition) = edition.parse() {
|
edition.parse()
|
||||||
edition
|
.chain_err(|| "failed to parse the `edition` key")?
|
||||||
} else {
|
|
||||||
bail!("the `rust` key must be one of: `2015`, `2018`")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Edition::Edition2015
|
Edition::Edition2015
|
||||||
};
|
};
|
||||||
|
@ -181,16 +181,16 @@ cargo +nightly build --out-dir=out -Z unstable-options
|
|||||||
* Tracking Issue: [rust-lang/rust#44581](https://github.com/rust-lang/rust/issues/44581)
|
* Tracking Issue: [rust-lang/rust#44581](https://github.com/rust-lang/rust/issues/44581)
|
||||||
* RFC: [#2052](https://github.com/rust-lang/rfcs/blob/master/text/2052-epochs.md)
|
* RFC: [#2052](https://github.com/rust-lang/rfcs/blob/master/text/2052-epochs.md)
|
||||||
|
|
||||||
You can opt in to a specific Rust Edition for your package with the `rust` key
|
You can opt in to a specific Rust Edition for your package with the `edition`
|
||||||
in `Cargo.toml`. If you don't specify the edition, it will default to 2015.
|
key in `Cargo.toml`. If you don't specify the edition, it will default to
|
||||||
You need to include the appropriate `cargo-features`:
|
2015. You need to include the appropriate `cargo-features`:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
cargo-features = ["edition"]
|
cargo-features = ["edition"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
...
|
...
|
||||||
rust = "2018"
|
edition = "2018"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -713,7 +713,7 @@ fn bench_autodiscover_2015() {
|
|||||||
name = "foo"
|
name = "foo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = []
|
||||||
rust = "2015"
|
edition = "2015"
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_magic"
|
name = "bench_magic"
|
||||||
|
@ -1496,7 +1496,7 @@ fn doc_edition() {
|
|||||||
name = "foo"
|
name = "foo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = []
|
||||||
rust = "2018"
|
edition = "2018"
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.file("src/lib.rs", "")
|
.file("src/lib.rs", "")
|
||||||
|
@ -1038,7 +1038,7 @@ fn installs_from_cwd_with_2018_warnings() {
|
|||||||
name = "foo"
|
name = "foo"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = []
|
authors = []
|
||||||
rust = "2018"
|
edition = "2018"
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.file("src/main.rs", "fn main() {}")
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
@ -1110,7 +1110,7 @@ fn test_edition() {
|
|||||||
name = "foo"
|
name = "foo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = []
|
||||||
rust = "2018"
|
edition = "2018"
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.file("src/lib.rs", r#" "#)
|
.file("src/lib.rs", r#" "#)
|
||||||
@ -1178,7 +1178,7 @@ fn test_edition_malformed() {
|
|||||||
name = "foo"
|
name = "foo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = []
|
||||||
rust = "chicken"
|
edition = "chicken"
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.file("src/lib.rs", r#" "#)
|
.file("src/lib.rs", r#" "#)
|
||||||
@ -1191,7 +1191,10 @@ fn test_edition_malformed() {
|
|||||||
error: failed to parse manifest at `[..]`
|
error: failed to parse manifest at `[..]`
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
the `rust` key must be one of: `2015`, `2018`
|
failed to parse the `edition` key
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
supported edition values are `2015` or `2018`, but `chicken` is unknown
|
||||||
"
|
"
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
@ -1207,7 +1210,7 @@ fn test_edition_nightly() {
|
|||||||
name = "foo"
|
name = "foo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = []
|
||||||
rust = "2015"
|
edition = "2015"
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.file("src/lib.rs", r#" "#)
|
.file("src/lib.rs", r#" "#)
|
||||||
|
@ -403,7 +403,7 @@ fn autodiscover_examples_project(rust_edition: &str, autoexamples: Option<bool>)
|
|||||||
name = "foo"
|
name = "foo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = []
|
||||||
rust = "{rust_edition}"
|
edition = "{rust_edition}"
|
||||||
{autoexamples}
|
{autoexamples}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user