Rollup merge of #111880 - compiler-errors:pointer-like-param-env, r=jackh726
Don't ICE when computing PointerLike trait when region vars are in param-env Fixes #111877
This commit is contained in:
@@ -967,16 +967,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
) {
|
||||
// The regions of a type don't affect the size of the type
|
||||
let tcx = self.tcx();
|
||||
let self_ty =
|
||||
tcx.erase_regions(tcx.erase_late_bound_regions(obligation.predicate.self_ty()));
|
||||
|
||||
let self_ty = tcx.erase_late_bound_regions(obligation.predicate.self_ty());
|
||||
// We should erase regions from both the param-env and type, since both
|
||||
// may have infer regions. Specifically, after canonicalizing and instantiating,
|
||||
// early bound regions turn into region vars in both the new and old solver.
|
||||
let key = tcx.erase_regions(obligation.param_env.and(self_ty));
|
||||
// But if there are inference variables, we have to wait until it's resolved.
|
||||
if self_ty.has_non_region_infer() {
|
||||
if key.has_non_region_infer() {
|
||||
candidates.ambiguous = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if let Ok(layout) = tcx.layout_of(obligation.param_env.and(self_ty))
|
||||
if let Ok(layout) = tcx.layout_of(key)
|
||||
&& layout.layout.is_pointer_like(&tcx.data_layout)
|
||||
{
|
||||
candidates.vec.push(BuiltinCandidate { has_nested: false });
|
||||
|
||||
Reference in New Issue
Block a user