about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-31 15:51:33 -0700
committerbors <bors@rust-lang.org>2014-03-31 15:51:33 -0700
commitb8ef9fd9c9f642ce7b8aed82782a1ed745d08d64 (patch)
tree1e66451d207e19694d62608a8e1724c71796dc00 /src/libnative
parenta7e057d402a345f547e67a326871621472d04035 (diff)
parent37a3131640d0fa2633aa26db7f849d110250ce51 (diff)
downloadrust-b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64.tar.gz
rust-b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64.zip
auto merge of #13184 : alexcrichton/rust/priv-fields, r=brson
This is an implementation of a portion of [RFC #4](https://github.com/rust-lang/rfcs/blob/master/active/0004-private-fields.md). This PR makes named struct fields private by default (as opposed to inherited by default).

The only real meaty change is the first commit to `rustc`, all other commits are just fallout of that change.

Summary of changes made:

* Named fields are private by default *everywhere*
* The `priv` keyword is now default-deny on named fields (done in a "lint" pass in privacy)

Changes yet to be done (before the RFC is closed)

* Change tuple structs to have private fields by default
* Remove `priv` enum variants
* Make `priv` a reserved keyword
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/file_unix.rs6
-rw-r--r--src/libnative/io/file_win32.rs2
-rw-r--r--src/libnative/io/mod.rs2
-rw-r--r--src/libnative/io/net.rs8
-rw-r--r--src/libnative/io/pipe_unix.rs8
-rw-r--r--src/libnative/io/pipe_win32.rs14
-rw-r--r--src/libnative/io/process.rs6
-rw-r--r--src/libnative/io/timer_other.rs4
-rw-r--r--src/libnative/io/timer_timerfd.rs20
-rw-r--r--src/libnative/io/timer_win32.rs4
-rw-r--r--src/libnative/lib.rs2
11 files changed, 39 insertions, 37 deletions
diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs
index 2e33110b700..143228b14e9 100644
--- a/src/libnative/io/file_unix.rs
+++ b/src/libnative/io/file_unix.rs
@@ -30,7 +30,7 @@ struct Inner {
 }
 
 pub struct FileDesc {
-    priv inner: UnsafeArc<Inner>
+    inner: UnsafeArc<Inner>
 }
 
 impl FileDesc {
@@ -216,8 +216,8 @@ impl Drop for Inner {
 }
 
 pub struct CFile {
-    priv file: *libc::FILE,
-    priv fd: FileDesc,
+    file: *libc::FILE,
+    fd: FileDesc,
 }
 
 impl CFile {
diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs
index d9d7fbbce9c..c19e81b5de4 100644
--- a/src/libnative/io/file_win32.rs
+++ b/src/libnative/io/file_win32.rs
@@ -34,7 +34,7 @@ struct Inner {
 }
 
 pub struct FileDesc {
-    priv inner: UnsafeArc<Inner>
+    inner: UnsafeArc<Inner>
 }
 
 impl FileDesc {
diff --git a/src/libnative/io/mod.rs b/src/libnative/io/mod.rs
index 3536ec7dec6..e6e9cbb7ce3 100644
--- a/src/libnative/io/mod.rs
+++ b/src/libnative/io/mod.rs
@@ -215,7 +215,7 @@ fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
 /// Implementation of rt::rtio's IoFactory trait to generate handles to the
 /// native I/O functionality.
 pub struct IoFactory {
-    priv cannot_construct_outside_of_this_module: ()
+    cannot_construct_outside_of_this_module: ()
 }
 
 impl IoFactory {
diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs
index 6f6ddeec86b..bf751be1f7f 100644
--- a/src/libnative/io/net.rs
+++ b/src/libnative/io/net.rs
@@ -237,7 +237,7 @@ pub fn init() {
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct TcpStream {
-    priv inner: UnsafeArc<Inner>,
+    inner: UnsafeArc<Inner>,
 }
 
 struct Inner {
@@ -373,7 +373,7 @@ impl Drop for Inner {
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct TcpListener {
-    priv inner: UnsafeArc<Inner>,
+    inner: UnsafeArc<Inner>,
 }
 
 impl TcpListener {
@@ -430,7 +430,7 @@ impl rtio::RtioSocket for TcpListener {
 }
 
 pub struct TcpAcceptor {
-    priv listener: TcpListener,
+    listener: TcpListener,
 }
 
 impl TcpAcceptor {
@@ -474,7 +474,7 @@ impl rtio::RtioTcpAcceptor for TcpAcceptor {
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct UdpSocket {
-    priv inner: UnsafeArc<Inner>,
+    inner: UnsafeArc<Inner>,
 }
 
 impl UdpSocket {
diff --git a/src/libnative/io/pipe_unix.rs b/src/libnative/io/pipe_unix.rs
index e25571d02c9..fb9ac27d830 100644
--- a/src/libnative/io/pipe_unix.rs
+++ b/src/libnative/io/pipe_unix.rs
@@ -106,7 +106,7 @@ fn bind(addr: &CString, ty: libc::c_int) -> IoResult<Inner> {
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct UnixStream {
-    priv inner: UnsafeArc<Inner>,
+    inner: UnsafeArc<Inner>,
 }
 
 impl UnixStream {
@@ -160,7 +160,7 @@ impl rtio::RtioPipe for UnixStream {
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct UnixDatagram {
-    priv inner: UnsafeArc<Inner>,
+    inner: UnsafeArc<Inner>,
 }
 
 impl UnixDatagram {
@@ -231,7 +231,7 @@ impl UnixDatagram {
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct UnixListener {
-    priv inner: Inner,
+    inner: Inner,
 }
 
 impl UnixListener {
@@ -256,7 +256,7 @@ impl rtio::RtioUnixListener for UnixListener {
 }
 
 pub struct UnixAcceptor {
-    priv listener: UnixListener,
+    listener: UnixListener,
 }
 
 impl UnixAcceptor {
diff --git a/src/libnative/io/pipe_win32.rs b/src/libnative/io/pipe_win32.rs
index d629e5867c9..36f2dc7d65c 100644
--- a/src/libnative/io/pipe_win32.rs
+++ b/src/libnative/io/pipe_win32.rs
@@ -154,9 +154,9 @@ unsafe fn pipe(name: *u16, init: bool) -> libc::HANDLE {
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct UnixStream {
-    priv inner: UnsafeArc<Inner>,
-    priv write: Option<Event>,
-    priv read: Option<Event>,
+    inner: UnsafeArc<Inner>,
+    write: Option<Event>,
+    read: Option<Event>,
 }
 
 impl UnixStream {
@@ -349,8 +349,8 @@ impl rtio::RtioPipe for UnixStream {
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct UnixListener {
-    priv handle: libc::HANDLE,
-    priv name: CString,
+    handle: libc::HANDLE,
+    name: CString,
 }
 
 impl UnixListener {
@@ -389,8 +389,8 @@ impl rtio::RtioUnixListener for UnixListener {
 }
 
 pub struct UnixAcceptor {
-    priv listener: UnixListener,
-    priv event: Event,
+    listener: UnixListener,
+    event: Event,
 }
 
 impl UnixAcceptor {
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index b0f2495e98c..c729473eecd 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -31,15 +31,15 @@ use super::file;
  */
 pub struct Process {
     /// The unique id of the process (this should never be negative).
-    priv pid: pid_t,
+    pid: pid_t,
 
     /// A handle to the process - on unix this will always be NULL, but on
     /// windows it will be a HANDLE to the process, which will prevent the
     /// pid being re-used until the handle is closed.
-    priv handle: *(),
+    handle: *(),
 
     /// None until finish() is called.
-    priv exit_code: Option<p::ProcessExit>,
+    exit_code: Option<p::ProcessExit>,
 }
 
 impl Process {
diff --git a/src/libnative/io/timer_other.rs b/src/libnative/io/timer_other.rs
index edd7af312c8..ea237944bad 100644
--- a/src/libnative/io/timer_other.rs
+++ b/src/libnative/io/timer_other.rs
@@ -59,8 +59,8 @@ use io::IoResult;
 use io::timer_helper;
 
 pub struct Timer {
-    priv id: uint,
-    priv inner: Option<~Inner>,
+    id: uint,
+    inner: Option<~Inner>,
 }
 
 struct Inner {
diff --git a/src/libnative/io/timer_timerfd.rs b/src/libnative/io/timer_timerfd.rs
index a8018bec0a6..d7202d9d765 100644
--- a/src/libnative/io/timer_timerfd.rs
+++ b/src/libnative/io/timer_timerfd.rs
@@ -40,8 +40,8 @@ use io::IoResult;
 use io::timer_helper;
 
 pub struct Timer {
-    priv fd: FileDesc,
-    priv on_worker: bool,
+    fd: FileDesc,
+    on_worker: bool,
 }
 
 #[allow(visible_private_types)]
@@ -285,24 +285,24 @@ mod imp {
     #[cfg(target_arch = "x86_64")]
     #[packed]
     pub struct epoll_event {
-        events: u32,
-        data: i64,
+        pub events: u32,
+        pub data: i64,
     }
 
     #[cfg(not(target_arch = "x86_64"))]
     pub struct epoll_event {
-        events: u32,
-        data: i64,
+        pub events: u32,
+        pub data: i64,
     }
 
     pub struct timespec {
-        tv_sec: libc::time_t,
-        tv_nsec: libc::c_long,
+        pub tv_sec: libc::time_t,
+        pub tv_nsec: libc::c_long,
     }
 
     pub struct itimerspec {
-        it_interval: timespec,
-        it_value: timespec,
+        pub it_interval: timespec,
+        pub it_value: timespec,
     }
 
     extern {
diff --git a/src/libnative/io/timer_win32.rs b/src/libnative/io/timer_win32.rs
index cdfe2e0d033..a342afa6854 100644
--- a/src/libnative/io/timer_win32.rs
+++ b/src/libnative/io/timer_win32.rs
@@ -29,8 +29,8 @@ use io::timer_helper;
 use io::IoResult;
 
 pub struct Timer {
-    priv obj: libc::HANDLE,
-    priv on_worker: bool,
+    obj: libc::HANDLE,
+    on_worker: bool,
 }
 
 pub enum Req {
diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs
index d06ca15f30c..06b51b56306 100644
--- a/src/libnative/lib.rs
+++ b/src/libnative/lib.rs
@@ -51,6 +51,8 @@
 #![deny(unused_result, unused_must_use)]
 #![allow(non_camel_case_types)]
 
+#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
+
 // NB this crate explicitly does *not* allow glob imports, please seriously
 //    consider whether they're needed before adding that feature here (the
 //    answer is that you don't need them)