Skip to content

Commit ed24426

Browse files
committed
remove some unnecessary to_owned
1 parent 5dee646 commit ed24426

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/tools/miri/src/shims/unix/fd.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ impl FileDescription for io::Stdout {
173173
dest: &MPlaceTy<'tcx>,
174174
ecx: &mut MiriInterpCx<'tcx>,
175175
) -> InterpResult<'tcx> {
176-
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
176+
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
177177
// We allow writing to stderr even with isolation enabled.
178-
let result = Write::write(&mut { self }, &bytes);
178+
let result = Write::write(&mut { self }, bytes);
179179
// Stdout is buffered, flush to make sure it appears on the
180180
// screen. This is the write() syscall of the interpreted
181181
// program, we want it to correspond to a write() syscall on
@@ -204,10 +204,10 @@ impl FileDescription for io::Stderr {
204204
dest: &MPlaceTy<'tcx>,
205205
ecx: &mut MiriInterpCx<'tcx>,
206206
) -> InterpResult<'tcx> {
207-
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
207+
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
208208
// We allow writing to stderr even with isolation enabled.
209209
// No need to flush, stderr is not buffered.
210-
let result = Write::write(&mut { self }, &bytes);
210+
let result = Write::write(&mut { self }, bytes);
211211
ecx.return_written_byte_count_or_error(result, dest)
212212
}
213213

src/tools/miri/src/shims/unix/fs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl FileDescription for FileHandle {
5555
ecx: &mut MiriInterpCx<'tcx>,
5656
) -> InterpResult<'tcx> {
5757
assert!(communicate_allowed, "isolation should have prevented even opening a file");
58-
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
59-
let result = (&mut &self.file).write(&bytes);
58+
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
59+
let result = (&mut &self.file).write(bytes);
6060
ecx.return_written_byte_count_or_error(result, dest)
6161
}
6262

@@ -102,11 +102,11 @@ impl FileDescription for FileHandle {
102102
// Correctness of this emulation relies on sequential nature of Miri execution.
103103
// The closure is used to emulate `try` block, since we "bubble" `io::Error` using `?`.
104104
let file = &mut &self.file;
105-
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
105+
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
106106
let mut f = || {
107107
let cursor_pos = file.stream_position()?;
108108
file.seek(SeekFrom::Start(offset))?;
109-
let res = file.write(&bytes);
109+
let res = file.write(bytes);
110110
// Attempt to restore cursor position even if the write has failed
111111
file.seek(SeekFrom::Start(cursor_pos))
112112
.expect("failed to restore file position, this shouldn't be possible");

src/tools/miri/src/shims/unix/unnamed_socket.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl FileDescription for AnonSocket {
245245
}
246246
// Do full write / partial write based on the space available.
247247
let actual_write_size = len.min(available_space);
248-
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
248+
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
249249
writebuf.buf.extend(&bytes[..actual_write_size]);
250250

251251
// Need to stop accessing peer_fd so that it can be notified.

0 commit comments

Comments
 (0)