Skip to content

Commit 53c24cb

Browse files
committed
rarw
1 parent 88dd764 commit 53c24cb

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

compiler/rustc_infer/src/infer/canonical/query_response.rs

+4-35
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ use std::iter;
1313
use rustc_index::{Idx, IndexVec};
1414
use rustc_middle::arena::ArenaAllocatable;
1515
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};
1917
use rustc_middle::{bug, span_bug};
2018
use tracing::{debug, instrument};
2119

@@ -422,16 +420,7 @@ impl<'tcx> InferCtxt<'tcx> {
422420
for (original_value, result_value) in iter::zip(&original_values.var_values, result_values)
423421
{
424422
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(_) => {}
435424
GenericArgKind::Lifetime(result_value) => {
436425
// e.g., here `result_value` might be `'?1` in the example above...
437426
if let ty::ReBound(debruijn, br) = result_value.kind() {
@@ -457,7 +446,7 @@ impl<'tcx> InferCtxt<'tcx> {
457446
// Create result arguments: if we found a value for a
458447
// given variable in the loop above, use that. Otherwise, use
459448
// a fresh inference variable.
460-
let mut var_values = Vec::new();
449+
let mut var_values = Vec::with_capacity(query_response.variables.len());
461450
for (index, info) in query_response.variables.iter().enumerate() {
462451
let value = if info.universe() != ty::UniverseIndex::ROOT {
463452
// A variable from inside a binder of the query. While ideally these shouldn't
@@ -470,27 +459,7 @@ impl<'tcx> InferCtxt<'tcx> {
470459
// We need to still make sure to register any subtype relations returned by the
471460
// query.
472461
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,
494463
None => self.instantiate_canonical_var(cause.span, info, &var_values, |u| {
495464
universe_map[u.as_usize()]
496465
}),

0 commit comments

Comments
 (0)