about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-08-08 14:25:03 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2023-08-08 15:38:20 +1000
commit8378487f2796571da288ac54a4696bd67c0933b8 (patch)
tree7ef791726d93e7d01870ade19fa1ca1aeb641b05 /compiler/rustc_trait_selection/src/traits
parent3c99b3dbd01389be9c6f320f179bd3fdf68913f5 (diff)
downloadrust-8378487f2796571da288ac54a4696bd67c0933b8.tar.gz
rust-8378487f2796571da288ac54a4696bd67c0933b8.zip
Only dedup obligation after new ones have been added.
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
-rw-r--r--compiler/rustc_trait_selection/src/traits/project.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index 519b5f80d26..06a1027e5df 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -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,
@@ -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());
             }