@@ -88,6 +88,16 @@ 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+ 
91101 fn  visit_token_stream ( & mut  self ,  tokens :  & mut  TokenStream )  -> bool  { 
92102 let  mut  out = Vec :: new ( ) ; 
93103 let  mut  modified = false ; 
@@ -106,7 +116,7 @@ impl ReplaceSelf {
106116 for  tt in  tokens { 
107117 match  tt { 
108118 TokenTree :: Ident ( mut  ident)  => { 
109-  * modified |= prepend_underscore_to_self ( & mut  ident) ; 
119+  * modified |= visitor . prepend_underscore_to_self ( & mut  ident) ; 
110120 out. push ( TokenTree :: Ident ( ident) ) ; 
111121 } 
112122 TokenTree :: Group ( group)  => { 
@@ -125,7 +135,7 @@ impl ReplaceSelf {
125135
126136impl  VisitMut  for  ReplaceSelf  { 
127137 fn  visit_ident_mut ( & mut  self ,  i :  & mut  Ident )  { 
128-  prepend_underscore_to_self ( i) ; 
138+  self . prepend_underscore_to_self ( i) ; 
129139 } 
130140
131141 fn  visit_item_mut ( & mut  self ,  i :  & mut  Item )  { 
@@ -149,13 +159,3 @@ impl VisitMut for ReplaceSelf {
149159 } 
150160 } 
151161} 
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