Add a special case for CStr/CString in the improper_ctypes lint · patricklam/verify-rust-std@4a3da12 (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 4a3da12
and
committed
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 jieyouxu@outlook.com
File tree
1 file changed
lines changed
1 file changed
lines changed
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -91,6 +91,7 @@ use crate::{fmt, intrinsics, ops, slice, str}; | ||
91 | 91 | /// [str]: prim@str "str" |
92 | 92 | #[derive(PartialEq, Eq, Hash)] |
93 | 93 | #[stable(feature = "core_c_str", since = "1.64.0")] |
94 | +#[rustc_diagnostic_item = "cstr_type"] | |
94 | 95 | #[rustc_has_incoherent_inherent_impls] |
95 | 96 | #[lang = "CStr"] |
96 | 97 | // `fn from` in `impl From<&CStr> for Box` current implementation relies |