about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-04-05 12:44:35 -0400
committerGitHub <noreply@github.com>2017-04-05 12:44:35 -0400
commit6251e4bb35517e7dc4d229e370752fd718ddecff (patch)
treef23395db1e4d59f45cb1b219b08d065775b10d23 /src/libstd
parent5935fe47a9cf95b4577cad2efb5cddcd5d2b3e04 (diff)
parent9c1b7ae3f37a34a39f837ad8ae90da3fad052798 (diff)
downloadrust-6251e4bb35517e7dc4d229e370752fd718ddecff.tar.gz
rust-6251e4bb35517e7dc4d229e370752fd718ddecff.zip
Rollup merge of #41035 - jmesmon:revert-bad-raw-fd-impls, r=aturon
Revert "Implement AsRawFd/IntoRawFd for RawFd"

This reverts commit 2cf686f2cdd6446a3cd47df0305ead40fabe85df (#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
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys/unix/ext/io.rs15
1 files changed, 0 insertions, 15 deletions
diff --git a/src/libstd/sys/unix/ext/io.rs b/src/libstd/sys/unix/ext/io.rs
index 75aa72e3cff..296235e173d 100644
--- a/src/libstd/sys/unix/ext/io.rs
+++ b/src/libstd/sys/unix/ext/io.rs
@@ -73,13 +73,6 @@ pub trait IntoRawFd {
 }
 
 #[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 {
         self.as_inner().fd().raw()
@@ -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 {