commit
c654940fbf
5 changed files with 12 additions and 12 deletions
|
|
@ -201,7 +201,7 @@ fn setup(ask_user: bool) {
|
|||
// Let's see if it is already installed.
|
||||
if std::env::var("XARGO_RUST_SRC").is_err() {
|
||||
let sysroot = Command::new("rustc").args(&["--print", "sysroot"]).output().unwrap().stdout;
|
||||
let sysroot = std::str::from_utf8(&sysroot[..]).unwrap();
|
||||
let sysroot = std::str::from_utf8(&sysroot).unwrap();
|
||||
let src = Path::new(sysroot.trim_end_matches('\n')).join("lib").join("rustlib").join("src");
|
||||
if !src.exists() {
|
||||
if ask_user {
|
||||
|
|
@ -336,7 +336,7 @@ fn in_cargo_miri() {
|
|||
// So after the first `--`, we add `-Zcargo-miri-marker`.
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.arg("rustc");
|
||||
match (subcommand, &kind[..]) {
|
||||
match (subcommand, kind.as_str()) {
|
||||
(MiriCommand::Run, "bin") => {
|
||||
// FIXME: we just run all the binaries here.
|
||||
// We should instead support `cargo miri --bin foo`.
|
||||
|
|
|
|||
|
|
@ -60,15 +60,15 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
let this = self.eval_context_mut();
|
||||
let attrs = this.tcx.get_attrs(def_id);
|
||||
let link_name = match attr::first_attr_value_str_by_name(&attrs, "link_name") {
|
||||
Some(name) => name.as_str(),
|
||||
None => this.tcx.item_name(def_id).as_str(),
|
||||
Some(name) => name.as_str().get(),
|
||||
None => this.tcx.item_name(def_id).as_str().get(),
|
||||
};
|
||||
// Strip linker suffixes (seen on 32-bit macOS).
|
||||
let link_name = link_name.trim_end_matches("$UNIX2003");
|
||||
let tcx = &{this.tcx.tcx};
|
||||
|
||||
// First: functions that could diverge.
|
||||
match &link_name[..] {
|
||||
match link_name {
|
||||
"__rust_start_panic" | "panic_impl" => {
|
||||
return err!(MachineError("the evaluated program panicked".to_string()));
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
// Next: functions that assume a ret and dest.
|
||||
let dest = dest.expect("we already checked for a dest");
|
||||
let ret = ret.expect("dest is `Some` but ret is `None`");
|
||||
match &link_name[..] {
|
||||
match link_name {
|
||||
"malloc" => {
|
||||
let size = this.read_scalar(args[0])?.to_usize(this)?;
|
||||
if size == 0 {
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
layout::FieldPlacement::Arbitrary { .. } => {
|
||||
// Gather the subplaces and sort them before visiting.
|
||||
let mut places = fields.collect::<EvalResult<'tcx, Vec<MPlaceTy<'tcx, Borrow>>>>()?;
|
||||
places[..].sort_by_key(|place| place.ptr.get_ptr_offset(self.ecx()));
|
||||
places.sort_by_key(|place| place.ptr.get_ptr_offset(self.ecx()));
|
||||
self.walk_aggregate(place, places.into_iter().map(Ok))
|
||||
}
|
||||
layout::FieldPlacement::Union { .. } => {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
|
|||
// (as opposed to through a place), we have to remember to erase any tag
|
||||
// that might still hang around!
|
||||
|
||||
let intrinsic_name = &this.tcx.item_name(instance.def_id()).as_str()[..];
|
||||
let intrinsic_name = this.tcx.item_name(instance.def_id()).as_str().get();
|
||||
match intrinsic_name {
|
||||
"arith_offset" => {
|
||||
let offset = this.read_scalar(args[1])?.to_isize(this)?;
|
||||
|
|
|
|||
|
|
@ -461,17 +461,17 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
) -> EvalResult<'tcx, Cow<'tcx, Allocation<Borrow, Self::AllocExtra>>> {
|
||||
let attrs = tcx.get_attrs(def_id);
|
||||
let link_name = match attr::first_attr_value_str_by_name(&attrs, "link_name") {
|
||||
Some(name) => name.as_str(),
|
||||
None => tcx.item_name(def_id).as_str(),
|
||||
Some(name) => name.as_str().get(),
|
||||
None => tcx.item_name(def_id).as_str().get(),
|
||||
};
|
||||
|
||||
let alloc = match &link_name[..] {
|
||||
let alloc = match link_name {
|
||||
"__cxa_thread_atexit_impl" => {
|
||||
// This should be all-zero, pointer-sized.
|
||||
let size = tcx.data_layout.pointer_size;
|
||||
let data = vec![0; size.bytes() as usize];
|
||||
let extra = AllocationExtra::memory_allocated(size, memory_extra);
|
||||
Allocation::from_bytes(&data[..], tcx.data_layout.pointer_align.abi, extra)
|
||||
Allocation::from_bytes(&data, tcx.data_layout.pointer_align.abi, extra)
|
||||
}
|
||||
_ => return err!(Unimplemented(
|
||||
format!("can't access foreign static: {}", link_name),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue