Skip to content

Commit

Permalink
[WIP COMMIT, EXPECT OVERWRITING] lint: change help for pointers to dy…
Browse files Browse the repository at this point in the history
…n types in FFI
  • Loading branch information
niacdoial committed Oct 13, 2024
1 parent 2aa26d8 commit 1748f15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ lint_improper_ctypes_opaque = opaque types have no C equivalent
lint_improper_ctypes_pat_help = consider using the base type instead
lint_improper_ctypes_pat_reason = pattern types have no C equivalent
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 ...`)
lint_improper_ctypes_ptr_dyn_reason = pointers to trait objects have no C equivalent
lint_improper_ctypes_slice_help = consider using a raw pointer instead
lint_improper_ctypes_slice_reason = slices have no C equivalent
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,12 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
help: Some(fluent::lint_improper_ctypes_slice_help),
},

ty::RawPtr(ty, _) if matches!(ty.kind(), ty::Dynamic(..)) => FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_ptr_dyn_reason,
help: Some(fluent::lint_improper_ctypes_ptr_dyn_help),
},

ty::Dynamic(..) => {
FfiUnsafe { ty, reason: fluent::lint_improper_ctypes_dyn, help: None }
}
Expand Down

0 comments on commit 1748f15

Please sign in to comment.