Skip to content

Commit 1748f15

Browse files
committed
[WIP COMMIT, EXPECT OVERWRITING] lint: change help for pointers to dyn types in FFI
1 parent 2aa26d8 commit 1748f15

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

compiler/rustc_lint/messages.ftl

+5
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ lint_improper_ctypes_opaque = opaque types have no C equivalent
389389
lint_improper_ctypes_pat_help = consider using the base type instead
390390
391391
lint_improper_ctypes_pat_reason = pattern types have no C equivalent
392+
393+
lint_improper_ctypes_ptr_dyn_help = to pass an opaque pointer through a FFI boundary, consider replacing `*const dyn ...` by `*const & dyn ...` (or `*mut dyn ...` by `*const &mut dyn ...`)
394+
395+
lint_improper_ctypes_ptr_dyn_reason = pointers to trait objects have no C equivalent
396+
392397
lint_improper_ctypes_slice_help = consider using a raw pointer instead
393398
394399
lint_improper_ctypes_slice_reason = slices have no C equivalent

compiler/rustc_lint/src/types.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,12 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
10571057
help: Some(fluent::lint_improper_ctypes_slice_help),
10581058
},
10591059

1060+
ty::RawPtr(ty, _) if matches!(ty.kind(), ty::Dynamic(..)) => FfiUnsafe {
1061+
ty,
1062+
reason: fluent::lint_improper_ctypes_ptr_dyn_reason,
1063+
help: Some(fluent::lint_improper_ctypes_ptr_dyn_help),
1064+
},
1065+
10601066
ty::Dynamic(..) => {
10611067
FfiUnsafe { ty, reason: fluent::lint_improper_ctypes_dyn, help: None }
10621068
}

0 commit comments

Comments
 (0)