]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_data_structures/src/box_region.rs
Inline box_region macro calls
[rust.git] / compiler / rustc_data_structures / src / box_region.rs
index eb6f4e8213ec711dac0b945cc5c2f751c9511451..a1a757b705418c421fdbe92e3b51b8c5219f87be 100644 (file)
@@ -78,92 +78,3 @@ pub enum YieldType<I, A> {
     Initial(I),
     Accessor(Marker<A>),
 }
-
-#[macro_export]
-#[allow_internal_unstable(fn_traits)]
-macro_rules! declare_box_region_type {
-    (impl $v:vis
-     $name: ident,
-     $yield_type:ty,
-     for($($lifetimes:tt)*),
-     ($($args:ty),*) -> ($reti:ty, $retc:ty)
-    ) => {
-        $v struct $name($crate::box_region::PinnedGenerator<
-            $reti,
-            for<$($lifetimes)*> fn(($($args,)*)),
-            $retc
-        >);
-
-        impl $name {
-            fn new<T: ::std::ops::Generator<$crate::box_region::Action, Yield = $yield_type, Return = $retc> + 'static>(
-                generator: T
-            ) -> ($reti, Self) {
-                let (initial, pinned) = $crate::box_region::PinnedGenerator::new(generator);
-                (initial, $name(pinned))
-            }
-
-            $v fn access<F: for<$($lifetimes)*> FnOnce($($args,)*) -> R, R>(&mut self, f: F) -> R {
-                // Turn the FnOnce closure into *mut dyn FnMut()
-                // so we can pass it in to the generator
-                let mut r = None;
-                let mut f = Some(f);
-                let mut_f: &mut dyn for<$($lifetimes)*> FnMut(($($args,)*)) =
-                    &mut |args| {
-                        let f = f.take().unwrap();
-                        r = Some(FnOnce::call_once(f, args));
-                };
-                let mut_f = mut_f as *mut dyn for<$($lifetimes)*> FnMut(($($args,)*));
-
-                // Get the generator to call our closure
-                unsafe {
-                    self.0.access(::std::mem::transmute(mut_f));
-                }
-
-                // Unwrap the result
-                r.unwrap()
-            }
-
-            $v fn complete(mut self) -> $retc {
-                self.0.complete()
-            }
-
-            fn initial_yield(value: $reti) -> $yield_type {
-                $crate::box_region::YieldType::Initial(value)
-            }
-        }
-    };
-
-    ($v:vis $name: ident, for($($lifetimes:tt)*), ($($args:ty),*) -> ($reti:ty, $retc:ty)) => {
-        declare_box_region_type!(
-            impl $v $name,
-            $crate::box_region::YieldType<$reti, for<$($lifetimes)*> fn(($($args,)*))>,
-            for($($lifetimes)*),
-            ($($args),*) -> ($reti, $retc)
-        );
-    };
-}
-
-#[macro_export]
-#[allow_internal_unstable(fn_traits)]
-macro_rules! box_region_allow_access {
-    (for($($lifetimes:tt)*), ($($args:ty),*), ($($exprs:expr),*), $action:ident) => {
-        loop {
-            match $action {
-                $crate::box_region::Action::Access(accessor) => {
-                    let accessor: &mut dyn for<$($lifetimes)*> FnMut($($args),*) = unsafe {
-                        ::std::mem::transmute(accessor.get())
-                    };
-                    (*accessor)(($($exprs),*));
-                    unsafe {
-                        let marker = $crate::box_region::Marker::<
-                            for<$($lifetimes)*> fn(($($args,)*))
-                        >::new();
-                        $action = yield $crate::box_region::YieldType::Accessor(marker);
-                    };
-                }
-                $crate::box_region::Action::Complete => break,
-                $crate::box_region::Action::Initial => panic!("unexpected box_region action: Initial"),
-            }
-        }
-    }
-}