From 4338bd178d725c91fa052682ef6e26cc4280bf75 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 6 Mar 2018 14:05:03 -0800 Subject: [PATCH 1/9] Move epochs to libsyntax --- src/librustc/lint/builtin.rs | 2 +- src/librustc/lint/context.rs | 5 ++- src/librustc/lint/mod.rs | 5 ++- src/librustc/session/config.rs | 57 ++--------------------------- src/librustc/session/mod.rs | 3 +- src/librustc_lint/lib.rs | 3 +- src/libsyntax/epoch.rs | 67 ++++++++++++++++++++++++++++++++++ src/libsyntax/lib.rs | 2 + 8 files changed, 83 insertions(+), 61 deletions(-) create mode 100644 src/libsyntax/epoch.rs diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index a951265d458..c9a838a6628 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -17,8 +17,8 @@ use errors::DiagnosticBuilder; use lint::{LintPass, LateLintPass, LintArray}; use session::Session; -use session::config::Epoch; use syntax::codemap::Span; +use syntax::epoch::Epoch; declare_lint! { pub EXCEEDING_BITSHIFTS, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index bfd2034dd6c..b1e28f729ed 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -42,6 +42,7 @@ use util::nodemap::FxHashMap; use std::default::Default as StdDefault; use std::cell::{Ref, RefCell}; use syntax::ast; +use syntax::epoch; use syntax_pos::{MultiSpan, Span}; use errors::DiagnosticBuilder; use hir; @@ -105,7 +106,7 @@ pub struct FutureIncompatibleInfo { pub reference: &'static str, /// If this is an epoch fixing lint, the epoch in which /// this lint becomes obsolete - pub epoch: Option, + pub epoch: Option, } /// The target of the `by_name` map, which accounts for renaming/deprecation. @@ -201,7 +202,7 @@ impl LintStore { sess: Option<&Session>, lints: Vec) { - for epoch in config::ALL_EPOCHS { + for epoch in epoch::ALL_EPOCHS { let lints = lints.iter().filter(|f| f.epoch == Some(*epoch)).map(|f| f.id) .collect::>(); if !lints.is_empty() { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index affd02aa518..14f5fe779d1 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -38,10 +38,11 @@ use hir::def_id::{CrateNum, LOCAL_CRATE}; use hir::intravisit::{self, FnKind}; use hir; use lint::builtin::BuiltinLintDiagnostics; -use session::{config, Session, DiagnosticMessageId}; +use session::{Session, DiagnosticMessageId}; use std::hash; use syntax::ast; use syntax::codemap::MultiSpan; +use syntax::epoch::Epoch; use syntax::symbol::Symbol; use syntax::visit as ast_visit; use syntax_pos::Span; @@ -77,7 +78,7 @@ pub struct Lint { pub desc: &'static str, /// Deny lint after this epoch - pub epoch_deny: Option, + pub epoch_deny: Option, } impl Lint { diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 75b4409695e..1c5cfa87ef4 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -28,6 +28,7 @@ use middle::cstore; use syntax::ast::{self, IntTy, UintTy}; use syntax::codemap::{FileName, FilePathMapping}; +use syntax::epoch::Epoch; use syntax::parse::token; use syntax::parse; use syntax::symbol::Symbol; @@ -111,59 +112,6 @@ pub enum OutputType { DepInfo, } -/// The epoch of the compiler (RFC 2052) -#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)] -#[non_exhaustive] -pub enum Epoch { - // epochs must be kept in order, newest to oldest - /// The 2015 epoch - Epoch2015, - /// The 2018 epoch - Epoch2018, - // when adding new epochs, be sure to update: - // - // - the list in the `parse_epoch` static - // - the match in the `parse_epoch` function - // - add a `rust_####()` function to the session - // - update the enum in Cargo's sources as well - // - // When -Zepoch becomes --epoch, there will - // also be a check for the epoch being nightly-only - // somewhere. That will need to be updated - // whenever we're stabilizing/introducing a new epoch - // as well as changing the default Cargo template. -} - -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 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 { - match s { - "2015" => Ok(Epoch::Epoch2015), - "2018" => Ok(Epoch::Epoch2018), - _ => Err(()), - } - } -} impl_stable_hash_for!(enum self::OutputType { Bitcode, @@ -829,9 +777,10 @@ macro_rules! options { #[allow(dead_code)] mod $mod_set { - use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto, Epoch}; + use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto}; use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel}; use std::path::PathBuf; + use syntax::epoch::Epoch; $( pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool { diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index a355a1ca501..cdbbcf6a8dd 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -20,7 +20,7 @@ use lint::builtin::BuiltinLintDiagnostics; use middle::allocator::AllocatorKind; use middle::dependency_format; use session::search_paths::PathKind; -use session::config::{DebugInfoLevel, Epoch, OutputType}; +use session::config::{DebugInfoLevel, OutputType}; use ty::tls; use util::nodemap::{FxHashMap, FxHashSet}; use util::common::{duration_to_secs_str, ErrorReported}; @@ -30,6 +30,7 @@ use rustc_data_structures::sync::Lrc; use syntax::ast::NodeId; use errors::{self, DiagnosticBuilder, DiagnosticId}; use errors::emitter::{Emitter, EmitterWriter}; +use syntax::epoch::Epoch; use syntax::json::JsonEmitter; use syntax::feature_gate; use syntax::symbol::Symbol; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index e941f2e4e1c..03e159e74b9 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -47,6 +47,7 @@ use rustc::session; use rustc::util; use session::Session; +use syntax::epoch::Epoch; use lint::LintId; use lint::FutureIncompatibleInfo; @@ -279,7 +280,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { FutureIncompatibleInfo { id: LintId::of(lint::builtin::BARE_TRAIT_OBJECT), reference: "issue #48457 ", - epoch: Some(session::config::Epoch::Epoch2018), + epoch: Some(Epoch::Epoch2018), } ]); diff --git a/src/libsyntax/epoch.rs b/src/libsyntax/epoch.rs new file mode 100644 index 00000000000..603729f0de0 --- /dev/null +++ b/src/libsyntax/epoch.rs @@ -0,0 +1,67 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::str::FromStr; + +/// The epoch of the compiler (RFC 2052) +#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)] +#[non_exhaustive] +pub enum Epoch { + // epochs must be kept in order, newest to oldest + + /// The 2015 epoch + Epoch2015, + /// The 2018 epoch + Epoch2018, + + // when adding new epochs, be sure to update: + // + // - the list in the `parse_epoch` static in librustc::session::config + // - add a `rust_####()` function to the session + // - update the enum in Cargo's sources as well + // + // When -Zepoch becomes --epoch, there will + // also be a check for the epoch being nightly-only + // somewhere. That will need to be updated + // whenever we're stabilizing/introducing a new epoch + // as well as changing the default Cargo template. +} + +// 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 Epoch { + pub fn lint_name(&self) -> &'static str { + match *self { + Epoch::Epoch2015 => "epoch_2015", + Epoch::Epoch2018 => "epoch_2018", + } + } +} + +impl FromStr for Epoch { + type Err = (); + fn from_str(s: &str) -> Result { + match s { + "2015" => Ok(Epoch::Epoch2015), + "2018" => Ok(Epoch::Epoch2018), + _ => Err(()) + } + } +} diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 14e39b5af42..50e94e5cba7 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -23,6 +23,7 @@ #![feature(unicode)] #![feature(rustc_diagnostic_macros)] #![feature(match_default_bindings)] +#![feature(non_exhaustive)] #![feature(i128_type)] #![feature(const_atomic_usize_new)] #![feature(rustc_attrs)] @@ -114,6 +115,7 @@ pub mod codemap; #[macro_use] pub mod config; pub mod entry; +pub mod epoch; pub mod feature_gate; pub mod fold; pub mod parse; From c3fe3a56c25eec6923c47ac6c5434fcdaf27ad40 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 6 Mar 2018 16:02:58 -0800 Subject: [PATCH 2/9] Allow mentioning an optional epoch on features --- src/libsyntax/feature_gate.rs | 369 +++++++++++++++++----------------- 1 file changed, 185 insertions(+), 184 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 1a790bf78bd..c53fa2bd9a6 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -28,6 +28,7 @@ use self::AttributeGate::*; use abi::Abi; use ast::{self, NodeId, PatKind, RangeEnd, RangeSyntax}; use attr; +use epoch::Epoch; use codemap::Spanned; use syntax_pos::Span; use errors::{DiagnosticBuilder, Handler, FatalError}; @@ -54,12 +55,12 @@ macro_rules! set { } macro_rules! declare_features { - ($((active, $feature: ident, $ver: expr, $issue: expr),)+) => { + ($((active, $feature: ident, $ver: expr, $issue: expr, $epoch: expr),)+) => { /// Represents active features that are currently being implemented or /// currently being considered for addition/removal. const ACTIVE_FEATURES: - &'static [(&'static str, &'static str, Option, fn(&mut Features, Span))] = - &[$((stringify!($feature), $ver, $issue, set!($feature))),+]; + &'static [(&'static str, &'static str, Option, Option, fn(&mut Features, Span))] = + &[$((stringify!($feature), $ver, $issue, $epoch, set!($feature))),+]; /// A set of features to be used by later passes. #[derive(Clone)] @@ -88,21 +89,21 @@ macro_rules! declare_features { } }; - ($((removed, $feature: ident, $ver: expr, $issue: expr),)+) => { + ($((removed, $feature: ident, $ver: expr, $issue: expr, None),)+) => { /// Represents unstable features which have since been removed (it was once Active) const REMOVED_FEATURES: &'static [(&'static str, &'static str, Option)] = &[ $((stringify!($feature), $ver, $issue)),+ ]; }; - ($((stable_removed, $feature: ident, $ver: expr, $issue: expr),)+) => { + ($((stable_removed, $feature: ident, $ver: expr, $issue: expr, None),)+) => { /// Represents stable features which have since been removed (it was once Accepted) const STABLE_REMOVED_FEATURES: &'static [(&'static str, &'static str, Option)] = &[ $((stringify!($feature), $ver, $issue)),+ ]; }; - ($((accepted, $feature: ident, $ver: expr, $issue: expr),)+) => { + ($((accepted, $feature: ident, $ver: expr, $issue: expr, None),)+) => { /// Those language feature has since been Accepted (it was once Active) const ACCEPTED_FEATURES: &'static [(&'static str, &'static str, Option)] = &[ $((stringify!($feature), $ver, $issue)),+ @@ -122,78 +123,78 @@ macro_rules! declare_features { // source, so take care when modifying it. declare_features! ( - (active, asm, "1.0.0", Some(29722)), - (active, concat_idents, "1.0.0", Some(29599)), - (active, link_args, "1.0.0", Some(29596)), - (active, log_syntax, "1.0.0", Some(29598)), - (active, non_ascii_idents, "1.0.0", Some(28979)), - (active, plugin_registrar, "1.0.0", Some(29597)), - (active, thread_local, "1.0.0", Some(29594)), - (active, trace_macros, "1.0.0", Some(29598)), + (active, asm, "1.0.0", Some(29722), None), + (active, concat_idents, "1.0.0", Some(29599), None), + (active, link_args, "1.0.0", Some(29596), None), + (active, log_syntax, "1.0.0", Some(29598), None), + (active, non_ascii_idents, "1.0.0", Some(28979), None), + (active, plugin_registrar, "1.0.0", Some(29597), None), + (active, thread_local, "1.0.0", Some(29594), None), + (active, trace_macros, "1.0.0", Some(29598), None), // rustc internal, for now: - (active, intrinsics, "1.0.0", None), - (active, lang_items, "1.0.0", None), + (active, intrinsics, "1.0.0", None, None), + (active, lang_items, "1.0.0", None, None), - (active, link_llvm_intrinsics, "1.0.0", Some(29602)), - (active, linkage, "1.0.0", Some(29603)), - (active, quote, "1.0.0", Some(29601)), + (active, link_llvm_intrinsics, "1.0.0", Some(29602), None), + (active, linkage, "1.0.0", Some(29603), None), + (active, quote, "1.0.0", Some(29601), None), // rustc internal - (active, rustc_diagnostic_macros, "1.0.0", None), - (active, rustc_const_unstable, "1.0.0", None), - (active, advanced_slice_patterns, "1.0.0", Some(23121)), - (active, box_syntax, "1.0.0", Some(27779)), - (active, placement_in_syntax, "1.0.0", Some(27779)), - (active, unboxed_closures, "1.0.0", Some(29625)), + (active, rustc_diagnostic_macros, "1.0.0", None, None), + (active, rustc_const_unstable, "1.0.0", None, None), + (active, advanced_slice_patterns, "1.0.0", Some(23121), None), + (active, box_syntax, "1.0.0", Some(27779), None), + (active, placement_in_syntax, "1.0.0", Some(27779), None), + (active, unboxed_closures, "1.0.0", Some(29625), None), - (active, fundamental, "1.0.0", Some(29635)), - (active, main, "1.0.0", Some(29634)), - (active, needs_allocator, "1.4.0", Some(27389)), - (active, on_unimplemented, "1.0.0", Some(29628)), - (active, plugin, "1.0.0", Some(29597)), - (active, simd_ffi, "1.0.0", Some(27731)), - (active, start, "1.0.0", Some(29633)), - (active, structural_match, "1.8.0", Some(31434)), - (active, panic_runtime, "1.10.0", Some(32837)), - (active, needs_panic_runtime, "1.10.0", Some(32837)), + (active, fundamental, "1.0.0", Some(29635), None), + (active, main, "1.0.0", Some(29634), None), + (active, needs_allocator, "1.4.0", Some(27389), None), + (active, on_unimplemented, "1.0.0", Some(29628), None), + (active, plugin, "1.0.0", Some(29597), None), + (active, simd_ffi, "1.0.0", Some(27731), None), + (active, start, "1.0.0", Some(29633), None), + (active, structural_match, "1.8.0", Some(31434), None), + (active, panic_runtime, "1.10.0", Some(32837), None), + (active, needs_panic_runtime, "1.10.0", Some(32837), None), // OIBIT specific features - (active, optin_builtin_traits, "1.0.0", Some(13231)), + (active, optin_builtin_traits, "1.0.0", Some(13231), None), // macro re-export needs more discussion and stabilization - (active, macro_reexport, "1.0.0", Some(29638)), + (active, macro_reexport, "1.0.0", Some(29638), None), // Allows use of #[staged_api] // rustc internal - (active, staged_api, "1.0.0", None), + (active, staged_api, "1.0.0", None, None), // Allows using #![no_core] - (active, no_core, "1.3.0", Some(29639)), + (active, no_core, "1.3.0", Some(29639), None), // Allows using `box` in patterns; RFC 469 - (active, box_patterns, "1.0.0", Some(29641)), + (active, box_patterns, "1.0.0", Some(29641), None), // Allows using the unsafe_destructor_blind_to_params attribute; // RFC 1238 - (active, dropck_parametricity, "1.3.0", Some(28498)), + (active, dropck_parametricity, "1.3.0", Some(28498), None), // Allows using the may_dangle attribute; RFC 1327 - (active, dropck_eyepatch, "1.10.0", Some(34761)), + (active, dropck_eyepatch, "1.10.0", Some(34761), None), // Allows the use of custom attributes; RFC 572 - (active, custom_attribute, "1.0.0", Some(29642)), + (active, custom_attribute, "1.0.0", Some(29642), None), // Allows the use of #[derive(Anything)] as sugar for // #[derive_Anything]. - (active, custom_derive, "1.0.0", Some(29644)), + (active, custom_derive, "1.0.0", Some(29644), None), // Allows the use of rustc_* attributes; RFC 572 - (active, rustc_attrs, "1.0.0", Some(29642)), + (active, rustc_attrs, "1.0.0", Some(29642), None), // Allows the use of non lexical lifetimes; RFC 2094 - (active, nll, "1.0.0", Some(43234)), + (active, nll, "1.0.0", Some(43234), None), // Allows the use of #[allow_internal_unstable]. This is an // attribute on macro_rules! and can't use the attribute handling @@ -201,7 +202,7 @@ declare_features! ( // macros disappear). // // rustc internal - (active, allow_internal_unstable, "1.0.0", None), + (active, allow_internal_unstable, "1.0.0", None, None), // Allows the use of #[allow_internal_unsafe]. This is an // attribute on macro_rules! and can't use the attribute handling @@ -209,349 +210,349 @@ declare_features! ( // macros disappear). // // rustc internal - (active, allow_internal_unsafe, "1.0.0", None), + (active, allow_internal_unsafe, "1.0.0", None, None), // #23121. Array patterns have some hazards yet. - (active, slice_patterns, "1.0.0", Some(23121)), + (active, slice_patterns, "1.0.0", Some(23121), None), // Allows the definition of `const fn` functions. - (active, const_fn, "1.2.0", Some(24111)), + (active, const_fn, "1.2.0", Some(24111), None), // Allows using #[prelude_import] on glob `use` items. // // rustc internal - (active, prelude_import, "1.2.0", None), + (active, prelude_import, "1.2.0", None, None), // Allows default type parameters to influence type inference. - (active, default_type_parameter_fallback, "1.3.0", Some(27336)), + (active, default_type_parameter_fallback, "1.3.0", Some(27336), None), // Allows associated type defaults - (active, associated_type_defaults, "1.2.0", Some(29661)), + (active, associated_type_defaults, "1.2.0", Some(29661), None), // allow `repr(simd)`, and importing the various simd intrinsics - (active, repr_simd, "1.4.0", Some(27731)), + (active, repr_simd, "1.4.0", Some(27731), None), // Allows cfg(target_feature = "..."). - (active, cfg_target_feature, "1.4.0", Some(29717)), + (active, cfg_target_feature, "1.4.0", Some(29717), None), // allow `extern "platform-intrinsic" { ... }` - (active, platform_intrinsics, "1.4.0", Some(27731)), + (active, platform_intrinsics, "1.4.0", Some(27731), None), // allow `#[unwind(..)]` // rust runtime internal - (active, unwind_attributes, "1.4.0", None), + (active, unwind_attributes, "1.4.0", None, None), // allow the use of `#[naked]` on functions. - (active, naked_functions, "1.9.0", Some(32408)), + (active, naked_functions, "1.9.0", Some(32408), None), // allow `#[no_debug]` - (active, no_debug, "1.5.0", Some(29721)), + (active, no_debug, "1.5.0", Some(29721), None), // allow `#[omit_gdb_pretty_printer_section]` // rustc internal. - (active, omit_gdb_pretty_printer_section, "1.5.0", None), + (active, omit_gdb_pretty_printer_section, "1.5.0", None, None), // Allows cfg(target_vendor = "..."). - (active, cfg_target_vendor, "1.5.0", Some(29718)), + (active, cfg_target_vendor, "1.5.0", Some(29718), None), // Allow attributes on expressions and non-item statements - (active, stmt_expr_attributes, "1.6.0", Some(15701)), + (active, stmt_expr_attributes, "1.6.0", Some(15701), None), // allow using type ascription in expressions - (active, type_ascription, "1.6.0", Some(23416)), + (active, type_ascription, "1.6.0", Some(23416), None), // Allows cfg(target_thread_local) - (active, cfg_target_thread_local, "1.7.0", Some(29594)), + (active, cfg_target_thread_local, "1.7.0", Some(29594), None), // rustc internal - (active, abi_vectorcall, "1.7.0", None), + (active, abi_vectorcall, "1.7.0", None, None), // a..=b and ..=b - (active, inclusive_range_syntax, "1.7.0", Some(28237)), + (active, inclusive_range_syntax, "1.7.0", Some(28237), None), // X..Y patterns - (active, exclusive_range_pattern, "1.11.0", Some(37854)), + (active, exclusive_range_pattern, "1.11.0", Some(37854), None), // impl specialization (RFC 1210) - (active, specialization, "1.7.0", Some(31844)), + (active, specialization, "1.7.0", Some(31844), None), // Allows cfg(target_has_atomic = "..."). - (active, cfg_target_has_atomic, "1.9.0", Some(32976)), + (active, cfg_target_has_atomic, "1.9.0", Some(32976), None), // Allows `impl Trait` in function return types. - (active, conservative_impl_trait, "1.12.0", Some(34511)), + (active, conservative_impl_trait, "1.12.0", Some(34511), None), // Allows `impl Trait` in function arguments. - (active, universal_impl_trait, "1.23.0", Some(34511)), + (active, universal_impl_trait, "1.23.0", Some(34511), None), // The `!` type - (active, never_type, "1.13.0", Some(35121)), + (active, never_type, "1.13.0", Some(35121), None), // Allows all literals in attribute lists and values of key-value pairs. - (active, attr_literals, "1.13.0", Some(34981)), + (active, attr_literals, "1.13.0", Some(34981), None), // Allows untagged unions `union U { ... }` - (active, untagged_unions, "1.13.0", Some(32836)), + (active, untagged_unions, "1.13.0", Some(32836), None), // Used to identify the `compiler_builtins` crate // rustc internal - (active, compiler_builtins, "1.13.0", None), + (active, compiler_builtins, "1.13.0", None, None), // Allows attributes on lifetime/type formal parameters in generics (RFC 1327) - (active, generic_param_attrs, "1.11.0", Some(34761)), + (active, generic_param_attrs, "1.11.0", Some(34761), None), // Allows #[link(..., cfg(..))] - (active, link_cfg, "1.14.0", Some(37406)), + (active, link_cfg, "1.14.0", Some(37406), None), - (active, use_extern_macros, "1.15.0", Some(35896)), + (active, use_extern_macros, "1.15.0", Some(35896), None), // Allows #[target_feature(...)] - (active, target_feature, "1.15.0", None), + (active, target_feature, "1.15.0", None, None), // `extern "ptx-*" fn()` - (active, abi_ptx, "1.15.0", None), + (active, abi_ptx, "1.15.0", None, None), // The `i128` type - (active, i128_type, "1.16.0", Some(35118)), + (active, i128_type, "1.16.0", Some(35118), None), // The `repr(i128)` annotation for enums - (active, repr128, "1.16.0", Some(35118)), + (active, repr128, "1.16.0", Some(35118), None), // The `unadjusted` ABI. Perma unstable. - (active, abi_unadjusted, "1.16.0", None), + (active, abi_unadjusted, "1.16.0", None, None), // Procedural macros 2.0. - (active, proc_macro, "1.16.0", Some(38356)), + (active, proc_macro, "1.16.0", Some(38356), None), // Declarative macros 2.0 (`macro`). - (active, decl_macro, "1.17.0", Some(39412)), + (active, decl_macro, "1.17.0", Some(39412), None), // Allows #[link(kind="static-nobundle"...] - (active, static_nobundle, "1.16.0", Some(37403)), + (active, static_nobundle, "1.16.0", Some(37403), None), // `extern "msp430-interrupt" fn()` - (active, abi_msp430_interrupt, "1.16.0", Some(38487)), + (active, abi_msp430_interrupt, "1.16.0", Some(38487), None), // Used to identify crates that contain sanitizer runtimes // rustc internal - (active, sanitizer_runtime, "1.17.0", None), + (active, sanitizer_runtime, "1.17.0", None, None), // Used to identify crates that contain the profiler runtime // rustc internal - (active, profiler_runtime, "1.18.0", None), + (active, profiler_runtime, "1.18.0", None, None), // `extern "x86-interrupt" fn()` - (active, abi_x86_interrupt, "1.17.0", Some(40180)), + (active, abi_x86_interrupt, "1.17.0", Some(40180), None), // Allows the `catch {...}` expression - (active, catch_expr, "1.17.0", Some(31436)), + (active, catch_expr, "1.17.0", Some(31436), None), // Used to preserve symbols (see llvm.used) - (active, used, "1.18.0", Some(40289)), + (active, used, "1.18.0", Some(40289), None), // Allows module-level inline assembly by way of global_asm!() - (active, global_asm, "1.18.0", Some(35119)), + (active, global_asm, "1.18.0", Some(35119), None), // Allows overlapping impls of marker traits - (active, overlapping_marker_traits, "1.18.0", Some(29864)), + (active, overlapping_marker_traits, "1.18.0", Some(29864), None), // Allows use of the :vis macro fragment specifier - (active, macro_vis_matcher, "1.18.0", Some(41022)), + (active, macro_vis_matcher, "1.18.0", Some(41022), None), // rustc internal - (active, abi_thiscall, "1.19.0", None), + (active, abi_thiscall, "1.19.0", None, None), // Allows a test to fail without failing the whole suite - (active, allow_fail, "1.19.0", Some(42219)), + (active, allow_fail, "1.19.0", Some(42219), None), // Allows unsized tuple coercion. - (active, unsized_tuple_coercion, "1.20.0", Some(42877)), + (active, unsized_tuple_coercion, "1.20.0", Some(42877), None), // Generators - (active, generators, "1.21.0", None), + (active, generators, "1.21.0", None, None), // Trait aliases - (active, trait_alias, "1.24.0", Some(41517)), + (active, trait_alias, "1.24.0", Some(41517), None), // global allocators and their internals - (active, global_allocator, "1.20.0", None), - (active, allocator_internals, "1.20.0", None), + (active, global_allocator, "1.20.0", None, None), + (active, allocator_internals, "1.20.0", None, None), // #[doc(cfg(...))] - (active, doc_cfg, "1.21.0", Some(43781)), + (active, doc_cfg, "1.21.0", Some(43781), None), // #[doc(masked)] - (active, doc_masked, "1.21.0", Some(44027)), + (active, doc_masked, "1.21.0", Some(44027), None), // #[doc(spotlight)] - (active, doc_spotlight, "1.22.0", Some(45040)), + (active, doc_spotlight, "1.22.0", Some(45040), None), // #[doc(include="some-file")] - (active, external_doc, "1.22.0", Some(44732)), + (active, external_doc, "1.22.0", Some(44732), None), // allow `#[must_use]` on functions and comparison operators (RFC 1940) - (active, fn_must_use, "1.21.0", Some(43302)), + (active, fn_must_use, "1.21.0", Some(43302), None), // Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008) - (active, non_exhaustive, "1.22.0", Some(44109)), + (active, non_exhaustive, "1.22.0", Some(44109), None), // Copy/Clone closures (RFC 2132) - (active, clone_closures, "1.22.0", Some(44490)), - (active, copy_closures, "1.22.0", Some(44490)), + (active, clone_closures, "1.22.0", Some(44490), None), + (active, copy_closures, "1.22.0", Some(44490), None), // allow `'_` placeholder lifetimes - (active, underscore_lifetimes, "1.22.0", Some(44524)), + (active, underscore_lifetimes, "1.22.0", Some(44524), None), // allow `..=` in patterns (RFC 1192) - (active, dotdoteq_in_patterns, "1.22.0", Some(28237)), + (active, dotdoteq_in_patterns, "1.22.0", Some(28237), None), // Default match binding modes (RFC 2005) - (active, match_default_bindings, "1.22.0", Some(42640)), + (active, match_default_bindings, "1.22.0", Some(42640), None), // Trait object syntax with `dyn` prefix - (active, dyn_trait, "1.22.0", Some(44662)), + (active, dyn_trait, "1.22.0", Some(44662), None), // `crate` as visibility modifier, synonymous to `pub(crate)` - (active, crate_visibility_modifier, "1.23.0", Some(45388)), + (active, crate_visibility_modifier, "1.23.0", Some(45388), None), // extern types - (active, extern_types, "1.23.0", Some(43467)), + (active, extern_types, "1.23.0", Some(43467), None), // Allow trait methods with arbitrary self types - (active, arbitrary_self_types, "1.23.0", Some(44874)), + (active, arbitrary_self_types, "1.23.0", Some(44874), None), // `crate` in paths - (active, crate_in_paths, "1.23.0", Some(45477)), + (active, crate_in_paths, "1.23.0", Some(45477), None), // In-band lifetime bindings (e.g. `fn foo(x: &'a u8) -> &'a u8`) - (active, in_band_lifetimes, "1.23.0", Some(44524)), + (active, in_band_lifetimes, "1.23.0", Some(44524), None), // generic associated types (RFC 1598) - (active, generic_associated_types, "1.23.0", Some(44265)), + (active, generic_associated_types, "1.23.0", Some(44265), None), // Resolve absolute paths as paths from other crates - (active, extern_absolute_paths, "1.24.0", Some(44660)), + (active, extern_absolute_paths, "1.24.0", Some(44660), None), // `foo.rs` as an alternative to `foo/mod.rs` - (active, non_modrs_mods, "1.24.0", Some(44660)), + (active, non_modrs_mods, "1.24.0", Some(44660), None), // Termination trait in main (RFC 1937) - (active, termination_trait, "1.24.0", Some(43301)), + (active, termination_trait, "1.24.0", Some(43301), None), // Allows use of the :lifetime macro fragment specifier - (active, macro_lifetime_matcher, "1.24.0", Some(46895)), + (active, macro_lifetime_matcher, "1.24.0", Some(46895), None), // `extern` in paths - (active, extern_in_paths, "1.23.0", Some(44660)), + (active, extern_in_paths, "1.23.0", Some(44660), None), // Allows `#[repr(transparent)]` attribute on newtype structs - (active, repr_transparent, "1.25.0", Some(43036)), + (active, repr_transparent, "1.25.0", Some(43036), None), // Use `?` as the Kleene "at most one" operator - (active, macro_at_most_once_rep, "1.25.0", Some(48075)), + (active, macro_at_most_once_rep, "1.25.0", Some(48075), None), // Multiple patterns with `|` in `if let` and `while let` - (active, if_while_or_patterns, "1.26.0", Some(48215)), + (active, if_while_or_patterns, "1.26.0", Some(48215), None), // Parentheses in patterns - (active, pattern_parentheses, "1.26.0", None), + (active, pattern_parentheses, "1.26.0", None, None), ); declare_features! ( - (removed, import_shadowing, "1.0.0", None), - (removed, managed_boxes, "1.0.0", None), + (removed, import_shadowing, "1.0.0", None, None), + (removed, managed_boxes, "1.0.0", None, None), // Allows use of unary negate on unsigned integers, e.g. -e for e: u8 - (removed, negate_unsigned, "1.0.0", Some(29645)), - (removed, reflect, "1.0.0", Some(27749)), + (removed, negate_unsigned, "1.0.0", Some(29645), None), + (removed, reflect, "1.0.0", Some(27749), None), // A way to temporarily opt out of opt in copy. This will *never* be accepted. - (removed, opt_out_copy, "1.0.0", None), - (removed, quad_precision_float, "1.0.0", None), - (removed, struct_inherit, "1.0.0", None), - (removed, test_removed_feature, "1.0.0", None), - (removed, visible_private_types, "1.0.0", None), - (removed, unsafe_no_drop_flag, "1.0.0", None), + (removed, opt_out_copy, "1.0.0", None, None), + (removed, quad_precision_float, "1.0.0", None, None), + (removed, struct_inherit, "1.0.0", None, None), + (removed, test_removed_feature, "1.0.0", None, None), + (removed, visible_private_types, "1.0.0", None, None), + (removed, unsafe_no_drop_flag, "1.0.0", None, None), // Allows using items which are missing stability attributes // rustc internal - (removed, unmarked_api, "1.0.0", None), - (removed, pushpop_unsafe, "1.2.0", None), - (removed, allocator, "1.0.0", None), + (removed, unmarked_api, "1.0.0", None, None), + (removed, pushpop_unsafe, "1.2.0", None, None), + (removed, allocator, "1.0.0", None, None), // Allows the `#[simd]` attribute -- removed in favor of `#[repr(simd)]` - (removed, simd, "1.0.0", Some(27731)), + (removed, simd, "1.0.0", Some(27731), None), ); declare_features! ( - (stable_removed, no_stack_check, "1.0.0", None), + (stable_removed, no_stack_check, "1.0.0", None, None), ); declare_features! ( - (accepted, associated_types, "1.0.0", None), + (accepted, associated_types, "1.0.0", None, None), // allow overloading augmented assignment operations like `a += b` - (accepted, augmented_assignments, "1.8.0", Some(28235)), + (accepted, augmented_assignments, "1.8.0", Some(28235), None), // allow empty structs and enum variants with braces - (accepted, braced_empty_structs, "1.8.0", Some(29720)), + (accepted, braced_empty_structs, "1.8.0", Some(29720), None), // Allows indexing into constant arrays. - (accepted, const_indexing, "1.24.0", Some(29947)), - (accepted, default_type_params, "1.0.0", None), - (accepted, globs, "1.0.0", None), - (accepted, if_let, "1.0.0", None), + (accepted, const_indexing, "1.24.0", Some(29947), None), + (accepted, default_type_params, "1.0.0", None, None), + (accepted, globs, "1.0.0", None, None), + (accepted, if_let, "1.0.0", None, None), // A temporary feature gate used to enable parser extensions needed // to bootstrap fix for #5723. - (accepted, issue_5723_bootstrap, "1.0.0", None), - (accepted, macro_rules, "1.0.0", None), + (accepted, issue_5723_bootstrap, "1.0.0", None, None), + (accepted, macro_rules, "1.0.0", None, None), // Allows using #![no_std] - (accepted, no_std, "1.6.0", None), - (accepted, slicing_syntax, "1.0.0", None), - (accepted, struct_variant, "1.0.0", None), + (accepted, no_std, "1.6.0", None, None), + (accepted, slicing_syntax, "1.0.0", None, None), + (accepted, struct_variant, "1.0.0", None, None), // These are used to test this portion of the compiler, they don't actually // mean anything - (accepted, test_accepted_feature, "1.0.0", None), - (accepted, tuple_indexing, "1.0.0", None), + (accepted, test_accepted_feature, "1.0.0", None, None), + (accepted, tuple_indexing, "1.0.0", None, None), // Allows macros to appear in the type position. - (accepted, type_macros, "1.13.0", Some(27245)), - (accepted, while_let, "1.0.0", None), + (accepted, type_macros, "1.13.0", Some(27245), None), + (accepted, while_let, "1.0.0", None, None), // Allows `#[deprecated]` attribute - (accepted, deprecated, "1.9.0", Some(29935)), + (accepted, deprecated, "1.9.0", Some(29935), None), // `expr?` - (accepted, question_mark, "1.13.0", Some(31436)), + (accepted, question_mark, "1.13.0", Some(31436), None), // Allows `..` in tuple (struct) patterns - (accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627)), - (accepted, item_like_imports, "1.15.0", Some(35120)), + (accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627), None), + (accepted, item_like_imports, "1.15.0", Some(35120), None), // Allows using `Self` and associated types in struct expressions and patterns. - (accepted, more_struct_aliases, "1.16.0", Some(37544)), + (accepted, more_struct_aliases, "1.16.0", Some(37544), None), // elide `'static` lifetimes in `static`s and `const`s - (accepted, static_in_const, "1.17.0", Some(35897)), + (accepted, static_in_const, "1.17.0", Some(35897), None), // Allows field shorthands (`x` meaning `x: x`) in struct literal expressions. - (accepted, field_init_shorthand, "1.17.0", Some(37340)), + (accepted, field_init_shorthand, "1.17.0", Some(37340), None), // Allows the definition recursive static items. - (accepted, static_recursion, "1.17.0", Some(29719)), + (accepted, static_recursion, "1.17.0", Some(29719), None), // pub(restricted) visibilities (RFC 1422) - (accepted, pub_restricted, "1.18.0", Some(32409)), + (accepted, pub_restricted, "1.18.0", Some(32409), None), // The #![windows_subsystem] attribute - (accepted, windows_subsystem, "1.18.0", Some(37499)), + (accepted, windows_subsystem, "1.18.0", Some(37499), None), // Allows `break {expr}` with a value inside `loop`s. - (accepted, loop_break_value, "1.19.0", Some(37339)), + (accepted, loop_break_value, "1.19.0", Some(37339), None), // Permits numeric fields in struct expressions and patterns. - (accepted, relaxed_adts, "1.19.0", Some(35626)), + (accepted, relaxed_adts, "1.19.0", Some(35626), None), // Coerces non capturing closures to function pointers - (accepted, closure_to_fn_coercion, "1.19.0", Some(39817)), + (accepted, closure_to_fn_coercion, "1.19.0", Some(39817), None), // Allows attributes on struct literal fields. - (accepted, struct_field_attributes, "1.20.0", Some(38814)), + (accepted, struct_field_attributes, "1.20.0", Some(38814), None), // Allows the definition of associated constants in `trait` or `impl` // blocks. - (accepted, associated_consts, "1.20.0", Some(29646)), + (accepted, associated_consts, "1.20.0", Some(29646), None), // Usage of the `compile_error!` macro - (accepted, compile_error, "1.20.0", Some(40872)), + (accepted, compile_error, "1.20.0", Some(40872), None), // See rust-lang/rfcs#1414. Allows code like `let x: &'static u32 = &42` to work. - (accepted, rvalue_static_promotion, "1.21.0", Some(38865)), + (accepted, rvalue_static_promotion, "1.21.0", Some(38865), None), // Allow Drop types in constants (RFC 1440) - (accepted, drop_types_in_const, "1.22.0", Some(33156)), + (accepted, drop_types_in_const, "1.22.0", Some(33156), None), // Allows the sysV64 ABI to be specified on all platforms // instead of just the platforms on which it is the C ABI - (accepted, abi_sysv64, "1.24.0", Some(36167)), + (accepted, abi_sysv64, "1.24.0", Some(36167), None), // Allows `repr(align(16))` struct attribute (RFC 1358) - (accepted, repr_align, "1.25.0", Some(33626)), + (accepted, repr_align, "1.25.0", Some(33626), None), // allow '|' at beginning of match arms (RFC 1925) - (accepted, match_beginning_vert, "1.25.0", Some(44101)), + (accepted, match_beginning_vert, "1.25.0", Some(44101), None), // Nested groups in `use` (RFC 2128) - (accepted, use_nested_groups, "1.25.0", Some(44494)), + (accepted, use_nested_groups, "1.25.0", Some(44494), None), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -1818,8 +1819,8 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute]) -> F continue }; - if let Some(&(_, _, _, set)) = ACTIVE_FEATURES.iter() - .find(|& &(n, _, _, _)| name == n) { + if let Some(&(_, _, _, _, set)) = ACTIVE_FEATURES.iter() + .find(|& &(n, ..)| name == n) { set(&mut features, mi.span); feature_checker.collect(&features, mi.span); } From b88a61e36e6cc1e76a2f8de13318bc8b25cbf3e5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 6 Mar 2018 16:14:25 -0800 Subject: [PATCH 3/9] Make it possible to ungate features by epoch --- src/librustc_driver/driver.rs | 4 +++- src/libsyntax/config.rs | 5 +++-- src/libsyntax/feature_gate.rs | 20 ++++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index c9cf3f3b81f..f020f86b686 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -647,7 +647,9 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session, { let time_passes = sess.time_passes(); - let (mut krate, features) = syntax::config::features(krate, &sess.parse_sess, sess.opts.test); + let (mut krate, features) = syntax::config::features(krate, &sess.parse_sess, + sess.opts.test, + sess.opts.debugging_opts.epoch); // these need to be set "early" so that expansion sees `quote` if enabled. sess.init_features(features); diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index aa360ed1bf5..6013c20daf2 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -13,6 +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 parse::{token, ParseSess}; use ptr::P; @@ -26,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) +pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, epoch: Epoch) -> (ast::Crate, Features) { let features; { @@ -46,7 +47,7 @@ pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool) return (krate, Features::new()); } - features = get_features(&sess.span_diagnostic, &krate.attrs); + features = get_features(&sess.span_diagnostic, &krate.attrs, epoch); // Avoid reconfiguring malformed `cfg_attr`s if err_count == sess.span_diagnostic.err_count() { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index c53fa2bd9a6..ec9a15d9f2b 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -30,7 +30,7 @@ use ast::{self, NodeId, PatKind, RangeEnd, RangeSyntax}; use attr; use epoch::Epoch; use codemap::Spanned; -use syntax_pos::Span; +use syntax_pos::{Span, DUMMY_SP}; use errors::{DiagnosticBuilder, Handler, FatalError}; use visit::{self, FnKind, Visitor}; use parse::ParseSess; @@ -59,7 +59,8 @@ macro_rules! declare_features { /// Represents active features that are currently being implemented or /// currently being considered for addition/removal. const ACTIVE_FEATURES: - &'static [(&'static str, &'static str, Option, Option, fn(&mut Features, Span))] = + &'static [(&'static str, &'static str, Option, + Option, fn(&mut Features, Span))] = &[$((stringify!($feature), $ver, $issue, $epoch, set!($feature))),+]; /// A set of features to be used by later passes. @@ -408,7 +409,7 @@ declare_features! ( (active, match_default_bindings, "1.22.0", Some(42640), None), // Trait object syntax with `dyn` prefix - (active, dyn_trait, "1.22.0", Some(44662), None), + (active, dyn_trait, "1.22.0", Some(44662), Some(Epoch::Epoch2018)), // `crate` as visibility modifier, synonymous to `pub(crate)` (active, crate_visibility_modifier, "1.23.0", Some(45388), None), @@ -1794,11 +1795,22 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } -pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute]) -> Features { +pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], + epoch: Epoch) -> Features { let mut features = Features::new(); let mut feature_checker = FeatureChecker::default(); + for &(.., f_epoch, set) in ACTIVE_FEATURES.iter() { + if let Some(f_epoch) = f_epoch { + if epoch >= f_epoch { + // FIXME(Manishearth) there is currently no way to set + // lang features by epoch + set(&mut features, DUMMY_SP); + } + } + } + for attr in krate_attrs { if !attr.check_name("feature") { continue From 197f35c3e0887125242a937af86d88db097e3938 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 6 Mar 2018 17:32:29 -0800 Subject: [PATCH 4/9] Make bare_trait_lint allow for now --- src/librustc/lint/builtin.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index c9a838a6628..8e1f76c5018 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -18,7 +18,6 @@ use errors::DiagnosticBuilder; use lint::{LintPass, LateLintPass, LintArray}; use session::Session; use syntax::codemap::Span; -use syntax::epoch::Epoch; declare_lint! { pub EXCEEDING_BITSHIFTS, @@ -264,9 +263,8 @@ declare_lint! { declare_lint! { pub BARE_TRAIT_OBJECT, - Warn, - "suggest using `dyn Trait` for trait objects", - Epoch::Epoch2018 + Allow, + "suggest using `dyn Trait` for trait objects" } declare_lint! { From 29542ec85a435e5d91ef3b4846c99034a862530b Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 8 Mar 2018 09:30:07 -0800 Subject: [PATCH 5/9] Add test --- src/test/run-pass/epoch-gate-feature.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/run-pass/epoch-gate-feature.rs diff --git a/src/test/run-pass/epoch-gate-feature.rs b/src/test/run-pass/epoch-gate-feature.rs new file mode 100644 index 00000000000..37d092c06e0 --- /dev/null +++ b/src/test/run-pass/epoch-gate-feature.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks if the correct registers are being used to pass arguments +// when the sysv64 ABI is specified. + +// compile-flags: -Zepoch=2018 + +pub trait Foo {} + +// should compile without the dyn trait feature flag +fn foo(x: &dyn Foo) {} + +pub fn main() {} From ae5ae846cd2da41c1f38f71830f416e36f77c1de Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 8 Mar 2018 09:37:37 -0800 Subject: [PATCH 6/9] Make tyvar_behind_raw_pointer an epoch lint --- src/librustc_lint/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 03e159e74b9..d78b2b654f0 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -275,7 +275,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { FutureIncompatibleInfo { id: LintId::of(TYVAR_BEHIND_RAW_POINTER), reference: "issue #46906 ", - epoch: None, + epoch: Some(Epoch::Epoch2018), }, FutureIncompatibleInfo { id: LintId::of(lint::builtin::BARE_TRAIT_OBJECT), From fbe57cf13e59b9697f3c840e93611cab6e4a8fab Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 8 Mar 2018 09:37:50 -0800 Subject: [PATCH 7/9] Make bare_trait_object not be an epoch lint --- src/librustc_lint/lib.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index d78b2b654f0..98751b4c12e 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -276,12 +276,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { id: LintId::of(TYVAR_BEHIND_RAW_POINTER), reference: "issue #46906 ", epoch: Some(Epoch::Epoch2018), - }, - FutureIncompatibleInfo { - id: LintId::of(lint::builtin::BARE_TRAIT_OBJECT), - reference: "issue #48457 ", - epoch: Some(Epoch::Epoch2018), - } + } ]); // Register renamed and removed lints From 667973204d5ff01a92eef35c54d004797413b8a2 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 8 Mar 2018 13:16:36 -0800 Subject: [PATCH 8/9] Note the future epoch for epoch lints --- src/librustc/lint/mod.rs | 7 ++++++- 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) } } From a08cfc4cb6020164372a52080b64280c711d1bd5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 8 Mar 2018 13:23:52 -0800 Subject: [PATCH 9/9] Add rust_2018_idioms lint group --- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/lib.rs | 6 ++++++ src/test/ui/inference-variable-behind-raw-pointer.stderr | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 831d4fc755f..d39e00ab18f 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1263,7 +1263,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields { pub struct UnreachablePub; declare_lint! { - UNREACHABLE_PUB, + pub UNREACHABLE_PUB, Allow, "`pub` items not reachable from crate root" } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 98751b4c12e..81609db6292 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -43,6 +43,7 @@ extern crate rustc_mir; extern crate syntax_pos; use rustc::lint; +use rustc::lint::builtin::BARE_TRAIT_OBJECT; use rustc::session; use rustc::util; @@ -177,6 +178,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { UNUSED_FEATURES, UNUSED_PARENS); + add_lint_group!(sess, + "rust_2018_idioms", + BARE_TRAIT_OBJECT, + UNREACHABLE_PUB); + // Guidelines for creating a future incompatibility lint: // // - Create a lint defaulting to warn as normal, with ideally the same error diff --git a/src/test/ui/inference-variable-behind-raw-pointer.stderr b/src/test/ui/inference-variable-behind-raw-pointer.stderr index e1d4df85c2f..eb40151615d 100644 --- a/src/test/ui/inference-variable-behind-raw-pointer.stderr +++ b/src/test/ui/inference-variable-behind-raw-pointer.stderr @@ -5,6 +5,6 @@ LL | if data.is_null() {} | ^^^^^^^ | = note: #[warn(tyvar_behind_raw_pointer)] on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 epoch! = note: for more information, see issue #46906