From 8b464d96af8d2f3773efb352f66777add61a3a1f Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 28 Nov 2024 19:35:36 +0100 Subject: [PATCH] Remove reference to static mut This is what UnsafeCell is for: Providing interior mutability. The docs at https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html give an example just like this - `&mut *ptr.get()` Without, rustc may complain - https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html --- src/reader.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index c787dd51e..4f4dc59b2 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -212,10 +212,10 @@ fn reader_data_stack() -> &'static mut Vec>> { // Safety: only used on main thread. unsafe impl Sync for ReaderDataStack {} - static mut READER_DATA_STACK: ReaderDataStack = ReaderDataStack(UnsafeCell::new(vec![])); + static READER_DATA_STACK: ReaderDataStack = ReaderDataStack(UnsafeCell::new(vec![])); assert_is_main_thread(); - unsafe { READER_DATA_STACK.0.get_mut() } + unsafe { &mut *READER_DATA_STACK.0.get() } } /// Access the top level reader data.