diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-01-28 22:25:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-28 22:25:42 +0100 |
| commit | 76dbfdd595894dd113f22188477ff3ad46bb0a13 (patch) | |
| tree | 6573c29347a73b4c098c636061b57d72aef6e60e /src | |
| parent | f21f83d11710f13e285dab4bea7b9bebd1d47814 (diff) | |
| parent | da06898a7539ff66e636a5bf9d3b176b865a2737 (diff) | |
| download | rust-76dbfdd595894dd113f22188477ff3ad46bb0a13.tar.gz rust-76dbfdd595894dd113f22188477ff3ad46bb0a13.zip | |
Rollup merge of #57674 - dotdash:erase_reg, r=varkor
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/erase_regions.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc/ty/erase_regions.rs b/src/librustc/ty/erase_regions.rs index bbf71c62ca6..da7e021b2d5 100644 --- a/src/librustc/ty/erase_regions.rs +++ b/src/librustc/ty/erase_regions.rs @@ -1,4 +1,4 @@ -use ty::{self, Ty, TyCtxt}; +use ty::{self, Ty, TyCtxt, TypeFlags}; use ty::fold::{TypeFolder, TypeFoldable}; pub(super) fn provide(providers: &mut ty::query::Providers<'_>) { @@ -21,6 +21,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn erase_regions<T>(self, value: &T) -> T where T : TypeFoldable<'tcx> { + // If there's nothing to erase avoid performing the query at all + if !value.has_type_flags(TypeFlags::HAS_RE_LATE_BOUND | TypeFlags::HAS_FREE_REGIONS) { + return value.clone(); + } + let value1 = value.fold_with(&mut RegionEraserVisitor { tcx: self }); debug!("erase_regions({:?}) = {:?}", value, value1); value1 |
