Skip to content

Commit d6c668d

Browse files
bors[bot]couchand
andauthored
Merge #480
480: Add repr(transparent) to Reg struct r=therealprof a=couchand To guarantee that the register has the proper layout so that the [cast](https://github.com/rust-embedded/svd2rust/blob/971814070cd7be848d3c6524734192903de66866/src/generate/peripheral.rs#L63) of an integer to a `*const RegisterBlock` is sound. Note that this is necessary but not sufficient. The underlying `VolatileCell` also currently uses the default repr. There is an open [issue](japaric/vcell#5) and [PR](https://github.com/japaric/vcell/pull/6/files) to address the concern. Co-authored-by: Andrew Dona-Couch <[email protected]>
2 parents 3960899 + 96cfd8c commit d6c668d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/generate/generic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub trait Resettable: RegisterSpec {
3434
}
3535

3636
/// This structure provides volatile access to registers.
37+
#[repr(transparent)]
3738
pub struct Reg<REG: RegisterSpec> {
3839
register: vcell::VolatileCell<REG::Ux>,
3940
_marker: marker::PhantomData<REG>,

0 commit comments

Comments
 (0)