Rollup merge of #128162 - ChrisDenton:cleanup, r=joboet · model-checking/verify-rust-std@1e3976b (original) (raw)

1

``

`-

use crate::io;

`

2

1

`use crate::os::windows::io::{

`

3

2

`AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,

`

4

3

`};

`

5

4

`use crate::pipe::{PipeReader, PipeWriter};

`

6

5

`use crate::process::Stdio;

`

``

6

`+

use crate::sys::c;

`

7

7

`use crate::sys::handle::Handle;

`

8

``

`-

use crate::sys::pipe::unnamed_anon_pipe;

`

9

8

`use crate::sys_common::{FromInner, IntoInner};

`

``

9

`+

use crate::{io, ptr};

`

10

10

``

11

``

`-

pub(crate) type AnonPipe = Handle;

`

``

11

`+

pub type AnonPipe = Handle;

`

12

12

``

13

``

`-

#[inline]

`

14

``

`-

pub(crate) fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {

`

15

``

`-

unnamed_anon_pipe().map(|(rx, wx)| (rx.into_inner(), wx.into_inner()))

`

``

13

`+

pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {

`

``

14

`+

let mut read_pipe = c::INVALID_HANDLE_VALUE;

`

``

15

`+

let mut write_pipe = c::INVALID_HANDLE_VALUE;

`

``

16

+

``

17

`+

let ret = unsafe { c::CreatePipe(&mut read_pipe, &mut write_pipe, ptr::null_mut(), 0) };

`

``

18

+

``

19

`+

if ret == 0 {

`

``

20

`+

Err(io::Error::last_os_error())

`

``

21

`+

} else {

`

``

22

`+

unsafe { Ok((Handle::from_raw_handle(read_pipe), Handle::from_raw_handle(write_pipe))) }

`

``

23

`+

}

`

16

24

`}

`

17

25

``

18

26

`#[unstable(feature = "anonymous_pipe", issue = "127154")]

`

`@@ -31,7 +39,7 @@ impl AsRawHandle for PipeReader {

`

31

39

`#[unstable(feature = "anonymous_pipe", issue = "127154")]

`

32

40

`impl FromRawHandle for PipeReader {

`

33

41

`unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {

`

34

``

`-

Self(Handle::from_raw_handle(raw_handle))

`

``

42

`+

unsafe { Self(Handle::from_raw_handle(raw_handle)) }

`

35

43

`}

`

36

44

`}

`

37

45

`#[unstable(feature = "anonymous_pipe", issue = "127154")]

`

`@@ -70,7 +78,7 @@ impl AsRawHandle for PipeWriter {

`

70

78

`#[unstable(feature = "anonymous_pipe", issue = "127154")]

`

71

79

`impl FromRawHandle for PipeWriter {

`

72

80

`unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {

`

73

``

`-

Self(Handle::from_raw_handle(raw_handle))

`

``

81

`+

unsafe { Self(Handle::from_raw_handle(raw_handle)) }

`

74

82

`}

`

75

83

`}

`

76

84

`#[unstable(feature = "anonymous_pipe", issue = "127154")]

`