BurntSushi/same-file

Handle’s std::os::unix::io::IntoRawFd implementation panics on stdin/stdout/stderr

chris-morgan opened this issue · 1 comments

This panics:

std::os::unix::io::IntoRawFd::into_raw_fd(same_file::Handle::stdin().unwrap())

The Option<File> field is treated carelessly, and so the reassuring “unwrapping won’t panic” comment in the Drop implementation is wrong.

Really, Option is the wrong tool to use here; it should be ManuallyDrop these days (✓ available within the current MSRV).

(I found this as part of a detailed review.)