about summary refs log tree commit diff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2017-05-23 02:28:13 +0200
committerest31 <MTest31@outlook.com>2017-05-25 11:57:55 +0200
commit87950b79de4bd12ad02f32dbebc60ab1bef17f82 (patch)
tree58b14b827856b87aec2de39489550f9ce85cfb72
parentd0811c9148ff4fa15aba69e7fb11d7ec5dabbe8d (diff)
downloadrust-87950b79de4bd12ad02f32dbebc60ab1bef17f82.tar.gz
rust-87950b79de4bd12ad02f32dbebc60ab1bef17f82.zip
Stabilize non capturing closure to fn coercion
-rw-r--r--src/doc/unstable-book/src/SUMMARY.md1
-rw-r--r--src/doc/unstable-book/src/language-features/closure-to-fn-coercion.md7
-rw-r--r--src/librustc_typeck/check/coercion.rs9
-rw-r--r--src/libsyntax/feature_gate.rs8
-rw-r--r--src/test/compile-fail/feature-gate-closure_to_fn_coercion.rs45
-rw-r--r--src/test/compile-fail/issue-40000.rs2
-rw-r--r--src/test/run-pass/closure-to-fn-coercion.rs4
-rw-r--r--src/test/run-pass/closure_to_fn_coercion-expected-types.rs1
8 files changed, 2 insertions, 75 deletions
diff --git a/src/doc/unstable-book/src/SUMMARY.md b/src/doc/unstable-book/src/SUMMARY.md
index 028f5c9ee5a..2058d4be17e 100644
--- a/src/doc/unstable-book/src/SUMMARY.md
+++ b/src/doc/unstable-book/src/SUMMARY.md
@@ -24,7 +24,6 @@
     - [cfg_target_has_atomic](language-features/cfg-target-has-atomic.md)
     - [cfg_target_thread_local](language-features/cfg-target-thread-local.md)
     - [cfg_target_vendor](language-features/cfg-target-vendor.md)
-    - [closure_to_fn_coercion](language-features/closure-to-fn-coercion.md)
     - [compiler_builtins](language-features/compiler-builtins.md)
     - [concat_idents](language-features/concat-idents.md)
     - [conservative_impl_trait](language-features/conservative-impl-trait.md)
