-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminate uses of C types in std #7313
Comments
Hi @brson, just to clarify the scope of this change... Is this only to change the use of What about in the external declarations of libc functions - which style should be used, as per an example in
IOW if we can be certain that the usage of a c_int is consistently defined on each supported arch/os, should i32 be substituted globally? |
The general guideline I suggest is that |
Thanks, @brson. I performed a little analysis of the
The type The The The After having a stab at changing things piecemeal and then discovering inconsistencies lurking in every corner (eg. strings sometimes being So, how does that sound as a plan of attack? |
@gavinb Sounds good. |
Is our |
@bstrie: yeah, they're both just uninhabited enums, although neither compiles to the LLVM type that's expected for |
…richton I've started working on a patch for #7313 . So far I tried to replace C types in `src/libstd/unstable/*` and related files. So far, I have two questions. Is there a convention for passing pointers around in `std` as Rust types? Sometimes pointers are passed around as `*c_char` (which seems to be an `*i8`), `*c_void` or `*u8`, which leads to a lot of casts. E.g: [`exchange_malloc`](https://github.com/fhahn/rust/compare/issue-7313-replace-c-types?expand=1#diff-39f44b8c3f4496abab854b3425ac1617R60) used to return a `*c_char` but the function in turn only calls `malloc_raw` which returns a `*c_void`. Is there a specific reason for this? The second question is about `CString` and related functions like `with_c_str`. At the moment these functions use `*c_char*`. Should I replace it with `*u8` or keep it, because it's an wrapper around classical C strings?
Rustup Empty rustup. No changes to Clippy in the Rust repo for the last 2 weeks 😮 changelog: none
There is a lot of runtime code in std that, for various reasons, uses C types instead of Rust types. Let's push all those C types down to the FFI layer and stop using them for other purposes.
The text was updated successfully, but these errors were encountered: