Remove usage of extern_types feature gate

This commit is contained in:
bjorn3 2022-03-25 16:12:57 +01:00
parent 681ea25b20
commit 4b67506baa
2 changed files with 8 additions and 8 deletions

View file

@ -1,24 +1,25 @@
//! Closure type (equivalent to `&mut dyn FnMut(A) -> R`) that's `repr(C)`.
use std::marker::PhantomData;
#[repr(C)]
pub struct Closure<'a, A, R> {
call: unsafe extern "C" fn(&mut Env, A) -> R,
env: &'a mut Env,
call: unsafe extern "C" fn(*mut Env, A) -> R,
env: *mut Env,
_marker: PhantomData<&'a mut ()>,
}
extern "C" {
type Env;
}
struct Env;
impl<'a, A, R> !Sync for Closure<'a, A, R> {}
impl<'a, A, R> !Send for Closure<'a, A, R> {}
impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> {
fn from(f: &'a mut F) -> Self {
unsafe extern "C" fn call<A, R, F: FnMut(A) -> R>(env: &mut Env, arg: A) -> R {
unsafe extern "C" fn call<A, R, F: FnMut(A) -> R>(env: *mut Env, arg: A) -> R {
(*(env as *mut _ as *mut F))(arg)
}
Closure { call: call::<A, R, F>, env: unsafe { &mut *(f as *mut _ as *mut Env) } }
Closure { call: call::<A, R, F>, env: f as *mut _ as *mut Env, _marker: PhantomData }
}
}

View file

@ -24,7 +24,6 @@
#![cfg_attr(bootstrap, feature(const_fn_fn_ptr_basics))]
#![feature(allow_internal_unstable)]
#![feature(decl_macro)]
#![feature(extern_types)]
#![feature(negative_impls)]
#![feature(restricted_std)]
#![feature(rustc_attrs)]