make unsized cast illegal
This commit is contained in:
parent
8759de0a49
commit
861448b426
3 changed files with 18 additions and 2 deletions
|
@ -725,6 +725,9 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
},
|
||||
// array-ptr-cast
|
||||
Ptr(mt) => {
|
||||
if !fcx.type_is_sized_modulo_regions(fcx.param_env, mt.ty) {
|
||||
return Err(CastError::IllegalCast);
|
||||
}
|
||||
self.check_ref_cast(fcx, TypeAndMut { mutbl, ty: inner_ty }, mt)
|
||||
}
|
||||
_ => Err(CastError::NonScalar),
|
||||
|
@ -735,7 +738,6 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
}
|
||||
_ => return Err(CastError::NonScalar),
|
||||
};
|
||||
|
||||
if let ty::Adt(adt_def, _) = *self.expr_ty.kind() {
|
||||
if adt_def.did().krate != LOCAL_CRATE {
|
||||
if adt_def.variants().iter().any(VariantDef::is_field_list_non_exhaustive) {
|
||||
|
@ -743,7 +745,6 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
match (t_from, t_cast) {
|
||||
// These types have invariants! can't cast into them.
|
||||
(_, Int(CEnum) | FnPtr) => Err(CastError::NonScalar),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue