1
+ use crate :: bound:: { has_bound, InferredBound , Supertraits } ;
1
2
use crate :: lifetime:: { AddLifetimeToImplTrait , CollectLifetimes } ;
2
3
use crate :: parse:: Item ;
3
4
use crate :: receiver:: { has_self_in_block, has_self_in_sig, mut_pat, ReplaceSelf } ;
@@ -10,7 +11,7 @@ use syn::visit_mut::{self, VisitMut};
10
11
use syn:: {
11
12
parse_quote, parse_quote_spanned, Attribute , Block , FnArg , GenericParam , Generics , Ident ,
12
13
ImplItem , Lifetime , LifetimeDef , Pat , PatIdent , Receiver , ReturnType , Signature , Stmt , Token ,
13
- TraitItem , Type , TypeParamBound , TypePath , WhereClause ,
14
+ TraitItem , Type , TypePath , WhereClause ,
14
15
} ;
15
16
16
17
impl ToTokens for Item {
@@ -51,8 +52,6 @@ impl Context<'_> {
51
52
}
52
53
}
53
54
54
- type Supertraits = Punctuated < TypeParamBound , Token ! [ +] > ;
55
-
56
55
pub fn expand ( input : & mut Item , is_local : bool ) {
57
56
match input {
58
57
Item :: Trait ( input) => {
@@ -235,7 +234,7 @@ fn transform_sig(
235
234
reference : Some ( _) ,
236
235
mutability : None ,
237
236
..
238
- } ) ) => Ident :: new ( " Sync" , default_span ) ,
237
+ } ) ) => InferredBound :: Sync ,
239
238
Some ( FnArg :: Typed ( arg) )
240
239
if match ( arg. pat . as_ref ( ) , arg. ty . as_ref ( ) ) {
241
240
( Pat :: Ident ( pat) , Type :: Reference ( ty) ) => {
@@ -244,9 +243,9 @@ fn transform_sig(
244
243
_ => false ,
245
244
} =>
246
245
{
247
- Ident :: new ( " Sync" , default_span )
246
+ InferredBound :: Sync
248
247
}
249
- _ => Ident :: new ( " Send" , default_span ) ,
248
+ _ => InferredBound :: Send ,
250
249
} ;
251
250
252
251
let assume_bound = match context {
@@ -258,6 +257,7 @@ fn transform_sig(
258
257
where_clause. predicates . push ( if assume_bound || is_local {
259
258
parse_quote_spanned ! ( default_span=> Self : ' async_trait)
260
259
} else {
260
+ let bound = bound. spanned_ident ( default_span) ;
261
261
parse_quote_spanned ! ( default_span=> Self : :: core:: marker:: #bound + ' async_trait)
262
262
} ) ;
263
263
}
@@ -402,23 +402,6 @@ fn positional_arg(i: usize, pat: &Pat) -> Ident {
402
402
format_ident ! ( "__arg{}" , i, span = span)
403
403
}
404
404
405
- fn has_bound ( supertraits : & Supertraits , marker : & Ident ) -> bool {
406
- for bound in supertraits {
407
- if let TypeParamBound :: Trait ( bound) = bound {
408
- if bound. path . is_ident ( marker)
409
- || bound. path . segments . len ( ) == 3
410
- && ( bound. path . segments [ 0 ] . ident == "std"
411
- || bound. path . segments [ 0 ] . ident == "core" )
412
- && bound. path . segments [ 1 ] . ident == "marker"
413
- && bound. path . segments [ 2 ] . ident == * marker
414
- {
415
- return true ;
416
- }
417
- }
418
- }
419
- false
420
- }
421
-
422
405
fn contains_associated_type_impl_trait ( context : Context , ret : & mut Type ) -> bool {
423
406
struct AssociatedTypeImplTraits < ' a > {
424
407
set : & ' a Set < Ident > ,
0 commit comments