@@ -44,12 +44,13 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
44
44
where
45
45
V : TypeFoldable < ' tcx > ,
46
46
{
47
- self . tcx . sess . perf_stats . queries_canonicalized . fetch_add ( 1 , Ordering :: Relaxed ) ;
47
+ let tcx = self . tcx ;
48
+ tcx. sess . perf_stats . queries_canonicalized . fetch_add ( 1 , Ordering :: Relaxed ) ;
48
49
49
50
Canonicalizer :: canonicalize (
50
51
value,
51
52
Some ( self ) ,
52
- self . tcx ,
53
+ tcx,
53
54
& CanonicalizeAllFreeRegions ,
54
55
query_state,
55
56
)
@@ -84,11 +85,12 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
84
85
where
85
86
V : TypeFoldable < ' tcx > ,
86
87
{
88
+ let tcx = self . tcx ;
87
89
let mut query_state = OriginalQueryValues :: default ( ) ;
88
90
Canonicalizer :: canonicalize (
89
91
value,
90
92
Some ( self ) ,
91
- self . tcx ,
93
+ tcx,
92
94
& CanonicalizeQueryResponse ,
93
95
& mut query_state,
94
96
)
@@ -98,11 +100,12 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
98
100
where
99
101
V : TypeFoldable < ' tcx > ,
100
102
{
103
+ let tcx = self . tcx ;
101
104
let mut query_state = OriginalQueryValues :: default ( ) ;
102
105
Canonicalizer :: canonicalize (
103
106
value,
104
107
Some ( self ) ,
105
- self . tcx ,
108
+ tcx,
106
109
& CanonicalizeUserTypeAnnotation ,
107
110
& mut query_state,
108
111
)
@@ -129,12 +132,13 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
129
132
where
130
133
V : TypeFoldable < ' tcx > ,
131
134
{
132
- self . tcx . sess . perf_stats . queries_canonicalized . fetch_add ( 1 , Ordering :: Relaxed ) ;
135
+ let tcx = self . tcx ;
136
+ tcx. sess . perf_stats . queries_canonicalized . fetch_add ( 1 , Ordering :: Relaxed ) ;
133
137
134
138
Canonicalizer :: canonicalize (
135
139
value,
136
140
Some ( self ) ,
137
- self . tcx ,
141
+ tcx,
138
142
& CanonicalizeFreeRegionsOtherThanStatic ,
139
143
query_state,
140
144
)
@@ -316,6 +320,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
316
320
ty:: ReVar ( vid) => {
317
321
let resolved_vid = self
318
322
. infcx
323
+ . as_mut ( )
319
324
. unwrap ( )
320
325
. inner
321
326
. unwrap_region_constraints ( )
@@ -342,7 +347,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
342
347
match * t. kind ( ) {
343
348
ty:: Infer ( ty:: TyVar ( vid) ) => {
344
349
debug ! ( "canonical: type var found with vid {:?}" , vid) ;
345
- match self . infcx . unwrap ( ) . probe_ty_var ( vid) {
350
+ match self . infcx . as_mut ( ) . unwrap ( ) . probe_ty_var ( vid) {
346
351
// `t` could be a float / int variable; canonicalize that instead.
347
352
Ok ( t) => {
348
353
debug ! ( "(resolved to {:?})" , t) ;
@@ -352,7 +357,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
352
357
// `TyVar(vid)` is unresolved, track its universe index in the canonicalized
353
358
// result.
354
359
Err ( mut ui) => {
355
- if !self . infcx . unwrap ( ) . tcx . sess . opts . debugging_opts . chalk {
360
+ if !self . infcx . as_ref ( ) . unwrap ( ) . tcx . sess . opts . debugging_opts . chalk {
356
361
// FIXME: perf problem described in #55921.
357
362
ui = ty:: UniverseIndex :: ROOT ;
358
363
}
@@ -430,7 +435,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
430
435
match ct. val {
431
436
ty:: ConstKind :: Infer ( InferConst :: Var ( vid) ) => {
432
437
debug ! ( "canonical: const var found with vid {:?}" , vid) ;
433
- match self . infcx . unwrap ( ) . probe_const_var ( vid) {
438
+ match self . infcx . as_mut ( ) . unwrap ( ) . probe_const_var ( vid) {
434
439
Ok ( c) => {
435
440
debug ! ( "(resolved to {:?})" , c) ;
436
441
return self . fold_const ( c) ;
@@ -439,7 +444,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
439
444
// `ConstVar(vid)` is unresolved, track its universe index in the
440
445
// canonicalized result
441
446
Err ( mut ui) => {
442
- if !self . infcx . unwrap ( ) . tcx . sess . opts . debugging_opts . chalk {
447
+ if !self . infcx . as_ref ( ) . unwrap ( ) . tcx . sess . opts . debugging_opts . chalk {
443
448
// FIXME: perf problem described in #55921.
444
449
ui = ty:: UniverseIndex :: ROOT ;
445
450
}
@@ -612,8 +617,8 @@ impl<'cx, 'tcx> Canonicalizer<'_, 'cx, 'tcx> {
612
617
}
613
618
614
619
/// Returns the universe in which `vid` is defined.
615
- fn region_var_universe ( & self , vid : ty:: RegionVid ) -> ty:: UniverseIndex {
616
- self . infcx . unwrap ( ) . inner . unwrap_region_constraints ( ) . var_universe ( vid)
620
+ fn region_var_universe ( & mut self , vid : ty:: RegionVid ) -> ty:: UniverseIndex {
621
+ self . infcx . as_mut ( ) . unwrap ( ) . inner . unwrap_region_constraints ( ) . var_universe ( vid)
617
622
}
618
623
619
624
/// Creates a canonical variable (with the given `info`)
@@ -634,7 +639,7 @@ impl<'cx, 'tcx> Canonicalizer<'_, 'cx, 'tcx> {
634
639
/// *that*. Otherwise, create a new canonical variable for
635
640
/// `ty_var`.
636
641
fn canonicalize_ty_var ( & mut self , info : CanonicalVarInfo < ' tcx > , ty_var : Ty < ' tcx > ) -> Ty < ' tcx > {
637
- let infcx = self . infcx . expect ( "encountered ty-var without infcx" ) ;
642
+ let infcx = self . infcx . as_mut ( ) . expect ( "encountered ty-var without infcx" ) ;
638
643
let bound_to = infcx. shallow_resolve ( ty_var) ;
639
644
if bound_to != ty_var {
640
645
self . fold_ty ( bound_to)
@@ -653,7 +658,7 @@ impl<'cx, 'tcx> Canonicalizer<'_, 'cx, 'tcx> {
653
658
info : CanonicalVarInfo < ' tcx > ,
654
659
const_var : & ' tcx ty:: Const < ' tcx > ,
655
660
) -> & ' tcx ty:: Const < ' tcx > {
656
- let infcx = self . infcx . expect ( "encountered const-var without infcx" ) ;
661
+ let infcx = self . infcx . as_mut ( ) . expect ( "encountered const-var without infcx" ) ;
657
662
let bound_to = infcx. shallow_resolve ( const_var) ;
658
663
if bound_to != const_var {
659
664
self . fold_const ( bound_to)
0 commit comments