diff options
| author | bors <bors@rust-lang.org> | 2022-12-16 06:45:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-16 06:45:08 +0000 |
| commit | a803f313fdf8f6eb2d674d7dfb3694a2b437ee1e (patch) | |
| tree | 311ccf71f46b7d3f40eb3420e7a5f08bf67a0f80 /compiler/rustc_middle/src | |
| parent | 39b2a41b39b445bf7efab02f6eade16135d7df85 (diff) | |
| parent | 3eb5b62898a8e7f24679aa7a4a9ce4d769f4ba32 (diff) | |
| download | rust-a803f313fdf8f6eb2d674d7dfb3694a2b437ee1e.tar.gz rust-a803f313fdf8f6eb2d674d7dfb3694a2b437ee1e.zip | |
Auto merge of #105717 - compiler-errors:anonymize, r=jackh726
always use `anonymize_bound_vars` Unless this is perf-sensitive, it's probably best to always use one anonymize function that does the right thing for all bound vars. r? types
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/fold.rs | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index d431d008ddf..09fee0c3f7c 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -583,36 +583,6 @@ impl<'tcx> TyCtxt<'tcx> { self.replace_late_bound_regions(value, |_| self.lifetimes.re_erased).0 } - /// Rewrite any late-bound regions so that they are anonymous. Region numbers are - /// assigned starting at 0 and increasing monotonically in the order traversed - /// by the fold operation. - /// - /// The chief purpose of this function is to canonicalize regions so that two - /// `FnSig`s or `TraitRef`s which are equivalent up to region naming will become - /// structurally identical. For example, `for<'a, 'b> fn(&'a isize, &'b isize)` and - /// `for<'a, 'b> fn(&'b isize, &'a isize)` will become identical after anonymization. - pub fn anonymize_late_bound_regions<T>(self, sig: Binder<'tcx, T>) -> Binder<'tcx, T> - where - T: TypeFoldable<'tcx>, - { - let mut counter = 0; - let inner = self - .replace_late_bound_regions(sig, |_| { - let br = ty::BoundRegion { - var: ty::BoundVar::from_u32(counter), - kind: ty::BrAnon(counter, None), - }; - let r = self.mk_region(ty::ReLateBound(ty::INNERMOST, br)); - counter += 1; - r - }) - .0; - let bound_vars = self.mk_bound_variable_kinds( - (0..counter).map(|i| ty::BoundVariableKind::Region(ty::BrAnon(i, None))), - ); - Binder::bind_with_vars(inner, bound_vars) - } - /// Anonymize all bound variables in `value`, this is mostly used to improve caching. pub fn anonymize_bound_vars<T>(self, value: Binder<'tcx, T>) -> Binder<'tcx, T> where |
