diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2018-03-08 13:16:36 -0800 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2018-03-08 17:10:06 -0800 |
| commit | 667973204d5ff01a92eef35c54d004797413b8a2 (patch) | |
| tree | e51ac3b2386b321e0f18860fcef35ff24189d9c6 | |
| parent | fbe57cf13e59b9697f3c840e93611cab6e4a8fab (diff) | |
Note the future epoch for epoch lints
| -rw-r--r-- | src/librustc/lint/mod.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/epoch.rs | 14 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 14f5fe779d1..668e099ebab 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -493,9 +493,14 @@ 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) + } else { + "a future release".to_owned() + }; let explanation = format!("this was previously accepted by the compiler \ but is being phased out; \ - it will become a hard error in a future release!"); + it will become a hard error in {}!", future); let citation = format!("for more information, see {}", future_incompatible.reference); err.warn(&explanation); diff --git a/src/libsyntax/epoch.rs b/src/libsyntax/epoch.rs index 603729f0de0..32cbc79c550 100644 --- a/src/libsyntax/epoch.rs +++ b/src/libsyntax/epoch.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::fmt; use std::str::FromStr; /// The epoch of the compiler (RFC 2052) @@ -37,12 +38,13 @@ pub enum Epoch { // must be in order from oldest to newest pub const ALL_EPOCHS: &[Epoch] = &[Epoch::Epoch2015, Epoch::Epoch2018]; -impl ToString for Epoch { - fn to_string(&self) -> String { - match *self { - Epoch::Epoch2015 => "2015".into(), - Epoch::Epoch2018 => "2018".into(), - } +impl fmt::Display for Epoch { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let s = match *self { + Epoch::Epoch2015 => "2015", + Epoch::Epoch2018 => "2018", + }; + write!(f, "{}", s) } } |
