Skip to content

Commit f42e490

Browse files
committed
Register obligations from type relation
1 parent 9a8e1ee commit f42e490

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
155155
true
156156
}
157157

158-
fn register_opaque_type_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
158+
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
159159
self.type_checker
160160
.fully_perform_op(
161161
self.locations,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
740740
true
741741
}
742742

743-
fn register_opaque_type_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
743+
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
744744
self.obligations.extend(obligations);
745745
}
746746
}

compiler/rustc_infer/src/infer/nll_relate/mod.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::infer::combine::ConstEquateRelation;
2525
use crate::infer::InferCtxt;
2626
use crate::infer::{ConstVarValue, ConstVariableValue};
2727
use crate::infer::{TypeVariableOrigin, TypeVariableOriginKind};
28-
use crate::traits::PredicateObligation;
28+
use crate::traits::{Obligation, PredicateObligation};
2929
use rustc_data_structures::fx::FxHashMap;
3030
use rustc_middle::traits::ObligationCause;
3131
use rustc_middle::ty::error::TypeError;
@@ -93,7 +93,7 @@ pub trait TypeRelatingDelegate<'tcx> {
9393
);
9494

9595
fn const_equate(&mut self, a: ty::Const<'tcx>, b: ty::Const<'tcx>);
96-
fn register_opaque_type_obligations(&mut self, obligations: Vec<PredicateObligation<'tcx>>);
96+
fn register_obligations(&mut self, obligations: Vec<PredicateObligation<'tcx>>);
9797

9898
/// Creates a new universe index. Used when instantiating placeholders.
9999
fn create_next_universe(&mut self) -> ty::UniverseIndex;
@@ -416,7 +416,7 @@ where
416416
.infcx
417417
.handle_opaque_type(a, b, true, &cause, self.delegate.param_env())?
418418
.obligations;
419-
self.delegate.register_opaque_type_obligations(obligations);
419+
self.delegate.register_obligations(obligations);
420420
trace!(a = ?a.kind(), b = ?b.kind(), "opaque type instantiated");
421421
Ok(a)
422422
}
@@ -545,7 +545,14 @@ where
545545
}
546546

547547
fn mark_ambiguous(&mut self) {
548-
bug!()
548+
let cause = ObligationCause::dummy_with_span(self.delegate.span());
549+
let param_env = self.delegate.param_env();
550+
self.delegate.register_obligations(vec![Obligation::new(
551+
self.tcx(),
552+
cause,
553+
param_env,
554+
ty::Binder::dummy(ty::PredicateKind::Ambiguous),
555+
)]);
549556
}
550557

551558
#[instrument(skip(self, info), level = "trace", ret)]

0 commit comments

Comments
 (0)