From d415844f5e82944dc1907ff4b66f9f74fcbaf6ff Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 2 Dec 2018 03:59:25 +0300 Subject: [PATCH] syntax: Remove `#[non_exhaustive]` from `Edition` `Edition` is not a public API, we want users to break when a new edition is added --- src/librustc/ich/impls_syntax.rs | 12 ++++-------- src/librustc/ty/context.rs | 6 ------ src/libsyntax/ext/tt/quoted.rs | 1 - src/libsyntax_pos/edition.rs | 1 - src/libsyntax_pos/hygiene.rs | 4 ++-- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index b629fb820b34..b9ed0fcd4f38 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -134,14 +134,10 @@ impl_stable_hash_for!(struct ::syntax::attr::Stability { const_stability }); -impl<'a> HashStable> -for ::syntax::edition::Edition { - fn hash_stable(&self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) { - mem::discriminant(self).hash_stable(hcx, hasher); - } -} +impl_stable_hash_for!(enum ::syntax::edition::Edition { + Edition2015, + Edition2018, +}); impl<'a> HashStable> for ::syntax::attr::StabilityLevel { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 7862a72433ae..f04119241310 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1493,12 +1493,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { BorrowckMode::Ast => match self.sess.edition() { Edition::Edition2015 => BorrowckMode::Ast, Edition::Edition2018 => BorrowckMode::Migrate, - - // For now, future editions mean Migrate. (But it - // would make a lot of sense for it to be changed to - // `BorrowckMode::Mir`, depending on how we plan to - // time the forcing of full migration to NLL.) - _ => BorrowckMode::Migrate, }, } } diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index edc431be3694..a7415e845cae 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -444,7 +444,6 @@ where macro_node_id, ), Edition::Edition2018 => parse_sep_and_kleene_op_2018(input, span, sess, features, attrs), - _ => unimplemented!(), } } diff --git a/src/libsyntax_pos/edition.rs b/src/libsyntax_pos/edition.rs index 5819cd7f480a..d57078ce9140 100644 --- a/src/libsyntax_pos/edition.rs +++ b/src/libsyntax_pos/edition.rs @@ -13,7 +13,6 @@ use std::str::FromStr; /// The edition of the compiler (RFC 2052) #[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, RustcEncodable, RustcDecodable, Eq)] -#[non_exhaustive] pub enum Edition { // editions must be kept in order, oldest to newest diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index bc52a3e1c7c2..074687fc726e 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -17,7 +17,7 @@ use GLOBALS; use Span; -use edition::Edition; +use edition::{Edition, DEFAULT_EDITION}; use symbol::Symbol; use serialize::{Encodable, Decodable, Encoder, Decoder}; @@ -217,7 +217,7 @@ impl HygieneData { opaque_and_semitransparent: SyntaxContext(0), }], markings: FxHashMap::default(), - default_edition: Edition::Edition2015, + default_edition: DEFAULT_EDITION, } }