Skip to content

Commit

Permalink
Rollup merge of rust-lang#41035 - jmesmon:revert-bad-raw-fd-impls, r=…
Browse files Browse the repository at this point in the history
…aturon

Revert "Implement AsRawFd/IntoRawFd for RawFd"

This reverts commit 2cf686f (rust-lang#40842)

RawFd is a type alias for c_int, which is itself a type alias for i32.
As a result, adding AsRawFd and IntoRawFd impls for RawFd actually adds
them for i32.

As a result, the reverted commit makes this valid:

```
use std::os::unix::io::AsRawFd;

fn arf<T: AsRawFd>(_: T) {}

fn main() {
    arf(32i32)
}
```

Implimenting AsRawFd and IntoRawFd for i32 breaks the promises of both
those traits that their methods return a valid RawFd.

r? @aturon
cc @Mic92 @kamalmarhubi
  • Loading branch information
frewsxcv authored Apr 5, 2017
2 parents 695588e + 9c1b7ae commit 5b23ae5
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/libstd/sys/unix/ext/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ pub trait IntoRawFd {
fn into_raw_fd(self) -> RawFd;
}

#[stable(feature = "rust1", since = "1.0.0")]
impl AsRawFd for RawFd {
fn as_raw_fd(&self) -> RawFd {
*self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl AsRawFd for fs::File {
fn as_raw_fd(&self) -> RawFd {
Expand All @@ -91,14 +84,6 @@ impl FromRawFd for fs::File {
fs::File::from_inner(sys::fs::File::from_inner(fd))
}
}

#[stable(feature = "into_raw_os", since = "1.4.0")]
impl IntoRawFd for RawFd {
fn into_raw_fd(self) -> RawFd {
self
}
}

#[stable(feature = "into_raw_os", since = "1.4.0")]
impl IntoRawFd for fs::File {
fn into_raw_fd(self) -> RawFd {
Expand Down

0 comments on commit 5b23ae5

Please sign in to comment.