Allow future-incompat lints to mention an epoch

This commit is contained in:
Manish Goregaokar 2018-02-22 16:51:42 -08:00
parent d9438c30d5
commit da9dc0507b
9 changed files with 102 additions and 30 deletions

View file

@ -113,7 +113,7 @@ pub enum OutputType {
}
/// The epoch of the compiler (RFC 2052)
#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq)]
#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)]
#[non_exhaustive]
pub enum Epoch {
// epochs must be kept in order, newest to oldest
@ -148,6 +148,15 @@ impl ToString for Epoch {
}
}
impl Epoch {
pub fn lint_name(&self) -> &'static str {
match *self {
Epoch::Epoch2015 => "epoch_2015",
Epoch::Epoch2018 => "epoch_2018",
}
}
}
impl str::FromStr for Epoch {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {

View file

@ -869,6 +869,10 @@ impl Session {
pub fn rust_2018(&self) -> bool {
self.opts.debugging_opts.epoch >= Epoch::Epoch2018
}
pub fn epoch(&self) -> Epoch {
self.opts.debugging_opts.epoch
}
}
pub fn build_session(sopts: config::Options,