@@ -37,7 +37,7 @@ enum Context<'a> {
37
37
38
38
type Supertraits = Punctuated < TypeParamBound , Token ! [ +] > ;
39
39
40
- pub fn expand ( input : & mut Item ) {
40
+ pub fn expand( input : & mut Item , is_local : bool ) {
41
41
match input {
42
42
Item :: Trait ( input) => {
43
43
let context = Context :: Trait {
@@ -47,16 +47,32 @@ pub fn expand(input: &mut Item) {
47
47
} ;
48
48
for inner in & mut input. items {
49
49
if let TraitItem :: Method ( method) = inner {
50
+ <<<<<<< HEAD
50
51
let sig = & mut method. sig;
51
52
if sig. asyncness. is_some ( ) {
52
53
let block = & mut method. default ;
53
54
let mut has_self = has_self_in_sig ( sig ) ;
54
55
if let Some ( block ) = block {
55
56
has_self |= has_self_in_block ( block ) ;
56
57
transform_block ( context , sig , block , has_self ) ;
58
+ ||||||| merged common ancestors
59
+ if method. sig. asyncness. is_some ( ) {
60
+ if let Some ( block ) = & mut method. default {
61
+ transform_block ( context , & method . sig, block ) ;
62
+ =======
63
+ if method. sig. asyncness. is_some ( ) {
64
+ if let Some ( block ) = & mut method. default {
65
+ transform_block ( context , & method . sig, block , is_local ) ;
66
+ >>>>>>> pr/10
57
67
}
58
68
let has_default = method. default . is_some ( ) ;
69
+ <<<<<<< HEAD
59
70
transform_sig ( context , sig , has_self , has_default ) ;
71
+ ||||||| merged common ancestors
72
+ transform_sig ( context , & mut method . sig, has_default ) ;
73
+ =======
74
+ transform_sig ( context , & mut method . sig, has_default , is_local ) ;
75
+ >>>>>>> pr/10
60
76
}
61
77
}
62
78
}
@@ -69,12 +85,22 @@ pub fn expand(input: &mut Item) {
69
85
} ;
70
86
for inner in & mut input. items {
71
87
if let ImplItem :: Method ( method) = inner {
88
+ <<<<<<< HEAD
72
89
let sig = & mut method. sig;
73
90
if sig. asyncness. is_some ( ) {
74
91
let block = & mut method. block;
75
92
let has_self = has_self_in_sig ( sig ) || has_self_in_block ( block ) ;
76
93
transform_block ( context , sig , block , has_self ) ;
77
94
transform_sig( context , sig , has_self , false ) ;
95
+ ||||||| merged common ancestors
96
+ if method. sig. asyncness. is_some ( ) {
97
+ transform_block( context, & method. sig, & mut method. block) ;
98
+ transform_sig( context, & mut method. sig, false ) ;
99
+ =======
100
+ if method. sig. asyncness. is_some( ) {
101
+ transform_block( context, & method. sig, & mut method. block, is_local) ;
102
+ transform_sig( context, & mut method. sig, false , is_local) ;
103
+ >>>>>>> pr/10
78
104
}
79
105
}
80
106
}
@@ -95,7 +121,13 @@ pub fn expand(input: &mut Item) {
95
121
// 'life1: 'async_trait,
96
122
// T: 'async_trait,
97
123
// Self: Sync + 'async_trait;
124
+ < <<<<<< HEAD
98
125
fn transform_sig( context : Context , sig : & mut MethodSig , has_self : bool , has_default : bool ) {
126
+ ||||||| merged common ancestors
127
+ fn transform_sig ( context : Context , sig : & mut MethodSig , has_default : bool ) {
128
+ =======
129
+ fn transform_sig ( context : Context , sig : & mut MethodSig , has_default : bool , is_local : bool ) {
130
+ >>>>>>> pr/10
99
131
sig. decl. fn_token. span = sig. asyncness. take( ) . unwrap( ) . span;
100
132
101
133
let ret = match & sig. decl. output {
@@ -189,9 +221,15 @@ fn transform_sig(context: Context, sig: &mut MethodSig, has_self: bool, has_defa
189
221
}
190
222
}
191
223
224
+ let bounds: Supertraits = if is_local {
225
+ parse_quote ! ( #lifetime)
226
+ } else {
227
+ parse_quote ! ( #lifetime + core:: marker:: Send )
228
+ } ;
229
+
192
230
sig. decl . output = parse_quote ! {
193
231
-> core:: pin:: Pin <Box <
194
- dyn core:: future:: Future <Output = #ret> + core :: marker :: Send + #lifetime
232
+ dyn core:: future:: Future <Output = #ret> + #bounds
195
233
>>
196
234
} ;
197
235
}
@@ -206,7 +244,13 @@ fn transform_sig(context: Context, sig: &mut MethodSig, has_self: bool, has_defa
206
244
// _self + x
207
245
// }
208
246
// Pin::from(Box::new(async_trait_method::<T, Self>(self, x)))
247
+ <<<<<<< HEAD
209
248
fn transform_block( context: Context , sig : & mut MethodSig , block : & mut Block , has_self : bool ) {
249
+ ||||||| merged common ancestors
250
+ fn transform_block ( context : Context , sig : & MethodSig , block : & mut Block ) {
251
+ =======
252
+ fn transform_block ( context : Context , sig : & MethodSig , block : & mut Block , is_local : bool ) {
253
+ >>>>>>> pr/10
210
254
let inner = Ident :: new ( & format!( "__{ } ", sig. ident) , sig. ident. span( ) ) ;
211
255
let args = sig
212
256
. decl
@@ -275,6 +319,26 @@ fn transform_block(context: Context, sig: &mut MethodSig, block: &mut Block, has
275
319
* arg = parse_quote! {
276
320
#under_self: & #lifetime #mutability AsyncTrait
277
321
} ;
322
+ <<<<<<< HEAD
323
+ ||||||| merged common ancestors
324
+ let ( _ , generics , _ ) = generics. split_for_impl ( ) ;
325
+ standalone. decl. generics. params. push ( parse_quote ! {
326
+ AsyncTrait : ?Sized + #name #generics + core:: marker:: #bound
327
+ } ) ;
328
+ types. push( Ident :: new( "Self" , Span :: call_site( ) ) ) ;
329
+ =======
330
+ let ( _, generics, _) = generics. split_for_impl( ) ;
331
+ if is_local {
332
+ standalone. decl. generics. params. push( parse_quote ! {
333
+ AsyncTrait : ?Sized + #name #generics
334
+ } ) ;
335
+ } else {
336
+ standalone. decl. generics. params. push( parse_quote ! {
337
+ AsyncTrait : ?Sized + #name #generics + core:: marker:: #bound
338
+ } ) ;
339
+ }
340
+ types. push( Ident :: new( "Self" , Span :: call_site( ) ) ) ;
341
+ >>>>>>> pr/10
278
342
}
279
343
Context :: Impl { receiver, .. } => {
280
344
* arg = parse_quote ! {
0 commit comments