diff --git a/src/shims/posix/fs.rs b/src/shims/posix/fs.rs index dec1e97816..79539fd9c4 100644 --- a/src/shims/posix/fs.rs +++ b/src/shims/posix/fs.rs @@ -31,16 +31,19 @@ trait FileDescriptor: std::fmt::Debug { communicate_allowed: bool, bytes: &mut [u8], ) -> InterpResult<'tcx, io::Result>; + fn write<'tcx>( &self, communicate_allowed: bool, bytes: &[u8], ) -> InterpResult<'tcx, io::Result>; + fn seek<'tcx>( &mut self, communicate_allowed: bool, offset: SeekFrom, ) -> InterpResult<'tcx, io::Result>; + fn close<'tcx>( self: Box, _communicate_allowed: bool, @@ -304,14 +307,14 @@ pub struct FileHandler { impl<'tcx> FileHandler { pub(crate) fn new(mute_stdout_stderr: bool) -> FileHandler { let mut handles: BTreeMap<_, Box> = BTreeMap::new(); + handles.insert(0i32, Box::new(io::stdin())); if mute_stdout_stderr { - handles.insert(0i32, Box::new(DummyOutput)); handles.insert(1i32, Box::new(DummyOutput)); + handles.insert(2i32, Box::new(DummyOutput)); } else { - handles.insert(0i32, Box::new(io::stdin())); handles.insert(1i32, Box::new(io::stdout())); + handles.insert(2i32, Box::new(io::stderr())); } - handles.insert(2i32, Box::new(io::stderr())); FileHandler { handles } } diff --git a/tests/run-pass/hide_stdout.rs b/tests/run-pass/hide_stdout.rs index 849fce9138..3ee68d01f4 100644 --- a/tests/run-pass/hide_stdout.rs +++ b/tests/run-pass/hide_stdout.rs @@ -1,5 +1,6 @@ // compile-flags: -Zmiri-mute-stdout-stderr fn main() { - println!("cake"); + println!("print to stdout"); + eprintln!("print to stderr"); }