mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-19 05:13:44 +08:00
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
This commit is contained in:
parent
281df5daad
commit
8b464d96af
|
@ -212,10 +212,10 @@ fn reader_data_stack() -> &'static mut Vec<Pin<Box<ReaderData>>> {
|
||||||
// Safety: only used on main thread.
|
// Safety: only used on main thread.
|
||||||
unsafe impl Sync for ReaderDataStack {}
|
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();
|
assert_is_main_thread();
|
||||||
unsafe { READER_DATA_STACK.0.get_mut() }
|
unsafe { &mut *READER_DATA_STACK.0.get() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Access the top level reader data.
|
/// Access the top level reader data.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user