@@ -23,7 +23,7 @@ pub(super) fn mangle(
2323 let substs = tcx. normalize_erasing_regions ( ty:: ParamEnv :: reveal_all ( ) , instance. substs ) ;
2424
2525 let prefix = "_R" ;
26- let mut cx = SymbolMangler {
26+ let mut cx = & mut SymbolMangler {
2727 tcx,
2828 start_offset : prefix. len ( ) ,
2929 paths : FxHashMap :: default ( ) ,
@@ -49,7 +49,7 @@ pub(super) fn mangle(
4949 if let Some ( instantiating_crate) = instantiating_crate {
5050 cx = cx. print_def_path ( instantiating_crate. as_def_id ( ) , & [ ] ) . unwrap ( ) ;
5151 }
52- cx. out
52+ std :: mem :: take ( & mut cx. out )
5353}
5454
5555struct BinderLevel {
@@ -153,13 +153,13 @@ impl SymbolMangler<'tcx> {
153153 self . push ( ident) ;
154154 }
155155
156- fn path_append_ns (
157- mut self ,
158- print_prefix : impl FnOnce ( Self ) -> Result < Self , !> ,
156+ fn path_append_ns < ' a > (
157+ mut self : & ' a mut Self ,
158+ print_prefix : impl FnOnce ( & ' a mut Self ) -> Result < & ' a mut Self , !> ,
159159 ns : char ,
160160 disambiguator : u64 ,
161161 name : & str ,
162- ) -> Result < Self , !> {
162+ ) -> Result < & ' a mut Self , !> {
163163 self . push ( "N" ) ;
164164 self . out . push ( ns) ;
165165 self = print_prefix ( self ) ?;
@@ -168,17 +168,17 @@ impl SymbolMangler<'tcx> {
168168 Ok ( self )
169169 }
170170
171- fn print_backref ( mut self , i : usize ) -> Result < Self , !> {
171+ fn print_backref ( & mut self , i : usize ) -> Result < & mut Self , !> {
172172 self . push ( "B" ) ;
173173 self . push_integer_62 ( ( i - self . start_offset ) as u64 ) ;
174174 Ok ( self )
175175 }
176176
177- fn in_binder < T > (
178- mut self ,
177+ fn in_binder < ' a , T > (
178+ mut self : & ' a mut Self ,
179179 value : & ty:: Binder < ' tcx , T > ,
180- print_value : impl FnOnce ( Self , & T ) -> Result < Self , !> ,
181- ) -> Result < Self , !>
180+ print_value : impl FnOnce ( & ' a mut Self , & T ) -> Result < & ' a mut Self , !> ,
181+ ) -> Result < & ' a mut Self , !>
182182 where
183183 T : TypeFoldable < ' tcx > ,
184184 {
@@ -211,7 +211,7 @@ impl SymbolMangler<'tcx> {
211211 }
212212}
213213
214- impl Printer < ' tcx > for SymbolMangler < ' tcx > {
214+ impl Printer < ' tcx > for & mut SymbolMangler < ' tcx > {
215215 type Error = !;
216216
217217 type Path = Self ;
@@ -303,7 +303,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
303303 Ok ( self )
304304 }
305305
306- fn print_region ( mut self , region : ty:: Region < ' _ > ) -> Result < Self :: Region , Self :: Error > {
306+ fn print_region ( self , region : ty:: Region < ' _ > ) -> Result < Self :: Region , Self :: Error > {
307307 let i = match * region {
308308 // Erased lifetimes use the index 0, for a
309309 // shorter mangling of `L_`.
@@ -577,7 +577,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
577577 Ok ( self )
578578 }
579579
580- fn path_crate ( mut self , cnum : CrateNum ) -> Result < Self :: Path , Self :: Error > {
580+ fn path_crate ( self , cnum : CrateNum ) -> Result < Self :: Path , Self :: Error > {
581581 self . push ( "C" ) ;
582582 let stable_crate_id = self . tcx . def_path_hash ( cnum. as_def_id ( ) ) . stable_crate_id ( ) ;
583583 self . push_disambiguator ( stable_crate_id. to_u64 ( ) ) ;
0 commit comments