@@ -25,13 +25,13 @@ pub(super) fn mangle(
2525 let prefix = "_R" ;
2626 let mut cx = SymbolMangler {
2727 tcx,
28- compress : Some ( Box :: new ( CompressionCaches {
28+ compress : Box :: new ( CompressionCaches {
2929 start_offset : prefix. len ( ) ,
3030
3131 paths : FxHashMap :: default ( ) ,
3232 types : FxHashMap :: default ( ) ,
3333 consts : FxHashMap :: default ( ) ,
34- } ) ) ,
34+ } ) ,
3535 binders : vec ! [ ] ,
3636 out : String :: from ( prefix) ,
3737 } ;
@@ -81,7 +81,7 @@ struct BinderLevel {
8181
8282struct SymbolMangler < ' tcx > {
8383 tcx : TyCtxt < ' tcx > ,
84- compress : Option < Box < CompressionCaches < ' tcx > > > ,
84+ compress : Box < CompressionCaches < ' tcx > > ,
8585 binders : Vec < BinderLevel > ,
8686 out : String ,
8787}
@@ -177,7 +177,7 @@ impl SymbolMangler<'tcx> {
177177
178178 fn print_backref ( mut self , i : usize ) -> Result < Self , !> {
179179 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 ) ;
181181 Ok ( self )
182182 }
183183
@@ -236,7 +236,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
236236 def_id : DefId ,
237237 substs : & ' tcx [ GenericArg < ' tcx > ] ,
238238 ) -> 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) ) {
240240 return self . print_backref ( i) ;
241241 }
242242 let start = self . out . len ( ) ;
@@ -246,9 +246,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
246246 // Only cache paths that do not refer to an enclosing
247247 // binder (which would change depending on context).
248248 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) ;
252250 }
253251 Ok ( self )
254252 }
@@ -367,7 +365,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
367365 return Ok ( self ) ;
368366 }
369367
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) {
371369 return self . print_backref ( i) ;
372370 }
373371 let start = self . out . len ( ) ;
@@ -476,9 +474,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
476474 // Only cache types that do not refer to an enclosing
477475 // binder (which would change depending on context).
478476 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) ;
482478 }
483479 Ok ( self )
484480 }
@@ -545,7 +541,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
545541 }
546542
547543 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) {
549545 return self . print_backref ( i) ;
550546 }
551547 let start = self . out . len ( ) ;
@@ -583,9 +579,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
583579 // Only cache consts that do not refer to an enclosing
584580 // binder (which would change depending on context).
585581 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) ;
589583 }
590584 Ok ( self )
591585 }
0 commit comments