Register obligations from type relation

This commit is contained in:
Oli Scherer 2022-11-14 17:48:27 +00:00
parent 9a8e1eea7a
commit f42e490d6f
3 changed files with 13 additions and 6 deletions

View File

@ -155,7 +155,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
true true
} }
fn register_opaque_type_obligations(&mut self, obligations: PredicateObligations<'tcx>) { fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
self.type_checker self.type_checker
.fully_perform_op( .fully_perform_op(
self.locations, self.locations,

View File

@ -740,7 +740,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
true true
} }
fn register_opaque_type_obligations(&mut self, obligations: PredicateObligations<'tcx>) { fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
self.obligations.extend(obligations); self.obligations.extend(obligations);
} }
} }

View File

@ -25,7 +25,7 @@ use crate::infer::combine::ConstEquateRelation;
use crate::infer::InferCtxt; use crate::infer::InferCtxt;
use crate::infer::{ConstVarValue, ConstVariableValue}; use crate::infer::{ConstVarValue, ConstVariableValue};
use crate::infer::{TypeVariableOrigin, TypeVariableOriginKind}; use crate::infer::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::traits::PredicateObligation; use crate::traits::{Obligation, PredicateObligation};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_middle::traits::ObligationCause; use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::error::TypeError; use rustc_middle::ty::error::TypeError;
@ -93,7 +93,7 @@ pub trait TypeRelatingDelegate<'tcx> {
); );
fn const_equate(&mut self, a: ty::Const<'tcx>, b: ty::Const<'tcx>); fn const_equate(&mut self, a: ty::Const<'tcx>, b: ty::Const<'tcx>);
fn register_opaque_type_obligations(&mut self, obligations: Vec<PredicateObligation<'tcx>>); fn register_obligations(&mut self, obligations: Vec<PredicateObligation<'tcx>>);
/// Creates a new universe index. Used when instantiating placeholders. /// Creates a new universe index. Used when instantiating placeholders.
fn create_next_universe(&mut self) -> ty::UniverseIndex; fn create_next_universe(&mut self) -> ty::UniverseIndex;
@ -416,7 +416,7 @@ where
.infcx .infcx
.handle_opaque_type(a, b, true, &cause, self.delegate.param_env())? .handle_opaque_type(a, b, true, &cause, self.delegate.param_env())?
.obligations; .obligations;
self.delegate.register_opaque_type_obligations(obligations); self.delegate.register_obligations(obligations);
trace!(a = ?a.kind(), b = ?b.kind(), "opaque type instantiated"); trace!(a = ?a.kind(), b = ?b.kind(), "opaque type instantiated");
Ok(a) Ok(a)
} }
@ -545,7 +545,14 @@ where
} }
fn mark_ambiguous(&mut self) { fn mark_ambiguous(&mut self) {
bug!() let cause = ObligationCause::dummy_with_span(self.delegate.span());
let param_env = self.delegate.param_env();
self.delegate.register_obligations(vec![Obligation::new(
self.tcx(),
cause,
param_env,
ty::Binder::dummy(ty::PredicateKind::Ambiguous),
)]);
} }
#[instrument(skip(self, info), level = "trace", ret)] #[instrument(skip(self, info), level = "trace", ret)]