@@ -82,37 +82,35 @@ pub enum YieldType<I, A> {
8282#[ macro_export]
8383#[ allow_internal_unstable( fn_traits) ]
8484macro_rules! declare_box_region_type {
85- ( impl $v: vis
86- $name: ident,
87- $yield_type: ty,
88- for ( $( $lifetimes: tt) * ) ,
89- ( $( $args: ty) ,* ) -> ( $reti: ty, $retc: ty)
90- ) => {
85+ ( $v: vis $name: ident, ( $( $args: ty) ,* ) -> ( $reti: ty, $retc: ty) ) => {
9186 $v struct $name( $crate:: box_region:: PinnedGenerator <
9287 $reti,
93- for <$ ( $lifetimes ) * > fn ( ( $( $args, ) * ) ) ,
88+ fn ( ( $( $args, ) * ) ) ,
9489 $retc
9590 >) ;
9691
9792 impl $name {
98- fn new<T : :: std:: ops:: Generator <$crate:: box_region:: Action , Yield = $yield_type, Return = $retc> + ' static >(
99- generator: T
100- ) -> ( $reti, Self ) {
93+ fn new<T >( generator: T ) -> ( $reti, Self )
94+ where T : :: std:: ops:: Generator <
95+ $crate:: box_region:: Action ,
96+ Yield = $crate:: box_region:: YieldType <$reti, fn ( ( $( $args, ) * ) ) >,
97+ Return = $retc,
98+ > + ' static {
10199 let ( initial, pinned) = $crate:: box_region:: PinnedGenerator :: new( generator) ;
102100 ( initial, $name( pinned) )
103101 }
104102
105- $v fn access<F : for <$ ( $lifetimes ) * > FnOnce ( $( $args, ) * ) -> R , R >( & mut self , f: F ) -> R {
103+ $v fn access<F : FnOnce ( $( $args, ) * ) -> R , R >( & mut self , f: F ) -> R {
106104 // Turn the FnOnce closure into *mut dyn FnMut()
107105 // so we can pass it in to the generator
108106 let mut r = None ;
109107 let mut f = Some ( f) ;
110- let mut_f: & mut dyn for <$ ( $lifetimes ) * > FnMut ( ( $( $args, ) * ) ) =
108+ let mut_f: & mut dyn FnMut ( ( $( $args, ) * ) ) =
111109 & mut |args| {
112110 let f = f. take( ) . unwrap( ) ;
113111 r = Some ( FnOnce :: call_once( f, args) ) ;
114112 } ;
115- let mut_f = mut_f as * mut dyn for <$ ( $lifetimes ) * > FnMut ( ( $( $args, ) * ) ) ;
113+ let mut_f = mut_f as * mut dyn FnMut ( ( $( $args, ) * ) ) ;
116114
117115 // Get the generator to call our closure
118116 unsafe {
@@ -127,36 +125,29 @@ macro_rules! declare_box_region_type {
127125 self . 0 . complete( )
128126 }
129127
130- fn initial_yield( value: $reti) -> $yield_type {
128+ fn initial_yield(
129+ value: $reti,
130+ ) -> $crate:: box_region:: YieldType <$reti, fn ( ( $( $args, ) * ) ) > {
131131 $crate:: box_region:: YieldType :: Initial ( value)
132132 }
133133 }
134134 } ;
135-
136- ( $v: vis $name: ident, for ( $( $lifetimes: tt) * ) , ( $( $args: ty) ,* ) -> ( $reti: ty, $retc: ty) ) => {
137- declare_box_region_type!(
138- impl $v $name,
139- $crate:: box_region:: YieldType <$reti, for <$( $lifetimes) * > fn ( ( $( $args, ) * ) ) >,
140- for ( $( $lifetimes) * ) ,
141- ( $( $args) ,* ) -> ( $reti, $retc)
142- ) ;
143- } ;
144135}
145136
146137#[ macro_export]
147138#[ allow_internal_unstable( fn_traits) ]
148139macro_rules! box_region_allow_access {
149- ( for ( $ ( $lifetimes : tt ) * ) , ( $( $args: ty) ,* ) , ( $( $exprs: expr) ,* ) , $action: ident) => {
140+ ( ( $( $args: ty) ,* ) , ( $( $exprs: expr) ,* ) , $action: ident) => {
150141 loop {
151142 match $action {
152143 $crate:: box_region:: Action :: Access ( accessor) => {
153- let accessor: & mut dyn for <$ ( $lifetimes ) * > FnMut ( $( $args) ,* ) = unsafe {
144+ let accessor: & mut dyn FnMut ( $( $args) ,* ) = unsafe {
154145 :: std:: mem:: transmute( accessor. get( ) )
155146 } ;
156147 ( * accessor) ( ( $( $exprs) ,* ) ) ;
157148 unsafe {
158149 let marker = $crate:: box_region:: Marker :: <
159- for <$ ( $lifetimes ) * > fn ( ( $( $args, ) * ) )
150+ fn ( ( $( $args, ) * ) )
160151 >:: new( ) ;
161152 $action = yield $crate:: box_region:: YieldType :: Accessor ( marker) ;
162153 } ;
0 commit comments