@@ -9,9 +9,9 @@ use std::mem;
9
9
use syn:: punctuated:: Punctuated ;
10
10
use syn:: visit_mut:: { self , VisitMut } ;
11
11
use syn:: {
12
- parse_quote, parse_quote_spanned, Attribute , Block , FnArg , GenericParam , Generics , Ident ,
13
- ImplItem , Lifetime , LifetimeDef , Pat , PatIdent , Receiver , ReturnType , Signature , Stmt , Token ,
14
- TraitItem , Type , TypePath , WhereClause ,
12
+ parse_quote, parse_quote_spanned, Attribute , Block , FnArg , GenericArgument , GenericParam ,
13
+ Generics , Ident , ImplItem , Lifetime , LifetimeDef , Pat , PatIdent , PathArguments , Receiver ,
14
+ ReturnType , Signature , Stmt , Token , TraitItem , Type , TypePath , WhereClause ,
15
15
} ;
16
16
17
17
impl ToTokens for Item {
@@ -242,8 +242,27 @@ fn transform_sig(
242
242
} =>
243
243
{
244
244
match arg. ty . as_ref ( ) {
245
+ // self: &Self
245
246
Type :: Reference ( ty) if ty. mutability . is_none ( ) => & [ InferredBound :: Sync ] ,
246
- Type :: Path ( ty) if ty. path . segments . last ( ) . unwrap ( ) . ident == "Arc" => {
247
+ // self: Arc<Self>
248
+ Type :: Path ( ty)
249
+ if {
250
+ let segment = ty. path . segments . last ( ) . unwrap ( ) ;
251
+ segment. ident == "Arc"
252
+ && match & segment. arguments {
253
+ PathArguments :: AngleBracketed ( arguments) => {
254
+ arguments. args . len ( ) == 1
255
+ && match & arguments. args [ 0 ] {
256
+ GenericArgument :: Type ( Type :: Path ( arg) ) => {
257
+ arg. path . is_ident ( "Self" )
258
+ }
259
+ _ => false ,
260
+ }
261
+ }
262
+ _ => false ,
263
+ }
264
+ } =>
265
+ {
247
266
& [ InferredBound :: Sync , InferredBound :: Send ]
248
267
}
249
268
_ => & [ InferredBound :: Send ] ,
0 commit comments