@@ -176,7 +176,9 @@ impl<'a> ParseBufferExt<'a> for ParseBuffer<'a> {
176
176
// visitors
177
177
178
178
// Replace `self`/`Self` with `__self`/`self_ty`.
179
- // Based on https://github.com/dtolnay/async-trait/blob/0.1.35/src/receiver.rs
179
+ // Based on:
180
+ // - https://github.com/dtolnay/async-trait/blob/0.1.35/src/receiver.rs
181
+ // - https://github.com/dtolnay/async-trait/commit/6029cbf375c562ca98fa5748e9d950a8ff93b0e7
180
182
181
183
pub ( crate ) struct ReplaceReceiver < ' a > ( pub ( crate ) & ' a TypePath ) ;
182
184
@@ -313,7 +315,6 @@ impl VisitMut for ReplaceReceiver<'_> {
313
315
// `Self::method` -> `<Receiver>::method`
314
316
fn visit_expr_path_mut ( & mut self , expr : & mut ExprPath ) {
315
317
if expr. qself . is_none ( ) {
316
- prepend_underscore_to_self ( & mut expr. path . segments [ 0 ] . ident ) ;
317
318
self . self_to_qself ( & mut expr. qself , & mut expr. path ) ;
318
319
}
319
320
visit_mut:: visit_expr_path_mut ( self , expr) ;
@@ -341,6 +342,16 @@ impl VisitMut for ReplaceReceiver<'_> {
341
342
visit_mut:: visit_pat_tuple_struct_mut ( self , pat) ;
342
343
}
343
344
345
+ fn visit_path_mut ( & mut self , path : & mut Path ) {
346
+ if path. segments . len ( ) == 1 {
347
+ // Replace `self`, but not `self::function`.
348
+ prepend_underscore_to_self ( & mut path. segments [ 0 ] . ident ) ;
349
+ }
350
+ for segment in & mut path. segments {
351
+ self . visit_path_arguments_mut ( & mut segment. arguments ) ;
352
+ }
353
+ }
354
+
344
355
fn visit_item_mut ( & mut self , item : & mut Item ) {
345
356
match item {
346
357
// Visit `macro_rules!` because locally defined macros can refer to `self`.
0 commit comments