]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #1158 - divergentdave:shim-rename, r=RalfJung
authorbors <bors@rust-lang.org>
Fri, 14 Feb 2020 20:26:23 +0000 (20:26 +0000)
committerbors <bors@rust-lang.org>
Fri, 14 Feb 2020 20:26:23 +0000 (20:26 +0000)
Add shim for rename

This adds a straightforward shim for rename, which is used by `std::fs::rename`. Testing is included.

As a heads up, I expect one or two merge conflicts between my PRs, since some of them touch the same `use` statements, or add items near the same places. I'll rebase and fix them as they come up.

1  2 
src/shims/foreign_items.rs

index 4a1d62d3567e89ed452ad70bfd46ab42b2a23cc8,2fd886ed0e84cd894877823be78b1a29cd2e48af..ff5ffb0e3ac6ac7daa6f81e3dba39221e2cbe1ab
@@@ -177,7 -177,7 +177,7 @@@ pub trait EvalContextExt<'mir, 'tcx: 'm
                  let items = this.read_scalar(args[0])?.to_machine_usize(this)?;
                  let len = this.read_scalar(args[1])?.to_machine_usize(this)?;
                  let size =
 -                    items.checked_mul(len).ok_or_else(|| err_panic!(Overflow(mir::BinOp::Mul)))?;
 +                    items.checked_mul(len).ok_or_else(|| err_ub_format!("overflow during calloc size computation"))?;
                  let res = this.malloc(size, /*zero_init:*/ true, MiriMemoryKind::C);
                  this.write_scalar(res, dest)?;
              }
                  this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
              }
  
+             "rename" => {
+                 let result = this.rename(args[0], args[1])?;
+                 this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
+             }
              "clock_gettime" => {
                  let result = this.clock_gettime(args[0], args[1])?;
                  this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;