Skip to content

Commit fefe61b

Browse files
committed
Auto merge of rust-lang#165672 - adwinwhite:typeop-perf, r=jdonszelmann
Restore the fast path of `QueryTypeOp` Fix the perf regression in rust-lang#165335 by moving the fast path back to its previous place. r? ghost
2 parents 495625e + 2ea7e03 commit fefe61b

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

  • compiler/rustc_trait_selection/src/traits/query/type_op

‎compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
9797
),
9898
NoSolution,
9999
> {
100-
if !infcx.disable_trait_solver_fast_paths()
101-
&& let Some(result) = QueryTypeOp::try_fast_path(infcx, &query_key)
102-
{
103-
debug_assert_eq!(result, infcx.deeply_resolve_ignoring_regions(result.clone()));
104-
return Ok((result, None, PredicateObligations::new(), Certainty::Proven));
105-
}
106-
107100
let mut canonical_var_values = OriginalQueryValues::default();
108101
let old_param_env = query_key.param_env;
109102
let canonical_self = infcx.canonicalize_query(query_key, &mut canonical_var_values);
@@ -135,6 +128,14 @@ where
135128
root_def_id: LocalDefId,
136129
span: Span,
137130
) -> Result<TypeOpOutput<'tcx, Self>, ErrorGuaranteed> {
131+
if !infcx.disable_trait_solver_fast_paths()
132+
&& let Some(value) = QueryTypeOp::try_fast_path(infcx, &self)
133+
{
134+
debug_assert_eq!(value, infcx.deeply_resolve_ignoring_regions(value.clone()));
135+
136+
return Ok(TypeOpOutput { output: value, constraints: None, error_info: None });
137+
}
138+
138139
let mut error_info = None;
139140
let mut region_constraints = QueryRegionConstraints::default();
140141

0 commit comments

Comments
 (0)