@@ -54,65 +54,59 @@ impl<S: Types> Decode<'_, '_, HandleStore<MarkedTypes<S>>> for Marked<S::Span, c
5454}
5555
5656pub trait Types {
57- type FreeFunctions : ' static ;
5857 type TokenStream : ' static + Clone ;
5958 type Span : ' static + Copy + Eq + Hash ;
6059 type Symbol : ' static ;
6160}
6261
6362macro_rules! declare_server_traits {
6463 (
65- FreeFunctions {
64+ Methods {
6665 $( fn $method: ident( $( $arg: ident: $arg_ty: ty) ,* $( , ) ?) $( -> $ret_ty: ty) * ; ) *
6766 } ,
6867 $( $name: ident) ,* $( , ) ?
6968 ) => {
70- pub trait FreeFunctions : Types {
71- $( fn $method( & mut self , $( $arg: $arg_ty) ,* ) $( -> $ret_ty) ?; ) *
72- }
73-
74- pub trait Server : Types + FreeFunctions {
69+ pub trait Server : Types {
7570 fn globals( & mut self ) -> ExpnGlobals <Self :: Span >;
7671
7772 /// Intern a symbol received from RPC
7873 fn intern_symbol( ident: & str ) -> Self :: Symbol ;
7974
8075 /// Recover the string value of a symbol, and invoke a callback with it.
8176 fn with_symbol_string( symbol: & Self :: Symbol , f: impl FnOnce ( & str ) ) ;
77+
78+ $( fn $method( & mut self , $( $arg: $arg_ty) ,* ) $( -> $ret_ty) ?; ) *
8279 }
8380 }
8481}
8582with_api ! ( Self , self_, declare_server_traits) ;
8683
8784pub ( super ) struct MarkedTypes < S : Types > ( S ) ;
8885
89- impl < S : Server > Server for MarkedTypes < S > {
90- fn globals ( & mut self ) -> ExpnGlobals < Self :: Span > {
91- <_ >:: mark ( Server :: globals ( & mut self . 0 ) )
92- }
93- fn intern_symbol ( ident : & str ) -> Self :: Symbol {
94- <_ >:: mark ( S :: intern_symbol ( ident) )
95- }
96- fn with_symbol_string ( symbol : & Self :: Symbol , f : impl FnOnce ( & str ) ) {
97- S :: with_symbol_string ( symbol. unmark ( ) , f)
98- }
99- }
100-
10186macro_rules! define_mark_types_impls {
10287 (
103- FreeFunctions {
88+ Methods {
10489 $( fn $method: ident( $( $arg: ident: $arg_ty: ty) ,* $( , ) ?) $( -> $ret_ty: ty) * ; ) *
10590 } ,
10691 $( $name: ident) ,* $( , ) ?
10792 ) => {
10893 impl <S : Types > Types for MarkedTypes <S > {
109- type FreeFunctions = Marked <S :: FreeFunctions , client:: FreeFunctions >;
11094 $( type $name = Marked <S :: $name, client:: $name>; ) *
11195 }
11296
113- impl <S : FreeFunctions > FreeFunctions for MarkedTypes <S > {
97+ impl <S : Server > Server for MarkedTypes <S > {
98+ fn globals( & mut self ) -> ExpnGlobals <Self :: Span > {
99+ <_>:: mark( Server :: globals( & mut self . 0 ) )
100+ }
101+ fn intern_symbol( ident: & str ) -> Self :: Symbol {
102+ <_>:: mark( S :: intern_symbol( ident) )
103+ }
104+ fn with_symbol_string( symbol: & Self :: Symbol , f: impl FnOnce ( & str ) ) {
105+ S :: with_symbol_string( symbol. unmark( ) , f)
106+ }
107+
114108 $( fn $method( & mut self , $( $arg: $arg_ty) ,* ) $( -> $ret_ty) ? {
115- <_>:: mark( FreeFunctions :: $method( & mut self . 0 , $( $arg. unmark( ) ) ,* ) )
109+ <_>:: mark( S :: $method( & mut self . 0 , $( $arg. unmark( ) ) ,* ) )
116110 } ) *
117111 }
118112 }
@@ -126,22 +120,20 @@ struct Dispatcher<S: Types> {
126120
127121macro_rules! define_dispatcher_impl {
128122 (
129- FreeFunctions {
123+ Methods {
130124 $( fn $method: ident( $( $arg: ident: $arg_ty: ty) ,* $( , ) ?) $( -> $ret_ty: ty) * ; ) *
131125 } ,
132126 $( $name: ident) ,* $( , ) ?
133127 ) => {
134128 // FIXME(eddyb) `pub` only for `ExecutionStrategy` below.
135129 pub trait DispatcherTrait {
136130 // HACK(eddyb) these are here to allow `Self::$name` to work below.
137- type FreeFunctions ;
138131 $( type $name; ) *
139132
140133 fn dispatch( & mut self , buf: Buffer ) -> Buffer ;
141134 }
142135
143136 impl <S : Server > DispatcherTrait for Dispatcher <MarkedTypes <S >> {
144- type FreeFunctions = <MarkedTypes <S > as Types >:: FreeFunctions ;
145137 $( type $name = <MarkedTypes <S > as Types >:: $name; ) *
146138
147139 fn dispatch( & mut self , mut buf: Buffer ) -> Buffer {
@@ -152,7 +144,7 @@ macro_rules! define_dispatcher_impl {
152144 $( api_tags:: Method :: $method => {
153145 let mut call_method = || {
154146 $( let $arg = <$arg_ty>:: decode( & mut reader, handle_store) ; ) *
155- FreeFunctions :: $method( server , $( $arg) ,* )
147+ server . $method( $( $arg) ,* )
156148 } ;
157149 // HACK(eddyb) don't use `panic::catch_unwind` in a panic.
158150 // If client and server happen to use the same `std`,
0 commit comments