Skip to content

Commit 551f6f3

Browse files
committed
Auto merge of #5274 - klnusbaum:epoch_5214, r=alexcrichton
rename epoch to edition Per issue #5214 let's rename all instances of epoch to Edition
2 parents 85671e7 + 3bbe93c commit 551f6f3

File tree

7 files changed

+55
-55
lines changed

7 files changed

+55
-55
lines changed

src/cargo/core/features.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,29 @@ use std::str::FromStr;
4545

4646
use util::errors::CargoResult;
4747

48-
/// The epoch of the compiler (RFC 2052)
48+
/// The edition of the compiler (RFC 2052)
4949
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, Eq, PartialEq, Serialize, Deserialize)]
50-
pub enum Epoch {
51-
/// The 2015 epoch
52-
Epoch2015,
53-
/// The 2018 epoch
54-
Epoch2018,
50+
pub enum Edition {
51+
/// The 2015 edition
52+
Edition2015,
53+
/// The 2018 edition
54+
Edition2018,
5555
}
5656

57-
impl fmt::Display for Epoch {
57+
impl fmt::Display for Edition {
5858
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5959
match *self {
60-
Epoch::Epoch2015 => f.write_str("2015"),
61-
Epoch::Epoch2018 => f.write_str("2018"),
60+
Edition::Edition2015 => f.write_str("2015"),
61+
Edition::Edition2018 => f.write_str("2018"),
6262
}
6363
}
6464
}
65-
impl FromStr for Epoch {
65+
impl FromStr for Edition {
6666
type Err = ();
6767
fn from_str(s: &str) -> Result<Self, ()> {
6868
match s {
69-
"2015" => Ok(Epoch::Epoch2015),
70-
"2018" => Ok(Epoch::Epoch2018),
69+
"2015" => Ok(Edition::Edition2015),
70+
"2018" => Ok(Edition::Edition2018),
7171
_ => Err(()),
7272
}
7373
}
@@ -156,8 +156,8 @@ features! {
156156
// Downloading packages from alternative registry indexes.
157157
[unstable] alternative_registries: bool,
158158

159-
// Using epochs
160-
[unstable] epoch: bool,
159+
// Using editions
160+
[unstable] edition: bool,
161161

162162
// Renaming a package in the manifest via the `package` key
163163
[unstable] rename_dependency: bool,

src/cargo/core/manifest.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use serde::ser;
99
use url::Url;
1010

1111
use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
12-
use core::{Epoch, Feature, Features, WorkspaceConfig};
12+
use core::{Edition, Feature, Features, WorkspaceConfig};
1313
use core::interning::InternedString;
1414
use util::Config;
1515
use util::toml::TomlManifest;
@@ -38,7 +38,7 @@ pub struct Manifest {
3838
workspace: WorkspaceConfig,
3939
original: Rc<TomlManifest>,
4040
features: Features,
41-
epoch: Epoch,
41+
edition: Edition,
4242
im_a_teapot: Option<bool>,
4343
}
4444

@@ -272,7 +272,7 @@ impl Manifest {
272272
patch: HashMap<Url, Vec<Dependency>>,
273273
workspace: WorkspaceConfig,
274274
features: Features,
275-
epoch: Epoch,
275+
edition: Edition,
276276
im_a_teapot: Option<bool>,
277277
original: Rc<TomlManifest>,
278278
) -> Manifest {
@@ -290,7 +290,7 @@ impl Manifest {
290290
patch,
291291
workspace,
292292
features,
293-
epoch,
293+
edition,
294294
original,
295295
im_a_teapot,
296296
publish_lockfile,
@@ -406,8 +406,8 @@ impl Manifest {
406406
}
407407
}
408408

409-
pub fn epoch(&self) -> Epoch {
410-
self.epoch
409+
pub fn edition(&self) -> Edition {
410+
self.edition
411411
}
412412
}
413413

src/cargo/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub use self::dependency::Dependency;
2-
pub use self::features::{CliUnstable, Epoch, Feature, Features};
2+
pub use self::features::{CliUnstable, Edition, Feature, Features};
33
pub use self::manifest::{EitherManifest, VirtualManifest};
44
pub use self::manifest::{LibKind, Manifest, Profile, Profiles, Target, TargetKind};
55
pub use self::package::{Package, PackageSet};

src/cargo/ops/cargo_rustc/fingerprint.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use serde::ser::{self, Serialize};
99
use serde::de::{self, Deserialize};
1010
use serde_json;
1111

12-
use core::{Epoch, Package, TargetKind};
12+
use core::{Edition, Package, TargetKind};
1313
use util;
1414
use util::{internal, profile, Dirty, Fresh, Freshness};
1515
use util::errors::{CargoResult, CargoResultExt};
@@ -155,7 +155,7 @@ pub struct Fingerprint {
155155
#[serde(skip_serializing, skip_deserializing)]
156156
memoized_hash: Mutex<Option<u64>>,
157157
rustflags: Vec<String>,
158-
epoch: Epoch,
158+
edition: Edition,
159159
}
160160

161161
fn serialize_deps<S>(deps: &[(String, Arc<Fingerprint>)], ser: S) -> Result<S::Ok, S::Error>
@@ -187,7 +187,7 @@ where
187187
features: String::new(),
188188
deps: Vec::new(),
189189
memoized_hash: Mutex::new(Some(hash)),
190-
epoch: Epoch::Epoch2015,
190+
edition: Edition::Edition2015,
191191
rustflags: Vec::new(),
192192
}),
193193
)
@@ -271,8 +271,8 @@ impl Fingerprint {
271271
if self.local.len() != old.local.len() {
272272
bail!("local lens changed");
273273
}
274-
if self.epoch != old.epoch {
275-
bail!("epoch changed")
274+
if self.edition != old.edition {
275+
bail!("edition changed")
276276
}
277277
for (new, old) in self.local.iter().zip(&old.local) {
278278
match (new, old) {
@@ -350,7 +350,7 @@ impl hash::Hash for Fingerprint {
350350
profile,
351351
ref deps,
352352
ref local,
353-
epoch,
353+
edition,
354354
ref rustflags,
355355
..
356356
} = *self;
@@ -361,7 +361,7 @@ impl hash::Hash for Fingerprint {
361361
path,
362362
profile,
363363
local,
364-
epoch,
364+
edition,
365365
rustflags,
366366
).hash(h);
367367

@@ -467,7 +467,7 @@ fn calculate<'a, 'cfg>(
467467
deps,
468468
local: vec![local],
469469
memoized_hash: Mutex::new(None),
470-
epoch: unit.pkg.manifest().epoch(),
470+
edition: unit.pkg.manifest().edition(),
471471
rustflags: extra_flags,
472472
});
473473
cx.fingerprints.insert(*unit, Arc::clone(&fingerprint));
@@ -520,7 +520,7 @@ pub fn prepare_build_cmd<'a, 'cfg>(
520520
deps: Vec::new(),
521521
local,
522522
memoized_hash: Mutex::new(None),
523-
epoch: Epoch::Epoch2015,
523+
edition: Edition::Edition2015,
524524
rustflags: Vec::new(),
525525
};
526526
let compare = compare_old_fingerprint(&loc, &fingerprint);

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,8 @@ fn build_base_args<'a, 'cfg>(
896896
}
897897
let manifest = unit.pkg.manifest();
898898

899-
if manifest.features().is_enabled(Feature::epoch()) {
900-
cmd.arg(format!("-Zepoch={}", manifest.epoch()));
899+
if manifest.features().is_enabled(Feature::edition()) {
900+
cmd.arg(format!("-Zedition={}", manifest.edition()));
901901
}
902902

903903
// Disable LTO for host builds as prefer_dynamic and it are mutually

src/cargo/util/toml/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use url::Url;
1414

1515
use core::{GitReference, PackageIdSpec, Profiles, SourceId, WorkspaceConfig, WorkspaceRootConfig};
1616
use core::{Dependency, Manifest, PackageId, Summary, Target};
17-
use core::{EitherManifest, Epoch, Feature, Features, VirtualManifest};
17+
use core::{EitherManifest, Edition, Feature, Features, VirtualManifest};
1818
use core::dependency::{Kind, Platform};
1919
use core::manifest::{LibKind, Lto, ManifestMetadata, Profile};
2020
use sources::CRATES_IO;
@@ -798,17 +798,17 @@ impl TomlManifest {
798798
None => false,
799799
};
800800

801-
let epoch = if let Some(ref epoch) = project.rust {
801+
let edition = if let Some(ref edition) = project.rust {
802802
features
803-
.require(Feature::epoch())
804-
.chain_err(|| "epoches are unstable")?;
805-
if let Ok(epoch) = epoch.parse() {
806-
epoch
803+
.require(Feature::edition())
804+
.chain_err(|| "editiones are unstable")?;
805+
if let Ok(edition) = edition.parse() {
806+
edition
807807
} else {
808808
bail!("the `rust` key must be one of: `2015`, `2018`")
809809
}
810810
} else {
811-
Epoch::Epoch2015
811+
Edition::Edition2015
812812
};
813813
let mut manifest = Manifest::new(
814814
summary,
@@ -824,7 +824,7 @@ impl TomlManifest {
824824
patch,
825825
workspace_config,
826826
features,
827-
epoch,
827+
edition,
828828
project.im_a_teapot,
829829
Rc::clone(me),
830830
);

tests/testsuite/package.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,12 +1100,12 @@ fn package_two_kinds_of_deps() {
11001100
}
11011101

11021102
#[test]
1103-
fn test_epoch() {
1103+
fn test_edition() {
11041104
let p = project("foo")
11051105
.file(
11061106
"Cargo.toml",
11071107
r#"
1108-
cargo-features = ["epoch"]
1108+
cargo-features = ["edition"]
11091109
[package]
11101110
name = "foo"
11111111
version = "0.0.1"
@@ -1119,13 +1119,13 @@ fn test_epoch() {
11191119
assert_that(
11201120
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
11211121
execs()
1122-
// -Zepoch is still in flux and we're not passing -Zunstable-options
1122+
// -Zedition is still in flux and we're not passing -Zunstable-options
11231123
// from Cargo so it will probably error. Only partially match the output
11241124
// until stuff stabilizes
11251125
.with_stderr_contains(format!("\
11261126
[COMPILING] foo v0.0.1 ({url})
11271127
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \
1128-
--emit=dep-info,link -Zepoch=2018 -C debuginfo=2 \
1128+
--emit=dep-info,link -Zedition=2018 -C debuginfo=2 \
11291129
-C metadata=[..] \
11301130
--out-dir [..] \
11311131
-L dependency={dir}[/]target[/]debug[/]deps`
@@ -1134,13 +1134,13 @@ fn test_epoch() {
11341134
}
11351135

11361136
#[test]
1137-
fn test_epoch_missing() {
1138-
// no epoch = 2015
1137+
fn test_edition_missing() {
1138+
// no edition = 2015
11391139
let p = project("foo")
11401140
.file(
11411141
"Cargo.toml",
11421142
r#"
1143-
cargo-features = ["epoch"]
1143+
cargo-features = ["edition"]
11441144
[package]
11451145
name = "foo"
11461146
version = "0.0.1"
@@ -1153,13 +1153,13 @@ fn test_epoch_missing() {
11531153
assert_that(
11541154
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
11551155
execs()
1156-
// -Zepoch is still in flux and we're not passing -Zunstable-options
1156+
// -Zedition is still in flux and we're not passing -Zunstable-options
11571157
// from Cargo so it will probably error. Only partially match the output
11581158
// until stuff stabilizes
11591159
.with_stderr_contains(format!("\
11601160
[COMPILING] foo v0.0.1 ({url})
11611161
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \
1162-
--emit=dep-info,link -Zepoch=2015 -C debuginfo=2 \
1162+
--emit=dep-info,link -Zedition=2015 -C debuginfo=2 \
11631163
-C metadata=[..] \
11641164
--out-dir [..] \
11651165
-L dependency={dir}[/]target[/]debug[/]deps`
@@ -1168,12 +1168,12 @@ fn test_epoch_missing() {
11681168
}
11691169

11701170
#[test]
1171-
fn test_epoch_malformed() {
1171+
fn test_edition_malformed() {
11721172
let p = project("foo")
11731173
.file(
11741174
"Cargo.toml",
11751175
r#"
1176-
cargo-features = ["epoch"]
1176+
cargo-features = ["edition"]
11771177
[package]
11781178
name = "foo"
11791179
version = "0.0.1"
@@ -1198,7 +1198,7 @@ Caused by:
11981198
}
11991199

12001200
#[test]
1201-
fn test_epoch_nightly() {
1201+
fn test_edition_nightly() {
12021202
let p = project("foo")
12031203
.file(
12041204
"Cargo.toml",
@@ -1220,12 +1220,12 @@ fn test_epoch_nightly() {
12201220
error: failed to parse manifest at `[..]`
12211221
12221222
Caused by:
1223-
epoches are unstable
1223+
editiones are unstable
12241224
12251225
Caused by:
1226-
feature `epoch` is required
1226+
feature `edition` is required
12271227
1228-
consider adding `cargo-features = [\"epoch\"]` to the manifest
1228+
consider adding `cargo-features = [\"edition\"]` to the manifest
12291229
"
12301230
)),
12311231
);

0 commit comments

Comments
 (0)