11
11
use super :: { CanonicalGoal , Certainty , EvalCtxt , Goal } ;
12
12
use crate :: solve:: canonicalize:: { CanonicalizeMode , Canonicalizer } ;
13
13
use crate :: solve:: { CanonicalResponse , QueryResult , Response } ;
14
+ use rustc_index:: vec:: IndexVec ;
14
15
use rustc_infer:: infer:: canonical:: query_response:: make_query_region_constraints;
15
16
use rustc_infer:: infer:: canonical:: CanonicalVarValues ;
16
17
use rustc_infer:: infer:: canonical:: { CanonicalExt , QueryRegionConstraints } ;
17
18
use rustc_middle:: traits:: query:: NoSolution ;
18
19
use rustc_middle:: traits:: solve:: { ExternalConstraints , ExternalConstraintsData } ;
19
- use rustc_middle:: ty:: { self , GenericArgKind } ;
20
+ use rustc_middle:: ty:: { self , BoundVar , GenericArgKind } ;
20
21
use rustc_span:: DUMMY_SP ;
21
22
use std:: iter;
22
23
use std:: ops:: Deref ;
@@ -139,25 +140,25 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
139
140
//
140
141
// We therefore instantiate the existential variable in the canonical response with the
141
142
// inference variable of the input right away, which is more performant.
142
- let mut opt_values = vec ! [ None ; response. variables. len( ) ] ;
143
+ let mut opt_values = IndexVec :: from_elem_n ( None , response. variables . len ( ) ) ;
143
144
for ( original_value, result_value) in iter:: zip ( original_values, var_values. var_values ) {
144
145
match result_value. unpack ( ) {
145
146
GenericArgKind :: Type ( t) => {
146
147
if let & ty:: Bound ( debruijn, b) = t. kind ( ) {
147
148
assert_eq ! ( debruijn, ty:: INNERMOST ) ;
148
- opt_values[ b. var . index ( ) ] = Some ( * original_value) ;
149
+ opt_values[ b. var ] = Some ( * original_value) ;
149
150
}
150
151
}
151
152
GenericArgKind :: Lifetime ( r) => {
152
153
if let ty:: ReLateBound ( debruijn, br) = * r {
153
154
assert_eq ! ( debruijn, ty:: INNERMOST ) ;
154
- opt_values[ br. var . index ( ) ] = Some ( * original_value) ;
155
+ opt_values[ br. var ] = Some ( * original_value) ;
155
156
}
156
157
}
157
158
GenericArgKind :: Const ( c) => {
158
159
if let ty:: ConstKind :: Bound ( debrujin, b) = c. kind ( ) {
159
160
assert_eq ! ( debrujin, ty:: INNERMOST ) ;
160
- opt_values[ b. index ( ) ] = Some ( * original_value) ;
161
+ opt_values[ b] = Some ( * original_value) ;
161
162
}
162
163
}
163
164
}
@@ -180,7 +181,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
180
181
// more placeholders then they should be able to. However the inference variables have
181
182
// to "come from somewhere", so by equating them with the original values of the caller
182
183
// later on, we pull them down into their correct universe again.
183
- if let Some ( v) = opt_values[ index] {
184
+ if let Some ( v) = opt_values[ BoundVar :: from_usize ( index) ] {
184
185
v
185
186
} else {
186
187
self . infcx . instantiate_canonical_var ( DUMMY_SP , info, |_| prev_universe)
0 commit comments