5 use syntax::source_map::{self, Span, DUMMY_SP};
6 use rustc::hir::def_id::DefId;
7 use rustc::hir::def::DefKind;
9 use rustc::ty::layout::{
10 self, Size, Align, HasDataLayout, LayoutOf, TyLayout
12 use rustc::ty::subst::{Subst, SubstsRef};
13 use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
14 use rustc::ty::query::TyCtxtAt;
15 use rustc_data_structures::indexed_vec::IndexVec;
16 use rustc::mir::interpret::{
18 GlobalId, Scalar, FrameInfo, AllocId,
19 EvalResult, InterpError,
20 truncate, sign_extend,
22 use rustc_data_structures::fx::FxHashMap;
25 Immediate, Operand, MemPlace, MPlaceTy, Place, PlaceTy, ScalarMaybeUndef,
29 pub struct InterpretCx<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'a, 'mir, 'tcx>> {
30 /// Stores the `Machine` instance.
33 /// The results of the type checker, from rustc.
34 pub tcx: TyCtxtAt<'a, 'tcx, 'tcx>,
36 /// Bounds in scope for polymorphic evaluations.
37 pub(crate) param_env: ty::ParamEnv<'tcx>,
39 /// The virtual memory system.
40 pub(crate) memory: Memory<'a, 'mir, 'tcx, M>,
42 /// The virtual call stack.
43 pub(crate) stack: Vec<Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>>,
45 /// A cache for deduplicating vtables
46 pub(super) vtables: FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), AllocId>,
51 pub struct Frame<'mir, 'tcx: 'mir, Tag=(), Extra=()> {
52 ////////////////////////////////////////////////////////////////////////////////
53 // Function and callsite information
54 ////////////////////////////////////////////////////////////////////////////////
55 /// The MIR for the function called on this frame.
56 pub mir: &'mir mir::Mir<'tcx>,
58 /// The def_id and substs of the current function.
59 pub instance: ty::Instance<'tcx>,
61 /// The span of the call site.
62 pub span: source_map::Span,
64 ////////////////////////////////////////////////////////////////////////////////
65 // Return place and locals
66 ////////////////////////////////////////////////////////////////////////////////
67 /// Work to perform when returning from this function.
68 pub return_to_block: StackPopCleanup,
70 /// The location where the result of the current stack frame should be written to,
71 /// and its layout in the caller.
72 pub return_place: Option<PlaceTy<'tcx, Tag>>,
74 /// The list of locals for this stack frame, stored in order as
75 /// `[return_ptr, arguments..., variables..., temporaries...]`.
76 /// The locals are stored as `Option<Value>`s.
77 /// `None` represents a local that is currently dead, while a live local
78 /// can either directly contain `Scalar` or refer to some part of an `Allocation`.
79 pub locals: IndexVec<mir::Local, LocalState<'tcx, Tag>>,
81 ////////////////////////////////////////////////////////////////////////////////
82 // Current position within the function
83 ////////////////////////////////////////////////////////////////////////////////
84 /// The block that is currently executed (or will be executed after the above call stacks
86 pub block: mir::BasicBlock,
88 /// The index of the currently evaluated statement.
91 /// Extra data for the machine.
95 #[derive(Clone, Debug, Eq, PartialEq, Hash)]
96 pub enum StackPopCleanup {
97 /// Jump to the next block in the caller, or cause UB if None (that's a function
98 /// that may never return). Also store layout of return place so
99 /// we can validate it at that layout.
100 Goto(Option<mir::BasicBlock>),
101 /// Just do nohing: Used by Main and for the box_alloc hook in miri.
102 /// `cleanup` says whether locals are deallocated. Static computation
103 /// wants them leaked to intern what they need (and just throw away
104 /// the entire `ecx` when it is done).
105 None { cleanup: bool },
108 /// State of a local variable including a memoized layout
109 #[derive(Clone, PartialEq, Eq)]
110 pub struct LocalState<'tcx, Tag=(), Id=AllocId> {
111 pub value: LocalValue<Tag, Id>,
112 /// Don't modify if `Some`, this is only used to prevent computing the layout twice
113 pub layout: Cell<Option<TyLayout<'tcx>>>,
116 /// Current value of a local variable
117 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
118 pub enum LocalValue<Tag=(), Id=AllocId> {
119 /// This local is not currently alive, and cannot be used at all.
121 /// This local is alive but not yet initialized. It can be written to
122 /// but not read from or its address taken. Locals get initialized on
123 /// first write because for unsized locals, we do not know their size
126 /// A normal, live local.
127 /// Mostly for convenience, we re-use the `Operand` type here.
128 /// This is an optimization over just always having a pointer here;
129 /// we can thus avoid doing an allocation when the local just stores
130 /// immediate values *and* never has its address taken.
131 Live(Operand<Tag, Id>),
134 impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
135 pub fn access(&self) -> EvalResult<'tcx, Operand<Tag>> {
137 LocalValue::Dead => err!(DeadLocal),
138 LocalValue::Uninitialized =>
139 bug!("The type checker should prevent reading from a never-written local"),
140 LocalValue::Live(val) => Ok(val),
144 /// Overwrite the local. If the local can be overwritten in place, return a reference
145 /// to do so; otherwise return the `MemPlace` to consult instead.
148 ) -> EvalResult<'tcx, Result<&mut LocalValue<Tag>, MemPlace<Tag>>> {
150 LocalValue::Dead => err!(DeadLocal),
151 LocalValue::Live(Operand::Indirect(mplace)) => Ok(Err(mplace)),
152 ref mut local @ LocalValue::Live(Operand::Immediate(_)) |
153 ref mut local @ LocalValue::Uninitialized => {
160 impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> HasDataLayout
161 for InterpretCx<'a, 'mir, 'tcx, M>
164 fn data_layout(&self) -> &layout::TargetDataLayout {
165 &self.tcx.data_layout
169 impl<'a, 'mir, 'tcx, M> layout::HasTyCtxt<'tcx> for InterpretCx<'a, 'mir, 'tcx, M>
170 where M: Machine<'a, 'mir, 'tcx>
173 fn tcx<'d>(&'d self) -> TyCtxt<'d, 'tcx, 'tcx> {
178 impl<'a, 'mir, 'tcx, M> layout::HasParamEnv<'tcx> for InterpretCx<'a, 'mir, 'tcx, M>
179 where M: Machine<'a, 'mir, 'tcx>
181 fn param_env(&self) -> ty::ParamEnv<'tcx> {
186 impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> LayoutOf
187 for InterpretCx<'a, 'mir, 'tcx, M>
190 type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>;
193 fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
194 self.tcx.layout_of(self.param_env.and(ty))
195 .map_err(|layout| InterpError::Layout(layout).into())
199 impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M> {
201 tcx: TyCtxtAt<'a, 'tcx, 'tcx>,
202 param_env: ty::ParamEnv<'tcx>,
209 memory: Memory::new(tcx),
211 vtables: FxHashMap::default(),
216 pub fn memory(&self) -> &Memory<'a, 'mir, 'tcx, M> {
221 pub fn memory_mut(&mut self) -> &mut Memory<'a, 'mir, 'tcx, M> {
226 pub fn stack(&self) -> &[Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>] {
231 pub fn cur_frame(&self) -> usize {
232 assert!(self.stack.len() > 0);
237 pub fn frame(&self) -> &Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra> {
238 self.stack.last().expect("no call frames exist")
242 pub fn frame_mut(&mut self) -> &mut Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra> {
243 self.stack.last_mut().expect("no call frames exist")
247 pub(super) fn mir(&self) -> &'mir mir::Mir<'tcx> {
251 pub(super) fn subst_and_normalize_erasing_regions<T: TypeFoldable<'tcx>>(
254 ) -> EvalResult<'tcx, T> {
255 match self.stack.last() {
256 Some(frame) => Ok(self.tcx.subst_and_normalize_erasing_regions(
257 frame.instance.substs,
261 None => if substs.needs_subst() {
262 err!(TooGeneric).into()
269 pub(super) fn resolve(
272 substs: SubstsRef<'tcx>
273 ) -> EvalResult<'tcx, ty::Instance<'tcx>> {
274 trace!("resolve: {:?}, {:#?}", def_id, substs);
275 trace!("param_env: {:#?}", self.param_env);
276 let substs = self.subst_and_normalize_erasing_regions(substs)?;
277 trace!("substs: {:#?}", substs);
278 ty::Instance::resolve(
283 ).ok_or_else(|| InterpError::TooGeneric.into())
286 pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
287 ty.is_sized(self.tcx, self.param_env)
290 pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
291 ty.is_freeze(*self.tcx, self.param_env, DUMMY_SP)
296 instance: ty::InstanceDef<'tcx>,
297 ) -> EvalResult<'tcx, &'tcx mir::Mir<'tcx>> {
298 // do not continue if typeck errors occurred (can only occur in local crate)
299 let did = instance.def_id();
301 && self.tcx.has_typeck_tables(did)
302 && self.tcx.typeck_tables_of(did).tainted_by_errors
304 return err!(TypeckError);
306 trace!("load mir {:?}", instance);
308 ty::InstanceDef::Item(def_id) => if self.tcx.is_mir_available(did) {
309 Ok(self.tcx.optimized_mir(did))
311 err!(NoMirFor(self.tcx.def_path_str(def_id)))
313 _ => Ok(self.tcx.instance_mir(instance)),
317 pub(super) fn monomorphize<T: TypeFoldable<'tcx> + Subst<'tcx>>(
320 ) -> EvalResult<'tcx, T> {
321 match self.stack.last() {
322 Some(frame) => Ok(self.monomorphize_with_substs(t, frame.instance.substs)),
323 None => if t.needs_subst() {
324 err!(TooGeneric).into()
331 fn monomorphize_with_substs<T: TypeFoldable<'tcx> + Subst<'tcx>>(
334 substs: SubstsRef<'tcx>
336 // miri doesn't care about lifetimes, and will choke on some crazy ones
337 // let's simply get rid of them
338 let substituted = t.subst(*self.tcx, substs);
339 self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), substituted)
342 pub fn layout_of_local(
344 frame: &Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>,
346 layout: Option<TyLayout<'tcx>>,
347 ) -> EvalResult<'tcx, TyLayout<'tcx>> {
348 match frame.locals[local].layout.get() {
350 let layout = crate::interpret::operand::from_known_layout(layout, || {
351 let local_ty = frame.mir.local_decls[local].ty;
352 let local_ty = self.monomorphize_with_substs(local_ty, frame.instance.substs);
353 self.layout_of(local_ty)
355 // Layouts of locals are requested a lot, so we cache them.
356 frame.locals[local].layout.set(Some(layout));
359 Some(layout) => Ok(layout),
363 pub fn str_to_immediate(&mut self, s: &str) -> EvalResult<'tcx, Immediate<M::PointerTag>> {
364 let ptr = self.memory.allocate_static_bytes(s.as_bytes()).with_default_tag();
365 Ok(Immediate::new_slice(Scalar::Ptr(ptr), s.len() as u64, self))
368 /// Returns the actual dynamic size and alignment of the place at the given type.
369 /// Only the "meta" (metadata) part of the place matters.
370 /// This can fail to provide an answer for extern types.
371 pub(super) fn size_and_align_of(
373 metadata: Option<Scalar<M::PointerTag>>,
374 layout: TyLayout<'tcx>,
375 ) -> EvalResult<'tcx, Option<(Size, Align)>> {
376 if !layout.is_unsized() {
377 return Ok(Some((layout.size, layout.align.abi)));
379 match layout.ty.sty {
380 ty::Adt(..) | ty::Tuple(..) => {
381 // First get the size of all statically known fields.
382 // Don't use type_of::sizing_type_of because that expects t to be sized,
383 // and it also rounds up to alignment, which we want to avoid,
384 // as the unsized field's alignment could be smaller.
385 assert!(!layout.ty.is_simd());
386 trace!("DST layout: {:?}", layout);
388 let sized_size = layout.fields.offset(layout.fields.count() - 1);
389 let sized_align = layout.align.abi;
391 "DST {} statically sized prefix size: {:?} align: {:?}",
397 // Recurse to get the size of the dynamically sized field (must be
398 // the last field). Can't have foreign types here, how would we
399 // adjust alignment and size for them?
400 let field = layout.field(self, layout.fields.count() - 1)?;
401 let (unsized_size, unsized_align) = match self.size_and_align_of(metadata, field)? {
402 Some(size_and_align) => size_and_align,
404 // A field with extern type. If this field is at offset 0, we behave
405 // like the underlying extern type.
406 // FIXME: Once we have made decisions for how to handle size and alignment
407 // of `extern type`, this should be adapted. It is just a temporary hack
408 // to get some code to work that probably ought to work.
409 if sized_size == Size::ZERO {
412 bug!("Fields cannot be extern types, unless they are at offset 0")
417 // FIXME (#26403, #27023): We should be adding padding
418 // to `sized_size` (to accommodate the `unsized_align`
419 // required of the unsized field that follows) before
420 // summing it with `sized_size`. (Note that since #26403
421 // is unfixed, we do not yet add the necessary padding
422 // here. But this is where the add would go.)
424 // Return the sum of sizes and max of aligns.
425 let size = sized_size + unsized_size;
427 // Choose max of two known alignments (combined value must
428 // be aligned according to more restrictive of the two).
429 let align = sized_align.max(unsized_align);
431 // Issue #27023: must add any necessary padding to `size`
432 // (to make it a multiple of `align`) before returning it.
434 // Namely, the returned size should be, in C notation:
436 // `size + ((size & (align-1)) ? align : 0)`
438 // emulated via the semi-standard fast bit trick:
440 // `(size + (align-1)) & -align`
442 Ok(Some((size.align_to(align), align)))
445 let vtable = metadata.expect("dyn trait fat ptr must have vtable").to_ptr()?;
446 // the second entry in the vtable is the dynamic size of the object.
447 Ok(Some(self.read_size_and_align_from_vtable(vtable)?))
450 ty::Slice(_) | ty::Str => {
451 let len = metadata.expect("slice fat ptr must have vtable").to_usize(self)?;
452 let elem = layout.field(self, 0)?;
453 Ok(Some((elem.size * len, elem.align.abi)))
460 _ => bug!("size_and_align_of::<{:?}> not supported", layout.ty),
464 pub fn size_and_align_of_mplace(
466 mplace: MPlaceTy<'tcx, M::PointerTag>
467 ) -> EvalResult<'tcx, Option<(Size, Align)>> {
468 self.size_and_align_of(mplace.meta, mplace.layout)
471 pub fn push_stack_frame(
473 instance: ty::Instance<'tcx>,
474 span: source_map::Span,
475 mir: &'mir mir::Mir<'tcx>,
476 return_place: Option<PlaceTy<'tcx, M::PointerTag>>,
477 return_to_block: StackPopCleanup,
478 ) -> EvalResult<'tcx> {
479 if self.stack.len() > 0 {
480 info!("PAUSING({}) {}", self.cur_frame(), self.frame().instance);
482 ::log_settings::settings().indentation += 1;
484 // first push a stack frame so we have access to the local substs
485 let extra = M::stack_push(self)?;
486 self.stack.push(Frame {
488 block: mir::START_BLOCK,
491 // empty local array, we fill it in below, after we are inside the stack frame and
492 // all methods actually know about the frame
493 locals: IndexVec::new(),
500 // don't allocate at all for trivial constants
501 if mir.local_decls.len() > 1 {
502 // Locals are initially uninitialized.
503 let dummy = LocalState {
504 value: LocalValue::Uninitialized,
505 layout: Cell::new(None),
507 let mut locals = IndexVec::from_elem(dummy, &mir.local_decls);
508 // Return place is handled specially by the `eval_place` functions, and the
509 // entry in `locals` should never be used. Make it dead, to be sure.
510 locals[mir::RETURN_PLACE].value = LocalValue::Dead;
511 // Now mark those locals as dead that we do not want to initialize
512 match self.tcx.def_kind(instance.def_id()) {
513 // statics and constants don't have `Storage*` statements, no need to look for them
514 Some(DefKind::Static)
515 | Some(DefKind::Const)
516 | Some(DefKind::AssocConst) => {},
518 trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
519 for block in mir.basic_blocks() {
520 for stmt in block.statements.iter() {
521 use rustc::mir::StatementKind::{StorageDead, StorageLive};
524 StorageDead(local) => {
525 locals[local].value = LocalValue::Dead;
534 self.frame_mut().locals = locals;
537 info!("ENTERING({}) {}", self.cur_frame(), self.frame().instance);
539 if self.stack.len() > self.tcx.sess.const_eval_stack_frame_limit {
540 err!(StackFrameLimitReached)
546 pub(super) fn pop_stack_frame(&mut self) -> EvalResult<'tcx> {
547 info!("LEAVING({}) {}", self.cur_frame(), self.frame().instance);
548 ::log_settings::settings().indentation -= 1;
549 let frame = self.stack.pop().expect(
550 "tried to pop a stack frame, but there were none",
552 M::stack_pop(self, frame.extra)?;
553 // Abort early if we do not want to clean up: We also avoid validation in that case,
554 // because this is CTFE and the final value will be thoroughly validated anyway.
555 match frame.return_to_block {
556 StackPopCleanup::Goto(_) => {},
557 StackPopCleanup::None { cleanup } => {
559 assert!(self.stack.is_empty(), "only the topmost frame should ever be leaked");
560 // Leak the locals, skip validation.
565 // Deallocate all locals that are backed by an allocation.
566 for local in frame.locals {
567 self.deallocate_local(local.value)?;
569 // Validate the return value. Do this after deallocating so that we catch dangling
571 if let Some(return_place) = frame.return_place {
572 if M::enforce_validity(self) {
573 // Data got changed, better make sure it matches the type!
574 // It is still possible that the return place held invalid data while
575 // the function is running, but that's okay because nobody could have
576 // accessed that same data from the "outside" to observe any broken
577 // invariant -- that is, unless a function somehow has a ptr to
578 // its return place... but the way MIR is currently generated, the
579 // return place is always a local and then this cannot happen.
580 self.validate_operand(
581 self.place_to_op(return_place)?,
588 // Uh, that shouldn't happen... the function did not intend to return
589 return err!(Unreachable);
591 // Jump to new block -- *after* validation so that the spans make more sense.
592 match frame.return_to_block {
593 StackPopCleanup::Goto(block) => {
594 self.goto_block(block)?;
596 StackPopCleanup::None { .. } => {}
599 if self.stack.len() > 0 {
600 info!("CONTINUING({}) {}", self.cur_frame(), self.frame().instance);
606 /// Mark a storage as live, killing the previous content and returning it.
607 /// Remember to deallocate that!
611 ) -> EvalResult<'tcx, LocalValue<M::PointerTag>> {
612 assert!(local != mir::RETURN_PLACE, "Cannot make return place live");
613 trace!("{:?} is now live", local);
615 let local_val = LocalValue::Uninitialized;
616 // StorageLive *always* kills the value that's currently stored.
617 // However, we do not error if the variable already is live;
618 // see <https://github.com/rust-lang/rust/issues/42371>.
619 Ok(mem::replace(&mut self.frame_mut().locals[local].value, local_val))
622 /// Returns the old value of the local.
623 /// Remember to deallocate that!
624 pub fn storage_dead(&mut self, local: mir::Local) -> LocalValue<M::PointerTag> {
625 assert!(local != mir::RETURN_PLACE, "Cannot make return place dead");
626 trace!("{:?} is now dead", local);
628 mem::replace(&mut self.frame_mut().locals[local].value, LocalValue::Dead)
631 pub(super) fn deallocate_local(
633 local: LocalValue<M::PointerTag>,
634 ) -> EvalResult<'tcx> {
635 // FIXME: should we tell the user that there was a local which was never written to?
636 if let LocalValue::Live(Operand::Indirect(MemPlace { ptr, .. })) = local {
637 trace!("deallocating local");
638 let ptr = ptr.to_ptr()?;
639 self.memory.dump_alloc(ptr.alloc_id);
640 self.memory.deallocate_local(ptr)?;
645 pub fn const_eval_raw(
648 ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
649 let param_env = if self.tcx.is_static(gid.instance.def_id()) {
650 ty::ParamEnv::reveal_all()
654 // We use `const_eval_raw` here, and get an unvalidated result. That is okay:
655 // Our result will later be validated anyway, and there seems no good reason
656 // to have to fail early here. This is also more consistent with
657 // `Memory::get_static_alloc` which has to use `const_eval_raw` to avoid cycles.
658 let val = self.tcx.const_eval_raw(param_env.and(gid)).map_err(|err| {
660 ErrorHandled::Reported => InterpError::ReferencedConstant,
661 ErrorHandled::TooGeneric => InterpError::TooGeneric,
664 self.raw_const_to_mplace(val)
667 pub fn dump_place(&self, place: Place<M::PointerTag>) {
669 if !log_enabled!(::log::Level::Trace) {
673 Place::Local { frame, local } => {
674 let mut allocs = Vec::new();
675 let mut msg = format!("{:?}", local);
676 if frame != self.cur_frame() {
677 write!(msg, " ({} frames up)", self.cur_frame() - frame).unwrap();
679 write!(msg, ":").unwrap();
681 match self.stack[frame].locals[local].value {
682 LocalValue::Dead => write!(msg, " is dead").unwrap(),
683 LocalValue::Uninitialized => write!(msg, " is uninitialized").unwrap(),
684 LocalValue::Live(Operand::Indirect(mplace)) => {
686 Scalar::Ptr(ptr) => {
687 write!(msg, " by align({}){} ref:",
688 mplace.align.bytes(),
690 Some(meta) => format!(" meta({:?})", meta),
691 None => String::new()
694 allocs.push(ptr.alloc_id);
696 ptr => write!(msg, " by integral ref: {:?}", ptr).unwrap(),
699 LocalValue::Live(Operand::Immediate(Immediate::Scalar(val))) => {
700 write!(msg, " {:?}", val).unwrap();
701 if let ScalarMaybeUndef::Scalar(Scalar::Ptr(ptr)) = val {
702 allocs.push(ptr.alloc_id);
705 LocalValue::Live(Operand::Immediate(Immediate::ScalarPair(val1, val2))) => {
706 write!(msg, " ({:?}, {:?})", val1, val2).unwrap();
707 if let ScalarMaybeUndef::Scalar(Scalar::Ptr(ptr)) = val1 {
708 allocs.push(ptr.alloc_id);
710 if let ScalarMaybeUndef::Scalar(Scalar::Ptr(ptr)) = val2 {
711 allocs.push(ptr.alloc_id);
717 self.memory.dump_allocs(allocs);
719 Place::Ptr(mplace) => {
721 Scalar::Ptr(ptr) => {
722 trace!("by align({}) ref:", mplace.align.bytes());
723 self.memory.dump_alloc(ptr.alloc_id);
725 ptr => trace!(" integral by ref: {:?}", ptr),
731 pub fn generate_stacktrace(&self, explicit_span: Option<Span>) -> Vec<FrameInfo<'tcx>> {
732 let mut last_span = None;
733 let mut frames = Vec::new();
734 for &Frame { instance, span, mir, block, stmt, .. } in self.stack().iter().rev() {
735 // make sure we don't emit frames that are duplicates of the previous
736 if explicit_span == Some(span) {
737 last_span = Some(span);
740 if let Some(last) = last_span {
745 last_span = Some(span);
747 let block = &mir.basic_blocks()[block];
748 let source_info = if stmt < block.statements.len() {
749 block.statements[stmt].source_info
751 block.terminator().source_info
753 let lint_root = match mir.source_scope_local_data {
754 mir::ClearCrossCrate::Set(ref ivs) => Some(ivs[source_info.scope].lint_root),
755 mir::ClearCrossCrate::Clear => None,
757 frames.push(FrameInfo { call_site: span, instance, lint_root });
759 trace!("generate stacktrace: {:#?}, {:?}", frames, explicit_span);
764 pub fn sign_extend(&self, value: u128, ty: TyLayout<'_>) -> u128 {
765 assert!(ty.abi.is_signed());
766 sign_extend(value, ty.size)
770 pub fn truncate(&self, value: u128, ty: TyLayout<'_>) -> u128 {
771 truncate(value, ty.size)