Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Change `feature(doc_auto_cfg)` to `feature(doc_cfg)` to allow nightly docs to build.
- 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
10 changes: 8 additions & 2 deletions src/generate/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
});
}

Expand Down 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