diff --git a/src/doc/unstable-book/src/language-features/closure-to-fn-coercion.md b/src/doc/unstable-book/src/language-features/closure-to-fn-coercion.md
deleted file mode 100644
index 4e3b735e24f..00000000000
--- a/src/doc/unstable-book/src/language-features/closure-to-fn-coercion.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# `closure_to_fn_coercion`
-
-The tracking issue for this feature is: [#39817]
-
-[#39817]: https://github.com/rust-lang/rust/issues/39817
-
-------------------------
diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs
index c228fc6b24a..883a0a9d88a 100644
--- a/src/librustc_typeck/check/coercion.rs
+++ b/src/librustc_typeck/check/coercion.rs
@@ -76,7 +76,6 @@ use rustc::ty::relate::RelateResult;
 use rustc::ty::subst::Subst;
 use errors::DiagnosticBuilder;
 use syntax::abi;
-use syntax::feature_gate;
 use syntax::ptr::P;
 use syntax_pos;
 
@@ -614,14 +613,6 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
         let node_id_a = self.tcx.hir.as_local_node_id(def_id_a).unwrap();
         match b.sty {
             ty::TyFnPtr(_) if self.tcx.with_freevars(node_id_a, |v| v.is_empty()) => {
-                if !self.tcx.sess.features.borrow().closure_to_fn_coercion {
-                    feature_gate::emit_feature_err(&self.tcx.sess.parse_sess,
-                                                   "closure_to_fn_coercion",
-                                                   self.cause.span,
-                                                   feature_gate::GateIssue::Language,
-                                                   feature_gate::CLOSURE_TO_FN_COERCION);
-                    return self.unify_and(a, b, identity());
-                }
                 // We coerce the closure, which has fn type
                 //     `extern "rust-call" fn((arg0,arg1,...)) -> _`
                 // to
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 6acf27f314a..70ab2e8dfe7 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -318,9 +318,6 @@ declare_features! (
     // `extern "msp430-interrupt" fn()`
     (active, abi_msp430_interrupt, "1.16.0", Some(38487)),
 
-    // Coerces non capturing closures to function pointers
-    (active, closure_to_fn_coercion, "1.17.0", Some(39817)),
-
     // Used to identify crates that contain sanitizer runtimes
     // rustc internal
     (active, sanitizer_runtime, "1.17.0", None),
@@ -421,6 +418,8 @@ declare_features! (
     (accepted, loop_break_value, "1.19.0", Some(37339)),
     // Permits numeric fields in struct expressions and patterns.
     (accepted, relaxed_adts, "1.19.0", Some(35626)),
+    // Coerces non capturing closures to function pointers
+    (accepted, closure_to_fn_coercion, "1.19.0", Some(39817)),
 );
 
 // If you change this, please modify src/doc/unstable-book as well. You must
@@ -1020,9 +1019,6 @@ pub const EXPLAIN_VIS_MATCHER: &'static str =
 pub const EXPLAIN_PLACEMENT_IN: &'static str =
     "placement-in expression syntax is experimental and subject to change.";
 
-pub const CLOSURE_TO_FN_COERCION: &'static str =
-    "non-capturing closure to fn coercion is experimental";
-
 struct PostExpansionVisitor<'a> {
     context: &'a Context<'a>,
 }
diff --git a/src/test/compile-fail/feature-gate-closure_to_fn_coercion.rs b/src/test/compile-fail/feature-gate-closure_to_fn_coercion.rs
deleted file mode 100644
index d074a35628e..00000000000
--- a/src/test/compile-fail/feature-gate-closure_to_fn_coercion.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2017 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// ignore-stage0: new feature, remove this when SNAP
-// revisions: a b
-
-#[cfg(a)]
-mod a {
-    const FOO: fn(u8) -> u8 = |v: u8| { v };
-    //[a]~^ ERROR non-capturing closure to fn coercion is experimental
-    //[a]~^^ ERROR mismatched types
-
-    const BAR: [fn(&mut u32); 1] = [
-        |v: &mut u32| *v += 1,
-    //[a]~^ ERROR non-capturing closure to fn coercion is experimental
-    //[a]~^^ ERROR mismatched types
-    ];
-}
-
-#[cfg(b)]
-mod b {
-    fn func_specific() -> (fn() -> u32) {
-        || return 42
-        //[b]~^ ERROR non-capturing closure to fn coercion is experimental
-        //[b]~^^ ERROR mismatched types
-    }
-    fn foo() {
-        // Items
-        assert_eq!(func_specific()(), 42);
-        let foo: fn(u8) -> u8 = |v: u8| { v };
-        //[b]~^ ERROR non-capturing closure to fn coercion is experimental
-        //[b]~^^ ERROR mismatched types
-    }
-
-}
-
-
-
diff --git a/src/test/compile-fail/issue-40000.rs b/src/test/compile-fail/issue-40000.rs
index 3ccee0f12be..7daf4bcbaa4 100644
--- a/src/test/compile-fail/issue-40000.rs
+++ b/src/test/compile-fail/issue-40000.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(closure_to_fn_coercion)]
-
 fn main() {
     let bar: fn(&mut u32) = |_| {};
 
diff --git a/src/test/run-pass/closure-to-fn-coercion.rs b/src/test/run-pass/closure-to-fn-coercion.rs
index 13d1d6aa139..7fb26bdc936 100644
--- a/src/test/run-pass/closure-to-fn-coercion.rs
+++ b/src/test/run-pass/closure-to-fn-coercion.rs
@@ -8,10 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// ignore-stage0: new feature, remove this when SNAP
-
-#![feature(closure_to_fn_coercion)]
-
 const FOO: fn(u8) -> u8 = |v: u8| { v };
 
 const BAR: [fn(&mut u32); 5] = [
diff --git a/src/test/run-pass/closure_to_fn_coercion-expected-types.rs b/src/test/run-pass/closure_to_fn_coercion-expected-types.rs
index 7214ebfaf07..41da3089c88 100644
--- a/src/test/run-pass/closure_to_fn_coercion-expected-types.rs
+++ b/src/test/run-pass/closure_to_fn_coercion-expected-types.rs
@@ -9,7 +9,6 @@
 // except according to those terms.
 // Ensure that we deduce expected argument types when a `fn()` type is expected (#41755)
 
-#![feature(closure_to_fn_coercion)]
 fn foo(f: fn(Vec<u32>) -> usize) { }
 
 fn main() {