Stabilize non capturing closure to fn coercion

This commit is contained in:
est31 2017-05-23 02:28:13 +02:00
parent d0811c9148
commit 87950b79de
8 changed files with 2 additions and 75 deletions

View file

@ -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)

View file

@ -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
------------------------

View file

@ -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

View file

@ -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>,
}

View file

@ -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
}
}

View file

@ -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) = |_| {};

View file

@ -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] = [

View file

@ -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() {