Require #[repr(C)] on MiriFrame
This commit is contained in:
parent
dba7f13549
commit
5571bcfc4f
@ -277,6 +277,7 @@ extern "Rust" {
|
||||
/// and `MiriFrame` should be declared as follows:
|
||||
///
|
||||
/// ```rust
|
||||
/// #[repr(C)]
|
||||
/// struct MiriFrame {
|
||||
/// // The name of the function being executed, encoded in UTF-8
|
||||
/// name: Box<[u8]>,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::*;
|
||||
use helpers::check_arg_count;
|
||||
use rustc_middle::ty::TypeAndMut;
|
||||
use rustc_middle::ty::{self, TypeAndMut};
|
||||
use rustc_ast::ast::Mutability;
|
||||
use rustc_span::BytePos;
|
||||
use rustc_target::abi::Size;
|
||||
@ -105,7 +105,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
let lineno_alloc = Scalar::from_u32(lineno);
|
||||
let colno_alloc = Scalar::from_u32(colno);
|
||||
|
||||
let dest = this.force_allocation_maybe_sized(dest, MemPlaceMeta::None)?.0;
|
||||
let dest = this.force_allocation(dest)?;
|
||||
if let ty::Adt(adt, _) = dest.layout.ty.kind() {
|
||||
if !adt.repr.c() {
|
||||
throw_ub_format!("miri_resolve_frame must be declared with a `#[repr(C)]` return type");
|
||||
}
|
||||
}
|
||||
|
||||
this.write_immediate(name_alloc.to_ref(), this.mplace_field(dest, 0)?.into())?;
|
||||
this.write_immediate(filename_alloc.to_ref(), this.mplace_field(dest, 1)?.into())?;
|
||||
|
@ -7,6 +7,7 @@ extern "Rust" {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
struct MiriFrame {
|
||||
name: Box<[u8]>,
|
||||
filename: Box<[u8]>,
|
||||
|
@ -1,7 +1,7 @@
|
||||
$DIR/backtrace-api.rs:19:59 (func_c)
|
||||
$DIR/backtrace-api.rs:18:53 (func_b::<u8>)
|
||||
$DIR/backtrace-api.rs:17:50 (func_a)
|
||||
$DIR/backtrace-api.rs:23:18 (main)
|
||||
$DIR/backtrace-api.rs:20:59 (func_c)
|
||||
$DIR/backtrace-api.rs:19:53 (func_b::<u8>)
|
||||
$DIR/backtrace-api.rs:18:50 (func_a)
|
||||
$DIR/backtrace-api.rs:24:18 (main)
|
||||
RUSTLIB/src/rust/library/core/src/ops/function.rs:LL:COL (<fn() as std::ops::FnOnce<()>>::call_once - shim(fn()))
|
||||
RUSTLIB/src/rust/library/std/src/sys_common/backtrace.rs:LL:COL (std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>)
|
||||
RUSTLIB/src/rust/library/std/src/rt.rs:LL:COL (std::rt::lang_start::<()>::{{closure}}#0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
$DIR/backtrace-api.rs:19:59 (func_c)
|
||||
$DIR/backtrace-api.rs:18:53 (func_b::<u8>)
|
||||
$DIR/backtrace-api.rs:17:50 (func_a)
|
||||
$DIR/backtrace-api.rs:23:18 (main)
|
||||
$DIR/backtrace-api.rs:20:59 (func_c)
|
||||
$DIR/backtrace-api.rs:19:53 (func_b::<u8>)
|
||||
$DIR/backtrace-api.rs:18:50 (func_a)
|
||||
$DIR/backtrace-api.rs:24:18 (main)
|
||||
|
Loading…
x
Reference in New Issue
Block a user