Rollup merge of #128735 - jieyouxu:pr-120176-revive, r=cjgillot
Add a special case for `CStr`/`CString` in the `improper_ctypes` lint Revives #120176. Just needed to bless a test and fix an argument, but seemed reasonable to me otherwise. Instead of saying to "consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct", we now tell users to "Use `*const ffi::c_char` instead, and pass the value from `CStr::as_ptr()`" when the type involved is a `CStr` or a `CString`. The suggestion is not made for `&mut CString` or `*mut CString`. r? ``````@cjgillot`````` (since you were the reviewer of the original PR #120176, but feel free to reroll)
This commit is contained in:
commit
198a68df1c
7 changed files with 172 additions and 21 deletions
|
@ -361,6 +361,11 @@ lint_improper_ctypes_box = box cannot be represented as a single pointer
|
|||
lint_improper_ctypes_char_help = consider using `u32` or `libc::wchar_t` instead
|
||||
|
||||
lint_improper_ctypes_char_reason = the `char` type has no C equivalent
|
||||
|
||||
lint_improper_ctypes_cstr_help =
|
||||
consider passing a `*const std::ffi::c_char` instead, and use `CStr::as_ptr()`
|
||||
lint_improper_ctypes_cstr_reason = `CStr`/`CString` do not have a guaranteed layout
|
||||
|
||||
lint_improper_ctypes_dyn = trait objects have no C equivalent
|
||||
|
||||
lint_improper_ctypes_enum_repr_help =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue