From 86b3ebe2da46081b58a1f6208eb0f9c3ac4f3ec0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 31 May 2021 15:17:04 +0200 Subject: Inline box_region macro calls --- compiler/rustc_data_structures/src/box_region.rs | 80 ------------------------ 1 file changed, 80 deletions(-) (limited to 'compiler/rustc_data_structures') diff --git a/compiler/rustc_data_structures/src/box_region.rs b/compiler/rustc_data_structures/src/box_region.rs index 2f212b03e08..a1a757b7054 100644 --- a/compiler/rustc_data_structures/src/box_region.rs +++ b/compiler/rustc_data_structures/src/box_region.rs @@ -78,83 +78,3 @@ pub enum YieldType { Initial(I), Accessor(Marker), } - -#[macro_export] -#[allow_internal_unstable(fn_traits)] -macro_rules! declare_box_region_type { - ($v:vis $name: ident, ($($args:ty),*) -> ($reti:ty, $retc:ty)) => { - $v struct $name($crate::box_region::PinnedGenerator< - $reti, - fn(($($args,)*)), - $retc - >); - - impl $name { - fn new(generator: T) -> ($reti, Self) - where T: ::std::ops::Generator< - $crate::box_region::Action, - Yield = $crate::box_region::YieldType<$reti, fn(($($args,)*))>, - Return = $retc, - > + 'static { - let (initial, pinned) = $crate::box_region::PinnedGenerator::new(generator); - (initial, $name(pinned)) - } - - $v fn access 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 FnMut(($($args,)*)) = - &mut |args| { - let f = f.take().unwrap(); - r = Some(FnOnce::call_once(f, args)); - }; - let mut_f = mut_f as *mut dyn 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, - ) -> $crate::box_region::YieldType<$reti, fn(($($args,)*))> { - $crate::box_region::YieldType::Initial(value) - } - } - }; -} - -#[macro_export] -#[allow_internal_unstable(fn_traits)] -macro_rules! box_region_allow_access { - (($($args:ty),*), ($($exprs:expr),*), $action:ident) => { - loop { - match $action { - $crate::box_region::Action::Access(accessor) => { - let accessor: &mut dyn FnMut($($args),*) = unsafe { - ::std::mem::transmute(accessor.get()) - }; - (*accessor)(($($exprs),*)); - unsafe { - let marker = $crate::box_region::Marker::< - 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"), - } - } - } -} -- cgit 1.4.1-3-g733a5