Skip to content

Commit

Permalink
impl_or_trait_obligations: deduplicate obligations
Browse files Browse the repository at this point in the history
  • Loading branch information
ishitatsuyuki committed Feb 18, 2018
1 parent 3d81698 commit 4a40c55
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3282,7 +3282,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// that order.
let predicates = tcx.predicates_of(def_id);
assert_eq!(predicates.parent, None);
let predicates = predicates.predicates.iter().flat_map(|predicate| {
let mut predicates: Vec<_> = predicates.predicates.iter().flat_map(|predicate| {
let predicate = normalize_with_depth(self, param_env, cause.clone(), recursion_depth,
&predicate.subst(tcx, substs));
predicate.obligations.into_iter().chain(
Expand All @@ -3293,6 +3293,17 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
predicate: predicate.value
}))
}).collect();
if predicates.len() > 1 {
let mut i = 0;
while i != predicates.len() {
let has_dup = (0..i).any(|j| predicates[i] == predicates[j]);
if has_dup {
predicates.swap_remove(i);
} else {
i += 1;
}
}
}
self.infcx().plug_leaks(skol_map, snapshot, predicates)
}
}
Expand Down

0 comments on commit 4a40c55

Please sign in to comment.