diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2021-10-30 14:14:28 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-01-05 17:08:34 -0500 |
| commit | 2e491ae8920b6a9018c88d31290948a490eab8a7 (patch) | |
| tree | a0ffc8ec5bafaa5b0e41492518328ad0ecbcfedd | |
| parent | d632ce11b4c38b0e49a8f323ce0609dae2f99caa (diff) | |
| download | rust-2e491ae8920b6a9018c88d31290948a490eab8a7.tar.gz rust-2e491ae8920b6a9018c88d31290948a490eab8a7.zip | |
Deduplicate projection sub-obligations
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/project.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index b8c66931cbe..dba17183e6b 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -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; @@ -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| { |
