1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-04 21:58:46 +02:00

Updates for Rust 1.82 (#2449)

Rust 1.82 adds `&raw` expressions, and marks some attributes as unsafe.
This commit is contained in:
Andrew Walbran
2024-11-01 07:39:56 +00:00
committed by GitHub
parent 2bba470415
commit f8882190f3
24 changed files with 100 additions and 72 deletions

View File

@ -10,7 +10,7 @@ Creating pointers is safe, but dereferencing them requires `unsafe`:
fn main() {
let mut s = String::from("careful!");
let r1 = &mut s as *mut String;
let r1 = &raw mut s;
let r2 = r1 as *const String;
// SAFETY: r1 and r2 were obtained from references and so are guaranteed to

View File

@ -51,11 +51,11 @@ mod ffi {
pub d_name: [c_char; 1024],
}
extern "C" {
pub fn opendir(s: *const c_char) -> *mut DIR;
unsafe extern "C" {
pub unsafe fn opendir(s: *const c_char) -> *mut DIR;
#[cfg(not(all(target_os = "macos", target_arch = "x86_64")))]
pub fn readdir(s: *mut DIR) -> *const dirent;
pub unsafe fn readdir(s: *mut DIR) -> *const dirent;
// See https://github.com/rust-lang/libc/issues/414 and the section on
// _DARWIN_FEATURE_64_BIT_INODE in the macOS man page for stat(2).
@ -64,9 +64,9 @@ mod ffi {
// to macOS (as opposed to iOS / wearOS / etc.) on Intel and PowerPC.
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
#[link_name = "readdir$INODE64"]
pub fn readdir(s: *mut DIR) -> *const dirent;
pub unsafe fn readdir(s: *mut DIR) -> *const dirent;
pub fn closedir(s: *mut DIR) -> c_int;
pub unsafe fn closedir(s: *mut DIR) -> c_int;
}
}