Skip to content

Commit

Permalink
Fix for rust 1.57
Browse files Browse the repository at this point in the history
Some options aren't available for const yet in rust 1.57
  • Loading branch information
Dr-Emann committed Feb 24, 2024
1 parent 9f55e1a commit 87a35e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rust/iced-x86/src/formatter/fast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<decorators1>, op1, op2, op3, op4<decorators2>"
// prefixes = "es xacquire xrelease lock notrack repe repne "
Expand Down Expand Up @@ -114,7 +115,7 @@ impl<const SIZE: usize> FastString<SIZE> {
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<SIZE>) };
let len_data: &'static FastStringRepr<SIZE> = unsafe { mem::transmute(len_data.as_ptr()) };
Self::new(len_data)
}

Expand All @@ -131,7 +132,7 @@ impl<const SIZE: usize> FastString<SIZE> {
}

#[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()) }
}
}
Expand Down

0 comments on commit 87a35e6

Please sign in to comment.