@@ -159,19 +159,14 @@ fn transform_sig(
159159 has_default : bool ,
160160 is_local : bool ,
161161) {
162- sig. fn_token . span = sig. asyncness . take ( ) . unwrap ( ) . span ;
162+ let default_span = sig. asyncness . take ( ) . unwrap ( ) . span ;
163+ sig. fn_token . span = default_span;
163164
164- let ret = match & sig. output {
165- ReturnType :: Default => quote ! ( ( ) ) ,
166- ReturnType :: Type ( _ , ret) => quote ! ( #ret) ,
165+ let ( ret_arrow , ret) = match & sig. output {
166+ ReturnType :: Default => ( Token ! [ -> ] ( default_span ) , quote_spanned ! ( default_span=> ( ) ) ) ,
167+ ReturnType :: Type ( arrow , ret) => ( * arrow , quote ! ( #ret) ) ,
167168 } ;
168169
169- let default_span = sig
170- . ident
171- . span ( )
172- . join ( sig. paren_token . span )
173- . unwrap_or_else ( || sig. ident . span ( ) ) ;
174-
175170 let mut lifetimes = CollectLifetimes :: new ( "'life" , default_span) ;
176171 for arg in sig. inputs . iter_mut ( ) {
177172 match arg {
@@ -235,13 +230,12 @@ fn transform_sig(
235230 . push ( parse_quote_spanned ! ( default_span=> ' async_trait) ) ;
236231
237232 if has_self {
238- let bound_span = sig. ident . span ( ) ;
239233 let bound = match sig. inputs . iter ( ) . next ( ) {
240234 Some ( FnArg :: Receiver ( Receiver {
241235 reference : Some ( _) ,
242236 mutability : None ,
243237 ..
244- } ) ) => Ident :: new ( "Sync" , bound_span ) ,
238+ } ) ) => Ident :: new ( "Sync" , default_span ) ,
245239 Some ( FnArg :: Typed ( arg) )
246240 if match ( arg. pat . as_ref ( ) , arg. ty . as_ref ( ) ) {
247241 ( Pat :: Ident ( pat) , Type :: Reference ( ty) ) => {
@@ -250,9 +244,9 @@ fn transform_sig(
250244 _ => false ,
251245 } =>
252246 {
253- Ident :: new ( "Sync" , bound_span )
247+ Ident :: new ( "Sync" , default_span )
254248 }
255- _ => Ident :: new ( "Send" , bound_span ) ,
249+ _ => Ident :: new ( "Send" , default_span ) ,
256250 } ;
257251
258252 let assume_bound = match context {
@@ -262,9 +256,9 @@ fn transform_sig(
262256
263257 let where_clause = where_clause_or_default ( & mut sig. generics . where_clause ) ;
264258 where_clause. predicates . push ( if assume_bound || is_local {
265- parse_quote_spanned ! ( bound_span => Self : ' async_trait)
259+ parse_quote_spanned ! ( default_span => Self : ' async_trait)
266260 } else {
267- parse_quote_spanned ! ( bound_span => Self : :: core:: marker:: #bound + ' async_trait)
261+ parse_quote_spanned ! ( default_span => Self : :: core:: marker:: #bound + ' async_trait)
268262 } ) ;
269263 }
270264
@@ -288,14 +282,13 @@ fn transform_sig(
288282 }
289283 }
290284
291- let ret_span = sig. ident . span ( ) ;
292285 let bounds = if is_local {
293- quote_spanned ! ( ret_span => ' async_trait)
286+ quote_spanned ! ( default_span => ' async_trait)
294287 } else {
295- quote_spanned ! ( ret_span => :: core:: marker:: Send + ' async_trait)
288+ quote_spanned ! ( default_span => :: core:: marker:: Send + ' async_trait)
296289 } ;
297- sig. output = parse_quote_spanned ! { ret_span =>
298- -> :: core:: pin:: Pin <Box <
290+ sig. output = parse_quote_spanned ! { default_span =>
291+ #ret_arrow :: core:: pin:: Pin <Box <
299292 dyn :: core:: future:: Future <Output = #ret> + #bounds
300293 >>
301294 } ;
0 commit comments