Skip to content
Merged
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
2 changes: 1 addition & 1 deletion esp-hal/src/peripherals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ macro_rules! create_peripheral {
#[doc = r"Return a reference to the register block"]
#[inline(always)]
#[instability::unstable]
pub const fn regs<'a>() -> &'a <pac::$base as core::ops::Deref>::Target {
pub fn regs<'a>() -> &'a <pac::$base as core::ops::Deref>::Target {
unsafe { &*Self::PTR }

@RalfJung RalfJung Aug 3, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, doing this on a pointer without provenance is Undefined Behavior both in const-eval and at runtime (except if Target is a zero-sized type). Similarly, writing to and reading from a pointer without provenance is UB (except if the read/write is volatile, or zero-sized).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are aware, but the underlying PAC does the same and until std2rust fixes is, we really don't have a good solution.

}

Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/spi/master/low_level/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ for_each_spi_master! {
}

static INFO: Info = Info {
register_block: crate::peripherals::$peri::regs(),
register_block: crate::peripherals::$peri::ptr(),
peripheral: crate::system::Peripheral::$sys,
async_handler: irq_handler,
sclk: OutputSignal::$sclk,
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/spi/slave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ for_each_spi_slave! {
#[inline(always)]
fn info(&self) -> &'static Info {
static INFO: Info = Info {
register_block: crate::peripherals::$peri::regs(),
register_block: crate::peripherals::$peri::ptr(),
peripheral: crate::system::Peripheral::$sys,
sclk: InputSignal::$sclk,
mosi: InputSignal::$mosi,
Expand Down
Loading