Skip to content

Commit

Permalink
Only dedup obligation after new ones have been added.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Aug 8, 2023
1 parent 3c99b3d commit 8378487
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(

let projected_term = selcx.infcx.resolve_vars_if_possible(projected_term);

let mut result = if projected_term.has_projections() {
let result = if projected_term.has_projections() {
let mut normalizer = AssocTypeNormalizer::new(
selcx,
param_env,
Expand All @@ -1224,14 +1224,14 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
);
let normalized_ty = normalizer.fold(projected_term);

let mut deduped = SsoHashSet::with_capacity(projected_obligations.len());
projected_obligations.retain(|obligation| deduped.insert(obligation.clone()));

Normalized { value: normalized_ty, obligations: projected_obligations }
} else {
Normalized { value: projected_term, obligations: projected_obligations }
};

let mut deduped = SsoHashSet::with_capacity(projected_obligations.len());
result.obligations.retain(|obligation| deduped.insert(obligation.clone()));

if use_cache {
infcx.inner.borrow_mut().projection_cache().insert_term(cache_key, result.clone());
}
Expand Down

0 comments on commit 8378487

Please sign in to comment.