Rollup merge of #101022 - compiler-errors:issue-101020, r=jackh726

Erase late bound regions before comparing types in `suggest_dereferences`

Fixes #101020
This commit is contained in:
Dylan DPC 2022-08-30 11:26:50 +05:30 committed by GitHub
commit 1ea84961e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 5 deletions

View file

@ -690,13 +690,17 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
real_trait_pred = parent_trait_pred;
}
// Skipping binder here, remapping below
let real_ty = real_trait_pred.self_ty().skip_binder();
if self.can_eq(obligation.param_env, real_ty, arg_ty).is_err() {
let real_ty = real_trait_pred.self_ty();
// We `erase_late_bound_regions` here because `make_subregion` does not handle
// `ReLateBound`, and we don't particularly care about the regions.
if self
.can_eq(obligation.param_env, self.tcx.erase_late_bound_regions(real_ty), arg_ty)
.is_err()
{
continue;
}
if let ty::Ref(region, base_ty, mutbl) = *real_ty.kind() {
if let ty::Ref(region, base_ty, mutbl) = *real_ty.skip_binder().kind() {
let mut autoderef = Autoderef::new(
self,
obligation.param_env,