Skip to content

Commit

Permalink
Merge pull request #820 from rust-embedded/core-ptr
Browse files Browse the repository at this point in the history
use core::ptr::from_ref
  • Loading branch information
burrbull authored Oct 18, 2024
2 parents 65fb8e0 + 228bfc4 commit f4a317e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- { rust: stable, vendor: Toshiba, options: all }
- { rust: stable, vendor: Toshiba, options: "" }
# Test MSRV
- { rust: 1.74.0, vendor: Nordic, options: "" }
- { rust: 1.76.0, vendor: Nordic, options: "" }
# Use nightly for architectures which don't support stable
- { rust: nightly, vendor: MSP430, options: "--atomics" }
- { rust: nightly, vendor: MSP430, options: "" }
Expand Down
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Bump MSRV of generated code to 1.76
- move `must_use` from methods to generic type

## [v0.33.5] - 2024-10-12
Expand Down Expand Up @@ -907,9 +908,7 @@ peripheral.register.write(|w| w.field().set());

- Initial version of the `svd2rust` tool

[Unreleased]: https://github.com/rust-embedded/svd2rust/compare/v0.33.5...HEAD
[v0.33.5]: https://github.com/rust-embedded/svd2rust/compare/v0.33.4...v0.33.5
[v0.33.4]: https://github.com/rust-embedded/svd2rust/compare/v0.33.3...v0.33.4
[Unreleased]: https://github.com/rust-embedded/svd2rust/compare/v0.33.3...HEAD
[v0.33.3]: https://github.com/rust-embedded/svd2rust/compare/v0.33.2...v0.33.3
[v0.33.2]: https://github.com/rust-embedded/svd2rust/compare/v0.33.1...v0.33.2
[v0.33.1]: https://github.com/rust-embedded/svd2rust/compare/v0.33.0...v0.33.1
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ This project is developed and maintained by the [Tools team][team].

## Minimum Supported Rust Version (MSRV)

The **generated code** is guaranteed to compile on stable Rust 1.65.0 and up.
The **generated code** is guaranteed to compile on stable Rust 1.76.0 and up.

If you encounter compilation errors on any stable version newer than 1.65.0, please open an issue.
If you encounter compilation errors on any stable version newer than 1.76.0, please open an issue.

# Testing Locally

Expand Down
2 changes: 1 addition & 1 deletion src/generate/generic_atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod atomic {

impl<REG: Readable + Writable> Reg<REG>
where
REG::Ux: AtomicOperations + Default + core::ops::Not<Output = REG::Ux>,
REG::Ux: AtomicOperations
{
/// Set high every bit in the register that was set in the write proxy. Leave other bits
/// untouched. The write is done in a single atomic instruction.
Expand Down
4 changes: 2 additions & 2 deletions src/generate/peripheral/accessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl ToTokens for AccessType {
#[doc = #doc]
#[inline(always)]
pub const fn #name(&self) -> &#ty {
unsafe { &*(self as *const Self).cast::<u8>().add(#offset).cast() }
unsafe { &*core::ptr::from_ref(self).cast::<u8>().add(#offset).cast() }
}
}
}
Expand Down Expand Up @@ -84,7 +84,7 @@ impl ToTokens for AccessType {
increment,
})) => {
let name_iter = Ident::new(&format!("{name}_iter"), Span::call_site());
let cast = quote! { unsafe { &*(self as *const Self).cast::<u8>().add(#offset).add(#increment * n).cast() } };
let cast = quote! { unsafe { &*core::ptr::from_ref(self).cast::<u8>().add(#offset).add(#increment * n).cast() } };
quote! {
#[doc = #doc]
#[inline(always)]
Expand Down

0 comments on commit f4a317e

Please sign in to comment.