@@ -422,16 +422,7 @@ impl<'tcx> InferCtxt<'tcx> {
422422 for ( original_value, result_value) in iter:: zip ( & original_values. var_values , result_values)
423423 {
424424 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- }
425+ GenericArgKind :: Type ( _) => { }
435426 GenericArgKind :: Lifetime ( result_value) => {
436427 // e.g., here `result_value` might be `'?1` in the example above...
437428 if let ty:: ReBound ( debruijn, br) = result_value. kind ( ) {
@@ -457,7 +448,7 @@ impl<'tcx> InferCtxt<'tcx> {
457448 // Create result arguments: if we found a value for a
458449 // given variable in the loop above, use that. Otherwise, use
459450 // a fresh inference variable.
460- let mut var_values = Vec :: new ( ) ;
451+ let mut var_values = Vec :: with_capacity ( query_response . variables . len ( ) ) ;
461452 for ( index, info) in query_response. variables . iter ( ) . enumerate ( ) {
462453 let value = if info. universe ( ) != ty:: UniverseIndex :: ROOT {
463454 // A variable from inside a binder of the query. While ideally these shouldn't
@@ -470,27 +461,7 @@ impl<'tcx> InferCtxt<'tcx> {
470461 // We need to still make sure to register any subtype relations returned by the
471462 // query.
472463 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- }
464+ Some ( v) => v,
494465 None => self . instantiate_canonical_var ( cause. span , info, & var_values, |u| {
495466 universe_map[ u. as_usize ( ) ]
496467 } ) ,
0 commit comments