diff options
| author | bors <bors@rust-lang.org> | 2025-04-14 19:54:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-14 19:54:27 +0000 |
| commit | 2da29dbe8fe23df1c7c4ab1d8740ca3c32b15526 (patch) | |
| tree | 5dbc8160d1ee8024ac2a47ac8932312cd8489560 /compiler/rustc_trait_selection/src/traits/select/mod.rs | |
| parent | 990039ec53d5bffe0ec77391e00f0e5be05924e8 (diff) | |
| parent | 72d17bfebbf5463dac1a7eb71c513b151b523e1f (diff) | |
| download | rust-2da29dbe8fe23df1c7c4ab1d8740ca3c32b15526.tar.gz rust-2da29dbe8fe23df1c7c4ab1d8740ca3c32b15526.zip | |
Auto merge of #139577 - davidtwco:sizedness-go-vroom, r=oli-obk
re-use `Sized` fast-path There's an existing fast path for the `type_op_prove_predicate` predicate, checking for trivially `Sized` types, which can be re-used when evaluating obligations within queries. This should improve performance and was found to be beneficial in #137944. r? types
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/select/mod.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 56ff46e89e7..4d88a23250a 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -49,7 +49,9 @@ use crate::infer::{InferCtxt, InferOk, TypeFreshener}; use crate::solve::InferCtxtSelectExt as _; use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to}; use crate::traits::project::{ProjectAndUnifyResult, ProjectionCacheKeyExt}; -use crate::traits::{EvaluateConstErr, ProjectionCacheKey, Unimplemented, effects}; +use crate::traits::{ + EvaluateConstErr, ProjectionCacheKey, Unimplemented, effects, sizedness_fast_path, +}; mod _match; mod candidate_assembly; @@ -603,6 +605,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { None => self.check_recursion_limit(&obligation, &obligation)?, } + if sizedness_fast_path(self.tcx(), obligation.predicate) { + return Ok(EvaluatedToOk); + } + ensure_sufficient_stack(|| { let bound_predicate = obligation.predicate.kind(); match bound_predicate.skip_binder() { |
