]> git.nega.tv - josh/narcissus/commitdiff
misc: Update to Rust 2024 edition
authorJosh Simmons <josh@nega.tv>
Sat, 5 Apr 2025 21:26:07 +0000 (23:26 +0200)
committerJosh Simmons <josh@nega.tv>
Sat, 5 Apr 2025 21:26:07 +0000 (23:26 +0200)
42 files changed:
Cargo.lock
engine/narcissus-app/Cargo.toml
engine/narcissus-core/Cargo.toml
engine/narcissus-core/src/arena.rs
engine/narcissus-core/src/libc.rs
engine/narcissus-core/src/manual_arc.rs
engine/narcissus-core/src/ref_count.rs
engine/narcissus-core/src/virtual_mem.rs
engine/narcissus-core/src/virtual_vec/deque.rs
engine/narcissus-core/src/virtual_vec/vec.rs
engine/narcissus-font/Cargo.toml
engine/narcissus-gpu/Cargo.toml
engine/narcissus-gpu/src/backend/vulkan/allocator.rs
engine/narcissus-gpu/src/backend/vulkan/libc.rs
engine/narcissus-gpu/src/backend/vulkan/mod.rs
engine/narcissus-gpu/src/mapped_buffer.rs
engine/narcissus-image/Cargo.toml
engine/narcissus-maths/Cargo.toml
engine/narcissus-maths/src/lib.rs
engine/narcissus-maths/src/mat4.rs
engine/narcissus-maths/src/next_after_f32.rs [deleted file]
engine/narcissus-maths/tests/exhaustive_f32.rs
engine/narcissus-maths/tests/next_after_f32.rs [deleted file]
engine/narcissus-sqlite/Cargo.toml
engine/narcissus-sqlite/src/lib.rs
engine/narcissus-world/Cargo.toml
external/blake3-smol/Cargo.toml
external/blake3-smol/src/ffi.rs
external/renderdoc-sys/Cargo.toml
external/renderdoc-sys/src/lib.rs
external/sqlite-sys/Cargo.toml
external/sqlite-sys/src/lib.rs
external/stb_image-sys/Cargo.toml
external/stb_image-sys/src/lib.rs
external/stb_truetype-sys/Cargo.toml
external/stb_truetype-sys/src/lib.rs
external/vulkan-sys/Cargo.toml
external/vulkan-sys/examples/triangle.rs
external/vulkan-sys/src/lib.rs
title/shark-shaders/Cargo.toml
title/shark/Cargo.toml
title/shark/src/main.rs

index d2bf7d2ff860072ffdec83e81a19311faaada9d2..645e7956c0368cecaec9af2a77ef3f81933b8843 100644 (file)
@@ -1,6 +1,6 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
-version = 3
+version = 4
 
 [[package]]
 name = "blake3-smol"
@@ -19,9 +19,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
 [[package]]
 name = "constant_time_eq"
-version = "0.3.0"
+version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
+checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
 
 [[package]]
 name = "fast-float2"
@@ -31,9 +31,9 @@ checksum = "f8eb564c5c7423d25c886fb561d1e4ee69f72354d16918afa32c08811f6b6a55"
 
 [[package]]
 name = "getrandom"
