about summary refs log tree commit diff
path: root/compiler/rustc_traits/src/evaluate_obligation.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-04-14 19:54:27 +0000
committerbors <bors@rust-lang.org>2025-04-14 19:54:27 +0000
commit2da29dbe8fe23df1c7c4ab1d8740ca3c32b15526 (patch)
tree5dbc8160d1ee8024ac2a47ac8932312cd8489560 /compiler/rustc_traits/src/evaluate_obligation.rs
parent990039ec53d5bffe0ec77391e00f0e5be05924e8 (diff)
parent72d17bfebbf5463dac1a7eb71c513b151b523e1f (diff)
downloadrust-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_traits/src/evaluate_obligation.rs')
-rw-r--r--compiler/rustc_traits/src/evaluate_obligation.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_traits/src/evaluate_obligation.rs b/compiler/rustc_traits/src/evaluate_obligation.rs
index c9ad096c6e9..7771db855d7 100644
--- a/compiler/rustc_traits/src/evaluate_obligation.rs
+++ b/compiler/rustc_traits/src/evaluate_obligation.rs
@@ -5,6 +5,7 @@ use rustc_span::DUMMY_SP;
 use rustc_trait_selection::traits::query::CanonicalPredicateGoal;
 use rustc_trait_selection::traits::{
     EvaluationResult, Obligation, ObligationCause, OverflowError, SelectionContext, TraitQueryMode,
+    sizedness_fast_path,
 };
 use tracing::debug;
 
@@ -23,6 +24,10 @@ fn evaluate_obligation<'tcx>(
     debug!("evaluate_obligation: goal={:#?}", goal);
     let ParamEnvAnd { param_env, value: predicate } = goal;
 
+    if sizedness_fast_path(tcx, predicate) {
+        return Ok(EvaluationResult::EvaluatedToOk);
+    }
+
     let mut selcx = SelectionContext::with_query_mode(infcx, TraitQueryMode::Canonical);
     let obligation = Obligation::new(tcx, ObligationCause::dummy(), param_env, predicate);