# HG changeset patch # User Yuya Nishihara # Date 1586527737 -32400 # Node ID cb5822e6e545495922bdbb493f6c31b7867ade9b # Parent 1be605526c34c7b98dd98999685645da6be1da7b rust-chg: have attach_io() simply take reference of AsRawFd object We no longer have to deal with the restriction of the Future type. Before, these file objects couldn't be references and that's the only reason why we had to make stderr an Option. This fixes future type deduction issue of stderr = None, where rustc would complain that T of Option couldn't be deduced. Differential Revision: https://phab.mercurial-scm.org/D8443 diff -r 1be605526c34 -r cb5822e6e545 rust/chg/src/attachio.rs --- a/rust/chg/src/attachio.rs Fri Apr 10 22:07:11 2020 +0900 +++ b/rust/chg/src/attachio.rs Fri Apr 10 23:08:57 2020 +0900 @@ -21,14 +21,12 @@ /// 3. Client sends fds with 1-byte dummy payload in response. /// 4. Server returns the number of the fds received. /// -/// If the stderr is omitted, it will be redirected to the stdout. This -/// allows us to attach the pager stdin to both stdout and stderr, and -/// dispose of the client-side handle once attached. +/// The client-side fds may be dropped once duplicated to the server. pub async fn attach_io( proto: &mut Protocol, - stdin: impl AsRawFd, - stdout: impl AsRawFd, - stderr: Option, + stdin: &impl AsRawFd, + stdout: &impl AsRawFd, + stderr: &impl AsRawFd, ) -> io::Result<()> { // TODO: unindent { @@ -56,7 +54,7 @@ let sock_fd = proto.as_raw_fd(); let ifd = stdin.as_raw_fd(); let ofd = stdout.as_raw_fd(); - let efd = stderr.as_ref().map_or(ofd, |f| f.as_raw_fd()); + let efd = stderr.as_raw_fd(); procutil::send_raw_fds(sock_fd, &[ifd, ofd, efd])?; } ChannelMessage::InputRequest(..)