Skip to content

Commit 9374cd2

Browse files
committed
compute_trait_ref: Restore original order of predicates
This can matter for obligation causes that get reported as errors, when there are more than one of the same obligation in the forest.
1 parent 0faf7fb commit 9374cd2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/librustc/ty/wf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
465465
def_id: trait_ref.def_id,
466466
substs: Substs::identity_for_item(self.infcx.tcx, trait_ref.def_id)
467467
};
468-
predicates.predicates.push(identity_trait_ref.to_poly_trait_ref().to_predicate());
468+
predicates.predicates.insert(0, identity_trait_ref.to_poly_trait_ref().to_predicate());
469469

470470
debug!("nominal_trait_obligations: trait_ref={:?} predicates={:?}",
471471
trait_ref, predicates.predicates);

src/librustc_typeck/check/wfcheck.rs

+2
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
447447
let predicates = predicates.instantiate_identity(fcx.tcx);
448448
let predicates = fcx.normalize_associated_types_in(span, &predicates);
449449

450+
debug!("check_where_clauses: predicates={:?}", predicates.predicates);
450451
let obligations =
451452
predicates.predicates
452453
.iter()
@@ -457,6 +458,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
457458
span));
458459

459460
for obligation in obligations {
461+
debug!("next obligation cause: {:?}", obligation.cause);
460462
fcx.register_predicate(obligation);
461463
}
462464
}

0 commit comments

Comments
 (0)