diff --git a/cranelift/codegen/meta/src/gen_inst.rs b/cranelift/codegen/meta/src/gen_inst.rs index 7d8353dad3..ed28a83794 100644 --- a/cranelift/codegen/meta/src/gen_inst.rs +++ b/cranelift/codegen/meta/src/gen_inst.rs @@ -97,9 +97,14 @@ fn gen_instruction_data(registry: &FormatRegistry, fmt: &mut Formatter) { fn gen_arguments_method(registry: &FormatRegistry, fmt: &mut Formatter, is_mut: bool) { let (method, mut_, rslice, as_slice) = if is_mut { - ("arguments_mut", "mut ", "ref_slice_mut", "as_mut_slice") + ( + "arguments_mut", + "mut ", + "core::slice::from_mut", + "as_mut_slice", + ) } else { - ("arguments", "", "ref_slice", "as_slice") + ("arguments", "", "core::slice::from_ref", "as_slice") }; fmtln!( diff --git a/cranelift/codegen/src/ir/instructions.rs b/cranelift/codegen/src/ir/instructions.rs index 30e8d14689..b3c3d0d211 100644 --- a/cranelift/codegen/src/ir/instructions.rs +++ b/cranelift/codegen/src/ir/instructions.rs @@ -18,7 +18,6 @@ use crate::isa; use crate::bitset::BitSet; use crate::entity; -use crate::ref_slice::{ref_slice, ref_slice_mut}; /// Some instructions use an external list of argument values because there is not enough space in /// the 16-byte `InstructionData` struct. These value lists are stored in a memory pool in diff --git a/cranelift/codegen/src/lib.rs b/cranelift/codegen/src/lib.rs index 1e97dfd6e0..73f2114561 100644 --- a/cranelift/codegen/src/lib.rs +++ b/cranelift/codegen/src/lib.rs @@ -95,7 +95,6 @@ mod partition_slice; mod postopt; mod predicates; mod redundant_reload_remover; -mod ref_slice; mod regalloc; mod result; mod scoped_hash_map; diff --git a/cranelift/codegen/src/ref_slice.rs b/cranelift/codegen/src/ref_slice.rs deleted file mode 100644 index 2fad921cea..0000000000 --- a/cranelift/codegen/src/ref_slice.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! Functions for converting a reference into a singleton slice. -//! -//! See also the [`ref_slice` crate](https://crates.io/crates/ref_slice). -//! -//! We define the functions here to avoid external dependencies, and to ensure that they are -//! inlined in this crate. -//! -//! Despite their using an unsafe block, these functions are completely safe. - -use core::slice; - -pub fn ref_slice(s: &T) -> &[T] { - unsafe { slice::from_raw_parts(s, 1) } -} - -pub fn ref_slice_mut(s: &mut T) -> &mut [T] { - unsafe { slice::from_raw_parts_mut(s, 1) } -} diff --git a/cranelift/codegen/src/regalloc/virtregs.rs b/cranelift/codegen/src/regalloc/virtregs.rs index fc267c3f61..df2b480490 100644 --- a/cranelift/codegen/src/regalloc/virtregs.rs +++ b/cranelift/codegen/src/regalloc/virtregs.rs @@ -18,9 +18,9 @@ use crate::entity::{EntityList, ListPool}; use crate::entity::{Keys, PrimaryMap, SecondaryMap}; use crate::ir::{Function, Value}; use crate::packed_option::PackedOption; -use crate::ref_slice::ref_slice; use core::cmp::Ordering; use core::fmt; +use core::slice; use smallvec::SmallVec; use std::vec::Vec; @@ -104,7 +104,7 @@ impl VirtRegs { 'a: 'b, { self.get(*value) - .map_or_else(|| ref_slice(value), |vr| self.values(vr)) + .map_or_else(|| slice::from_ref(value), |vr| self.values(vr)) } /// Check if `a` and `b` belong to the same congruence class.