Skip to content

Commit

Permalink
reverse obligations for better diagnostics on multiple conflicting fn…
Browse files Browse the repository at this point in the history
… bounds
  • Loading branch information
compiler-errors committed Nov 3, 2022
1 parent caa701e commit bc3516d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bc3516d

Please sign in to comment.