@@ -46,13 +46,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
46
46
{
47
47
self . tcx . sess . perf_stats . queries_canonicalized . fetch_add ( 1 , Ordering :: Relaxed ) ;
48
48
49
- Canonicalizer :: canonicalize (
50
- value,
51
- Some ( self ) ,
52
- self . tcx ,
53
- & CanonicalizeAllFreeRegions ,
54
- query_state,
55
- )
49
+ Canonicalizer :: canonicalize ( value, self , self . tcx , & CanonicalizeAllFreeRegions , query_state)
56
50
}
57
51
58
52
/// Canonicalizes a query *response* `V`. When we canonicalize a
@@ -87,7 +81,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
87
81
let mut query_state = OriginalQueryValues :: default ( ) ;
88
82
Canonicalizer :: canonicalize (
89
83
value,
90
- Some ( self ) ,
84
+ self ,
91
85
self . tcx ,
92
86
& CanonicalizeQueryResponse ,
93
87
& mut query_state,
@@ -101,7 +95,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
101
95
let mut query_state = OriginalQueryValues :: default ( ) ;
102
96
Canonicalizer :: canonicalize (
103
97
value,
104
- Some ( self ) ,
98
+ self ,
105
99
self . tcx ,
106
100
& CanonicalizeUserTypeAnnotation ,
107
101
& mut query_state,
@@ -133,7 +127,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
133
127
134
128
Canonicalizer :: canonicalize (
135
129
value,
136
- Some ( self ) ,
130
+ self ,
137
131
self . tcx ,
138
132
& CanonicalizeFreeRegionsOtherThanStatic ,
139
133
query_state,
@@ -275,7 +269,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
275
269
}
276
270
277
271
struct Canonicalizer < ' cx , ' tcx > {
278
- infcx : Option < & ' cx InferCtxt < ' cx , ' tcx > > ,
272
+ infcx : & ' cx InferCtxt < ' cx , ' tcx > ,
279
273
tcx : TyCtxt < ' tcx > ,
280
274
variables : SmallVec < [ CanonicalVarInfo < ' tcx > ; 8 ] > ,
281
275
query_state : & ' cx mut OriginalQueryValues < ' tcx > ,
@@ -316,7 +310,6 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
316
310
ty:: ReVar ( vid) => {
317
311
let resolved_vid = self
318
312
. infcx
319
- . unwrap ( )
320
313
. inner
321
314
. borrow_mut ( )
322
315
. unwrap_region_constraints ( )
@@ -343,7 +336,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
343
336
match * t. kind ( ) {
344
337
ty:: Infer ( ty:: TyVar ( vid) ) => {
345
338
debug ! ( "canonical: type var found with vid {:?}" , vid) ;
346
- match self . infcx . unwrap ( ) . probe_ty_var ( vid) {
339
+ match self . infcx . probe_ty_var ( vid) {
347
340
// `t` could be a float / int variable; canonicalize that instead.
348
341
Ok ( t) => {
349
342
debug ! ( "(resolved to {:?})" , t) ;
@@ -429,7 +422,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
429
422
match ct. val {
430
423
ty:: ConstKind :: Infer ( InferConst :: Var ( vid) ) => {
431
424
debug ! ( "canonical: const var found with vid {:?}" , vid) ;
432
- match self . infcx . unwrap ( ) . probe_const_var ( vid) {
425
+ match self . infcx . probe_const_var ( vid) {
433
426
Ok ( c) => {
434
427
debug ! ( "(resolved to {:?})" , c) ;
435
428
return self . fold_const ( c) ;
@@ -476,7 +469,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
476
469
/// `canonicalize_query` and `canonicalize_response`.
477
470
fn canonicalize < V > (
478
471
value : V ,
479
- infcx : Option < & InferCtxt < ' _ , ' tcx > > ,
472
+ infcx : & InferCtxt < ' _ , ' tcx > ,
480
473
tcx : TyCtxt < ' tcx > ,
481
474
canonicalize_region_mode : & dyn CanonicalizeRegionMode ,
482
475
query_state : & mut OriginalQueryValues < ' tcx > ,
@@ -610,7 +603,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
610
603
611
604
/// Returns the universe in which `vid` is defined.
612
605
fn region_var_universe ( & self , vid : ty:: RegionVid ) -> ty:: UniverseIndex {
613
- self . infcx . unwrap ( ) . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . var_universe ( vid)
606
+ self . infcx . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . var_universe ( vid)
614
607
}
615
608
616
609
/// Creates a canonical variable (with the given `info`)
@@ -631,7 +624,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
631
624
/// *that*. Otherwise, create a new canonical variable for
632
625
/// `ty_var`.
633
626
fn canonicalize_ty_var ( & mut self , info : CanonicalVarInfo < ' tcx > , ty_var : Ty < ' tcx > ) -> Ty < ' tcx > {
634
- let infcx = self . infcx . expect ( "encountered ty-var without infcx" ) ;
627
+ let infcx = self . infcx ;
635
628
let bound_to = infcx. shallow_resolve ( ty_var) ;
636
629
if bound_to != ty_var {
637
630
self . fold_ty ( bound_to)
@@ -650,7 +643,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
650
643
info : CanonicalVarInfo < ' tcx > ,
651
644
const_var : & ' tcx ty:: Const < ' tcx > ,
652
645
) -> & ' tcx ty:: Const < ' tcx > {
653
- let infcx = self . infcx . expect ( "encountered const-var without infcx" ) ;
646
+ let infcx = self . infcx ;
654
647
let bound_to = infcx. shallow_resolve ( const_var) ;
655
648
if bound_to != const_var {
656
649
self . fold_const ( bound_to)
0 commit comments