Skip to content

Commit 5ee6f8a

Browse files
committed
Add a method to create an arbitrary OpTy from outside rustc_mir
1 parent a73ecb3 commit 5ee6f8a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/librustc_mir/interpret/operand.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ use rustc::mir::interpret::{
1212
InterpResult, InterpError, InboundsCheck,
1313
sign_extend, truncate,
1414
};
15-
use super::{
16-
InterpretCx, Machine,
17-
MemPlace, MPlaceTy, PlaceTy, Place,
18-
};
15+
use super::{InterpretCx, Machine, MemPlace, MPlaceTy, PlaceTy, Place};
1916
pub use rustc::mir::interpret::ScalarMaybeUndef;
2017

2118
/// A `Value` represents a single immediate self-contained Rust value.
@@ -190,6 +187,19 @@ impl<'tcx, Tag: Copy> ImmTy<'tcx, Tag>
190187
}
191188
}
192189

190+
impl<'tcx, Tag> OpTy<'tcx, Tag>
191+
{
192+
/// This is used by [priroda](https://github.com/oli-obk/priroda) to create an `OpTy`.
193+
///
194+
/// Do not use this from inside rustc.
195+
pub fn from_op_and_layout_unchecked(op: Operand<Tag>, layout: TyLayout<'tcx>) -> Self {
196+
OpTy {
197+
op,
198+
layout,
199+
}
200+
}
201+
}
202+
193203
// Use the existing layout if given (but sanity check in debug mode),
194204
// or compute the layout.
195205
#[inline(always)]
@@ -395,7 +405,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
395405
})
396406
}
397407

398-
/// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local
399408
pub fn access_local(
400409
&self,
401410
frame: &super::Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>,

0 commit comments

Comments
 (0)