Skip to content

Commit 9693862

Browse files
committed
Avoid vacuous Constraint::{VarSubVar,RegSubReg} constraints.
If the two regions are the same, we can skip it. This is a small perf win.
1 parent e05ab47 commit 9693862

File tree

1 file changed

+6
-2
lines changed
  • compiler/rustc_infer/src/infer/region_constraints

1 file changed

+6
-2
lines changed

compiler/rustc_infer/src/infer/region_constraints/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,9 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
471471
// all regions are subregions of static, so we can ignore this
472472
}
473473
(ReVar(sub_id), ReVar(sup_id)) => {
474-
self.add_constraint(Constraint::VarSubVar(sub_id, sup_id), origin);
474+
if sub_id != sup_id {
475+
self.add_constraint(Constraint::VarSubVar(sub_id, sup_id), origin);
476+
}
475477
}
476478
(_, ReVar(sup_id)) => {
477479
self.add_constraint(Constraint::RegSubVar(sub, sup_id), origin);
@@ -480,7 +482,9 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
480482
self.add_constraint(Constraint::VarSubReg(sub_id, sup), origin);
481483
}
482484
_ => {
483-
self.add_constraint(Constraint::RegSubReg(sub, sup), origin);
485+
if sub != sup {
486+
self.add_constraint(Constraint::RegSubReg(sub, sup), origin);
487+
}
484488
}
485489
}
486490
}

0 commit comments

Comments
 (0)