Skip to content

Commit

Permalink
update failure messages
Browse files Browse the repository at this point in the history
  • Loading branch information
DebugSteven committed Jul 25, 2022
1 parent 33c5e7c commit 9bca3ae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
13 changes: 6 additions & 7 deletions src/shims/unix/fs/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,38 @@ pub struct Epoll;

impl FileDescriptor for Epoll {
fn as_file_handle<'tcx>(&self) -> InterpResult<'tcx, &FileHandle> {
throw_unsup_format!("stderr and stdout cannot be used as FileHandle");
throw_unsup_format!("epoll file descriptors cannot be used as FileHandle");
}

fn read<'tcx>(
&mut self,
_communicate_allowed: bool,
_bytes: &mut [u8],
) -> InterpResult<'tcx, io::Result<usize>> {
throw_unsup_format!("cannot read from stderr or stdout");
throw_unsup_format!("cannot read from epoll file descriptors");
}

fn write<'tcx>(
&self,
_communicate_allowed: bool,
bytes: &[u8],
_bytes: &[u8],
) -> InterpResult<'tcx, io::Result<usize>> {
// We just don't write anything, but report to the user that we did.
Ok(Ok(bytes.len()))
throw_unsup_format!("cannot write from epoll file descriptors");
}

fn seek<'tcx>(
&mut self,
_communicate_allowed: bool,
_offset: SeekFrom,
) -> InterpResult<'tcx, io::Result<u64>> {
throw_unsup_format!("cannot seek on stderr or stdout");
throw_unsup_format!("cannot seek on epoll file descriptors");
}

fn close<'tcx>(
self: Box<Self>,
_communicate_allowed: bool,
) -> InterpResult<'tcx, io::Result<i32>> {
throw_unsup_format!("stderr and stdout cannot be closed");
throw_unsup_format!("epoll file descriptors cannot be closed");
}

fn dup<'tcx>(&mut self) -> io::Result<Box<dyn FileDescriptor>> {
Expand Down
13 changes: 6 additions & 7 deletions src/shims/unix/fs/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,38 @@ pub struct Event;

impl FileDescriptor for Event {
fn as_file_handle<'tcx>(&self) -> InterpResult<'tcx, &FileHandle> {
throw_unsup_format!("stderr and stdout cannot be used as FileHandle");
throw_unsup_format!("event file descriptors cannot be used as FileHandle");
}

fn read<'tcx>(
&mut self,
_communicate_allowed: bool,
_bytes: &mut [u8],
) -> InterpResult<'tcx, io::Result<usize>> {
throw_unsup_format!("cannot read from stderr or stdout");
throw_unsup_format!("cannot read event file descriptors");
}

fn write<'tcx>(
&self,
_communicate_allowed: bool,
bytes: &[u8],
_bytes: &[u8],
) -> InterpResult<'tcx, io::Result<usize>> {
// We just don't write anything, but report to the user that we did.
Ok(Ok(bytes.len()))
throw_unsup_format!("cannot write event file descriptors");
}

fn seek<'tcx>(
&mut self,
_communicate_allowed: bool,
_offset: SeekFrom,
) -> InterpResult<'tcx, io::Result<u64>> {
throw_unsup_format!("cannot seek on stderr or stdout");
throw_unsup_format!("cannot seek on event file descriptors");
}

fn close<'tcx>(
self: Box<Self>,
_communicate_allowed: bool,
) -> InterpResult<'tcx, io::Result<i32>> {
throw_unsup_format!("stderr and stdout cannot be closed");
throw_unsup_format!("event file descriptors cannot be closed");
}

fn dup<'tcx>(&mut self) -> io::Result<Box<dyn FileDescriptor>> {
Expand Down
2 changes: 1 addition & 1 deletion tests/fail/crates/tokio_mvp.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation
//@error-pattern: unsupported operation: stderr and stdout cannot be closed
//@error-pattern: unsupported operation: event file descriptors cannot be closed
//@normalize-stderr-test: " = note: inside .*\n" -> ""
//@only-target-linux: the errors differ too much between platforms

Expand Down
4 changes: 2 additions & 2 deletions tests/fail/crates/tokio_mvp.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: unsupported operation: stderr and stdout cannot be closed
error: unsupported operation: event file descriptors cannot be closed
--> RUSTLIB/std/src/os/fd/owned.rs:LL:CC
|
LL | let _ = libc::close(self.fd);
| ^^^^^^^^^^^^^^^^^^^^ stderr and stdout cannot be closed
| ^^^^^^^^^^^^^^^^^^^^ event file descriptors cannot be closed
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
= note: backtrace:
Expand Down

0 comments on commit 9bca3ae

Please sign in to comment.