Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Add unsafe block around `DEVICE_PERIPHERALS = true` in `Peripherals::steal()`
to support Rust 2024 edition.

## [v0.37.0] - 2025-08-14

- Fix new `mismatched-lifetime-syntaxes` lint warnings
Expand Down
8 changes: 7 additions & 1 deletion src/generate/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
quote!(#[no_mangle])
};

let set_device_peripherals_true = if config.edition >= RustEdition::E2024 {
quote!(unsafe { DEVICE_PERIPHERALS = true })
} else {
quote!(DEVICE_PERIPHERALS = true;)
};

out.extend(quote! {
// NOTE `no_mangle` is used here to prevent linking different minor versions of the device
// crate as that would let you `take` the device peripherals more than once (one per minor
Expand Down Expand Up @@ -339,7 +345,7 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
/// Each of the returned peripherals must be used at most once.
#[inline]
pub unsafe fn steal() -> Self {
DEVICE_PERIPHERALS = true;
#set_device_peripherals_true

Peripherals {
#exprs
Expand Down
Loading