@@ -901,15 +901,24 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
901
901
902
902
match * ty. kind ( ) {
903
903
ty:: Adt ( def, args) => {
904
- if let Some ( boxed ) = ty. boxed_ty ( )
904
+ if let Some ( inner_ty ) = ty. boxed_ty ( )
905
905
&& matches ! ( self . mode, CItemKind :: Definition )
906
906
{
907
- if boxed. is_sized ( tcx, self . cx . param_env ) {
907
+ if inner_ty. is_sized ( tcx, self . cx . param_env )
908
+ || matches ! ( inner_ty. kind( ) , ty:: Foreign ( ..) )
909
+ {
910
+ let _probe = self . check_type_for_ffi ( acc, inner_ty) ;
908
911
return FfiSafe ;
909
912
} else {
913
+ //let help = match inner_ty.kind() {
914
+ // ty::Dynamic(..) => Some(fluent::lint_improper_ctypes_unsized_help_dyn),
915
+ // ty::Closure(..) => Some(fluent::lint_improper_ctypes_unsized_help_closure),
916
+ // ty::Slice(..) => Some(fluent::lint_improper_ctypes_unsized_help_slice),
917
+ // _ => None,
918
+ //};
910
919
return FfiUnsafe {
911
920
ty,
912
- reason : fluent:: lint_improper_ctypes_box ,
921
+ reason : fluent:: lint_improper_ctypes_unsized_box ,
913
922
help : None ,
914
923
} ;
915
924
}
@@ -1057,6 +1066,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
1057
1066
help : Some ( fluent:: lint_improper_ctypes_slice_help) ,
1058
1067
} ,
1059
1068
1069
+
1060
1070
ty:: Dynamic ( ..) => {
1061
1071
FfiUnsafe { ty, reason : fluent:: lint_improper_ctypes_dyn, help : None }
1062
1072
}
@@ -1073,13 +1083,22 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
1073
1083
help : Some ( fluent:: lint_improper_ctypes_tuple_help) ,
1074
1084
} ,
1075
1085
1076
- ty:: RawPtr ( ty, _) | ty:: Ref ( _, ty, _)
1077
- if {
1078
- matches ! ( self . mode, CItemKind :: Definition )
1079
- && ty. is_sized ( self . cx . tcx , self . cx . param_env )
1080
- } =>
1086
+ ty:: RawPtr ( inner_ty, _) | ty:: Ref ( _, inner_ty, _)
1087
+ if matches ! ( self . mode, CItemKind :: Definition ) =>
1081
1088
{
1082
- FfiSafe
1089
+ if inner_ty. is_sized ( tcx, self . cx . param_env )
1090
+ || matches ! ( inner_ty. kind( ) , ty:: Foreign ( ..) )
1091
+ {
1092
+ let _probe = self . check_type_for_ffi ( acc, inner_ty) ;
1093
+ FfiSafe
1094
+ } else {
1095
+ let reason = match ty. kind ( ) {
1096
+ ty:: RawPtr ( ..) => fluent:: lint_improper_ctypes_unsized_ptr,
1097
+ ty:: Ref ( ..) => fluent:: lint_improper_ctypes_unsized_ref,
1098
+ _ => unreachable ! ( ) ,
1099
+ } ;
1100
+ FfiUnsafe { ty, reason, help : None }
1101
+ }
1083
1102
}
1084
1103
1085
1104
ty:: RawPtr ( ty, _)
0 commit comments