From 6bb9d7db5a6cf8b937db81da35423924cecf1ffe Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Mon, 15 Jan 2024 10:13:45 +0100 Subject: [PATCH] Update toolchain to a working nightly Now that https://github.com/rust-lang/rust/issues/118609 is fixed. The previous nightly was broken and rolled-back in #338. --- crates/prelude/CHANGELOG.md | 1 + crates/prelude/src/allocator/wasm.rs | 3 +-- crates/prelude/src/callback.rs | 2 +- crates/runner-nordic/crates/header/src/lib.rs | 4 +++- crates/runner-nordic/src/allocator.rs | 6 ++++-- crates/runner-nordic/src/storage.rs | 5 +++-- crates/scheduler/CHANGELOG.md | 1 + crates/scheduler/src/event.rs | 2 +- rust-toolchain.toml | 2 +- 9 files changed, 16 insertions(+), 10 deletions(-) diff --git a/crates/prelude/CHANGELOG.md b/crates/prelude/CHANGELOG.md index 0096d0f7e..ebb31fd4f 100644 --- a/crates/prelude/CHANGELOG.md +++ b/crates/prelude/CHANGELOG.md @@ -28,6 +28,7 @@ ### Patch +- Fix lints of nightly-2024-01-14 - Use `ENUM::to_result()` to convert errors - Only depend on `portable-atomic` through `wasefire-sync` - Use `wasefire-sync::executed!()` to ensure the allocator is initialized at diff --git a/crates/prelude/src/allocator/wasm.rs b/crates/prelude/src/allocator/wasm.rs index 61111ad09..0222a4ce0 100644 --- a/crates/prelude/src/allocator/wasm.rs +++ b/crates/prelude/src/allocator/wasm.rs @@ -30,8 +30,7 @@ extern "C" fn init() { struct Pool(MaybeUninit<[u8; SIZE]>); static mut POOL: Pool = Pool(MaybeUninit::uninit()); // SAFETY: This function is called at most once and POOL is only accessed here. - let pool = unsafe { &mut POOL }; - let pool_ptr = NonNull::new(pool.0.as_mut_ptr()).unwrap(); + let pool_ptr = NonNull::new(unsafe { POOL.0.as_mut_ptr() }).unwrap(); let mut allocator = ALLOCATOR.0.lock(); // SAFETY: POOL is static and won't be used again. let size = unsafe { allocator.insert_free_block_ptr(pool_ptr) }; diff --git a/crates/prelude/src/callback.rs b/crates/prelude/src/callback.rs index 403b49500..80926c143 100644 --- a/crates/prelude/src/callback.rs +++ b/crates/prelude/src/callback.rs @@ -20,7 +20,7 @@ macro_rules! define { (#[$m:meta] $n:ident $(, $x:ident)*) => { #[$m] #[no_mangle] extern "C" fn $n ( - ptr: extern "C" fn(*const u8 $(, usize ${ignore(x)})*), + ptr: extern "C" fn(*const u8 $(, usize ${ignore($x)})*), this: *const u8 $(, $x: usize)* ) { ptr(this $(, $x)*); diff --git a/crates/runner-nordic/crates/header/src/lib.rs b/crates/runner-nordic/crates/header/src/lib.rs index 3d6638f28..2878f145d 100644 --- a/crates/runner-nordic/crates/header/src/lib.rs +++ b/crates/runner-nordic/crates/header/src/lib.rs @@ -14,6 +14,8 @@ #![no_std] +use core::ptr::addr_of; + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct Header(u32); @@ -63,7 +65,7 @@ impl Side { extern "C" { static mut __header_origin: u32; } - Self::new(unsafe { &__header_origin as *const u32 } as u32) + Self::new(unsafe { addr_of!(__header_origin) } as u32) } fn new(addr: u32) -> Option { diff --git a/crates/runner-nordic/src/allocator.rs b/crates/runner-nordic/src/allocator.rs index 9f33589e1..90fa3df12 100644 --- a/crates/runner-nordic/src/allocator.rs +++ b/crates/runner-nordic/src/allocator.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use core::ptr::addr_of_mut; + use embedded_alloc::Heap; #[global_allocator] @@ -22,8 +24,8 @@ pub fn init() { static mut __sheap: u32; static mut __eheap: u32; } - let sheap = unsafe { &mut __sheap } as *mut u32 as usize; - let eheap = unsafe { &mut __eheap } as *mut u32 as usize; + let sheap = unsafe { addr_of_mut!(__sheap) as usize }; + let eheap = unsafe { addr_of_mut!(__eheap) as usize }; assert!(sheap < eheap); // Unsafe: Called only once before any allocation. unsafe { ALLOCATOR.init(sheap, eheap - sheap) } diff --git a/crates/runner-nordic/src/storage.rs b/crates/runner-nordic/src/storage.rs index 95f977566..4af499a20 100644 --- a/crates/runner-nordic/src/storage.rs +++ b/crates/runner-nordic/src/storage.rs @@ -14,6 +14,7 @@ use alloc::borrow::Cow; use alloc::vec; +use core::ptr::addr_of_mut; use core::slice; use embedded_storage::nor_flash::{ @@ -41,8 +42,8 @@ macro_rules! take_storage { static mut $start: u32; static mut $end: u32; } - let start = unsafe { &mut $start as *mut u32 as *mut u8 }; - let end = unsafe { &mut $end as *mut u32 as usize }; + let start = unsafe { addr_of_mut!($start) as *mut u8 }; + let end = unsafe { addr_of_mut!($end) as usize }; let length = end.checked_sub(start as usize).unwrap(); assert_eq!(length % PAGE_SIZE, 0); unsafe { slice::from_raw_parts_mut(start, length) } diff --git a/crates/scheduler/CHANGELOG.md b/crates/scheduler/CHANGELOG.md index 56732d1e0..0d66456e0 100644 --- a/crates/scheduler/CHANGELOG.md +++ b/crates/scheduler/CHANGELOG.md @@ -31,6 +31,7 @@ ### Patch +- Fix lints of nightly-2024-01-24 - Support zero-length slices in native - Fix board API feature gates for AES-128-CCM and AES-256-GCM - Remove unreachable `multivalue` feature gates diff --git a/crates/scheduler/src/event.rs b/crates/scheduler/src/event.rs index 7f17083a7..fff8ab31f 100644 --- a/crates/scheduler/src/event.rs +++ b/crates/scheduler/src/event.rs @@ -181,7 +181,7 @@ pub fn process(scheduler: &mut Scheduler, event: Event) { #[derive(Copy, Clone)] #[repr(transparent)] - struct U8(*const u8); + struct U8(#[allow(dead_code)] *const u8); unsafe impl Send for U8 {} let InstId = inst; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 1260a17ee..41f1a17cd 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2023-11-14" +channel = "nightly-2024-01-14" components = ["clippy", "llvm-tools", "rust-src", "rustfmt"] targets = [ "i686-unknown-linux-gnu",