Skip to content

Commit 3eb5b62

Browse files
always use anonymize_bound_vars
1 parent ba64ba8 commit 3eb5b62

File tree

4 files changed

+6
-36
lines changed

4 files changed

+6
-36
lines changed

compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
489489
format!(
490490
"{}::",
491491
// Erase named lt, we want `<A as B<'_>::C`, not `<A as B<'a>::C`.
492-
self.tcx.anonymize_late_bound_regions(poly_trait_ref).skip_binder(),
492+
self.tcx.anonymize_bound_vars(poly_trait_ref).skip_binder(),
493493
),
494494
Applicability::MaybeIncorrect,
495495
);

compiler/rustc_hir_typeck/src/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
426426
// `deduce_expectations_from_expected_type` introduces
427427
// late-bound lifetimes defined elsewhere, which we now
428428
// anonymize away, so as not to confuse the user.
429-
let bound_sig = self.tcx.anonymize_late_bound_regions(bound_sig);
429+
let bound_sig = self.tcx.anonymize_bound_vars(bound_sig);
430430

431431
let closure_sigs = self.closure_sigs(expr_def_id, body, bound_sig);
432432

compiler/rustc_middle/src/ty/fold.rs

-30
Original file line numberDiff line numberDiff line change
@@ -583,36 +583,6 @@ impl<'tcx> TyCtxt<'tcx> {
583583
self.replace_late_bound_regions(value, |_| self.lifetimes.re_erased).0
584584
}
585585

586-
/// Rewrite any late-bound regions so that they are anonymous. Region numbers are
587-
/// assigned starting at 0 and increasing monotonically in the order traversed
588-
/// by the fold operation.
589-
///
590-
/// The chief purpose of this function is to canonicalize regions so that two
591-
/// `FnSig`s or `TraitRef`s which are equivalent up to region naming will become
592-
/// structurally identical. For example, `for<'a, 'b> fn(&'a isize, &'b isize)` and
593-
/// `for<'a, 'b> fn(&'b isize, &'a isize)` will become identical after anonymization.
594-
pub fn anonymize_late_bound_regions<T>(self, sig: Binder<'tcx, T>) -> Binder<'tcx, T>
595-
where
596-
T: TypeFoldable<'tcx>,
597-
{
598-
let mut counter = 0;
599-
let inner = self
600-
.replace_late_bound_regions(sig, |_| {
601-
let br = ty::BoundRegion {
602-
var: ty::BoundVar::from_u32(counter),
603-
kind: ty::BrAnon(counter, None),
604-
};
605-
let r = self.mk_region(ty::ReLateBound(ty::INNERMOST, br));
606-
counter += 1;
607-
r
608-
})
609-
.0;
610-
let bound_vars = self.mk_bound_variable_kinds(
611-
(0..counter).map(|i| ty::BoundVariableKind::Region(ty::BrAnon(i, None))),
612-
);
613-
Binder::bind_with_vars(inner, bound_vars)
614-
}
615-
616586
/// Anonymize all bound variables in `value`, this is mostly used to improve caching.
617587
pub fn anonymize_bound_vars<T>(self, value: Binder<'tcx, T>) -> Binder<'tcx, T>
618588
where

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1804,10 +1804,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
18041804
&& self.tcx.is_fn_trait(trait_pred.def_id())
18051805
{
18061806
let expected_self =
1807-
self.tcx.anonymize_late_bound_regions(pred.kind().rebind(trait_pred.self_ty()));
1807+
self.tcx.anonymize_bound_vars(pred.kind().rebind(trait_pred.self_ty()));
18081808
let expected_substs = self
18091809
.tcx
1810-
.anonymize_late_bound_regions(pred.kind().rebind(trait_pred.trait_ref.substs));
1810+
.anonymize_bound_vars(pred.kind().rebind(trait_pred.trait_ref.substs));
18111811

18121812
// Find another predicate whose self-type is equal to the expected self type,
18131813
// but whose substs don't match.
@@ -1820,12 +1820,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
18201820
// Make sure that the self type matches
18211821
// (i.e. constraining this closure)
18221822
&& expected_self
1823-
== self.tcx.anonymize_late_bound_regions(
1823+
== self.tcx.anonymize_bound_vars(
18241824
pred.kind().rebind(trait_pred.self_ty()),
18251825
)
18261826
// But the substs don't match (i.e. incompatible args)
18271827
&& expected_substs
1828-
!= self.tcx.anonymize_late_bound_regions(
1828+
!= self.tcx.anonymize_bound_vars(
18291829
pred.kind().rebind(trait_pred.trait_ref.substs),
18301830
) =>
18311831
{

0 commit comments

Comments
 (0)