Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errors
Optimize `mk_region` PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions. r? `@compiler-errors`
This commit is contained in:
commit
c5d1b3ea96
40 changed files with 254 additions and 186 deletions
|
@ -180,20 +180,20 @@ trait TypeOpInfo<'tcx> {
|
|||
return;
|
||||
};
|
||||
|
||||
let placeholder_region = tcx.mk_region(ty::RePlaceholder(ty::Placeholder {
|
||||
let placeholder_region = tcx.mk_re_placeholder(ty::Placeholder {
|
||||
name: placeholder.name,
|
||||
universe: adjusted_universe.into(),
|
||||
}));
|
||||
});
|
||||
|
||||
let error_region =
|
||||
if let RegionElement::PlaceholderRegion(error_placeholder) = error_element {
|
||||
let adjusted_universe =
|
||||
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
|
||||
adjusted_universe.map(|adjusted| {
|
||||
tcx.mk_region(ty::RePlaceholder(ty::Placeholder {
|
||||
tcx.mk_re_placeholder(ty::Placeholder {
|
||||
name: error_placeholder.name,
|
||||
universe: adjusted.into(),
|
||||
}))
|
||||
})
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
@ -390,7 +390,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
|
|||
error_region,
|
||||
®ion_constraints,
|
||||
|vid| ocx.infcx.region_var_origin(vid),
|
||||
|vid| ocx.infcx.universe_of_region(ocx.infcx.tcx.mk_region(ty::ReVar(vid))),
|
||||
|vid| ocx.infcx.universe_of_region(ocx.infcx.tcx.mk_re_var(vid)),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ fn try_extract_error_from_region_constraints<'tcx>(
|
|||
}
|
||||
// FIXME: Should this check the universe of the var?
|
||||
Constraint::VarSubReg(vid, sup) if sup == placeholder_region => {
|
||||
Some((infcx.tcx.mk_region(ty::ReVar(vid)), cause.clone()))
|
||||
Some((infcx.tcx.mk_re_var(vid), cause.clone()))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue