Skip to content

Commit 2079a08

Browse files
committed
Auto merge of #48860 - Manishearth:rollup, r=Manishearth
Rollup of 5 pull requests - Successful merges: #48527, #48588, #48801, #48856, #48857 - Failed merges:
2 parents 604d4ce + b65b171 commit 2079a08

22 files changed

+640
-436
lines changed

src/Cargo.lock

+7-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc/lint/builtin.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use errors::DiagnosticBuilder;
1818
use lint::{LintPass, LateLintPass, LintArray};
1919
use session::Session;
20-
use session::config::Epoch;
2120
use syntax::codemap::Span;
2221

2322
declare_lint! {
@@ -264,9 +263,8 @@ declare_lint! {
264263

265264
declare_lint! {
266265
pub BARE_TRAIT_OBJECT,
267-
Warn,
268-
"suggest using `dyn Trait` for trait objects",
269-
Epoch::Epoch2018
266+
Allow,
267+
"suggest using `dyn Trait` for trait objects"
270268
}
271269

272270
declare_lint! {

src/librustc/lint/context.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use util::nodemap::FxHashMap;
4242
use std::default::Default as StdDefault;
4343
use std::cell::{Ref, RefCell};
4444
use syntax::ast;
45+
use syntax::epoch;
4546
use syntax_pos::{MultiSpan, Span};
4647
use errors::DiagnosticBuilder;
4748
use hir;
@@ -105,7 +106,7 @@ pub struct FutureIncompatibleInfo {
105106
pub reference: &'static str,
106107
/// If this is an epoch fixing lint, the epoch in which
107108
/// this lint becomes obsolete
108-
pub epoch: Option<config::Epoch>,
109+
pub epoch: Option<epoch::Epoch>,
109110
}
110111

111112
/// The target of the `by_name` map, which accounts for renaming/deprecation.
@@ -201,7 +202,7 @@ impl LintStore {
201202
sess: Option<&Session>,
202203
lints: Vec<FutureIncompatibleInfo>) {
203204

204-
for epoch in config::ALL_EPOCHS {
205+
for epoch in epoch::ALL_EPOCHS {
205206
let lints = lints.iter().filter(|f| f.epoch == Some(*epoch)).map(|f| f.id)
206207
.collect::<Vec<_>>();
207208
if !lints.is_empty() {

src/librustc/lint/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ use hir::def_id::{CrateNum, LOCAL_CRATE};
3838
use hir::intravisit::{self, FnKind};
3939
use hir;
4040
use lint::builtin::BuiltinLintDiagnostics;
41-
use session::{config, Session, DiagnosticMessageId};
41+
use session::{Session, DiagnosticMessageId};
4242
use std::hash;
4343
use syntax::ast;
4444
use syntax::codemap::MultiSpan;
45+
use syntax::epoch::Epoch;
4546
use syntax::symbol::Symbol;
4647
use syntax::visit as ast_visit;
4748
use syntax_pos::Span;
@@ -77,7 +78,7 @@ pub struct Lint {
7778
pub desc: &'static str,
7879

7980
/// Deny lint after this epoch
80-
pub epoch_deny: Option<config::Epoch>,
81+
pub epoch_deny: Option<Epoch>,
8182
}
8283

8384
impl Lint {
@@ -492,9 +493,14 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
492493
// Check for future incompatibility lints and issue a stronger warning.
493494
let lints = sess.lint_store.borrow();
494495
if let Some(future_incompatible) = lints.future_incompatible(LintId::of(lint)) {
496+
let future = if let Some(epoch) = future_incompatible.epoch {
497+
format!("the {} epoch", epoch)
498+
} else {
499+
"a future release".to_owned()
500+
};
495501
let explanation = format!("this was previously accepted by the compiler \
496502
but is being phased out; \
497-
it will become a hard error in a future release!");
503+
it will become a hard error in {}!", future);
498504
let citation = format!("for more information, see {}",
499505
future_incompatible.reference);
500506
err.warn(&explanation);

src/librustc/session/config.rs

+3-54
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use middle::cstore;
2828

2929
use syntax::ast::{self, IntTy, UintTy};
3030
use syntax::codemap::{FileName, FilePathMapping};
31+
use syntax::epoch::Epoch;
3132
use syntax::parse::token;
3233
use syntax::parse;
3334
use syntax::symbol::Symbol;
@@ -111,59 +112,6 @@ pub enum OutputType {
111112
DepInfo,
112113
}
113114

114-
/// The epoch of the compiler (RFC 2052)
115-
#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)]
116-
#[non_exhaustive]
117-
pub enum Epoch {
118-
// epochs must be kept in order, newest to oldest
119-
/// The 2015 epoch
120-
Epoch2015,
121-
/// The 2018 epoch
122-
Epoch2018,
123-
// when adding new epochs, be sure to update:
124-
//
125-
// - the list in the `parse_epoch` static
126-
// - the match in the `parse_epoch` function
127-
// - add a `rust_####()` function to the session
128-
// - update the enum in Cargo's sources as well
129-
//
130-
// When -Zepoch becomes --epoch, there will
131-
// also be a check for the epoch being nightly-only
132-
// somewhere. That will need to be updated
133-
// whenever we're stabilizing/introducing a new epoch
134-
// as well as changing the default Cargo template.
135-
}
136-
137-
pub const ALL_EPOCHS: &[Epoch] = &[Epoch::Epoch2015, Epoch::Epoch2018];
138-
139-
impl ToString for Epoch {
140-
fn to_string(&self) -> String {
141-
match *self {
142-
Epoch::Epoch2015 => "2015".into(),
143-
Epoch::Epoch2018 => "2018".into(),
144-
}
145-
}
146-
}
147-
148-
impl Epoch {
149-
pub fn lint_name(&self) -> &'static str {
150-
match *self {
151-
Epoch::Epoch2015 => "epoch_2015",
152-
Epoch::Epoch2018 => "epoch_2018",
153-
}
154-
}
155-
}
156-
157-
impl str::FromStr for Epoch {
158-
type Err = ();
159-
fn from_str(s: &str) -> Result<Self, ()> {
160-
match s {
161-
"2015" => Ok(Epoch::Epoch2015),
162-
"2018" => Ok(Epoch::Epoch2018),
163-
_ => Err(()),
164-
}
165-
}
166-
}
167115

168116
impl_stable_hash_for!(enum self::OutputType {
169117
Bitcode,
@@ -829,9 +777,10 @@ macro_rules! options {
829777

830778
#[allow(dead_code)]
831779
mod $mod_set {
832-
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto, Epoch};
780+
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto};
833781
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
834782
use std::path::PathBuf;
783+
use syntax::epoch::Epoch;
835784

836785
$(
837786
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {

src/librustc/session/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use lint::builtin::BuiltinLintDiagnostics;
2020
use middle::allocator::AllocatorKind;
2121
use middle::dependency_format;
2222
use session::search_paths::PathKind;
23-
use session::config::{DebugInfoLevel, Epoch, OutputType};
23+
use session::config::{DebugInfoLevel, OutputType};
2424
use ty::tls;
2525
use util::nodemap::{FxHashMap, FxHashSet};
2626
use util::common::{duration_to_secs_str, ErrorReported};
@@ -30,6 +30,7 @@ use rustc_data_structures::sync::Lrc;
3030
use syntax::ast::NodeId;
3131
use errors::{self, DiagnosticBuilder, DiagnosticId};
3232
use errors::emitter::{Emitter, EmitterWriter};
33+
use syntax::epoch::Epoch;
3334
use syntax::json::JsonEmitter;
3435
use syntax::feature_gate;
3536
use syntax::symbol::Symbol;

src/librustc_driver/driver.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,9 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
647647
{
648648
let time_passes = sess.time_passes();
649649

650-
let (mut krate, features) = syntax::config::features(krate, &sess.parse_sess, sess.opts.test);
650+
let (mut krate, features) = syntax::config::features(krate, &sess.parse_sess,
651+
sess.opts.test,
652+
sess.opts.debugging_opts.epoch);
651653
// these need to be set "early" so that expansion sees `quote` if enabled.
652654
sess.init_features(features);
653655

src/librustc_errors/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ serialize = { path = "../libserialize" }
1313
syntax_pos = { path = "../libsyntax_pos" }
1414
rustc_data_structures = { path = "../librustc_data_structures" }
1515
unicode-width = "0.1.4"
16+
atty = "0.2"
17+
termcolor = "0.3"

0 commit comments

Comments
 (0)