rust-embedded / svd2rust

Generate Rust register maps (`struct`s) from SVD files
Apache License 2.0
698 stars 150 forks source link

Mark bits() as safe if a register has no reserved bits #666

Closed steelman closed 1 year ago

steelman commented 1 year ago

If a register has no fields but its write constraints allow full range of values to be written, then mark bits() as safe.

rust-highfive commented 1 year ago

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Emilgardis (or someone else) soon.

Please see the contribution instructions for more information.

steelman commented 1 year ago

@Rahix, you may be interested in this patch.

Emilgardis commented 1 year ago

wasn't this implemented before? ah my bad, was thinking of the specific writes, this is for the register

burrbull commented 1 year ago

You could reuse unsafety function. +changelog

steelman commented 1 year ago

@burrbull Can you explain?

burrbull commented 1 year ago

https://github.com/rust-embedded/svd2rust/blob/2d799693b4d3f20ad757010d008e565172f01d37/src/generate/register.rs#L972

https://github.com/rust-embedded/svd2rust/blob/2d799693b4d3f20ad757010d008e565172f01d37/src/generate/register.rs#L783

steelman commented 1 year ago

OK, I will.

steelman commented 1 year ago

I messed up. Moment.

burrbull commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build failed:

burrbull commented 1 year ago

format and rebase, please

burrbull commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build succeeded: