Skip to content

Commit

Permalink
Rollup merge of rust-lang#49035 - klnusbaum:49001_epoch, r=Manishearth
Browse files Browse the repository at this point in the history
rename epoch to edition

As outlined in rust-lang#49001 we'd like to rename all instances of `epoch` to `edition`. I developed the following bash script to assist in the rename. It renames all instances of `epoch` to `edition` and `Epoch` to `Edition` in all of the files I was able to determine were relevant. It then renames a few relevant files that had `epoch` in there name and finally prints out all of the remaining instance of the strings `epoch` and `Epoch` (which, as far as I can tell should not be changed). Here is the script:

```
replace() {
	sed -i '' "s/epoch/edition/g" "$1"
    sed -i '' "s/Epoch/Edition/g" "$1"
}

replace "src/librustc/lint/context.rs"
replace "src/librustc/lint/mod.rs"
replace "src/librustc/session/config.rs"
replace "src/librustc/session/mod.rs"
replace "src/librustc_driver/driver.rs"
replace "src/librustc_lint/lib.rs"
replace "src/librustc_typeck/check/method/probe.rs"
replace "src/libsyntax/config.rs"
replace "src/libsyntax/epoch.rs"
replace "src/libsyntax/feature_gate.rs"
replace "src/libsyntax/lib.rs"
replace "src/test/compile-fail/epoch-raw-pointer-method-2015.rs"
replace "src/test/compile-fail/epoch-raw-pointer-method-2018.rs"
replace "src/test/run-pass/dyn-trait.rs"
replace "src/test/run-pass/epoch-gate-feature.rs"
replace "src/test/ui/inference-variable-behind-raw-pointer.stderr"

git mv src/libsyntax/epoch.rs src/libsyntax/edition.rs
git mv src/test/compile-fail/epoch-raw-pointer-method-2015.rs src/test/compile-fail/edition-raw-pointer-method-2015.rs
git mv src/test/compile-fail/epoch-raw-pointer-method-2018.rs src/test/compile-fail/edition-raw-pointer-method-2018.rs

git grep "epoch" ./*
git grep "Epoch" ./*
```
And here is the output of the script:
```
kurtis-rust$ ./epoch_to_edition.sh
src/Cargo.lock: "crossbeam-epoch 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
src/Cargo.lock:name = "crossbeam-epoch"
src/Cargo.lock:"checksum crossbeam-epoch 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "59796cc6cbbdc6bb319161349db0c3250ec73ec7fcb763a51065ec4e2e158552"
src/ci/docker/scripts/android-start-emulator.sh:# Using the default qemu2 engine makes time::tests::since_epoch fails because
src/ci/docker/scripts/android-start-emulator.sh:# the emulator date is set to unix epoch (in armeabi-v7a-18 image). Using
src/librustc_incremental/persist/fs.rs:    let micros_since_unix_epoch = u64::from_str_radix(s, INT_ENCODE_BASE as u32);
src/librustc_incremental/persist/fs.rs:    if micros_since_unix_epoch.is_err() {
src/librustc_incremental/persist/fs.rs:    let micros_since_unix_epoch = micros_since_unix_epoch.unwrap();
src/librustc_incremental/persist/fs.rs:    let duration = Duration::new(micros_since_unix_epoch / 1_000_000,
src/librustc_incremental/persist/fs.rs:                                 1000 * (micros_since_unix_epoch % 1_000_000) as u32);
src/libstd/sys/cloudabi/abi/cloudabi.rs:  /// The epoch of this clock is undefined. The absolute
src/libstd/time.rs:        let one_second_from_epoch = UNIX_EPOCH + Duration::new(1, 0);
src/libstd/time.rs:        let one_second_from_epoch2 = UNIX_EPOCH + Duration::new(0, 500_000_000)
src/libstd/time.rs:        assert_eq!(one_second_from_epoch, one_second_from_epoch2);
src/libstd/time.rs:    fn since_epoch() {
src/test/run-pass/issue-29540.rs:    pub mon_min_osdmap_epochs: String,
src/test/run-pass/issue-29540.rs:    pub mon_max_pgmap_epochs: String,
src/test/run-pass/issue-29540.rs:    pub mon_max_log_epochs: String,
src/test/run-pass/issue-29540.rs:    pub mon_max_mdsmap_epochs: String,
src/test/run-pass/issue-29540.rs:    pub osd_map_share_max_epochs: String,
src/test/run-pass/issue-29540.rs:    pub osd_pg_epoch_persisted_max_stale: String,
```

If it looks like I've missed any things that should be converted, please let me know. There were also some notes in `src/libsyntax/epoch.rs` that indicated there might be some necessary/parallel changes that need to made in cargo. But we should probably make a separate issue for that.
  • Loading branch information
frewsxcv committed Mar 23, 2018
2 parents 832271f + 11f1406 commit c2dbfa6
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 95 deletions.
12 changes: 6 additions & 6 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use util::nodemap::FxHashMap;
use std::default::Default as StdDefault;
use std::cell::{Ref, RefCell};
use syntax::ast;
use syntax::epoch;
use syntax::edition;
use syntax_pos::{MultiSpan, Span};
use errors::DiagnosticBuilder;
use hir;
Expand Down Expand Up @@ -103,9 +103,9 @@ pub struct FutureIncompatibleInfo {
pub id: LintId,
/// e.g., a URL for an issue/PR/RFC or error code
pub reference: &'static str,
/// If this is an epoch fixing lint, the epoch in which
/// If this is an edition fixing lint, the edition in which
/// this lint becomes obsolete
pub epoch: Option<epoch::Epoch>,
pub edition: Option<edition::Edition>,
}

/// The target of the `by_name` map, which accounts for renaming/deprecation.
Expand Down Expand Up @@ -201,11 +201,11 @@ impl LintStore {
sess: Option<&Session>,
lints: Vec<FutureIncompatibleInfo>) {

for epoch in epoch::ALL_EPOCHS {
let lints = lints.iter().filter(|f| f.epoch == Some(*epoch)).map(|f| f.id)
for edition in edition::ALL_EDITIONS {
let lints = lints.iter().filter(|f| f.edition == Some(*edition)).map(|f| f.id)
.collect::<Vec<_>>();
if !lints.is_empty() {
self.register_group(sess, false, epoch.lint_name(), lints)
self.register_group(sess, false, edition.lint_name(), lints)
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use session::{Session, DiagnosticMessageId};
use std::hash;
use syntax::ast;
use syntax::codemap::MultiSpan;
use syntax::epoch::Epoch;
use syntax::edition::Edition;
use syntax::symbol::Symbol;
use syntax::visit as ast_visit;
use syntax_pos::Span;
Expand Down Expand Up @@ -77,8 +77,8 @@ pub struct Lint {
/// e.g. "imports that are never used"
pub desc: &'static str,

/// Deny lint after this epoch
pub epoch_deny: Option<Epoch>,
/// Deny lint after this edition
pub edition_deny: Option<Edition>,
}

impl Lint {
Expand All @@ -88,8 +88,8 @@ impl Lint {
}

pub fn default_level(&self, session: &Session) -> Level {
if let Some(epoch_deny) = self.epoch_deny {
if session.epoch() >= epoch_deny {
if let Some(edition_deny) = self.edition_deny {
if session.edition() >= edition_deny {
return Level::Deny
}
}
Expand All @@ -100,20 +100,20 @@ impl Lint {
/// Declare a static item of type `&'static Lint`.
#[macro_export]
macro_rules! declare_lint {
($vis: vis $NAME: ident, $Level: ident, $desc: expr, $epoch: expr) => (
($vis: vis $NAME: ident, $Level: ident, $desc: expr, $edition: expr) => (
$vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint {
name: stringify!($NAME),
default_level: $crate::lint::$Level,
desc: $desc,
epoch_deny: Some($epoch)
edition_deny: Some($edition)
};
);
($vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
$vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint {
name: stringify!($NAME),
default_level: $crate::lint::$Level,
desc: $desc,
epoch_deny: None,
edition_deny: None,
};
);
}
Expand Down Expand Up @@ -499,8 +499,8 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
// Check for future incompatibility lints and issue a stronger warning.
let lints = sess.lint_store.borrow();
if let Some(future_incompatible) = lints.future_incompatible(LintId::of(lint)) {
let future = if let Some(epoch) = future_incompatible.epoch {
format!("the {} epoch", epoch)
let future = if let Some(edition) = future_incompatible.edition {
format!("the {} edition", edition)
} else {
"a future release".to_owned()
};
Expand Down
24 changes: 12 additions & 12 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use middle::cstore;

use syntax::ast::{self, IntTy, UintTy};
use syntax::codemap::{FileName, FilePathMapping};
use syntax::epoch::Epoch;
use syntax::edition::Edition;
use syntax::parse::token;
use syntax::parse;
use syntax::symbol::Symbol;
Expand Down Expand Up @@ -771,7 +771,7 @@ macro_rules! options {
Some("`string` or `string=string`");
pub const parse_lto: Option<&'static str> =
Some("one of `thin`, `fat`, or omitted");
pub const parse_epoch: Option<&'static str> =
pub const parse_edition: Option<&'static str> =
Some("one of: `2015`, `2018`");
}

Expand All @@ -780,7 +780,7 @@ macro_rules! options {
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto};
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
use std::path::PathBuf;
use syntax::epoch::Epoch;
use syntax::edition::Edition;

$(
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
Expand Down Expand Up @@ -983,11 +983,11 @@ macro_rules! options {
true
}

fn parse_epoch(slot: &mut Epoch, v: Option<&str>) -> bool {
fn parse_edition(slot: &mut Edition, v: Option<&str>) -> bool {
match v {
Some(s) => {
let epoch = s.parse();
if let Ok(parsed) = epoch {
let edition = s.parse();
if let Ok(parsed) = edition {
*slot = parsed;
true
} else {
Expand Down Expand Up @@ -1280,10 +1280,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
`everybody_loops` (all function bodies replaced with `loop {}`),
`hir` (the HIR), `hir,identified`, or
`hir,typed` (HIR with types for each node)."),
epoch: Epoch = (Epoch::Epoch2015, parse_epoch, [TRACKED],
"The epoch to build Rust with. Newer epochs may include features
that require breaking changes. The default epoch is 2015 (the first
epoch). Crates compiled with different epochs can be linked together."),
edition: Edition = (Edition::Edition2015, parse_edition, [TRACKED],
"The edition to build Rust with. Newer editions may include features
that require breaking changes. The default edition is 2015 (the first
edition). Crates compiled with different editions can be linked together."),
run_dsymutil: Option<bool> = (None, parse_opt_bool, [TRACKED],
"run `dsymutil` and delete intermediate object files"),
ui_testing: bool = (false, parse_bool, [UNTRACKED],
Expand Down Expand Up @@ -2258,7 +2258,7 @@ mod dep_tracking {
use std::hash::Hash;
use std::path::PathBuf;
use std::collections::hash_map::DefaultHasher;
use super::{CrateType, DebugInfoLevel, Epoch, ErrorOutputType, Lto, OptLevel, OutputTypes,
use super::{CrateType, DebugInfoLevel, Edition, ErrorOutputType, Lto, OptLevel, OutputTypes,
Passes, Sanitizer};
use syntax::feature_gate::UnstableFeatures;
use rustc_back::{PanicStrategy, RelroLevel};
Expand Down Expand Up @@ -2320,7 +2320,7 @@ mod dep_tracking {
impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind);
impl_dep_tracking_hash_via_hash!(Sanitizer);
impl_dep_tracking_hash_via_hash!(Option<Sanitizer>);
impl_dep_tracking_hash_via_hash!(Epoch);
impl_dep_tracking_hash_via_hash!(Edition);

impl_dep_tracking_hash_for_sortable_vec_of!(String);
impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf);
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use rustc_data_structures::sync::{Lrc, Lock};
use syntax::ast::NodeId;
use errors::{self, DiagnosticBuilder, DiagnosticId};
use errors::emitter::{Emitter, EmitterWriter};
use syntax::epoch::Epoch;
use syntax::edition::Edition;
use syntax::json::JsonEmitter;
use syntax::feature_gate;
use syntax::symbol::Symbol;
Expand Down Expand Up @@ -976,13 +976,13 @@ impl Session {
self.opts.debugging_opts.teach && !self.parse_sess.span_diagnostic.code_emitted(code)
}

/// Are we allowed to use features from the Rust 2018 epoch?
/// Are we allowed to use features from the Rust 2018 edition?
pub fn rust_2018(&self) -> bool {
self.opts.debugging_opts.epoch >= Epoch::Epoch2018
self.opts.debugging_opts.edition >= Edition::Edition2018
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
{
let (mut krate, features) = syntax::config::features(krate, &sess.parse_sess,
sess.opts.test,
sess.opts.debugging_opts.epoch);
sess.opts.debugging_opts.edition);
// these need to be set "early" so that expansion sees `quote` if enabled.
sess.init_features(features);

Expand Down
34 changes: 17 additions & 17 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use rustc::session;
use rustc::util;

use session::Session;
use syntax::epoch::Epoch;
use syntax::edition::Edition;
use lint::LintId;
use lint::FutureIncompatibleInfo;

Expand Down Expand Up @@ -197,82 +197,82 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
FutureIncompatibleInfo {
id: LintId::of(PRIVATE_IN_PUBLIC),
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(PUB_USE_OF_PRIVATE_EXTERN_CRATE),
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(PATTERNS_IN_FNS_WITHOUT_BODY),
reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(SAFE_EXTERN_STATICS),
reference: "issue #36247 <https://github.com/rust-lang/rust/issues/36247>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(INVALID_TYPE_PARAM_DEFAULT),
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(LEGACY_DIRECTORY_OWNERSHIP),
reference: "issue #37872 <https://github.com/rust-lang/rust/issues/37872>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(LEGACY_IMPORTS),
reference: "issue #38260 <https://github.com/rust-lang/rust/issues/38260>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(LEGACY_CONSTRUCTOR_VISIBILITY),
reference: "issue #39207 <https://github.com/rust-lang/rust/issues/39207>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(MISSING_FRAGMENT_SPECIFIER),
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN),
reference: "issue #41620 <https://github.com/rust-lang/rust/issues/41620>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(ANONYMOUS_PARAMETERS),
reference: "issue #41686 <https://github.com/rust-lang/rust/issues/41686>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES),
reference: "issue #42238 <https://github.com/rust-lang/rust/issues/42238>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(LATE_BOUND_LIFETIME_ARGUMENTS),
reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(SAFE_PACKED_BORROWS),
reference: "issue #46043 <https://github.com/rust-lang/rust/issues/46043>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(INCOHERENT_FUNDAMENTAL_IMPLS),
reference: "issue #46205 <https://github.com/rust-lang/rust/issues/46205>",
epoch: None,
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(TYVAR_BEHIND_RAW_POINTER),
reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
epoch: Some(Epoch::Epoch2018),
edition: Some(Edition::Edition2018),
}
]);

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if reached_raw_pointer
&& !self.tcx.features().arbitrary_self_types {
// this case used to be allowed by the compiler,
// so we do a future-compat lint here for the 2015 epoch
// so we do a future-compat lint here for the 2015 edition
// (see https://github.com/rust-lang/rust/issues/46906)
if self.tcx.sess.rust_2018() {
span_err!(self.tcx.sess, span, E0908,
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use feature_gate::{feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features
use {fold, attr};
use ast;
use codemap::Spanned;
use epoch::Epoch;
use edition::Edition;
use parse::{token, ParseSess};

use ptr::P;
Expand All @@ -27,7 +27,7 @@ pub struct StripUnconfigured<'a> {
}

// `cfg_attr`-process the crate's attributes and compute the crate's features.
pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, epoch: Epoch)
pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, edition: Edition)
-> (ast::Crate, Features) {
let features;
{
Expand All @@ -47,7 +47,7 @@ pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, epoc
return (krate, Features::new());
}

features = get_features(&sess.span_diagnostic, &krate.attrs, epoch);
features = get_features(&sess.span_diagnostic, &krate.attrs, edition);

// Avoid reconfiguring malformed `cfg_attr`s
if err_count == sess.span_diagnostic.err_count() {
Expand Down
Loading

0 comments on commit c2dbfa6

Please sign in to comment.