Skip to content

Commit fd16988

Browse files
committed
Auto merge of rust-lang#114648 - compiler-errors:perf-114604, r=lqd
Only resolve target type in `try_coerce` in new solver Only needed in new solver, seems to affect perf in old solver. cc rust-lang#114604/rust-lang#114594
2 parents 832db2f + 214d78d commit fd16988

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1007,15 +1007,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10071007
&self,
10081008
expr: &hir::Expr<'_>,
10091009
expr_ty: Ty<'tcx>,
1010-
target: Ty<'tcx>,
1010+
mut target: Ty<'tcx>,
10111011
allow_two_phase: AllowTwoPhase,
10121012
cause: Option<ObligationCause<'tcx>>,
10131013
) -> RelateResult<'tcx, Ty<'tcx>> {
10141014
let source = self.try_structurally_resolve_type(expr.span, expr_ty);
1015-
let target = self.try_structurally_resolve_type(
1016-
cause.as_ref().map_or(expr.span, |cause| cause.span),
1017-
target,
1018-
);
1015+
if self.next_trait_solver() {
1016+
target = self.try_structurally_resolve_type(
1017+
cause.as_ref().map_or(expr.span, |cause| cause.span),
1018+
target,
1019+
);
1020+
}
10191021
debug!("coercion::try({:?}: {:?} -> {:?})", expr, source, target);
10201022

10211023
let cause =

0 commit comments

Comments
 (0)