@@ -13,9 +13,7 @@ use std::iter;
13
13
use rustc_index:: { Idx , IndexVec } ;
14
14
use rustc_middle:: arena:: ArenaAllocatable ;
15
15
use rustc_middle:: mir:: ConstraintCategory ;
16
- use rustc_middle:: ty:: {
17
- self , BoundVar , CanonicalVarKind , GenericArg , GenericArgKind , Ty , TyCtxt , TypeFoldable ,
18
- } ;
16
+ use rustc_middle:: ty:: { self , BoundVar , GenericArg , GenericArgKind , Ty , TyCtxt , TypeFoldable } ;
19
17
use rustc_middle:: { bug, span_bug} ;
20
18
use tracing:: { debug, instrument} ;
21
19
@@ -422,16 +420,7 @@ impl<'tcx> InferCtxt<'tcx> {
422
420
for ( original_value, result_value) in iter:: zip ( & original_values. var_values , result_values)
423
421
{
424
422
match result_value. unpack ( ) {
425
- GenericArgKind :: Type ( result_value) => {
426
- // e.g., here `result_value` might be `?0` in the example above...
427
- if let ty:: Bound ( debruijn, b) = * result_value. kind ( ) {
428
- // ...in which case we would set `canonical_vars[0]` to `Some(?U)`.
429
-
430
- // We only allow a `ty::INNERMOST` index in generic parameters.
431
- assert_eq ! ( debruijn, ty:: INNERMOST ) ;
432
- opt_values[ b. var ] = Some ( * original_value) ;
433
- }
434
- }
423
+ GenericArgKind :: Type ( _) => { }
435
424
GenericArgKind :: Lifetime ( result_value) => {
436
425
// e.g., here `result_value` might be `'?1` in the example above...
437
426
if let ty:: ReBound ( debruijn, br) = result_value. kind ( ) {
@@ -457,7 +446,7 @@ impl<'tcx> InferCtxt<'tcx> {
457
446
// Create result arguments: if we found a value for a
458
447
// given variable in the loop above, use that. Otherwise, use
459
448
// a fresh inference variable.
460
- let mut var_values = Vec :: new ( ) ;
449
+ let mut var_values = Vec :: with_capacity ( query_response . variables . len ( ) ) ;
461
450
for ( index, info) in query_response. variables . iter ( ) . enumerate ( ) {
462
451
let value = if info. universe ( ) != ty:: UniverseIndex :: ROOT {
463
452
// A variable from inside a binder of the query. While ideally these shouldn't
@@ -470,27 +459,7 @@ impl<'tcx> InferCtxt<'tcx> {
470
459
// We need to still make sure to register any subtype relations returned by the
471
460
// query.
472
461
match opt_values[ BoundVar :: new ( index) ] {
473
- Some ( v) => {
474
- if let CanonicalVarKind :: Ty { universe : _, sub_root } = info. kind {
475
- if let Some ( prev) = var_values. get ( sub_root. as_usize ( ) ) {
476
- // We cannot simply assume that previous `var_values`
477
- // are inference variables, see the comment in
478
- // `instantiate_canonical_var`.
479
- let v = self . shallow_resolve ( v. expect_ty ( ) ) ;
480
- let prev = self . shallow_resolve ( prev. expect_ty ( ) ) ;
481
- match ( v. kind ( ) , prev. kind ( ) ) {
482
- (
483
- & ty:: Infer ( ty:: TyVar ( vid) ) ,
484
- & ty:: Infer ( ty:: TyVar ( sub_root) ) ,
485
- ) => {
486
- self . inner . borrow_mut ( ) . type_variables ( ) . sub ( vid, sub_root)
487
- }
488
- _ => { }
489
- }
490
- }
491
- }
492
- v
493
- }
462
+ Some ( v) => v,
494
463
None => self . instantiate_canonical_var ( cause. span , info, & var_values, |u| {
495
464
universe_map[ u. as_usize ( ) ]
496
465
} ) ,
0 commit comments