diff options
| author | bors <bors@rust-lang.org> | 2023-08-18 06:29:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-18 06:29:38 +0000 |
| commit | a1e1dba9cc40a90409bccb8b19e359c4bdf573e5 (patch) | |
| tree | c40740cf5c37a1425e0d1bc4ad9943ee60a1f587 /compiler/rustc_trait_selection/src/traits/project.rs | |
| parent | fe3eae3f310b2f709aa5b39d76a94fc1ea843854 (diff) | |
| parent | 698f0e39e161cb0fdabb06ac34401ee87cfc5c9e (diff) | |
| download | rust-a1e1dba9cc40a90409bccb8b19e359c4bdf573e5.tar.gz rust-a1e1dba9cc40a90409bccb8b19e359c4bdf573e5.zip | |
Auto merge of #114611 - nnethercote:type-system-chess, r=compiler-errors
Speed up compilation of `type-system-chess` [`type-system-chess`](https://github.com/rust-lang/rustc-perf/pull/1680) is an unusual program that implements a compile-time chess position solver in the trait system(!) This PR is about making it compile faster. r? `@ghost`
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/project.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/project.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 3d800421b76..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,19 +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<_> = Default::default(); - result.obligations.retain(|projected_obligation| { - if !deduped.insert(projected_obligation.clone()) { - return false; - } - true - }); - if use_cache { infcx.inner.borrow_mut().projection_cache().insert_term(cache_key, result.clone()); } |
