Skip to content

Commit a70ae8a

Browse files
Auto merge of #150957 - matthiaskrgr:rollup-Cf6MsNU, r=matthiaskrgr
Rollup of 14 pull requests Successful merges: - rust-lang/rust#148941 (stabilize `Peekable::next_if_map` (`#![feature(peekable_next_if_map)]`)) - rust-lang/rust#150368 (adding Ordering enum to minicore.rs, importing minicore in "tests/assembly-llvm/rust-abi-arg-attr.rs" test file) - rust-lang/rust#150668 (Unix implementation for stdio set/take/replace) - rust-lang/rust#150743 (Reword the collect() docs) - rust-lang/rust#150776 (Fix the connect_error test on FreeBSD 15+) - rust-lang/rust#150781 (Use `rand` crate more idiomatically) - rust-lang/rust#150812 (Bump `diesel` to the most recent commit in `cargotest`) - rust-lang/rust#150862 (std: sys: fs: uefi: Implement File::flush) - rust-lang/rust#150873 (Reenable GCC CI download) - rust-lang/rust#150908 (llvm: Update `reliable_f16` configuration for LLVM22) - rust-lang/rust#150918 (std: sys: fs: uefi: Implement File::seek) - rust-lang/rust#150922 (Subscribe myself to attr parsing) - rust-lang/rust#150930 (Remove special case for `AllowedTargets::CrateLevel`) - rust-lang/rust#150942 (Port `#[rustc_has_incoherent_inherent_impls]` to attribute parser) Failed merges: - rust-lang/rust#150943 (Port `#[must_not_suspend]` to attribute parser) r? @ghost
2 parents 31fafcb + f26f16c commit a70ae8a

4 files changed

Lines changed: 45 additions & 22 deletions

File tree

src/shims/files.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ impl FileDescription for io::Stdin {
249249
finish.call(ecx, result)
250250
}
251251

252+
fn destroy<'tcx>(
253+
self,
254+
_self_id: FdId,
255+
_communicate_allowed: bool,
256+
_ecx: &mut MiriInterpCx<'tcx>,
257+
) -> InterpResult<'tcx, io::Result<()>> {
258+
interp_ok(Ok(()))
259+
}
260+
252261
fn is_tty(&self, communicate_allowed: bool) -> bool {
253262
communicate_allowed && self.is_terminal()
254263
}
@@ -279,6 +288,15 @@ impl FileDescription for io::Stdout {
279288
finish.call(ecx, result)
280289
}
281290

291+
fn destroy<'tcx>(
292+
self,
293+
_self_id: FdId,
294+
_communicate_allowed: bool,
295+
_ecx: &mut MiriInterpCx<'tcx>,
296+
) -> InterpResult<'tcx, io::Result<()>> {
297+
interp_ok(Ok(()))
298+
}
299+
282300
fn is_tty(&self, communicate_allowed: bool) -> bool {
283301
communicate_allowed && self.is_terminal()
284302
}
@@ -289,6 +307,15 @@ impl FileDescription for io::Stderr {
289307
"stderr"
290308
}
291309

310+
fn destroy<'tcx>(
311+
self,
312+
_self_id: FdId,
313+
_communicate_allowed: bool,
314+
_ecx: &mut MiriInterpCx<'tcx>,
315+
) -> InterpResult<'tcx, io::Result<()>> {
316+
interp_ok(Ok(()))
317+
}
318+
292319
fn write<'tcx>(
293320
self: FileDescriptionRef<Self>,
294321
_communicate_allowed: bool,
@@ -436,6 +463,15 @@ impl FileDescription for NullOutput {
436463
// We just don't write anything, but report to the user that we did.
437464
finish.call(ecx, Ok(len))
438465
}
466+
467+
fn destroy<'tcx>(
468+
self,
469+
_self_id: FdId,
470+
_communicate_allowed: bool,
471+
_ecx: &mut MiriInterpCx<'tcx>,
472+
) -> InterpResult<'tcx, io::Result<()>> {
473+
interp_ok(Ok(()))
474+
}
439475
}
440476

441477
/// Internal type of a file-descriptor - this is what [`FdTable`] expects

tests/fail-dep/libc/fs/close_stdout.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/fail-dep/libc/fs/close_stdout.stderr

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/pass-dep/libc/libc-fs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ fn main() {
4848
test_nofollow_not_symlink();
4949
#[cfg(target_os = "macos")]
5050
test_ioctl();
51+
test_close_stdout();
5152
}
5253

5354
fn test_file_open_unix_allow_two_args() {
@@ -579,3 +580,11 @@ fn test_ioctl() {
579580
assert_eq!(libc::ioctl(fd, libc::FIOCLEX), 0);
580581
}
581582
}
583+
584+
fn test_close_stdout() {
585+
// This is std library UB, but that's not relevant since we're
586+
// only interacting with libc here.
587+
unsafe {
588+
libc::close(1);
589+
}
590+
}

0 commit comments

Comments
 (0)