-version = "0.2.10"
+version = "0.2.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
+checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
 dependencies = [
  "cfg-if",
  "libc",
@@ -42,9 +42,9 @@ dependencies = [
 
 [[package]]
 name = "gmp-mpfr-sys"
-version = "1.6.2"
+version = "1.6.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "362a6cc3cbe9f41aebe49c03b91aee8fa8fc69d32fb90533f6ed965a882e08e3"
+checksum = "c66d61197a68f6323b9afa616cf83d55d69191e1bf364d4eb7d35ae18defe776"
 dependencies = [
  "libc",
  "windows-sys",
@@ -52,15 +52,15 @@ dependencies = [
 
 [[package]]
 name = "libc"
-version = "0.2.161"
+version = "0.2.171"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
+checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
 
 [[package]]
 name = "memchr"
-version = "2.5.0"
+version = "2.7.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
 
 [[package]]
 name = "narcissus-app"
@@ -126,9 +126,30 @@ dependencies = [
 
 [[package]]
 name = "ppv-lite86"
-version = "0.2.17"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
+dependencies = [
+ "zerocopy",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.94"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
+dependencies = [
+ "proc-macro2",
+]
 
 [[package]]
 name = "rand"
@@ -172,9 +193,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
 
 [[package]]
 name = "sdl3-sys"
-version = "0.1.2+SDL3-preview-3.1.6"
+version = "0.4.7+SDL3-3.2.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "48501d90bf219bf3126b26155c04834af300088432f98c6985aa8ad3a2441baa"
+checksum = "f0d16a8a3623a4cb39a3661c81d9d4c5fd77ada27fc056e320b3651bf7bde1b1"
 
 [[package]]
 name = "shark"
@@ -212,6 +233,23 @@ version = "0.1.0"
 name = "stb_truetype-sys"
 version = "0.1.0"
 
+[[package]]
+name = "syn"
+version = "2.0.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
+
 [[package]]
 name = "vulkan-sys"
 version = "0.1.0"
@@ -224,18 +262,18 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
 
 [[package]]
 name = "windows-sys"
-version = "0.52.0"
+version = "0.59.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
 dependencies = [
  "windows-targets",
 ]
 
 [[package]]
 name = "windows-targets"
-version = "0.52.5"
+version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
 dependencies = [
  "windows_aarch64_gnullvm",
  "windows_aarch64_msvc",
@@ -249,48 +287,68 @@ dependencies = [
 
 [[package]]
 name = "windows_aarch64_gnullvm"
-version = "0.52.5"
+version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
 
 [[package]]
 name = "windows_aarch64_msvc"
-version = "0.52.5"
+version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
 
 [[package]]
 name = "windows_i686_gnu"
-version = "0.52.5"
+version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
 
 [[package]]
 name = "windows_i686_gnullvm"
-version = "0.52.5"
+version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
 
 [[package]]
 name = "windows_i686_msvc"
-version = "0.52.5"
+version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
 
 [[package]]
 name = "windows_x86_64_gnu"
-version = "0.52.5"
+version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
 
 [[package]]
 name = "windows_x86_64_gnullvm"
-version = "0.52.5"
+version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
 
 [[package]]
 name = "windows_x86_64_msvc"
-version = "0.52.5"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "zerocopy"
+version = "0.8.24"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
+checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.8.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
index 089191df998d7554a069fd18a05781367ca93034..8a6af0be0a2d04ac9ae7e147797c7276c19ba96c 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "narcissus-app"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
@@ -10,4 +10,4 @@ workspace = true
 
 [dependencies]
 narcissus-core = { path = "../narcissus-core" }
-sdl3-sys = "0.1.2"
\ No newline at end of file
+sdl3-sys = "0.4.7"
\ No newline at end of file
index 2713a3904a1a5d8d01a2b25525e6807e51ee1637..4a2d13ab737795299e95c6a1b5086878ea678874 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "narcissus-core"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 3520edc4af9cd3716027b93bfa2e9648d164373d..ef7779cc6ad92ef968ee7caa686a3e295ea38457 100644 (file)
@@ -14,13 +14,13 @@ impl std::fmt::Display for AllocError {
 impl std::error::Error for AllocError {}
 
 #[inline(always)]
-unsafe fn layout_from_size_align(size: usize, align: usize) -> Layout {
+unsafe fn layout_from_size_align(size: usize, align: usize) -> Layout { unsafe {
     if cfg!(debug_assertions) {
         Layout::from_size_align(size, align).unwrap()
     } else {
         Layout::from_size_align_unchecked(size, align)
     }
-}
+}}
 
 /// Wrapper around a pointer to a page footer.
 ///
@@ -66,9 +66,9 @@ impl PagePointer {
     }
 
     #[inline(always)]
-    unsafe fn as_ref<'a>(&self) -> &'a PageFooter {
+    unsafe fn as_ref<'a>(&self) -> &'a PageFooter { unsafe {
         &*self.as_ptr()
-    }
+    }}
 }
 
 #[repr(C)]
@@ -131,11 +131,11 @@ impl PageFooter {
     /// This must only be called on pages which have no outstanding references to
     /// allocations, as it allows subsequent operations to allocate the same
     /// addresses.
-    unsafe fn reset(&self) {
+    unsafe fn reset(&self) { unsafe {
         self.bump.set(NonNull::new_unchecked(
             self.base.as_ptr().add(self.size - PAGE_FOOTER_SIZE),
         ));
-    }
+    }}
 }
 
 /// Special type for the empty page because static requires Sync.
@@ -166,7 +166,7 @@ static EMPTY_PAGE: PageFooterSync = PageFooterSync(unsafe {
 ///
 /// `page` must refer to a valid page footer, or the empty page.
 #[cold]
-unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option<PagePointer> {
+unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option<PagePointer> { unsafe {
     let page_size = page.as_ref().size;
     // Double each allocated page to amortize allocation cost.
     let new_page_size = page_size * 2;
@@ -203,7 +203,7 @@ unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option<PagePoin
     );
 
     Some(PagePointer::new_heap(footer))
-}
+}}
 
 /// Deallocate the given page if it was allocated with the global allocator, and
 /// all the heap pages linked to it.
@@ -213,7 +213,7 @@ unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option<PagePoin
 /// Must not be called on any pages that hold live allocations, or pages which
 /// link to pages that hold live allocations.
 #[cold]
-unsafe fn deallocate_page_list(mut page: PagePointer) {
+unsafe fn deallocate_page_list(mut page: PagePointer) { unsafe {
     // Walk the linked list of pages and deallocate each one that originates from
     // the heap. The last page is either the empty page, or the hybrid page, both of
     // which are marked as stack page pointers.
@@ -223,7 +223,7 @@ unsafe fn deallocate_page_list(mut page: PagePointer) {
         let layout = layout_from_size_align(p.as_ref().size, std::mem::align_of::<PageFooter>());
         std::alloc::dealloc(p.as_ref().base.as_ptr(), layout);
     }
-}
+}}
 
 /// An allocation arena.
 ///
@@ -648,7 +648,7 @@ impl<const STACK_CAP: usize> HybridArena<STACK_CAP> {
     /// the hybrid page.
     #[inline(never)]
     #[cold]
-    unsafe fn setup_hybrid_page(&self) {
+    unsafe fn setup_hybrid_page(&self) { unsafe {
         let base = self.data.as_ptr() as *mut u8;
         let bump = base.add(STACK_CAP);
         self.footer.set(PageFooter {
@@ -661,7 +661,7 @@ impl<const STACK_CAP: usize> HybridArena<STACK_CAP> {
         debug_assert_eq!(bump as usize, self.footer.as_ptr() as usize);
         self.page_list_head
             .set(PagePointer::new_stack(self.footer.as_ptr()));
-    }
+    }}
 
     #[inline(never)]
     #[cold]
index 24ec0817a38a66a388c541c70de0dabe86f5a522..7ef2e07c4598dc3c06fd6df681e17b85ab56f169 100644 (file)
@@ -430,7 +430,7 @@ pub const SYS_process_madvise: c_long = 440;
 pub const SYS_epoll_pwait2: c_long = 441;
 pub const SYS_mount_setattr: c_long = 442;
 
-extern "C" {
+unsafe extern "C" {
     pub fn syscall(num: c_long, ...) -> c_long;
 
     pub fn mmap(
index f83e86aa4be1dc9d20dde19ff4ad0ca8836cf3dc..e712a872fd9793bca589c4048f8ace3ad79c647d 100644 (file)
@@ -80,7 +80,7 @@ impl<T> ManualArc<T> {
     pub fn release(mut self) -> Release<T> {
         #[cold]
         #[inline(never)]
-        unsafe fn release_slow<T>(ptr: NonNull<Inner<T>>) -> T {
+        unsafe fn release_slow<T>(ptr: NonNull<Inner<T>>) -> T { unsafe {
             // Ref-counting operations imply a full memory barrier on x86, but not in general. So
             // insert an acquire barrier on the slow path to ensure all modifications to inner are
             // visible before we call drop.
@@ -94,7 +94,7 @@ impl<T> ManualArc<T> {
             drop(inner);
 
             value
-        }
+        }}
 
         // SAFETY: `release` consumes `self` so it's impossible to call twice on the same instance,
         // release is also the only function able to invalidate the pointer. Hence the pointer is
index 1b8ba0b597e261f32509ebe890bf873433ad6d1c..af58e8ddeb9615fdaface0ffe8ac7b8bee6763b6 100644 (file)
@@ -136,11 +136,11 @@ impl<T: ?Sized> Rc<T> {
     /// dereferenced for the duration of the returned borrow. This is trivially the
     /// case if no such pointers exist, for example immediately after [`Arc::new`].
     #[inline]
-    pub unsafe fn get_mut_unchecked(&mut self) -> &mut T {
+    pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { unsafe {
         // We are careful to *not* create a reference covering the "count" fields, as
         // this would alias with concurrent access to the reference counts.
         &mut (*self.ptr.as_ptr()).value
-    }
+    }}
 
     #[inline]
     fn from_inner(ptr: NonNull<Inner<T>>) -> Self {
@@ -254,11 +254,11 @@ impl<T: ?Sized> Arc<T> {
     /// Any other [`Rc`] or [`Arc`] pointers to the same allocation must not be dereferenced for the duration of the
     /// returned borrow. This is trivially the case if no such pointers exist, for example immediately after
     /// [`Arc::new`].
-    pub unsafe fn get_mut_unchecked(&mut self) -> &mut T {
+    pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { unsafe {
         // We are careful to *not* create a reference covering the "count" fields, as
         // this would alias with concurrent access to the reference counts.
         &mut (*self.ptr.as_ptr()).value
-    }
+    }}
 
     fn from_inner(ptr: NonNull<Inner<T>>) -> Self {
         Self {
index 9b660015d17389d3a6fb185f310530a3740f5946..f028eba26352a8db6801d2f7fce73340ca969be7 100644 (file)
@@ -55,10 +55,10 @@ pub fn virtual_reserve(size: usize) -> Result<*mut std::ffi::c_void, MapError> {
 /// Panics if changing page permissions for the range fails.
 #[cold]
 #[inline(never)]
-pub unsafe fn virtual_commit(ptr: *mut std::ffi::c_void, size: usize) {
+pub unsafe fn virtual_commit(ptr: *mut std::ffi::c_void, size: usize) { unsafe {
     let result = libc::mprotect(ptr, size, libc::PROT_READ | libc::PROT_WRITE);
     assert!(result == 0);
-}
+}}
 
 /// Release a reserved or comitted virtual memory range.
 ///
@@ -68,11 +68,11 @@ pub unsafe fn virtual_commit(ptr: *mut std::ffi::c_void, size: usize) {
 /// - `size` must be within range of that reservation.
 #[cold]
 #[inline(never)]
-pub unsafe fn virtual_free(ptr: *mut std::ffi::c_void, size: usize) -> Result<(), MapError> {
+pub unsafe fn virtual_free(ptr: *mut std::ffi::c_void, size: usize) -> Result<(), MapError> { unsafe {
     let result = libc::munmap(ptr, size);
     if result != 0 {
         Err(MapError::MapFailed)
     } else {
         Ok(())
     }
-}
+}}
index 44cae4ab2aff7260e38ee796ad8e8b1e304441a5..7d0412a11c128f915f8875dc9ae00d4aa7585b0f 100644 (file)
@@ -71,27 +71,27 @@ impl<T> VirtualDeque<T> {
 
     /// Turn ptr into a slice
     #[inline]
-    unsafe fn buffer_as_slice(&self) -> &[T] {
+    unsafe fn buffer_as_slice(&self) -> &[T] { unsafe {
         slice::from_raw_parts(self.ptr(), self.cap())
-    }
+    }}
 
     /// Turn ptr into a mut slice
     #[inline]
-    unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] {
+    unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] { unsafe {
         slice::from_raw_parts_mut(self.ptr(), self.cap())
-    }
+    }}
 
     /// Moves an element out of the buffer
     #[inline]
-    unsafe fn buffer_read(&mut self, off: usize) -> T {
+    unsafe fn buffer_read(&mut self, off: usize) -> T { unsafe {
         ptr::read(self.ptr().add(off))
-    }
+    }}
 
     /// Writes an element into the buffer, moving it.
     #[inline]
-    unsafe fn buffer_write(&mut self, off: usize, value: T) {
+    unsafe fn buffer_write(&mut self, off: usize, value: T) { unsafe {
         ptr::write(self.ptr().add(off), value);
-    }
+    }}
 
     pub fn len(&self) -> usize {
         count(self.tail, self.head, self.cap())
@@ -124,7 +124,7 @@ impl<T> VirtualDeque<T> {
 
     /// Copies a contiguous block of memory len long from src to dst
     #[inline]
-    unsafe fn copy(&self, dst: usize, src: usize, len: usize) {
+    unsafe fn copy(&self, dst: usize, src: usize, len: usize) { unsafe {
         debug_assert!(
             dst + len <= self.cap(),
             "cpy dst={} src={} len={} cap={}",
@@ -142,11 +142,11 @@ impl<T> VirtualDeque<T> {
             self.cap()
         );
         ptr::copy(self.ptr().add(src), self.ptr().add(dst), len);
-    }
+    }}
 
     /// Copies a contiguous block of memory len long from src to dst
     #[inline]
-    unsafe fn copy_nonoverlapping(&self, dst: usize, src: usize, len: usize) {
+    unsafe fn copy_nonoverlapping(&self, dst: usize, src: usize, len: usize) { unsafe {
         debug_assert!(
             dst + len <= self.cap(),
             "cno dst={} src={} len={} cap={}",
@@ -164,12 +164,12 @@ impl<T> VirtualDeque<T> {
             self.cap()
         );
         ptr::copy_nonoverlapping(self.ptr().add(src), self.ptr().add(dst), len);
-    }
+    }}
 
     /// Frobs the head and tail sections around to handle the fact that we
     /// just reallocated. Unsafe because it trusts old_capacity.
     #[inline]
-    unsafe fn handle_capacity_increase(&mut self, old_capacity: usize) {
+    unsafe fn handle_capacity_increase(&mut self, old_capacity: usize) { unsafe {
         let new_capacity = self.cap();
 
         // Move the shortest contiguous section of the ring buffer
@@ -204,7 +204,7 @@ impl<T> VirtualDeque<T> {
         debug_assert!(self.head < self.cap());
         debug_assert!(self.tail < self.cap());
         debug_assert!(self.cap().count_ones() == 1);
-    }
+    }}
 
     pub fn reserve_exact(&mut self, additional: usize) {
         self.reserve(additional);
index 62f7aaec4c22b29b26f2f53cbbf26cceec6f4269..d4128f634bda4ec83781e7eecec432ff52a4ac44 100644 (file)
@@ -66,13 +66,13 @@ impl<T> VirtualVec<T> {
     }
 
     #[inline]
-    unsafe fn append_elements(&mut self, other: *const [T]) {
+    unsafe fn append_elements(&mut self, other: *const [T]) { unsafe {
         let count = (*other).len();
         self.reserve(count);
         let len = self.len();
         ptr::copy_nonoverlapping(other as *const T, self.as_mut_ptr().add(len), count);
         self.len += count;
-    }
+    }}
 
     pub fn clear(&mut self) {
         self.truncate(0)
index 0c868deb904b484a285917011e28ccfe1b4ee7d8..1784953da454a986bb4334be7e6ac88274a9bf3f 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "narcissus-font"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 5f9bdd79d4cb86373f0a9ea227dd868744f32326..8f1a973748bffa892873a4f63e2aaa4e730be6e9 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "narcissus-gpu"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 29a3a4cae6e1c560cf350218e7edcbf4ee1f2fcd..2460bfcf0cab1e79805bac4cd9c59ece592f1314 100644 (file)
@@ -302,7 +302,7 @@ impl VulkanDevice {
         Some((memory, mapped_ptr))
     }
 
-    unsafe fn free_super_block(&self, user_data: &VulkanSuperBlockInfo) {
+    unsafe fn free_super_block(&self, user_data: &VulkanSuperBlockInfo) { unsafe {
         self.device_fn
             .free_memory(self.device, user_data.memory, None);
 
@@ -312,7 +312,7 @@ impl VulkanDevice {
         let size = self.allocator.tlsf_super_block_size[memory_heap_index.widen()];
 
         self.allocator.stats.free(memory_heap_index, size);
-    }
+    }}
 
     pub fn allocate_memory(
         &self,
index f761ff50dbfbbd260041c4d381158ebcb93850e9..f595ad4aff2f25f34026b5344ffc2ed56d074f9e 100644 (file)
@@ -3,7 +3,7 @@ use std::os::raw::{c_char, c_int, c_void};
 pub const RTLD_NOW: c_int = 0x2;
 pub const RTLD_LOCAL: c_int = 0;
 
-extern "C" {
+unsafe extern "C" {
     pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
     pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
 }
index 7477cdca1f0ca051cb9be281f68a5bce29e94aa0..79e4261229e06566c79e7fb468ba14fa61b09d27 100644 (file)
@@ -2360,29 +2360,31 @@ impl Device for VulkanDevice {
         ptr: *const u8,
         len: usize,
     ) {
-        let len = u32::try_from(len).unwrap();
-
-        let cmd_encoder = self.cmd_encoder_mut(cmd_encoder);
-        let command_buffer = cmd_encoder.command_buffer;
-
-        let VulkanBoundPipeline {
-            pipeline_layout,
-            pipeline_bind_point: _,
-        } = cmd_encoder
-            .bound_pipeline
-            .as_ref()
-            .expect("cannot push constants without a pipeline bound")
-            .clone();
-
-        let stage_flags = vulkan_shader_stage_flags(stage_flags);
-        self.device_fn.cmd_push_constants(
-            command_buffer,
-            pipeline_layout,
-            stage_flags,
-            offset,
-            len,
-            ptr as *const std::ffi::c_void,
-        )
+        unsafe {
+            let len = u32::try_from(len).unwrap();
+
+            let cmd_encoder = self.cmd_encoder_mut(cmd_encoder);
+            let command_buffer = cmd_encoder.command_buffer;
+
+            let VulkanBoundPipeline {
+                pipeline_layout,
+                pipeline_bind_point: _,
+            } = cmd_encoder
+                .bound_pipeline
+                .as_ref()
+                .expect("cannot push constants without a pipeline bound")
+                .clone();
+
+            let stage_flags = vulkan_shader_stage_flags(stage_flags);
+            self.device_fn.cmd_push_constants(
+                command_buffer,
+                pipeline_layout,
+                stage_flags,
+                offset,
+                len,
+                ptr as *const std::ffi::c_void,
+            )
+        }
     }
 
     fn cmd_copy_buffer_to_image(
index 638c429da06dc1bc46a3f5f7884c256407f5dc4f..c3d47c9ca94c4234662f32a176f2e2fbc6071d55 100644 (file)
@@ -21,7 +21,7 @@ fn overflow() -> ! {
 /// This function will propagate undefined values from T, for example, padding
 /// bytes, so it's vital that no Rust reference to the written memory exists
 /// after writing a `T` which contains undefined values.
-unsafe fn copy_from_with_offset<T: ?Sized>(ptr: NonNull<u8>, len: usize, offset: usize, src: &T) {
+unsafe fn copy_from_with_offset<T: ?Sized>(ptr: NonNull<u8>, len: usize, offset: usize, src: &T) { unsafe {
     let size = std::mem::size_of_val(src);
 
     let Some(end) = offset.checked_add(size) else {
@@ -50,7 +50,7 @@ unsafe fn copy_from_with_offset<T: ?Sized>(ptr: NonNull<u8>, len: usize, offset:
     let src = src.add(offset);
     let dst = ptr.as_ptr();
     std::ptr::copy_nonoverlapping(src, dst, count)
-}
+}}
 
 /// Persistent mapped buffer.
 ///
index 26e4c8bd9f6a49a8ca4d9c750f95cc5fdfca06a8..3638cec86b9f6382473441662b672a3db54f50d1 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "narcissus-image"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 6573c45638c3c1883323a5caeddc0e6ebe6e22bf..6da9f7ed1b8daf9db05429f0e334455310fc87ad 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "narcissus-maths"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 69eb43812e50d8b933e5dee7deb7fb9c7d3ce56e..8ed98342196329e9f95fa5b178e5432724ae8cea 100644 (file)
@@ -4,7 +4,6 @@ mod exp;
 mod mat2;
 mod mat3;
 mod mat4;
-mod next_after_f32;
 mod perlin;
 mod point2;
 mod point3;
@@ -21,7 +20,6 @@ pub use exp::exp_f32;
 pub use mat2::Mat2;
 pub use mat3::Mat3;
 pub use mat4::Mat4;
-pub use next_after_f32::next_after_f32;
 pub use perlin::{perlin_noise3, perlin_noise3_wrap, perlin_noise3_wrap_seed};
 pub use point2::{point2, Point2};
 pub use point3::{point3, Point3};
index 745aa4b21a17630152aea0dda2f90ef606299c8e..7663ae8b86652b4b9edd6bff8d9826b270650aee 100644 (file)
@@ -264,12 +264,12 @@ impl Mat4 {
     // SAFETY: Requires SSE2.
     #[inline]
     #[target_feature(enable = "sse2")]
-    unsafe fn transpose_sse2(self) -> Mat4 {
+    unsafe fn transpose_sse2(self) -> Mat4 { unsafe {
         use std::arch::x86_64::_MM_TRANSPOSE4_PS;
         let [mut row0, mut row1, mut row2, mut row3] = self.as_m128_array();
         _MM_TRANSPOSE4_PS(&mut row0, &mut row1, &mut row2, &mut row3);
         Mat4::from_m128_array([row0, row1, row2, row3])
-    }
+    }}
 
     /// Returns the transpose of `self`.
     #[must_use]
@@ -337,7 +337,7 @@ impl Mat4 {
     #[allow(dead_code)]
     #[inline]
     #[target_feature(enable = "sse4.1")]
-    unsafe fn transform_vec4_sse41(&self, vec: Vec4) -> Vec4 {
+    unsafe fn transform_vec4_sse41(&self, vec: Vec4) -> Vec4 { unsafe {
         use std::arch::x86_64::{_mm_hadd_ps, _mm_mul_ps};
 
         let vec = vec.into();
@@ -349,7 +349,7 @@ impl Mat4 {
         );
 
         values.into()
-    }
+    }}
 
     /// Transforms the given [`Vec4`] `vec` by `self`.
     #[must_use]
@@ -421,14 +421,14 @@ unsafe fn mul_mat4_sse2(lhs: Mat4, rhs: Mat4) -> Mat4 {
 #[allow(dead_code)]
 #[inline]
 #[target_feature(enable = "avx2")]
-unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 {
+unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 { unsafe {
     use std::arch::x86_64::{
         __m128, __m256, _mm256_add_ps, _mm256_broadcast_ps, _mm256_loadu_ps, _mm256_mul_ps,
         _mm256_shuffle_ps, _mm256_storeu_ps, _mm256_zeroupper,
     };
 
     #[inline(always)]
-    unsafe fn two_linear_combine(a: __m256, m: &[__m128; 4]) -> __m256 {
+    unsafe fn two_linear_combine(a: __m256, m: &[__m128; 4]) -> __m256 { unsafe {
         let m0 = _mm256_broadcast_ps(&m[0]);
         let m1 = _mm256_broadcast_ps(&m[1]);
         let m2 = _mm256_broadcast_ps(&m[2]);
@@ -437,7 +437,7 @@ unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 {
         let r = _mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0x55), m1));
         let r = _mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0xaa), m2));
         _mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0xff), m3))
-    }
+    }}
 
     _mm256_zeroupper();
 
@@ -452,7 +452,7 @@ unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 {
     _mm256_storeu_ps(&mut result.0[0], x0);
     _mm256_storeu_ps(&mut result.0[8], x1);
     result
-}
+}}
 
 impl std::ops::Mul for Mat4 {
     type Output = Mat4;
diff --git a/engine/narcissus-maths/src/next_after_f32.rs b/engine/narcissus-maths/src/next_after_f32.rs
deleted file mode 100644 (file)
index 7402c00..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/// Calculate the next representable floating-point value following x in the
-/// direction of y.
-///
-/// If y is less than x, these functions will return the largest representable
-/// number less than x.
-///
-/// # Returns
-///
-/// On success, the function returns the next representable floating-point value
-/// after x in the
-/// direction of y.
-///  
-/// * If `x` equals `y`, then `y` is returned.
-/// * If `x` or `y` is a `NaN`, a `NaN` is returned.
-/// * If `x` is finite, and the result would overflow, a range error occurs, and
-///   the function returns `inf` with the correct mathematical sign.
-/// * If `x` is not equal to `y`, and the correct function result would be
-///   subnormal, zero, or underflow, a range error occurs, and either the
-///   correct value (if it can be represented), or `0.0`, is returned.
-/// * If x equals y, the function returns y.
-pub fn next_after_f32(x: f32, y: f32) -> f32 {
-    if x.is_nan() || y.is_nan() {
-        return x + y;
-    }
-
-    let ux = x.to_bits();
-    let uy = y.to_bits();
-
-    if ux == uy {
-        return y;
-    }
-
-    let ax = ux & 0x7fff_ffff;
-    let ay = uy & 0x7fff_ffff;
-
-    let ux = if ax == 0 {
-        if ay == 0 {
-            return y;
-        }
-        (uy & 0x8000_0000) | 1
-    } else if ax > ay || ((ux ^ uy) & 0x8000_0000) != 0 {
-        ux - 1
-    } else {
-        ux + 1
-    };
-
-    let e = ux & 0x7f800000;
-    // Overflow if ux is infinite, and x is finite.
-    if e == 0x7f800000 {
-        return x + x;
-    }
-    // Force underflow if ux is subnormal or zero.
-    if e == 0 {
-        let mut force_eval = 0.0;
-        let val = f32::from_bits(ux);
-        unsafe { std::ptr::write_volatile(&mut force_eval, x * x + val * val) };
-    }
-
-    f32::from_bits(ux)
-}
index d14fe52ab6421854bb3915699b6732fecbb5400e..46e96e8d7196d9648ad3111d78273363f2b7f1cf 100644 (file)
@@ -5,7 +5,7 @@ use std::{
     sync::atomic::{AtomicUsize, Ordering},
 };
 
-use narcissus_maths::{exp_f32, next_after_f32, sin_cos_pi_f32, tan_pi_f32};
+use narcissus_maths::{exp_f32, sin_cos_pi_f32, tan_pi_f32};
 
 use gmp_mpfr_sys::mpfr;
 
@@ -288,7 +288,13 @@ impl FloatCheck {
         }
 
         let err = our_value - ref_value;
-        let ulp = next_after_f32(ref_value, our_value) - ref_value;
+        let ulp = if ref_value > our_value {
+            ref_value.next_down()
+        } else if ref_value < our_value {
+            ref_value.next_up()
+        } else {
+            ref_value
+        } - ref_value;
         let err = (err / ulp).abs();
         if err >= u32::MAX as f32 {
             u32::MAX
diff --git a/engine/narcissus-maths/tests/next_after_f32.rs b/engine/narcissus-maths/tests/next_after_f32.rs
deleted file mode 100644 (file)
index 46b7603..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-use narcissus_maths::next_after_f32;
-
-mod libc {
-    use std::os::raw::c_float;
-
-    extern "C" {
-        pub fn nextafterf(x: c_float, y: c_float) -> c_float;
-    }
-}
-
-#[inline(always)]
-fn nextafterf(x: f32, y: f32) -> f32 {
-    unsafe { libc::nextafterf(x, y) }
-}
-
-fn test_towards(y: f32) {
-    for u in 0..=0xffff_ffff_u32 {
-        let x = f32::from_bits(u);
-        let ours = next_after_f32(x, y);
-        let reference = nextafterf(x, y);
-        assert!(
-            ours == reference || (ours.is_nan() && reference.is_nan()),
-            "x ({u:X}): ours ({ours}) != reference ({reference})"
-        );
-    }
-}
-
-#[test]
-#[ignore]
-fn next_after_f32_to_zero() {
-    test_towards(0.0)
-}
-
-#[test]
-#[ignore]
-fn next_after_f32_to_inf() {
-    test_towards(f32::INFINITY)
-}
-
-#[test]
-#[ignore]
-fn next_after_f32_to_neg_inf() {
-    test_towards(f32::NEG_INFINITY)
-}
index 7d0b9310f6e4ddc65c68cf247682f3fe943a4de9..5727f5ebe67de0a85b09cb52c22e09f0c44f3783 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "narcissus-sqlite"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 6a6efacc1caa56cca34238b9eb4a8b44d5977db6..cefd0f635f70fed396cc140e14affbd2367f4532 100644 (file)
@@ -14,7 +14,7 @@ use sqlite_sys as ffi;
 static SQLITE_GLOBAL_INIT: OnceLock<()> = OnceLock::new();
 
 #[cold]
-unsafe fn initialize() {
+unsafe fn initialize() { unsafe {
     let ret = ffi::sqlite3_initialize();
     if ret != sqlite_sys::SQLITE_OK {
         panic!("error initializing sqlite: {:?}", Error::new(ret));
@@ -37,7 +37,7 @@ unsafe fn initialize() {
             panic!("error installing sqlite logger: {:?}", Error::new(ret));
         }
     }
-}
+}}
 
 fn check_initalized() {
     SQLITE_GLOBAL_INIT.get_or_init(|| unsafe { initialize() });
index 54a5860725dc0f18230ae69fd22e8699f5f15d75..55093bd44a9773fc07a77784a52bc53e3ba1ad59 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "narcissus-world"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index df3899979c9b6a1f90a17b6ecfea450c13d7ad4b..7a8516b917ca9ae97a42b5a0a146e359e30b1de0 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "blake3-smol"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 156730fc53abf4114ec776e2574267c449eb2468..3fe4a9c5e6209698b18a1f8720f0a3fc3f9e3052 100644 (file)
@@ -1,6 +1,6 @@
 
 #[allow(dead_code)]
-extern "C" {
+unsafe extern "C" {
     pub fn blake3_compress_in_place_avx512(
         cv: *mut u32,
         block: *const u8,
index 2fa16c6d28cf361e985780a5d0f2574e884cf811..272071ee2eb92ae740f2fa41e81b5bb56e6050f8 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "renderdoc-sys"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index c4ebafc8ae406dd295ee22570f72fbe16db6a4be..331045cff8090a7518777783ccf42df53ed470f8 100644 (file)
@@ -318,7 +318,7 @@ mod libc {
     pub const RTLD_NOW: c_int = 0x2;
     pub const RTLD_NOLOAD: c_int = 0x4;
 
-    extern "C" {
+    unsafe extern "C" {
         pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
         pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
     }
index 6de3e391d466c90221196e15963550b6840d581b..f308604047ab2931e7bd6ff50bcd7df20c311925 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "sqlite-sys"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index aa3aefecf4947b366295469da252f5a535f85968..3e51dabf88afe230acbc3413855b80a2058d7729 100644 (file)
@@ -323,7 +323,7 @@ impl Destructor {
 pub const SQLITE_STATIC: Destructor = unsafe { std::mem::transmute(0usize) };
 pub const SQLITE_TRANSIENT: Destructor = unsafe { std::mem::transmute(!0usize) };
 
-extern "C" {
+unsafe extern "C" {
     pub fn sqlite3_libversion_number() -> c_int;
 
     pub fn sqlite3_initialize() -> c_int;
index a808a1a04302afe14813db46274dbfd71d4ac260..4f6a43f18aa2889673c040c9efe7b22b861df5ae 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "stb_image-sys"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 402bde3019fb68069608c8f78cc708d5c848bebf..4ce4845f2c4bfd47ce331efcec731d6efc510343 100644 (file)
@@ -21,7 +21,7 @@ pub struct stbi_io_callbacks {
     pub eof: extern "C" fn(user: *mut c_void) -> i32,
 }
 
-extern "C" {
+unsafe extern "C" {
     pub fn stbi_load_from_memory(
         buffer: *const c_uchar,
         len: c_int,
index ea077477e2e1ae516b2e60ab102c5f221b8b0d9b..3cdfe9899ed98dcfaeff1b8296597ebd4926d8ac 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "stb_truetype-sys"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 9a6a2dec0db9597c9fe4c2553494a5d1143b674e..51cf0ed82c2eda397c4beba8a7bdcbb9bfbe7104 100644 (file)
@@ -155,7 +155,7 @@ pub mod truetype {
     }
 }
 
-extern "C" {
+unsafe extern "C" {
     pub fn stbrp_pack_rects(
         context: *mut rectpack::Context,
         rects: *mut rectpack::Rect,
index d6f3f1a982cde49003c3941372d22729dee28a59..84d2e5580fa78194cb5913afb0376dc06b1eb305 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "vulkan-sys"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index be8460f922d29b7191459ba696ba50da08075f14..0925e11e5a3bcb9fa1692afcff2f8be6c9be0299 100644 (file)
@@ -8,7 +8,7 @@ mod libc {
     pub const RTLD_NOW: c_int = 0x2;
     pub const RTLD_LOCAL: c_int = 0;
 
-    extern "C" {
+    unsafe extern "C" {
         pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
         pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
     }
@@ -765,12 +765,14 @@ pub fn main() {
 
     #[inline]
     unsafe fn as_chunks_unchecked<T, const N: usize>(slice: &[T]) -> &[[T; N]] {
-        debug_assert_ne!(N, 0);
-        debug_assert_eq!(slice.len() % N, 0);
-        let new_len = slice.len() / N;
-        // SAFETY: We cast a slice of `new_len * N` elements into
-        // a slice of `new_len` many `N` elements chunks.
-        std::slice::from_raw_parts(slice.as_ptr().cast(), new_len)
+        unsafe {
+            debug_assert_ne!(N, 0);
+            debug_assert_eq!(slice.len() % N, 0);
+            let new_len = slice.len() / N;
+            // SAFETY: We cast a slice of `new_len * N` elements into
+            // a slice of `new_len` many `N` elements chunks.
+            std::slice::from_raw_parts(slice.as_ptr().cast(), new_len)
+        }
     }
 
     print!("\x1b[2J");
index 9be6402ab2c38dc124d92d6c5eec33c37af16272..42f8ee62f21f989be2d97d5b8829e5d660e5f852 100644 (file)
@@ -318,7 +318,7 @@ pub struct GlobalFunctions {
 }
 
 impl GlobalFunctions {
-    pub unsafe fn new(get_proc_addr: *mut c_void) -> Self {
+    pub unsafe fn new(get_proc_addr: *mut c_void) -> Self { unsafe {
         let get_instance_proc_addr = transmute::<_, FnGetInstanceProcAddr>(get_proc_addr);
         Self {
             get_instance_proc_addr,
@@ -339,7 +339,7 @@ impl GlobalFunctions {
                     .expect("failed to load vkCreateInstance"),
             ),
         }
-    }
+    }}
 
     #[inline]
     pub unsafe fn get_instance_proc_addr(
index a5702d57fd5018d672f2faf6a93373e805945b85..64c27989e0b297e953691b463da468627f28153a 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "shark-shaders"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index f4567650f810e5ec023e30bfa905cbd75f7cbb0c..b450cad041813dcbde3e7e0759f158ec23493626 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "shark"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
index 9d5e21520689ad0238055f87b657660ac5a269fd..8529445342d0e5e4cc09931b98bdee23e4882c4c 100644 (file)
@@ -196,7 +196,8 @@ impl<'a> UiState<'a> {
 pub fn main() {
     #[cfg(debug_assertions)]
     if std::env::var("RUST_BACKTRACE").is_err() {
-        std::env::set_var("RUST_BACKTRACE", "1")
+        // SAFETY: Called on the main thread before other threads are spawned.
+        unsafe { std::env::set_var("RUST_BACKTRACE", "1") }
     }
 
     let renderdoc = rdoc::RenderdocApi1_5_0::load();
@@ -208,7 +209,8 @@ pub fn main() {
         // Hot new SDL 3 environment variables!
         && std::env::var("SDL_VIDEO_DRIVER").is_err()
     {
-        std::env::set_var("SDL_VIDEODRIVER", "wayland")
+        // SAFETY: Called on the main thread before other threads are spawned.
+        unsafe { std::env::set_var("SDL_VIDEODRIVER", "wayland") }
     }
 
     let ui_scale_override =