Skip to content

Commit afaba22

Browse files
committed
Auto merge of #57674 - dotdash:erase_reg, r=<try>
Avoid erase_regions_ty queries if there are no regions to erase It's overall faster to perform this extra check than to perform the query, even if the result is already in the query cache.
2 parents ceb2512 + dae6e8f commit afaba22

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/librustc/ty/erase_regions.rs

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2121
pub fn erase_regions<T>(self, value: &T) -> T
2222
where T : TypeFoldable<'tcx>
2323
{
24+
// If there's nothing to erase avoid performing the query at all
25+
if !value.has_erasable_regions() {
26+
return value.clone();
27+
}
28+
2429
let value1 = value.fold_with(&mut RegionEraserVisitor { tcx: self });
2530
debug!("erase_regions({:?}) = {:?}", value, value1);
2631
value1

0 commit comments

Comments
 (0)