@@ -88,16 +88,6 @@ impl VisitMut for HasSelf {
8888pub struct ReplaceSelf ( pub Span ) ;
8989
9090impl ReplaceSelf {
91- fn prepend_underscore_to_self ( & self , ident : & mut Ident ) -> bool {
92- let modified = ident == "self" ;
93- if modified {
94- * ident = Ident :: new ( "__self" , ident. span ( ) ) ;
95- #[ cfg( self_span_hack) ]
96- ident. set_span ( self . 0 ) ;
97- }
98- modified
99- }
100-
10191 fn visit_token_stream ( & mut self , tokens : & mut TokenStream ) -> bool {
10292 let mut out = Vec :: new ( ) ;
10393 let mut modified = false ;
@@ -116,7 +106,7 @@ impl ReplaceSelf {
116106 for tt in tokens {
117107 match tt {
118108 TokenTree :: Ident ( mut ident) => {
119- * modified |= visitor . prepend_underscore_to_self ( & mut ident) ;
109+ * modified |= prepend_underscore_to_self ( & mut ident) ;
120110 out. push ( TokenTree :: Ident ( ident) ) ;
121111 }
122112 TokenTree :: Group ( group) => {
@@ -135,7 +125,7 @@ impl ReplaceSelf {
135125
136126impl VisitMut for ReplaceSelf {
137127 fn visit_ident_mut ( & mut self , i : & mut Ident ) {
138- self . prepend_underscore_to_self ( i) ;
128+ prepend_underscore_to_self ( i) ;
139129 }
140130
141131 fn visit_item_mut ( & mut self , i : & mut Item ) {
@@ -159,3 +149,13 @@ impl VisitMut for ReplaceSelf {
159149 }
160150 }
161151}
152+
153+ fn prepend_underscore_to_self ( ident : & mut Ident ) -> bool {
154+ let modified = ident == "self" ;
155+ if modified {
156+ * ident = Ident :: new ( "__self" , ident. span ( ) ) ;
157+ #[ cfg( self_span_hack) ]
158+ ident. set_span ( self . 0 ) ;
159+ }
160+ modified
161+ }
0 commit comments