1
Fork 0

reverse obligations for better diagnostics on multiple conflicting fn bounds

This commit is contained in:
Michael Goulet 2022-10-15 18:48:13 +00:00
parent caa701e3c1
commit bc3516d474
2 changed files with 6 additions and 2 deletions

View file

@ -231,7 +231,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for obligation in traits::elaborate_obligations(
self.tcx,
self.obligations_for_self_ty(expected_vid).collect(),
// Reverse the obligations here, since `elaborate_*` uses a stack,
// and we want to keep inference generally in the same order of
// the registered obligations.
self.obligations_for_self_ty(expected_vid).rev().collect(),
) {
debug!(?obligation.predicate);
let bound_predicate = obligation.predicate.kind();

View file

@ -670,7 +670,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(in super::super) fn obligations_for_self_ty<'b>(
&'b self,
self_ty: ty::TyVid,
) -> impl Iterator<Item = traits::PredicateObligation<'tcx>> + Captures<'tcx> + 'b {
) -> impl DoubleEndedIterator<Item = traits::PredicateObligation<'tcx>> + Captures<'tcx> + 'b
{
// FIXME: consider using `sub_root_var` here so we
// can see through subtyping.
let ty_var_root = self.root_var(self_ty);