]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #49968 - christianpoveda:stabilize_dyn, r=nikomatsakis
authorkennytm <kennytm@gmail.com>
Fri, 27 Apr 2018 19:32:12 +0000 (03:32 +0800)
committerGitHub <noreply@github.com>
Fri, 27 Apr 2018 19:32:12 +0000 (03:32 +0800)
Stabilize dyn trait

This PR stabilizes RFC 2113. I followed the [stabilization guide](https://forge.rust-lang.org/stabilization-guide.html).

Related issue: https://github.com/rust-lang/rust/issues/49218

1  2 
src/librustc/hir/lowering.rs
src/librustc/lib.rs
src/librustc_mir/lib.rs
src/librustc_typeck/lib.rs
src/librustdoc/lib.rs
src/libsyntax/feature_gate.rs

index f5d590f25c80f19e2167ccd8f8cd77be326393bb,74fedd6bfbafee8c5670f50dbe0d7e412ecdc5d9..e4b9fc1385d4070904d0f850aa0068d27f9fee35
@@@ -655,7 -655,7 +655,7 @@@ impl<'a> LoweringContext<'a> 
                  self.resolver.definitions().create_def_with_parent(
                      parent_id.index,
                      def_node_id,
 -                    DefPathData::LifetimeDef(str_name),
 +                    DefPathData::LifetimeDef(str_name.as_interned_str()),
                      DefIndexAddressSpace::High,
                      Mark::root(),
                      span,
                      self.context.resolver.definitions().create_def_with_parent(
                          self.parent,
                          def_node_id,
 -                        DefPathData::LifetimeDef(name.name().as_str()),
 +                        DefPathData::LifetimeDef(name.name().as_interned_str()),
                          DefIndexAddressSpace::High,
                          Mark::root(),
                          lifetime.span,
      }
  
      fn maybe_lint_bare_trait(&self, span: Span, id: NodeId, is_global: bool) {
-         if self.sess.features_untracked().dyn_trait {
-             self.sess.buffer_lint_with_diagnostic(
-                 builtin::BARE_TRAIT_OBJECT,
-                 id,
-                 span,
-                 "trait objects without an explicit `dyn` are deprecated",
-                 builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
-             )
-         }
+         self.sess.buffer_lint_with_diagnostic(
+             builtin::BARE_TRAIT_OBJECT,
+             id,
+             span,
+             "trait objects without an explicit `dyn` are deprecated",
+             builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
+         )
      }
  
      fn wrap_in_try_constructor(
diff --combined src/librustc/lib.rs
index c2b1d7f09149e2c8a3dec39a4b2c3edb30237cb8,f29da5eb112809972fa17ad66c17b25f4086f7b7..24892dfcc8f7d63d034b3dd15635990708235136
@@@ -45,8 -45,8 +45,8 @@@
  #![feature(const_fn)]
  #![feature(core_intrinsics)]
  #![feature(drain_filter)]
- #![feature(dyn_trait)]
  #![feature(entry_or_default)]
+ #![cfg_attr(stage0, feature(dyn_trait))]
  #![feature(from_ref)]
  #![feature(fs_read_write)]
  #![cfg_attr(windows, feature(libc))]
@@@ -58,7 -58,6 +58,7 @@@
  #![feature(nonzero)]
  #![feature(proc_macro_internals)]
  #![feature(quote)]
 +#![feature(optin_builtin_traits)]
  #![feature(refcell_replace_swap)]
  #![feature(rustc_diagnostic_macros)]
  #![feature(slice_patterns)]
@@@ -82,7 -81,7 +82,7 @@@ extern crate graphviz
  #[macro_use] extern crate lazy_static;
  #[cfg(windows)]
  extern crate libc;
 -extern crate rustc_back;
 +extern crate rustc_target;
  #[macro_use] extern crate rustc_data_structures;
  extern crate serialize;
  extern crate rustc_const_math;
diff --combined src/librustc_mir/lib.rs
index 399892522a3531ebe9c61ce9bce31eeb937e3692,482fd5989f8bdd0bf5950b812c13228f8e2556ef..75b7a10097df4e0b5ac9f544b33134f067227b90
@@@ -24,7 -24,7 +24,7 @@@ Rust MIR: a lowered representation of R
  #![feature(const_fn)]
  #![feature(core_intrinsics)]
  #![feature(decl_macro)]
- #![feature(dyn_trait)]
+ #![cfg_attr(stage0, feature(dyn_trait))]
  #![feature(fs_read_write)]
  #![feature(macro_vis_matcher)]
  #![feature(exhaustive_patterns)]
@@@ -49,7 -49,7 +49,7 @@@ extern crate rustc_errors
  #[macro_use]
  extern crate syntax;
  extern crate syntax_pos;
 -extern crate rustc_back;
 +extern crate rustc_target;
  extern crate rustc_const_math;
  extern crate core; // for NonZero
  extern crate log_settings;
index 23fe91ffdebb641984993f3b49e7adb431397fe5,1e48926f2b3be3663375bd542590923f45503c3e..958960d3a36fd3660850b5d24cdcb72199f844eb
@@@ -71,6 -71,8 +71,8 @@@ This API is completely unstable and sub
  
  #![allow(non_camel_case_types)]
  
+ #![cfg_attr(stage0, feature(dyn_trait))]
  #![feature(box_patterns)]
  #![feature(box_syntax)]
  #![feature(crate_visibility_modifier)]
@@@ -81,7 -83,6 +83,6 @@@
  #![feature(rustc_diagnostic_macros)]
  #![feature(slice_patterns)]
  #![feature(slice_sort_by_cached_key)]
- #![feature(dyn_trait)]
  #![feature(never_type)]
  
  #[macro_use] extern crate log;
@@@ -94,7 -95,6 +95,7 @@@ extern crate rustc_platform_intrinsics 
  extern crate rustc_const_math;
  extern crate rustc_data_structures;
  extern crate rustc_errors as errors;
 +extern crate rustc_target;
  
  use rustc::hir;
  use rustc::lint;
@@@ -112,7 -112,7 +113,7 @@@ use session::{CompileIncomplete, config
  use util::common::time;
  
  use syntax::ast;
 -use syntax::abi::Abi;
 +use rustc_target::spec::abi::Abi;
  use syntax_pos::Span;
  
  use std::iter;
@@@ -213,7 -213,7 +214,7 @@@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCt
                  tcx.mk_nil()
              };
  
 -            let se_ty = tcx.mk_fn_ptr(ty::Binder(
 +            let se_ty = tcx.mk_fn_ptr(ty::Binder::bind(
                  tcx.mk_fn_sig(
                      iter::empty(),
                      expected_return_type,
@@@ -262,7 -262,7 +263,7 @@@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyC
                  _ => ()
              }
  
 -            let se_ty = tcx.mk_fn_ptr(ty::Binder(
 +            let se_ty = tcx.mk_fn_ptr(ty::Binder::bind(
                  tcx.mk_fn_sig(
                      [
                          tcx.types.isize,
diff --combined src/librustdoc/lib.rs
index 614386a583a7772ae76c30af1779791da9e70439,00153061fd5e97f4e630eb6bcbef0b8994ad9c6e..8efb51bccd80529d909975bff4ef9a0e8fca6e2c
@@@ -13,6 -13,8 +13,8 @@@
         html_root_url = "https://doc.rust-lang.org/nightly/",
         html_playground_url = "https://play.rust-lang.org/")]
  
+ #![cfg_attr(stage0, feature(dyn_trait))]
  #![feature(ascii_ctype)]
  #![feature(rustc_private)]
  #![feature(box_patterns)]
@@@ -23,7 -25,6 +25,6 @@@
  #![feature(test)]
  #![feature(vec_remove_item)]
  #![feature(entry_and_modify)]
- #![feature(dyn_trait)]
  
  extern crate arena;
  extern crate getopts;
@@@ -35,8 -36,8 +36,8 @@@ extern crate rustc_trans_utils
  extern crate rustc_driver;
  extern crate rustc_resolve;
  extern crate rustc_lint;
 -extern crate rustc_back;
  extern crate rustc_metadata;
 +extern crate rustc_target;
  extern crate rustc_typeck;
  extern crate serialize;
  #[macro_use] extern crate syntax;
@@@ -66,7 -67,7 +67,7 @@@ use externalfiles::ExternalHtml
  use rustc::session::search_paths::SearchPaths;
  use rustc::session::config::{ErrorOutputType, RustcOptGroup, Externs, CodegenOptions};
  use rustc::session::config::{nightly_options, build_codegen_options};
 -use rustc_back::target::TargetTriple;
 +use rustc_target::spec::TargetTriple;
  
  #[macro_use]
  pub mod externalfiles;
index 0331e90164f0c763e41acde31537f49de1985db1,6ab8a54cf96ad511ed519976519ea40169080c6f..a4a83712a083a730029d66aacb1542a13db6d45d
@@@ -25,7 -25,7 +25,7 @@@
  use self::AttributeType::*;
  use self::AttributeGate::*;
  
 -use abi::Abi;
 +use rustc_target::spec::abi::Abi;
  use ast::{self, NodeId, PatKind, RangeEnd};
  use attr;
  use edition::{ALL_EDITIONS, Edition};
@@@ -375,9 -375,6 +375,6 @@@ declare_features! 
      // Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
      (active, non_exhaustive, "1.22.0", Some(44109), None),
  
-     // Trait object syntax with `dyn` prefix
-     (active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)),
      // `crate` as visibility modifier, synonymous to `pub(crate)`
      (active, crate_visibility_modifier, "1.23.0", Some(45388), Some(Edition::Edition2018)),
  
@@@ -592,6 -589,8 +589,8 @@@ declare_features! 
      (accepted, cfg_target_feature, "1.27.0", Some(29717), None),
      // Allows #[target_feature(...)]
      (accepted, target_feature, "1.27.0", None, None),
+     // Trait object syntax with `dyn` prefix
+     (accepted, dyn_trait, "1.27.0", Some(44662), None),
  );
  
  // If you change this, please modify src/doc/unstable-book as well. You must
@@@ -936,7 -935,7 +935,7 @@@ pub const BUILTIN_ATTRIBUTES: &'static 
                                   "the `#[naked]` attribute \
                                    is an experimental feature",
                                   cfg_fn!(naked_functions))),
 -    ("target_feature", Normal, Ungated),
 +    ("target_feature", Whitelisted, Ungated),
      ("export_name", Whitelisted, Ungated),
      ("inline", Whitelisted, Ungated),
      ("link", Whitelisted, Ungated),
@@@ -1657,10 -1656,6 +1656,6 @@@ impl<'a> Visitor<'a> for PostExpansionV
                  gate_feature_post!(&self, never_type, ty.span,
                                     "The `!` type is experimental");
              }
-             ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
-                 gate_feature_post!(&self, dyn_trait, ty.span,
-                                    "`dyn Trait` syntax is unstable");
-             }
              _ => {}
          }
          visit::walk_ty(self, ty)