1
Fork 0

Normalize before erasing late-bound regions in equal_up_to_regions

This commit is contained in:
Michael Goulet 2022-09-05 06:44:33 +00:00
parent a2cdcb3fea
commit 76b494a9dd

View file

@ -89,7 +89,8 @@ pub fn equal_up_to_regions<'tcx>(
// Normalize lifetimes away on both sides, then compare. // Normalize lifetimes away on both sides, then compare.
let normalize = |ty: Ty<'tcx>| { let normalize = |ty: Ty<'tcx>| {
let ty = ty.fold_with(&mut BottomUpFolder { tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty).fold_with(
&mut BottomUpFolder {
tcx, tcx,
// FIXME: We erase all late-bound lifetimes, but this is not fully correct. // FIXME: We erase all late-bound lifetimes, but this is not fully correct.
// If you have a type like `<for<'a> fn(&'a u32) as SomeTrait>::Assoc`, // If you have a type like `<for<'a> fn(&'a u32) as SomeTrait>::Assoc`,
@ -101,8 +102,8 @@ pub fn equal_up_to_regions<'tcx>(
// Leave consts and types unchanged. // Leave consts and types unchanged.
ct_op: |ct| ct, ct_op: |ct| ct,
ty_op: |ty| ty, ty_op: |ty| ty,
}); },
tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty) )
}; };
tcx.infer_ctxt().enter(|infcx| infcx.can_eq(param_env, normalize(src), normalize(dest)).is_ok()) tcx.infer_ctxt().enter(|infcx| infcx.can_eq(param_env, normalize(src), normalize(dest)).is_ok())
} }