Skip to content
Permalink
Browse files

Remove a bunch of dead functions and make some functions private

  • Loading branch information
oli-obk committed Dec 26, 2019
1 parent 23b0c47 commit a1990db7c68ead195d1ddf4b245e3c0e6f721fbc
Showing with 3 additions and 37 deletions.
  1. +0 −24 src/librustc_mir/interpret/operand.rs
  2. +3 −13 src/librustc_mir/interpret/place.rs
@@ -153,30 +153,6 @@ pub enum Operand<Tag = (), Id = AllocId> {
Indirect(MemPlace<Tag, Id>),
}

impl<Tag> Operand<Tag> {
#[inline]
pub fn assert_mem_place(self) -> MemPlace<Tag>
where
Tag: ::std::fmt::Debug,
{
match self {
Operand::Indirect(mplace) => mplace,
_ => bug!("assert_mem_place: expected Operand::Indirect, got {:?}", self),
}
}

#[inline]
pub fn assert_immediate(self) -> Immediate<Tag>
where
Tag: ::std::fmt::Debug,
{
match self {
Operand::Immediate(imm) => imm,
_ => bug!("assert_immediate: expected Operand::Immediate, got {:?}", self),
}
}
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct OpTy<'tcx, Tag = ()> {
op: Operand<Tag>, // Keep this private; it helps enforce invariants.
@@ -131,13 +131,13 @@ impl<Tag> MemPlace<Tag> {
}

#[inline(always)]
pub fn from_scalar_ptr(ptr: Scalar<Tag>, align: Align) -> Self {
fn from_scalar_ptr(ptr: Scalar<Tag>, align: Align) -> Self {
MemPlace { ptr, align, meta: MemPlaceMeta::None }
}

/// Produces a Place that will error if attempted to be read from or written to
#[inline(always)]
pub fn null(cx: &impl HasDataLayout) -> Self {
fn null(cx: &impl HasDataLayout) -> Self {
Self::from_scalar_ptr(Scalar::ptr_null(cx), Align::from_bytes(1).unwrap())
}

@@ -263,20 +263,10 @@ impl<'tcx, Tag: ::std::fmt::Debug + Copy> OpTy<'tcx, Tag> {
impl<Tag: ::std::fmt::Debug> Place<Tag> {
/// Produces a Place that will error if attempted to be read from or written to
#[inline(always)]
pub fn null(cx: &impl HasDataLayout) -> Self {
fn null(cx: &impl HasDataLayout) -> Self {
Place::Ptr(MemPlace::null(cx))
}

#[inline(always)]
pub fn from_scalar_ptr(ptr: Scalar<Tag>, align: Align) -> Self {
Place::Ptr(MemPlace::from_scalar_ptr(ptr, align))
}

#[inline(always)]
pub fn from_ptr(ptr: Pointer<Tag>, align: Align) -> Self {
Place::Ptr(MemPlace::from_ptr(ptr, align))
}

#[inline]
pub fn assert_mem_place(self) -> MemPlace<Tag> {
match self {

0 comments on commit a1990db

Please sign in to comment.
You can’t perform that action at this time.