Skip to content

Commit

Permalink
Auto merge of #90423 - Aaron1011:deduplicate-projection, r=jackh726
Browse files Browse the repository at this point in the history
Deduplicate projection sub-obligations
  • Loading branch information
bors committed Dec 12, 2021
2 parents a0a4c7d + 39d44e7 commit 4c9bdf4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use super::{Normalized, NormalizedTy, ProjectionCacheEntry, ProjectionCacheKey};
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime};
use crate::traits::error_reporting::InferCtxtExt as _;
use rustc_data_structures::sso::SsoHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::ErrorReported;
use rustc_hir::def_id::DefId;
Expand Down Expand Up @@ -944,9 +945,14 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
Normalized { value: projected_ty, obligations: projected_obligations }
};

let mut deduped: SsoHashSet<_> = Default::default();
let mut canonical =
SelectionContext::with_query_mode(selcx.infcx(), TraitQueryMode::Canonical);

result.obligations.drain_filter(|projected_obligation| {
if !deduped.insert(projected_obligation.clone()) {
return true;
}
// If any global obligations always apply, considering regions, then we don't
// need to include them. The `is_global` check rules out inference variables,
// so there's no need for the caller of `opt_normalize_projection_type`
Expand Down

0 comments on commit 4c9bdf4

Please sign in to comment.