From 87a35e698d3d19fb8f1e6bb2da92112c2a81a18c Mon Sep 17 00:00:00 2001 From: Zachary Dremann Date: Sat, 24 Feb 2024 17:37:59 -0500 Subject: [PATCH] Fix for rust 1.57 Some options aren't available for const yet in rust 1.57 --- src/rust/iced-x86/src/formatter/fast.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rust/iced-x86/src/formatter/fast.rs b/src/rust/iced-x86/src/formatter/fast.rs index 1cf48a19f..68d63f7c4 100644 --- a/src/rust/iced-x86/src/formatter/fast.rs +++ b/src/rust/iced-x86/src/formatter/fast.rs @@ -29,7 +29,8 @@ use crate::*; use alloc::boxed::Box; use alloc::vec::Vec; use core::marker::PhantomData; -use core::{mem, ptr, slice}; +use core::{mem, ptr}; +use std::slice; // full fmt'd str = "prefixes mnemonic op0, op1, op2, op3, op4" // prefixes = "es xacquire xrelease lock notrack repe repne " @@ -114,7 +115,7 @@ impl FastString { let required_size = 1 + SIZE; assert!(len_data.len() >= required_size); assert!(len_data[0] as usize <= SIZE); - let len_data = unsafe { &*(len_data.as_ptr() as *const FastStringRepr) }; + let len_data: &'static FastStringRepr = unsafe { mem::transmute(len_data.as_ptr()) }; Self::new(len_data) } @@ -131,7 +132,7 @@ impl FastString { } #[allow(dead_code)] - const fn get_slice(self) -> &'static [u8] { + fn get_slice(self) -> &'static [u8] { unsafe { slice::from_raw_parts(self.utf8_data(), self.len()) } } }