Skip to content

Commit

Permalink
Rollup merge of rust-lang#128735 - jieyouxu:pr-120176-revive, r=cjgillot
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
tgross35 authored Aug 25, 2024
2 parents 0803686 + 4a3da12 commit 112ebc4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ use crate::{fmt, intrinsics, ops, slice, str};
/// [str]: prim@str "str"
#[derive(PartialEq, Eq, Hash)]
#[stable(feature = "core_c_str", since = "1.64.0")]
#[rustc_diagnostic_item = "cstr_type"]
#[rustc_has_incoherent_inherent_impls]
#[lang = "CStr"]
// `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies
Expand Down

0 comments on commit 112ebc4

Please sign in to comment.