@@ -25,13 +25,13 @@ pub(super) fn mangle(
25
25
let prefix = "_R" ;
26
26
let mut cx = SymbolMangler {
27
27
tcx,
28
- compress : Some ( Box :: new ( CompressionCaches {
28
+ compress : Box :: new ( CompressionCaches {
29
29
start_offset : prefix. len ( ) ,
30
30
31
31
paths : FxHashMap :: default ( ) ,
32
32
types : FxHashMap :: default ( ) ,
33
33
consts : FxHashMap :: default ( ) ,
34
- } ) ) ,
34
+ } ) ,
35
35
binders : vec ! [ ] ,
36
36
out : String :: from ( prefix) ,
37
37
} ;
@@ -81,7 +81,7 @@ struct BinderLevel {
81
81
82
82
struct SymbolMangler < ' tcx > {
83
83
tcx : TyCtxt < ' tcx > ,
84
- compress : Option < Box < CompressionCaches < ' tcx > > > ,
84
+ compress : Box < CompressionCaches < ' tcx > > ,
85
85
binders : Vec < BinderLevel > ,
86
86
out : String ,
87
87
}
@@ -177,7 +177,7 @@ impl SymbolMangler<'tcx> {
177
177
178
178
fn print_backref ( mut self , i : usize ) -> Result < Self , !> {
179
179
self . push ( "B" ) ;
180
- self . push_integer_62 ( ( i - self . compress . as_ref ( ) . unwrap ( ) . start_offset ) as u64 ) ;
180
+ self . push_integer_62 ( ( i - self . compress . start_offset ) as u64 ) ;
181
181
Ok ( self )
182
182
}
183
183
@@ -236,7 +236,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
236
236
def_id : DefId ,
237
237
substs : & ' tcx [ GenericArg < ' tcx > ] ,
238
238
) -> Result < Self :: Path , Self :: Error > {
239
- if let Some ( & i) = self . compress . as_ref ( ) . and_then ( |c| c . paths . get ( & ( def_id, substs) ) ) {
239
+ if let Some ( & i) = self . compress . paths . get ( & ( def_id, substs) ) {
240
240
return self . print_backref ( i) ;
241
241
}
242
242
let start = self . out . len ( ) ;
@@ -246,9 +246,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
246
246
// Only cache paths that do not refer to an enclosing
247
247
// binder (which would change depending on context).
248
248
if !substs. iter ( ) . any ( |k| k. has_escaping_bound_vars ( ) ) {
249
- if let Some ( c) = & mut self . compress {
250
- c. paths . insert ( ( def_id, substs) , start) ;
251
- }
249
+ self . compress . paths . insert ( ( def_id, substs) , start) ;
252
250
}
253
251
Ok ( self )
254
252
}
@@ -367,7 +365,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
367
365
return Ok ( self ) ;
368
366
}
369
367
370
- if let Some ( & i) = self . compress . as_ref ( ) . and_then ( |c| c . types . get ( & ty) ) {
368
+ if let Some ( & i) = self . compress . types . get ( & ty) {
371
369
return self . print_backref ( i) ;
372
370
}
373
371
let start = self . out . len ( ) ;
@@ -476,9 +474,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
476
474
// Only cache types that do not refer to an enclosing
477
475
// binder (which would change depending on context).
478
476
if !ty. has_escaping_bound_vars ( ) {
479
- if let Some ( c) = & mut self . compress {
480
- c. types . insert ( ty, start) ;
481
- }
477
+ self . compress . types . insert ( ty, start) ;
482
478
}
483
479
Ok ( self )
484
480
}
@@ -545,7 +541,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
545
541
}
546
542
547
543
fn print_const ( mut self , ct : & ' tcx ty:: Const < ' tcx > ) -> Result < Self :: Const , Self :: Error > {
548
- if let Some ( & i) = self . compress . as_ref ( ) . and_then ( |c| c . consts . get ( & ct) ) {
544
+ if let Some ( & i) = self . compress . consts . get ( & ct) {
549
545
return self . print_backref ( i) ;
550
546
}
551
547
let start = self . out . len ( ) ;
@@ -583,9 +579,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
583
579
// Only cache consts that do not refer to an enclosing
584
580
// binder (which would change depending on context).
585
581
if !ct. has_escaping_bound_vars ( ) {
586
- if let Some ( c) = & mut self . compress {
587
- c. consts . insert ( ct, start) ;
588
- }
582
+ self . compress . consts . insert ( ct, start) ;
589
583
}
590
584
Ok ( self )
591
585
}
0 commit comments