From f682b0b509cc78fa9c38ac81076bc16db10eaf8a Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Wed, 28 Feb 2024 08:21:34 +0300 Subject: [PATCH 1/2] use core::ptr::from_ref --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 5 ++--- README.md | 4 ++-- src/generate/peripheral/accessor.rs | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e63e963a..d6dec204 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: "" } diff --git a/CHANGELOG.md b/CHANGELOG.md index bffc3bce..6cfe7b61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/README.md b/README.md index f1f02e9e..d0bf6fb5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/generate/peripheral/accessor.rs b/src/generate/peripheral/accessor.rs index d30576c0..11897be0 100644 --- a/src/generate/peripheral/accessor.rs +++ b/src/generate/peripheral/accessor.rs @@ -55,7 +55,7 @@ impl ToTokens for AccessType { #[doc = #doc] #[inline(always)] pub const fn #name(&self) -> &#ty { - unsafe { &*(self as *const Self).cast::().add(#offset).cast() } + unsafe { &*core::ptr::from_ref(self).cast::().add(#offset).cast() } } } } @@ -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::().add(#offset).add(#increment * n).cast() } }; + let cast = quote! { unsafe { &*core::ptr::from_ref(self).cast::().add(#offset).add(#increment * n).cast() } }; quote! { #[doc = #doc] #[inline(always)] From 228bfc4ae962c4fba6e430cd8f793ca8a5de7f18 Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Fri, 18 Oct 2024 19:46:51 +0300 Subject: [PATCH 2/2] rm repeated traits --- src/generate/generic_atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generate/generic_atomic.rs b/src/generate/generic_atomic.rs index f0c436f6..54c491c3 100644 --- a/src/generate/generic_atomic.rs +++ b/src/generate/generic_atomic.rs @@ -39,7 +39,7 @@ mod atomic { impl Reg where - REG::Ux: AtomicOperations + Default + core::ops::Not, + 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.