@@ -1056,7 +1056,7 @@ fn get_nullable_type<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>>
10561056
10571057/// Check if this enum can be safely exported based on the "nullable pointer optimization". If it
10581058/// can, return the type that `ty` can be safely converted to, otherwise return `None`.
1059- /// Currently restricted to function pointers, boxes, references, `core::num::NonZero* `,
1059+ /// Currently restricted to function pointers, boxes, references, `core::num::NonZero`,
10601060/// `core::ptr::NonNull`, and `#[repr(transparent)]` newtypes.
10611061/// FIXME: This duplicates code in codegen.
10621062pub ( crate ) fn repr_nullable_ptr < ' tcx > (
@@ -1102,7 +1102,13 @@ pub(crate) fn repr_nullable_ptr<'tcx>(
11021102 return Some ( get_nullable_type ( tcx, field_ty) . unwrap ( ) ) ;
11031103 }
11041104 WrappingRange { start : 1 , .. } => {
1105- return Some ( get_nullable_type ( tcx, field_ty) . unwrap ( ) ) ;
1105+ let nullable_type = get_nullable_type ( tcx, field_ty) ;
1106+
1107+ if nullable_type. is_none ( ) {
1108+ bug ! ( "cannot get nullable type for field_ty {field_ty:?}" ) ;
1109+ }
1110+
1111+ return Some ( nullable_type. unwrap ( ) ) ;
11061112 }
11071113 WrappingRange { start, end } => {
11081114 unreachable ! ( "Unhandled start and end range: ({}, {})" , start, end)
0 commit comments