Rollup merge of #85853 - marmeladema:improper-ctypes-definitions-boxed-dst, r=petrochenkov
Warn against boxed DST in `improper_ctypes_definitions` lint Fixes #85714
This commit is contained in:
commit
ec9e7d5df1
3 changed files with 66 additions and 24 deletions
|
@ -909,11 +909,18 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
match *ty.kind() {
|
||||
ty::Adt(def, _) if def.is_box() && matches!(self.mode, CItemKind::Definition) => {
|
||||
FfiSafe
|
||||
}
|
||||
|
||||
ty::Adt(def, substs) => {
|
||||
if def.is_box() && matches!(self.mode, CItemKind::Definition) {
|
||||
if ty.boxed_ty().is_sized(tcx.at(DUMMY_SP), self.cx.param_env) {
|
||||
return FfiSafe;
|
||||
} else {
|
||||
return FfiUnsafe {
|
||||
ty,
|
||||
reason: format!("box cannot be represented as a single pointer"),
|
||||
help: None,
|
||||
};
|
||||
}
|
||||
}
|
||||
if def.is_phantom_data() {
|
||||
return FfiPhantom(ty);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue