Skip to content

Commit 4c9bdf4

Browse files
committed
Auto merge of rust-lang#90423 - Aaron1011:deduplicate-projection, r=jackh726
Deduplicate projection sub-obligations
2 parents a0a4c7d + 39d44e7 commit 4c9bdf4

File tree

1 file changed

+6
-0
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+6
-0
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use super::{Normalized, NormalizedTy, ProjectionCacheEntry, ProjectionCacheKey};
2020
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
2121
use crate::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime};
2222
use crate::traits::error_reporting::InferCtxtExt as _;
23+
use rustc_data_structures::sso::SsoHashSet;
2324
use rustc_data_structures::stack::ensure_sufficient_stack;
2425
use rustc_errors::ErrorReported;
2526
use rustc_hir::def_id::DefId;
@@ -944,9 +945,14 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
944945
Normalized { value: projected_ty, obligations: projected_obligations }
945946
};
946947

948+
let mut deduped: SsoHashSet<_> = Default::default();
947949
let mut canonical =
948950
SelectionContext::with_query_mode(selcx.infcx(), TraitQueryMode::Canonical);
951+
949952
result.obligations.drain_filter(|projected_obligation| {
953+
if !deduped.insert(projected_obligation.clone()) {
954+
return true;
955+
}
950956
// If any global obligations always apply, considering regions, then we don't
951957
// need to include them. The `is_global` check rules out inference variables,
952958
// so there's no need for the caller of `opt_normalize_projection_type`

0 commit comments

Comments
 (0)