@@ -1056,7 +1056,7 @@ fn get_nullable_type<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>>
1056
1056
1057
1057
/// Check if this enum can be safely exported based on the "nullable pointer optimization". If it
1058
1058
/// 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`,
1060
1060
/// `core::ptr::NonNull`, and `#[repr(transparent)]` newtypes.
1061
1061
/// FIXME: This duplicates code in codegen.
1062
1062
pub ( crate ) fn repr_nullable_ptr < ' tcx > (
@@ -1102,7 +1102,13 @@ pub(crate) fn repr_nullable_ptr<'tcx>(
1102
1102
return Some ( get_nullable_type ( tcx, field_ty) . unwrap ( ) ) ;
1103
1103
}
1104
1104
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 ( ) ) ;
1106
1112
}
1107
1113
WrappingRange { start, end } => {
1108
1114
unreachable ! ( "Unhandled start and end range: ({}, {})" , start, end)
0 commit comments