Skip to content

Commit 4a3da12

Browse files
Add a special case for CStr/CString in the improper_ctypes lint
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`. Co-authored-by: Jieyou Xu <[email protected]>
1 parent 9cc3bc6 commit 4a3da12

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: core/src/ffi/c_str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ use crate::{fmt, intrinsics, ops, slice, str};
9191
/// [str]: prim@str "str"
9292
#[derive(PartialEq, Eq, Hash)]
9393
#[stable(feature = "core_c_str", since = "1.64.0")]
94+
#[rustc_diagnostic_item = "cstr_type"]
9495
#[rustc_has_incoherent_inherent_impls]
9596
#[lang = "CStr"]
9697
// `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies

0 commit comments

Comments
 (0)