Skip to content

Commit 76b494a

Browse files
Normalize before erasing late-bound regions in equal_up_to_regions
1 parent a2cdcb3 commit 76b494a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

compiler/rustc_const_eval/src/transform/validate.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,21 @@ pub fn equal_up_to_regions<'tcx>(
8989

9090
// Normalize lifetimes away on both sides, then compare.
9191
let normalize = |ty: Ty<'tcx>| {
92-
let ty = ty.fold_with(&mut BottomUpFolder {
93-
tcx,
94-
// FIXME: We erase all late-bound lifetimes, but this is not fully correct.
95-
// If you have a type like `<for<'a> fn(&'a u32) as SomeTrait>::Assoc`,
96-
// this is not necessarily equivalent to `<fn(&'static u32) as SomeTrait>::Assoc`,
97-
// since one may have an `impl SomeTrait for fn(&32)` and
98-
// `impl SomeTrait for fn(&'static u32)` at the same time which
99-
// specify distinct values for Assoc. (See also #56105)
100-
lt_op: |_| tcx.lifetimes.re_erased,
101-
// Leave consts and types unchanged.
102-
ct_op: |ct| ct,
103-
ty_op: |ty| ty,
104-
});
105-
tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty)
92+
tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty).fold_with(
93+
&mut BottomUpFolder {
94+
tcx,
95+
// FIXME: We erase all late-bound lifetimes, but this is not fully correct.
96+
// If you have a type like `<for<'a> fn(&'a u32) as SomeTrait>::Assoc`,
97+
// this is not necessarily equivalent to `<fn(&'static u32) as SomeTrait>::Assoc`,
98+
// since one may have an `impl SomeTrait for fn(&32)` and
99+
// `impl SomeTrait for fn(&'static u32)` at the same time which
100+
// specify distinct values for Assoc. (See also #56105)
101+
lt_op: |_| tcx.lifetimes.re_erased,
102+
// Leave consts and types unchanged.
103+
ct_op: |ct| ct,
104+
ty_op: |ty| ty,
105+
},
106+
)
106107
};
107108
tcx.infer_ctxt().enter(|infcx| infcx.can_eq(param_env, normalize(src), normalize(dest)).is_ok())
108109
}

0 commit comments

Comments
 (0)