From d7d7a9a1627fd75d49ae9516a531154726d6190d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 22 May 2022 21:47:44 +0200 Subject: [PATCH 1/2] [NFC] shims: fs: fmt --- src/shims/posix/fs.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shims/posix/fs.rs b/src/shims/posix/fs.rs index dec1e9781680..3fcbbb803eaf 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, From 89da571b5d7d35220dd65c670caf66e25c10a892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 22 May 2022 21:54:00 +0200 Subject: [PATCH 2/2] shims: fs: silence stderr instead of stdout. Fixes #2143 --- src/shims/posix/fs.rs | 6 +++--- tests/run-pass/hide_stdout.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/shims/posix/fs.rs b/src/shims/posix/fs.rs index 3fcbbb803eaf..79539fd9c49e 100644 --- a/src/shims/posix/fs.rs +++ b/src/shims/posix/fs.rs @@ -307,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 849fce913862..3ee68d01f43d 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"); }