Skip to content

Commit

Permalink
Auto merge of #5274 - klnusbaum:epoch_5214, r=alexcrichton
Browse files Browse the repository at this point in the history
rename epoch to edition

Per issue #5214 let's rename all instances of epoch to Edition
  • Loading branch information
bors committed Apr 2, 2018
2 parents 85671e7 + 3bbe93c commit 551f6f3
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 55 deletions.
28 changes: 14 additions & 14 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()),
}
}
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -38,7 +38,7 @@ pub struct Manifest {
workspace: WorkspaceConfig,
original: Rc<TomlManifest>,
features: Features,
epoch: Epoch,
edition: Edition,
im_a_teapot: Option<bool>,
}

Expand Down Expand Up @@ -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 {
Expand All @@ -290,7 +290,7 @@ impl Manifest {
patch,
workspace,
features,
epoch,
edition,
original,
im_a_teapot,
publish_lockfile,
Expand Down Expand Up @@ -406,8 +406,8 @@ impl Manifest {
}
}

pub fn epoch(&self) -> Epoch {
self.epoch
pub fn edition(&self) -> Edition {
self.edition
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
18 changes: 9 additions & 9 deletions src/cargo/ops/cargo_rustc/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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(),
}),
)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -350,7 +350,7 @@ impl hash::Hash for Fingerprint {
profile,
ref deps,
ref local,
epoch,
edition,
ref rustflags,
..
} = *self;
Expand All @@ -361,7 +361,7 @@ impl hash::Hash for Fingerprint {
path,
profile,
local,
epoch,
edition,
rustflags,
).hash(h);

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -824,7 +824,7 @@ impl TomlManifest {
patch,
workspace_config,
features,
epoch,
edition,
project.im_a_teapot,
Rc::clone(me),
);
Expand Down
30 changes: 15 additions & 15 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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`
Expand All @@ -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"
Expand All @@ -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`
Expand All @@ -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"
Expand All @@ -1198,7 +1198,7 @@ Caused by:
}

#[test]
fn test_epoch_nightly() {
fn test_edition_nightly() {
let p = project("foo")
.file(
"Cargo.toml",
Expand All @@ -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
"
)),
);
Expand Down

0 comments on commit 551f6f3

Please sign in to comment.