fix(spi): take register block pointer via ptr() instead of regs() - #6022
Merged
Conversation
JurajSadel
requested review from
MabezDev,
bjoernQ,
bugadani and
playfulFence
as code owners
August 2, 2026 10:03
RalfJung
reviewed
Aug 3, 2026
| #[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 } |
There was a problem hiding this comment.
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).
Contributor
There was a problem hiding this comment.
We are aware, but the underlying PAC does the same and until std2rust fixes is, we really don't have a good solution.
Closed
bugadani
approved these changes
Aug 3, 2026
bugadani
enabled auto-merge
August 3, 2026 08:46
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 3, 2026
bugadani
enabled auto-merge
August 3, 2026 09:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rust-lang/rust#160012 now makes const evaluation check the validity of a reference at the point it is created. A MMIO address is an integer with no provenance, so the reference is not dereferenceable and const evaluation now fails with:
closes #6020