diff options
| author | lcnr <rust@lcnr.de> | 2023-12-07 16:13:09 +0100 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2023-12-07 16:13:09 +0100 |
| commit | 40aa9f4fd914cbbe043da1d5ffdecae287354dce (patch) | |
| tree | 437e3ffeada890eaaa6a6d91ec888f37893d19f0 /compiler/rustc_infer/src/infer/combine.rs | |
| parent | 7df0c211ace4157009eebd015f1a083490faa0bc (diff) | |
| download | rust-40aa9f4fd914cbbe043da1d5ffdecae287354dce.tar.gz rust-40aa9f4fd914cbbe043da1d5ffdecae287354dce.zip | |
avoid instantiating infer vars with infer
Diffstat (limited to 'compiler/rustc_infer/src/infer/combine.rs')
| -rw-r--r-- | compiler/rustc_infer/src/infer/combine.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs index 759ebaa1d1e..dfae279324f 100644 --- a/compiler/rustc_infer/src/infer/combine.rs +++ b/compiler/rustc_infer/src/infer/combine.rs @@ -34,6 +34,7 @@ use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue, EffectVa use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind}; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::relate::{RelateResult, TypeRelation}; +use rustc_middle::ty::TyVar; use rustc_middle::ty::{self, InferConst, ToPredicate, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{IntType, UintType}; use rustc_span::DUMMY_SP; @@ -459,7 +460,12 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> { ambient_variance, )?; - self.infcx.inner.borrow_mut().type_variables().instantiate(b_vid, b_ty); + // Constrain `b_vid` to the generalized type `b_ty`. + if let &ty::Infer(TyVar(b_ty_vid)) = b_ty.kind() { + self.infcx.inner.borrow_mut().type_variables().equate(b_vid, b_ty_vid); + } else { + self.infcx.inner.borrow_mut().type_variables().instantiate(b_vid, b_ty); + } if needs_wf { self.obligations.push(Obligation::new( |
