@@ -25,13 +25,10 @@ pub(super) fn mangle(
25
25
let prefix = "_R" ;
26
26
let mut cx = SymbolMangler {
27
27
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 ( ) ,
35
32
binders : vec ! [ ] ,
36
33
out : String :: from ( prefix) ,
37
34
} ;
@@ -55,16 +52,6 @@ pub(super) fn mangle(
55
52
cx. out
56
53
}
57
54
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
-
68
55
struct BinderLevel {
69
56
/// The range of distances from the root of what's
70
57
/// being printed, to the lifetimes in a binder.
@@ -81,9 +68,15 @@ struct BinderLevel {
81
68
82
69
struct SymbolMangler < ' tcx > {
83
70
tcx : TyCtxt < ' tcx > ,
84
- compress : Box < CompressionCaches < ' tcx > > ,
85
71
binders : Vec < BinderLevel > ,
86
72
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 > ,
87
80
}
88
81
89
82
impl SymbolMangler < ' tcx > {
@@ -177,7 +170,7 @@ impl SymbolMangler<'tcx> {
177
170
178
171
fn print_backref ( mut self , i : usize ) -> Result < Self , !> {
179
172
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 ) ;
181
174
Ok ( self )
182
175
}
183
176
@@ -236,7 +229,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
236
229
def_id : DefId ,
237
230
substs : & ' tcx [ GenericArg < ' tcx > ] ,
238
231
) -> 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) ) {
240
233
return self . print_backref ( i) ;
241
234
}
242
235
let start = self . out . len ( ) ;
@@ -246,7 +239,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
246
239
// Only cache paths that do not refer to an enclosing
247
240
// binder (which would change depending on context).
248
241
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) ;
250
243
}
251
244
Ok ( self )
252
245
}
@@ -365,7 +358,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
365
358
return Ok ( self ) ;
366
359
}
367
360
368
- if let Some ( & i) = self . compress . types . get ( & ty) {
361
+ if let Some ( & i) = self . types . get ( & ty) {
369
362
return self . print_backref ( i) ;
370
363
}
371
364
let start = self . out . len ( ) ;
@@ -474,7 +467,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
474
467
// Only cache types that do not refer to an enclosing
475
468
// binder (which would change depending on context).
476
469
if !ty. has_escaping_bound_vars ( ) {
477
- self . compress . types . insert ( ty, start) ;
470
+ self . types . insert ( ty, start) ;
478
471
}
479
472
Ok ( self )
480
473
}
@@ -541,7 +534,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
541
534
}
542
535
543
536
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) {
545
538
return self . print_backref ( i) ;
546
539
}
547
540
let start = self . out . len ( ) ;
@@ -579,7 +572,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
579
572
// Only cache consts that do not refer to an enclosing
580
573
// binder (which would change depending on context).
581
574
if !ct. has_escaping_bound_vars ( ) {
582
- self . compress . consts . insert ( ct, start) ;
575
+ self . consts . insert ( ct, start) ;
583
576
}
584
577
Ok ( self )
585
578
}
0 commit comments