Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 89da571

Browse files
committed
shims: fs: silence stderr instead of stdout.
Fixes rust-lang#2143
1 parent d7d7a9a commit 89da571

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/shims/posix/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,14 @@ pub struct FileHandler {
307307
impl<'tcx> FileHandler {
308308
pub(crate) fn new(mute_stdout_stderr: bool) -> FileHandler {
309309
let mut handles: BTreeMap<_, Box<dyn FileDescriptor>> = BTreeMap::new();
310+
handles.insert(0i32, Box::new(io::stdin()));
310311
if mute_stdout_stderr {
311-
handles.insert(0i32, Box::new(DummyOutput));
312312
handles.insert(1i32, Box::new(DummyOutput));
313+
handles.insert(2i32, Box::new(DummyOutput));
313314
} else {
314-
handles.insert(0i32, Box::new(io::stdin()));
315315
handles.insert(1i32, Box::new(io::stdout()));
316+
handles.insert(2i32, Box::new(io::stderr()));
316317
}
317-
handles.insert(2i32, Box::new(io::stderr()));
318318
FileHandler { handles }
319319
}
320320

tests/run-pass/hide_stdout.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// compile-flags: -Zmiri-mute-stdout-stderr
22

33
fn main() {
4-
println!("cake");
4+
println!("print to stdout");
5+
eprintln!("print to stderr");
56
}

0 commit comments

Comments
 (0)