use util::errors::CargoResult;
-/// The epoch of the compiler (RFC 2052)
+/// The edition of the compiler (RFC 2052)
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, Eq, PartialEq, Serialize, Deserialize)]
-pub enum Epoch {
- /// The 2015 epoch
- Epoch2015,
- /// The 2018 epoch
- Epoch2018,
+pub enum Edition {
+ /// The 2015 edition
+ Edition2015,
+ /// The 2018 edition
+ Edition2018,
}
-impl fmt::Display for Epoch {
+impl fmt::Display for Edition {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
- Epoch::Epoch2015 => f.write_str("2015"),
- Epoch::Epoch2018 => f.write_str("2018"),
+ Edition::Edition2015 => f.write_str("2015"),
+ Edition::Edition2018 => f.write_str("2018"),
}
}
}
-impl FromStr for Epoch {
+impl FromStr for Edition {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
match s {
- "2015" => Ok(Epoch::Epoch2015),
- "2018" => Ok(Epoch::Epoch2018),
+ "2015" => Ok(Edition::Edition2015),
+ "2018" => Ok(Edition::Edition2018),
_ => Err(()),
}
}
// Downloading packages from alternative registry indexes.
[unstable] alternative_registries: bool,
- // Using epochs
- [unstable] epoch: bool,
+ // Using editions
+ [unstable] edition: bool,
// Renaming a package in the manifest via the `package` key
[unstable] rename_dependency: bool,
use url::Url;
use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
-use core::{Epoch, Feature, Features, WorkspaceConfig};
+use core::{Edition, Feature, Features, WorkspaceConfig};
use core::interning::InternedString;
use util::Config;
use util::toml::TomlManifest;
workspace: WorkspaceConfig,
original: Rc<TomlManifest>,
features: Features,
- epoch: Epoch,
+ edition: Edition,
im_a_teapot: Option<bool>,
}
patch: HashMap<Url, Vec<Dependency>>,
workspace: WorkspaceConfig,
features: Features,
- epoch: Epoch,
+ edition: Edition,
im_a_teapot: Option<bool>,
original: Rc<TomlManifest>,
) -> Manifest {
patch,
workspace,
features,
- epoch,
+ edition,
original,
im_a_teapot,
publish_lockfile,
}
}
- pub fn epoch(&self) -> Epoch {
- self.epoch
+ pub fn edition(&self) -> Edition {
+ self.edition
}
}
pub use self::dependency::Dependency;
-pub use self::features::{CliUnstable, Epoch, Feature, Features};
+pub use self::features::{CliUnstable, Edition, Feature, Features};
pub use self::manifest::{EitherManifest, VirtualManifest};
pub use self::manifest::{LibKind, Manifest, Profile, Profiles, Target, TargetKind};
pub use self::package::{Package, PackageSet};
use serde::de::{self, Deserialize};
use serde_json;
-use core::{Epoch, Package, TargetKind};
+use core::{Edition, Package, TargetKind};
use util;
use util::{internal, profile, Dirty, Fresh, Freshness};
use util::errors::{CargoResult, CargoResultExt};
#[serde(skip_serializing, skip_deserializing)]
memoized_hash: Mutex<Option<u64>>,
rustflags: Vec<String>,
- epoch: Epoch,
+ edition: Edition,
}
fn serialize_deps<S>(deps: &[(String, Arc<Fingerprint>)], ser: S) -> Result<S::Ok, S::Error>
features: String::new(),
deps: Vec::new(),
memoized_hash: Mutex::new(Some(hash)),
- epoch: Epoch::Epoch2015,
+ edition: Edition::Edition2015,
rustflags: Vec::new(),
}),
)
if self.local.len() != old.local.len() {
bail!("local lens changed");
}
- if self.epoch != old.epoch {
- bail!("epoch changed")
+ if self.edition != old.edition {
+ bail!("edition changed")
}
for (new, old) in self.local.iter().zip(&old.local) {
match (new, old) {
profile,
ref deps,
ref local,
- epoch,
+ edition,
ref rustflags,
..
} = *self;
path,
profile,
local,
- epoch,
+ edition,
rustflags,
).hash(h);
deps,
local: vec![local],
memoized_hash: Mutex::new(None),
- epoch: unit.pkg.manifest().epoch(),
+ edition: unit.pkg.manifest().edition(),
rustflags: extra_flags,
});
cx.fingerprints.insert(*unit, Arc::clone(&fingerprint));
deps: Vec::new(),
local,
memoized_hash: Mutex::new(None),
- epoch: Epoch::Epoch2015,
+ edition: Edition::Edition2015,
rustflags: Vec::new(),
};
let compare = compare_old_fingerprint(&loc, &fingerprint);
}
let manifest = unit.pkg.manifest();
- if manifest.features().is_enabled(Feature::epoch()) {
- cmd.arg(format!("-Zepoch={}", manifest.epoch()));
+ if manifest.features().is_enabled(Feature::edition()) {
+ cmd.arg(format!("-Zedition={}", manifest.edition()));
}
// Disable LTO for host builds as prefer_dynamic and it are mutually
use core::{GitReference, PackageIdSpec, Profiles, SourceId, WorkspaceConfig, WorkspaceRootConfig};
use core::{Dependency, Manifest, PackageId, Summary, Target};
-use core::{EitherManifest, Epoch, Feature, Features, VirtualManifest};
+use core::{EitherManifest, Edition, Feature, Features, VirtualManifest};
use core::dependency::{Kind, Platform};
use core::manifest::{LibKind, Lto, ManifestMetadata, Profile};
use sources::CRATES_IO;
None => false,
};
- let epoch = if let Some(ref epoch) = project.rust {
+ let edition = if let Some(ref edition) = project.rust {
features
- .require(Feature::epoch())
- .chain_err(|| "epoches are unstable")?;
- if let Ok(epoch) = epoch.parse() {
- epoch
+ .require(Feature::edition())
+ .chain_err(|| "editiones are unstable")?;
+ if let Ok(edition) = edition.parse() {
+ edition
} else {
bail!("the `rust` key must be one of: `2015`, `2018`")
}
} else {
- Epoch::Epoch2015
+ Edition::Edition2015
};
let mut manifest = Manifest::new(
summary,
patch,
workspace_config,
features,
- epoch,
+ edition,
project.im_a_teapot,
Rc::clone(me),
);
}
#[test]
-fn test_epoch() {
+fn test_edition() {
let p = project("foo")
.file(
"Cargo.toml",
r#"
- cargo-features = ["epoch"]
+ cargo-features = ["edition"]
[package]
name = "foo"
version = "0.0.1"
assert_that(
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
execs()
- // -Zepoch is still in flux and we're not passing -Zunstable-options
+ // -Zedition is still in flux and we're not passing -Zunstable-options
// from Cargo so it will probably error. Only partially match the output
// until stuff stabilizes
.with_stderr_contains(format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \
- --emit=dep-info,link -Zepoch=2018 -C debuginfo=2 \
+ --emit=dep-info,link -Zedition=2018 -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \
-L dependency={dir}[/]target[/]debug[/]deps`
}
#[test]
-fn test_epoch_missing() {
- // no epoch = 2015
+fn test_edition_missing() {
+ // no edition = 2015
let p = project("foo")
.file(
"Cargo.toml",
r#"
- cargo-features = ["epoch"]
+ cargo-features = ["edition"]
[package]
name = "foo"
version = "0.0.1"
assert_that(
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
execs()
- // -Zepoch is still in flux and we're not passing -Zunstable-options
+ // -Zedition is still in flux and we're not passing -Zunstable-options
// from Cargo so it will probably error. Only partially match the output
// until stuff stabilizes
.with_stderr_contains(format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \
- --emit=dep-info,link -Zepoch=2015 -C debuginfo=2 \
+ --emit=dep-info,link -Zedition=2015 -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \
-L dependency={dir}[/]target[/]debug[/]deps`
}
#[test]
-fn test_epoch_malformed() {
+fn test_edition_malformed() {
let p = project("foo")
.file(
"Cargo.toml",
r#"
- cargo-features = ["epoch"]
+ cargo-features = ["edition"]
[package]
name = "foo"
version = "0.0.1"
}
#[test]
-fn test_epoch_nightly() {
+fn test_edition_nightly() {
let p = project("foo")
.file(
"Cargo.toml",
error: failed to parse manifest at `[..]`
Caused by:
- epoches are unstable
+ editiones are unstable
Caused by:
- feature `epoch` is required
+ feature `edition` is required
-consider adding `cargo-features = [\"epoch\"]` to the manifest
+consider adding `cargo-features = [\"edition\"]` to the manifest
"
)),
);