rename epoch to edition
authorKurtis Nusbaum <kurtis@uber.com>
Wed, 21 Mar 2018 16:41:22 +0000 (09:41 -0700)
committerKurtis Nusbaum <kurtis@uber.com>
Sun, 1 Apr 2018 18:01:28 +0000 (11:01 -0700)
src/cargo/core/features.rs
src/cargo/core/manifest.rs
src/cargo/core/mod.rs
src/cargo/ops/cargo_rustc/fingerprint.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/util/toml/mod.rs
tests/testsuite/package.rs

index 3ce6a8267b30a0d4c615b43c41b8023689d9cf35..09eff85455c4c6389a3269a888dc3736f5d29ed3 100644 (file)
@@ -45,29 +45,29 @@ use std::str::FromStr;
 
 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(()),
         }
     }
@@ -156,8 +156,8 @@ features! {
         // 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,
index c004089edb2efa3e7c4026b22f6f7b30fca8862d..75e1e38e86fd63009709666be7f97bb9187a815d 100644 (file)
@@ -9,7 +9,7 @@ use serde::ser;
 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;
@@ -38,7 +38,7 @@ pub struct Manifest {
     workspace: WorkspaceConfig,
     original: Rc<TomlManifest>,
     features: Features,
-    epoch: Epoch,
+    edition: Edition,
     im_a_teapot: Option<bool>,
 }
 
@@ -272,7 +272,7 @@ impl Manifest {
         patch: HashMap<Url, Vec<Dependency>>,
         workspace: WorkspaceConfig,
         features: Features,
-        epoch: Epoch,
+        edition: Edition,
         im_a_teapot: Option<bool>,
         original: Rc<TomlManifest>,
     ) -> Manifest {
@@ -290,7 +290,7 @@ impl Manifest {
             patch,
             workspace,
             features,
-            epoch,
+            edition,
             original,
             im_a_teapot,
             publish_lockfile,
@@ -406,8 +406,8 @@ impl Manifest {
         }
     }
 
-    pub fn epoch(&self) -> Epoch {
-        self.epoch
+    pub fn edition(&self) -> Edition {
+        self.edition
     }
 }
 
index dcd94cc962c036c1ae958692109afa0040539131..f6434f77362b25e61dd66583a2723a27a37d6701 100644 (file)
@@ -1,5 +1,5 @@
 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};
index 74deda193d8bf9044486f879bd0cd3ac98f9cafd..1e20297858366dcf3cf44a84c366f1ee122a8a25 100644 (file)
@@ -9,7 +9,7 @@ use serde::ser::{self, Serialize};
 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};
@@ -155,7 +155,7 @@ pub struct Fingerprint {
     #[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>
@@ -187,7 +187,7 @@ where
                     features: String::new(),
                     deps: Vec::new(),
                     memoized_hash: Mutex::new(Some(hash)),
-                    epoch: Epoch::Epoch2015,
+                    edition: Edition::Edition2015,
                     rustflags: Vec::new(),
                 }),
             )
@@ -271,8 +271,8 @@ impl Fingerprint {
         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) {
@@ -350,7 +350,7 @@ impl hash::Hash for Fingerprint {
             profile,
             ref deps,
             ref local,
-            epoch,
+            edition,
             ref rustflags,
             ..
         } = *self;
@@ -361,7 +361,7 @@ impl hash::Hash for Fingerprint {
             path,
             profile,
             local,
-            epoch,
+            edition,
             rustflags,
         ).hash(h);
 
@@ -467,7 +467,7 @@ fn calculate<'a, 'cfg>(
         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));
@@ -520,7 +520,7 @@ pub fn prepare_build_cmd<'a, 'cfg>(
         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);
index 0007ac15b4c0a0d2359def534d1a18eba3bd56be..036241aceef7e640d422d0d3523b843d2a3efb3b 100644 (file)
@@ -896,8 +896,8 @@ fn build_base_args<'a, 'cfg>(
     }
     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
index e0538d221e9b25e591e010edeb80c9925e282f87..3aa4f58755086f34a578c0350e6b65b7e035c91e 100644 (file)
@@ -14,7 +14,7 @@ use url::Url;
 
 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;
@@ -798,17 +798,17 @@ impl TomlManifest {
             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,
@@ -824,7 +824,7 @@ impl TomlManifest {
             patch,
             workspace_config,
             features,
-            epoch,
+            edition,
             project.im_a_teapot,
             Rc::clone(me),
         );
index 300b69d63b6276eef8f3d0436ec89d04d99d02fc..20e6821d3bba5bc572bb686591684344da5c704f 100644 (file)
@@ -1100,12 +1100,12 @@ fn package_two_kinds_of_deps() {
 }
 
 #[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"
@@ -1119,13 +1119,13 @@ fn test_epoch() {
     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`
@@ -1134,13 +1134,13 @@ fn test_epoch() {
 }
 
 #[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"
@@ -1153,13 +1153,13 @@ fn test_epoch_missing() {
     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`
@@ -1168,12 +1168,12 @@ fn test_epoch_missing() {
 }
 
 #[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"
@@ -1198,7 +1198,7 @@ Caused by:
 }
 
 #[test]
-fn test_epoch_nightly() {
+fn test_edition_nightly() {
     let p = project("foo")
         .file(
             "Cargo.toml",
@@ -1220,12 +1220,12 @@ fn test_epoch_nightly() {
 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
 "
         )),
     );