1
Fork 0

Don't ICE when computing ctype's repr_nullable_ptr for possibly-unsized ty

This commit is contained in:
Michael Goulet 2023-09-07 06:04:37 +00:00
parent f00c139998
commit 086cf34634
3 changed files with 30 additions and 1 deletions

View file

@ -923,7 +923,12 @@ pub(crate) fn repr_nullable_ptr<'tcx>(
}
// Return the nullable type this Option-like enum can be safely represented with.
let field_ty_abi = &tcx.layout_of(param_env.and(field_ty)).unwrap().abi;
let field_ty_layout = tcx.layout_of(param_env.and(field_ty));
if field_ty_layout.is_err() && !field_ty.has_non_region_param() {
bug!("should be able to compute the layout of non-polymorphic type");
}
let field_ty_abi = &field_ty_layout.ok()?.abi;
if let Abi::Scalar(field_ty_scalar) = field_ty_abi {
match field_ty_scalar.valid_range(&tcx) {
WrappingRange { start: 0, end }