Skip to content

Commit 32cbc76

Browse files
committed
Auto merge of #84944 - lcnr:obligation-dedup, r=jackh726
remove obligation dedup from `impl_or_trait_obligations` Looking at the examples from #38528 they all seem to compile fine even without this and it seems like this might be unnecessary effort
2 parents 4566094 + b941485 commit 32cbc76

File tree

1 file changed

+0
-22
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+0
-22
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/select/mod.rs

-22
Original file line numberDiff line numberDiff line change
@@ -2374,28 +2374,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
23742374
});
23752375
}
23762376

2377-
// We are performing deduplication here to avoid exponential blowups
2378-
// (#38528) from happening, but the real cause of the duplication is
2379-
// unknown. What we know is that the deduplication avoids exponential
2380-
// amount of predicates being propagated when processing deeply nested
2381-
// types.
2382-
//
2383-
// This code is hot enough that it's worth avoiding the allocation
2384-
// required for the FxHashSet when possible. Special-casing lengths 0,
2385-
// 1 and 2 covers roughly 75-80% of the cases.
2386-
if obligations.len() <= 1 {
2387-
// No possibility of duplicates.
2388-
} else if obligations.len() == 2 {
2389-
// Only two elements. Drop the second if they are equal.
2390-
if obligations[0] == obligations[1] {
2391-
obligations.truncate(1);
2392-
}
2393-
} else {
2394-
// Three or more elements. Use a general deduplication process.
2395-
let mut seen = FxHashSet::default();
2396-
obligations.retain(|i| seen.insert(i.clone()));
2397-
}
2398-
23992377
obligations
24002378
}
24012379
}

0 commit comments

Comments
 (0)