Skip to content

Commit 112ebc4

Browse files
authored
Rollup merge of rust-lang#128735 - jieyouxu:pr-120176-revive, r=cjgillot
Add a special case for `CStr`/`CString` in the `improper_ctypes` lint Revives rust-lang#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 rust-lang#120176, but feel free to reroll)
2 parents 0803686 + 4a3da12 commit 112ebc4

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)