Skip to content

Commit

Permalink
Deduplicate projection sub-obligations
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Oct 30, 2021
1 parent 9f13083 commit 67da0ff
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::fx::FxHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::ErrorReported;
use rustc_hir::def_id::DefId;
Expand Down Expand Up @@ -944,6 +945,11 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
Normalized { value: projected_ty, obligations: projected_obligations }
};

let mut deduped: FxHashSet<_> = Default::default();
result
.obligations
.drain_filter(|sub_obligation| !deduped.insert(sub_obligation.clone()));

let mut canonical =
SelectionContext::with_query_mode(selcx.infcx(), TraitQueryMode::Canonical);
result.obligations.drain_filter(|projected_obligation| {
Expand Down

0 comments on commit 67da0ff

Please sign in to comment.