diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-07-25 19:52:08 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-07-31 20:04:51 +1000 |
| commit | 75a1f47750fb34031f00cc2ee2b0d385426bec94 (patch) | |
| tree | 1377365731e8628019e346eaaf368a2e678236f8 /compiler/rustc_infer | |
| parent | 606dcc0d2e54d260f67d8a91f8adaf797a4ed38a (diff) | |
| download | rust-75a1f47750fb34031f00cc2ee2b0d385426bec94.tar.gz rust-75a1f47750fb34031f00cc2ee2b0d385426bec94.zip | |
Avoid vacuous `Constraint::{VarSubVar,RegSubReg}` constraints.
If the two regions are the same, we can skip it. This is a small perf win.
Diffstat (limited to 'compiler/rustc_infer')
| -rw-r--r-- | compiler/rustc_infer/src/infer/region_constraints/mod.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs index a1744b4df80..4747c203c80 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs @@ -471,7 +471,9 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { // all regions are subregions of static, so we can ignore this } (ReVar(sub_id), ReVar(sup_id)) => { - self.add_constraint(Constraint::VarSubVar(sub_id, sup_id), origin); + if sub_id != sup_id { + self.add_constraint(Constraint::VarSubVar(sub_id, sup_id), origin); + } } (_, ReVar(sup_id)) => { self.add_constraint(Constraint::RegSubVar(sub, sup_id), origin); @@ -480,7 +482,9 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { self.add_constraint(Constraint::VarSubReg(sub_id, sup), origin); } _ => { - self.add_constraint(Constraint::RegSubReg(sub, sup), origin); + if sub != sup { + self.add_constraint(Constraint::RegSubReg(sub, sup), origin); + } } } } |
