Skip to content

Commit 59d5204

Browse files
authored
Use Edition 2024, MSRV 1.85 (#749)
1 parent 2b30d01 commit 59d5204

27 files changed

+141
-119
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
matrix:
2525
os: [ubuntu-24.04, windows-2022]
26-
toolchain: [nightly, beta, stable, "1.63"]
26+
toolchain: [nightly, beta, stable, "1.85"]
2727
# Only Test macOS on stable to reduce macOS CI jobs
2828
include:
2929
# aarch64-apple-darwin.
@@ -340,7 +340,7 @@ jobs:
340340
- uses: actions/checkout@v5
341341
- uses: dtolnay/rust-toolchain@master
342342
with:
343-
toolchain: 1.82
343+
toolchain: 1.85
344344
targets: wasm32-wasip1,wasm32-wasip2
345345
- name: Install Wasmtime
346346
run: |

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- `RawOsError` type alias [#739]
1111

12+
### Changed
13+
- Use Edition 2024 and MSRV 1.85 [#749]
14+
1215
[#739]: https://github.com/rust-random/getrandom/pull/739
16+
[#749]: https://github.com/rust-random/getrandom/pull/749
1317

1418
## [0.3.4] - 2025-10-14
1519

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "getrandom"
33
version = "0.3.4"
4-
edition = "2021"
5-
rust-version = "1.63" # Sync tests.yml and README.md.
4+
edition = "2024"
5+
rust-version = "1.85" # Sync tests.yml and README.md.
66
authors = ["The Rand Project Developers"]
77
license = "MIT OR Apache-2.0"
88
description = "A small cross-platform library for retrieving random data from system source"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Next, you need to define an `extern` function with the following signature:
159159
```rust
160160
use getrandom::Error;
161161

162-
#[no_mangle]
162+
#[unsafe(no_mangle)]
163163
unsafe extern "Rust" fn __getrandom_v03_custom(
164164
dest: *mut u8,
165165
len: usize,
@@ -189,7 +189,7 @@ fn my_entropy_source(buf: &mut [u8]) -> Result<(), getrandom::Error> {
189189
Ok(())
190190
}
191191

192-
#[no_mangle]
192+
#[unsafe(no_mangle)]
193193
unsafe extern "Rust" fn __getrandom_v03_custom(
194194
dest: *mut u8,
195195
len: usize,
@@ -302,7 +302,7 @@ RUSTFLAGS="-Zsanitizer=memory" cargo test -Zbuild-std --target=x86_64-unknown-li
302302

303303
## Minimum Supported Rust Version
304304

305-
This crate requires Rust 1.63 or later.
305+
This crate requires Rust 1.85 or later.
306306

307307
## License
308308

benches/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extern crate test;
33

44
use std::{
5-
mem::{size_of, MaybeUninit},
5+
mem::{MaybeUninit, size_of},
66
slice,
77
};
88

nopanic_check/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "nopanic_check"
33
description = "Helper crate for checking that getrandom implementation does not contain potential panics"
44
version = "0.1.0"
5-
edition = "2021"
5+
edition = "2024"
66
publish = false
77

88
[workspace]

nopanic_check/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
#[cfg(not(any(test, all(target_arch = "wasm32", target_env = "p2"))))]
55
#[panic_handler]
66
fn panic(_info: &core::panic::PanicInfo) -> ! {
7-
extern "C" {
7+
unsafe extern "C" {
88
fn panic_nonexistent() -> !;
99
}
1010
unsafe { panic_nonexistent() }
1111
}
1212

13-
#[no_mangle]
14-
pub extern "C" fn getrandom_wrapper(buf_ptr: *mut u8, buf_len: usize) -> u32 {
13+
#[unsafe(no_mangle)]
14+
pub unsafe extern "C" fn getrandom_wrapper(buf_ptr: *mut u8, buf_len: usize) -> u32 {
1515
let buf = unsafe { core::slice::from_raw_parts_mut(buf_ptr.cast(), buf_len) };
1616
let res = getrandom::fill_uninit(buf).map(|_| ());
1717
unsafe { core::mem::transmute(res) }
1818
}
1919

2020
#[cfg(getrandom_backend = "custom")]
21-
#[no_mangle]
21+
#[unsafe(no_mangle)]
2222
unsafe extern "Rust" fn __getrandom_v03_custom(
2323
dest: *mut u8,
2424
len: usize,
2525
) -> Result<(), getrandom::Error> {
2626
for i in 0..len {
27-
core::ptr::write(dest.add(i), i as u8);
27+
unsafe { core::ptr::write(dest.add(i), i as u8) };
2828
}
2929
Ok(())
3030
}

src/backends/custom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub use crate::util::{inner_u32, inner_u64};
66

77
#[inline]
88
pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
9-
extern "Rust" {
9+
unsafe extern "Rust" {
1010
fn __getrandom_v03_custom(dest: *mut u8, len: usize) -> Result<(), Error>;
1111
}
1212
unsafe { __getrandom_v03_custom(dest.as_mut_ptr().cast(), dest.len()) }

src/backends/efi_rng.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use crate::Error;
33
use core::{
44
mem::MaybeUninit,
5-
ptr::{self, null_mut, NonNull},
5+
ptr::{self, NonNull, null_mut},
66
sync::atomic::{AtomicPtr, Ordering::Relaxed},
77
};
88
use r_efi::{

src/backends/esp_idf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::{ffi::c_void, mem::MaybeUninit};
44

55
pub use crate::util::{inner_u32, inner_u64};
66

7-
extern "C" {
7+
unsafe extern "C" {
88
fn esp_fill_random(buf: *mut c_void, len: usize) -> u32;
99
}
1010

0 commit comments

Comments
 (0)