@@ -9,9 +9,9 @@ use std::mem;
99use syn:: punctuated:: Punctuated ;
1010use syn:: visit_mut:: { self , VisitMut } ;
1111use 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 ,
1515} ;
1616
1717impl ToTokens for Item {
@@ -242,8 +242,27 @@ fn transform_sig(
242242 } =>
243243 {
244244 match arg. ty . as_ref ( ) {
245+ // self: &Self
245246 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+ {
247266 & [ InferredBound :: Sync , InferredBound :: Send ]
248267 }
249268 _ => & [ InferredBound :: Send ] ,
0 commit comments