Skip to content

Commit 8a0b215

Browse files
Micro-optimization in consider_assumption
1 parent 0654374 commit 8a0b215

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler/rustc_trait_selection/src/solve/project_goals.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
296296
goal: Goal<'tcx, Self>,
297297
assumption: ty::Predicate<'tcx>,
298298
) -> QueryResult<'tcx> {
299-
if let Some(poly_projection_pred) = assumption.to_opt_poly_projection_pred() {
299+
if let Some(poly_projection_pred) = assumption.to_opt_poly_projection_pred()
300+
&& poly_projection_pred.projection_def_id() == goal.predicate.def_id()
301+
{
300302
ecx.infcx.probe(|_| {
301303
let assumption_projection_pred =
302304
ecx.infcx.instantiate_bound_vars_with_infer(poly_projection_pred);

compiler/rustc_trait_selection/src/solve/trait_goals.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
6565
goal: Goal<'tcx, Self>,
6666
assumption: ty::Predicate<'tcx>,
6767
) -> QueryResult<'tcx> {
68-
if let Some(poly_trait_pred) = assumption.to_opt_poly_trait_pred() {
68+
if let Some(poly_trait_pred) = assumption.to_opt_poly_trait_pred()
69+
&& poly_trait_pred.def_id() == goal.predicate.def_id()
70+
{
6971
// FIXME: Constness and polarity
7072
ecx.infcx.probe(|_| {
7173
let assumption_trait_pred =

0 commit comments

Comments
 (0)