Skip to content

Stabilize non capturing closure to fn coercion #42162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/doc/unstable-book/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -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)

This file was deleted.

9 changes: 0 additions & 9 deletions src/librustc_typeck/check/coercion.rs
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -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>,
}
45 changes: 0 additions & 45 deletions src/test/compile-fail/feature-gate-closure_to_fn_coercion.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/compile-fail/issue-40000.rs
Original file line number Diff line number Diff line change
@@ -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) = |_| {};

4 changes: 0 additions & 4 deletions src/test/run-pass/closure-to-fn-coercion.rs
Original file line number Diff line number Diff line change
@@ -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] = [
1 change: 0 additions & 1 deletion src/test/run-pass/closure_to_fn_coercion-expected-types.rs
Original file line number Diff line number Diff line change
@@ -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() {