mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
remove some unnecessary to_owned
This commit is contained in:
parent
5dee646aea
commit
ed24426824
@ -173,9 +173,9 @@ impl FileDescription for io::Stdout {
|
||||
dest: &MPlaceTy<'tcx>,
|
||||
ecx: &mut MiriInterpCx<'tcx>,
|
||||
) -> InterpResult<'tcx> {
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||
// We allow writing to stderr even with isolation enabled.
|
||||
let result = Write::write(&mut { self }, &bytes);
|
||||
let result = Write::write(&mut { self }, bytes);
|
||||
// Stdout is buffered, flush to make sure it appears on the
|
||||
// screen. This is the write() syscall of the interpreted
|
||||
// program, we want it to correspond to a write() syscall on
|
||||
@ -204,10 +204,10 @@ impl FileDescription for io::Stderr {
|
||||
dest: &MPlaceTy<'tcx>,
|
||||
ecx: &mut MiriInterpCx<'tcx>,
|
||||
) -> InterpResult<'tcx> {
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||
// We allow writing to stderr even with isolation enabled.
|
||||
// No need to flush, stderr is not buffered.
|
||||
let result = Write::write(&mut { self }, &bytes);
|
||||
let result = Write::write(&mut { self }, bytes);
|
||||
ecx.return_written_byte_count_or_error(result, dest)
|
||||
}
|
||||
|
||||
|
@ -55,8 +55,8 @@ impl FileDescription for FileHandle {
|
||||
ecx: &mut MiriInterpCx<'tcx>,
|
||||
) -> InterpResult<'tcx> {
|
||||
assert!(communicate_allowed, "isolation should have prevented even opening a file");
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
||||
let result = (&mut &self.file).write(&bytes);
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||
let result = (&mut &self.file).write(bytes);
|
||||
ecx.return_written_byte_count_or_error(result, dest)
|
||||
}
|
||||
|
||||
@ -102,11 +102,11 @@ impl FileDescription for FileHandle {
|
||||
// Correctness of this emulation relies on sequential nature of Miri execution.
|
||||
// The closure is used to emulate `try` block, since we "bubble" `io::Error` using `?`.
|
||||
let file = &mut &self.file;
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||
let mut f = || {
|
||||
let cursor_pos = file.stream_position()?;
|
||||
file.seek(SeekFrom::Start(offset))?;
|
||||
let res = file.write(&bytes);
|
||||
let res = file.write(bytes);
|
||||
// Attempt to restore cursor position even if the write has failed
|
||||
file.seek(SeekFrom::Start(cursor_pos))
|
||||
.expect("failed to restore file position, this shouldn't be possible");
|
||||
|
@ -245,7 +245,7 @@ impl FileDescription for AnonSocket {
|
||||
}
|
||||
// Do full write / partial write based on the space available.
|
||||
let actual_write_size = len.min(available_space);
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||
writebuf.buf.extend(&bytes[..actual_write_size]);
|
||||
|
||||
// Need to stop accessing peer_fd so that it can be notified.
|
||||
|
Loading…
Reference in New Issue
Block a user