rust/compiler/rustc_codegen_llvm/src/debuginfo
Jubilee bd43f8e9fd
Rollup merge of #132260 - Zalathar:type-safe-cast, r=compiler-errors
cg_llvm: Use a type-safe helper to cast `&str` and `&[u8]` to `*const c_char`

In `rustc_codegen_llvm` there are many uses of `.as_ptr().cast()` to convert a string or byte-slice to `*const c_char`, which then gets passed through FFI.

This works, but is fragile, because there's nothing constraining the pointer cast to actually be from `u8` to `c_char`. If the original value changes to something else that has an `as_ptr` method, or the context changes to expect something other than `c_char`, the cast will silently do the wrong thing.

By making the cast more explicit via a helper method, we can be sure that it will either perform the intended cast, or fail at compile time.
2024-10-28 10:18:52 -07:00
..
metadata Use a type-safe helper to cast &str and &[u8] to *const c_char 2024-10-28 21:31:32 +11:00
create_scope_map.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
doc.md fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
gdb.rs Use safe wrappers get_linkage and set_linkage 2024-10-26 20:20:18 +11:00
metadata.rs Use a type-safe helper to cast &str and &[u8] to *const c_char 2024-10-28 21:31:32 +11:00
mod.rs Rollup merge of #132260 - Zalathar:type-safe-cast, r=compiler-errors 2024-10-28 10:18:52 -07:00
namespace.rs Use a type-safe helper to cast &str and &[u8] to *const c_char 2024-10-28 21:31:32 +11:00
utils.rs Use wide pointers consistenly across the compiler 2024-10-04 14:06:48 +02:00