@@ -25,13 +25,10 @@ pub(super) fn mangle(
2525 let prefix = "_R" ;
2626 let mut cx = SymbolMangler {
2727 tcx,
28- compress : Box :: new ( CompressionCaches {
29- start_offset : prefix. len ( ) ,
30-
31- paths : FxHashMap :: default ( ) ,
32- types : FxHashMap :: default ( ) ,
33- consts : FxHashMap :: default ( ) ,
34- } ) ,
28+ start_offset : prefix. len ( ) ,
29+ paths : FxHashMap :: default ( ) ,
30+ types : FxHashMap :: default ( ) ,
31+ consts : FxHashMap :: default ( ) ,
3532 binders : vec ! [ ] ,
3633 out : String :: from ( prefix) ,
3734 } ;
@@ -55,16 +52,6 @@ pub(super) fn mangle(
5552 cx. out
5653}
5754
58- struct CompressionCaches < ' tcx > {
59- // The length of the prefix in `out` (e.g. 2 for `_R`).
60- start_offset : usize ,
61-
62- // The values are start positions in `out`, in bytes.
63- paths : FxHashMap < ( DefId , & ' tcx [ GenericArg < ' tcx > ] ) , usize > ,
64- types : FxHashMap < Ty < ' tcx > , usize > ,
65- consts : FxHashMap < & ' tcx ty:: Const < ' tcx > , usize > ,
66- }
67-
6855struct BinderLevel {
6956 /// The range of distances from the root of what's
7057 /// being printed, to the lifetimes in a binder.
@@ -81,9 +68,15 @@ struct BinderLevel {
8168
8269struct SymbolMangler < ' tcx > {
8370 tcx : TyCtxt < ' tcx > ,
84- compress : Box < CompressionCaches < ' tcx > > ,
8571 binders : Vec < BinderLevel > ,
8672 out : String ,
73+
74+ /// The length of the prefix in `out` (e.g. 2 for `_R`).
75+ start_offset : usize ,
76+ /// The values are start positions in `out`, in bytes.
77+ paths : FxHashMap < ( DefId , & ' tcx [ GenericArg < ' tcx > ] ) , usize > ,
78+ types : FxHashMap < Ty < ' tcx > , usize > ,
79+ consts : FxHashMap < & ' tcx ty:: Const < ' tcx > , usize > ,
8780}
8881
8982impl SymbolMangler < ' tcx > {
@@ -177,7 +170,7 @@ impl SymbolMangler<'tcx> {
177170
178171 fn print_backref ( mut self , i : usize ) -> Result < Self , !> {
179172 self . push ( "B" ) ;
180- self . push_integer_62 ( ( i - self . compress . start_offset ) as u64 ) ;
173+ self . push_integer_62 ( ( i - self . start_offset ) as u64 ) ;
181174 Ok ( self )
182175 }
183176
@@ -236,7 +229,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
236229 def_id : DefId ,
237230 substs : & ' tcx [ GenericArg < ' tcx > ] ,
238231 ) -> Result < Self :: Path , Self :: Error > {
239- if let Some ( & i) = self . compress . paths . get ( & ( def_id, substs) ) {
232+ if let Some ( & i) = self . paths . get ( & ( def_id, substs) ) {
240233 return self . print_backref ( i) ;
241234 }
242235 let start = self . out . len ( ) ;
@@ -246,7 +239,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
246239 // Only cache paths that do not refer to an enclosing
247240 // binder (which would change depending on context).
248241 if !substs. iter ( ) . any ( |k| k. has_escaping_bound_vars ( ) ) {
249- self . compress . paths . insert ( ( def_id, substs) , start) ;
242+ self . paths . insert ( ( def_id, substs) , start) ;
250243 }
251244 Ok ( self )
252245 }
@@ -365,7 +358,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
365358 return Ok ( self ) ;
366359 }
367360
368- if let Some ( & i) = self . compress . types . get ( & ty) {
361+ if let Some ( & i) = self . types . get ( & ty) {
369362 return self . print_backref ( i) ;
370363 }
371364 let start = self . out . len ( ) ;
@@ -474,7 +467,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
474467 // Only cache types that do not refer to an enclosing
475468 // binder (which would change depending on context).
476469 if !ty. has_escaping_bound_vars ( ) {
477- self . compress . types . insert ( ty, start) ;
470+ self . types . insert ( ty, start) ;
478471 }
479472 Ok ( self )
480473 }
@@ -541,7 +534,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
541534 }
542535
543536 fn print_const ( mut self , ct : & ' tcx ty:: Const < ' tcx > ) -> Result < Self :: Const , Self :: Error > {
544- if let Some ( & i) = self . compress . consts . get ( & ct) {
537+ if let Some ( & i) = self . consts . get ( & ct) {
545538 return self . print_backref ( i) ;
546539 }
547540 let start = self . out . len ( ) ;
@@ -579,7 +572,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
579572 // Only cache consts that do not refer to an enclosing
580573 // binder (which would change depending on context).
581574 if !ct. has_escaping_bound_vars ( ) {
582- self . compress . consts . insert ( ct, start) ;
575+ self . consts . insert ( ct, start) ;
583576 }
584577 Ok ( self )
585578 }
0 commit comments