]> git.lizzy.rs Git - rust.git/commitdiff
std: Remove public bool,tuple,unit modules
authorAlex Crichton <alex@alexcrichton.com>
Fri, 19 Dec 2014 03:13:32 +0000 (19:13 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 19 Dec 2014 03:13:32 +0000 (19:13 -0800)
This commit modifies rustdoc to not require these empty modules to be public in
the standard library. The modules still remain as a location to attach
documentation to, but the modules themselves are now private (don't have to
commit to an API). The documentation for the standard library now shows all of
the primitive types on the main index page.

12 files changed:
src/libcore/bool.rs [deleted file]
src/libcore/lib.rs
src/libcore/tuple.rs [new file with mode: 0644]
src/libcore/tuple/mod.rs [deleted file]
src/libcore/tuple/unit.rs [deleted file]
src/librustdoc/clean/mod.rs
src/libstd/bool.rs [new file with mode: 0644]
src/libstd/lib.rs
src/libstd/prelude.rs
src/libstd/tuple.rs [new file with mode: 0644]
src/libstd/unit.rs [new file with mode: 0644]
src/test/compile-fail/issue-9957.rs

diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs
deleted file mode 100644 (file)
index 9d2ea81..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The boolean type
-
-#![doc(primitive = "bool")]
-#![unstable = "this module is purely for documentation and it will likely be \
-               removed from the public api"]
-
index 729cb69193e63d06a5dc8698ecae39f2ea4d101c..9b6622a7127d5de26b2e20c4b9f44566cbac6cd1 100644 (file)
 
 pub mod any;
 pub mod atomic;
-pub mod bool;
 pub mod borrow;
 pub mod cell;
 pub mod char;
 pub mod simd;
 pub mod slice;
 pub mod str;
-pub mod tuple;
 pub mod hash;
-// FIXME #15320: primitive documentation needs top-level modules, this
-// should be `core::tuple::unit`.
-#[path = "tuple/unit.rs"]
-pub mod unit;
 pub mod fmt;
 
 // note: does not need to be public
+mod tuple;
 mod array;
 
 #[doc(hidden)]
diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs
new file mode 100644 (file)
index 0000000..4984c8d
--- /dev/null
@@ -0,0 +1,329 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Operations on tuples
+//!
+//! To access a single element of a tuple one can use the following
+//! methods:
+//!
+//! * `valN` - returns a value of _N_-th element
+//! * `refN` - returns a reference to _N_-th element
+//! * `mutN` - returns a mutable reference to _N_-th element
+//!
+//! Indexing starts from zero, so `val0` returns first value, `val1`
+//! returns second value, and so on. In general, a tuple with _S_
+//! elements provides aforementioned methods suffixed with numbers
+//! from `0` to `S-1`. Traits which contain these methods are
+//! implemented for tuples with up to 12 elements.
+//!
+//! If every type inside a tuple implements one of the following
+//! traits, then a tuple itself also implements it.
+//!
+//! * `Clone`
+//! * `PartialEq`
+//! * `Eq`
+//! * `PartialOrd`
+//! * `Ord`
+//! * `Default`
+//!
+//! # Examples
+//!
+//! Using methods:
+//!
+//! ```
+//! #[allow(deprecated)]
+//! # fn main() {
+//! let pair = ("pi", 3.14f64);
+//! assert_eq!(pair.val0(), "pi");
+//! assert_eq!(pair.val1(), 3.14f64);
+//! # }
+//! ```
+//!
+//! Using traits implemented for tuples:
+//!
+//! ```
+//! use std::default::Default;
+//!
+//! let a = (1i, 2i);
+//! let b = (3i, 4i);
+//! assert!(a != b);
+//!
+//! let c = b.clone();
+//! assert!(b == c);
+//!
+//! let d : (u32, f32) = Default::default();
+//! assert_eq!(d, (0u32, 0.0f32));
+//! ```
+
+#![stable]
+
+#[unstable = "this is just a documentation module and should not be part \
+              of the public api"]
+
+use clone::Clone;
+use cmp::*;
+use default::Default;
+use option::Option;
+use option::Option::Some;
+
+// FIXME(#19630) Remove this work-around
+macro_rules! e {
+    ($e:expr) => { $e }
+}
+
+// macro for implementing n-ary tuple functions and operations
+macro_rules! tuple_impls {
+    ($(
+        $Tuple:ident {
+            $(($valN:ident, $refN:ident, $mutN:ident, $idx:tt) -> $T:ident)+
+        }
+    )+) => {
+        $(
+            #[allow(missing_docs)]
+            #[deprecated]
+            pub trait $Tuple<$($T),+> {
+                $(
+                    #[deprecated = "use tuple indexing: `tuple.N`"]
+                    fn $valN(self) -> $T;
+                    #[deprecated = "use tuple indexing: `&tuple.N`"]
+                    fn $refN<'a>(&'a self) -> &'a $T;
+                    #[deprecated = "use tuple indexing: `&mut tuple.N`"]
+                    fn $mutN<'a>(&'a mut self) -> &'a mut $T;
+                 )+
+            }
+
+            impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) {
+                $(
+                    #[inline]
+                    #[allow(unused_variables)]
+                    #[deprecated = "use tuple indexing: `tuple.N`"]
+                    fn $valN(self) -> $T {
+                        e!(self.$idx)
+                    }
+
+                    #[inline]
+                    #[allow(unused_variables)]
+                    #[deprecated = "use tuple indexing: `&tuple.N`"]
+                    fn $refN<'a>(&'a self) -> &'a $T {
+                        e!(&self.$idx)
+                    }
+
+                    #[inline]
+                    #[allow(unused_variables)]
+                    #[deprecated = "use tuple indexing: &mut tuple.N"]
+                    fn $mutN<'a>(&'a mut self) -> &'a mut $T {
+                        e!(&mut self.$idx)
+                    }
+                )+
+            }
+
+            #[unstable = "waiting for Clone to stabilize"]
+            impl<$($T:Clone),+> Clone for ($($T,)+) {
+                fn clone(&self) -> ($($T,)+) {
+                    ($(e!(self.$idx.clone()),)+)
+                }
+            }
+
+            #[unstable = "waiting for PartialEq to stabilize"]
+            impl<$($T:PartialEq),+> PartialEq for ($($T,)+) {
+                #[inline]
+                fn eq(&self, other: &($($T,)+)) -> bool {
+                    e!($(self.$idx == other.$idx)&&+)
+                }
+                #[inline]
+                fn ne(&self, other: &($($T,)+)) -> bool {
+                    e!($(self.$idx != other.$idx)||+)
+                }
+            }
+
+            #[unstable = "waiting for Eq to stabilize"]
+            impl<$($T:Eq),+> Eq for ($($T,)+) {}
+
+            #[unstable = "waiting for PartialOrd to stabilize"]
+            impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
+                #[inline]
+                fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
+                    lexical_partial_cmp!($(self.$idx, other.$idx),+)
+                }
+                #[inline]
+                fn lt(&self, other: &($($T,)+)) -> bool {
+                    lexical_ord!(lt, $(self.$idx, other.$idx),+)
+                }
+                #[inline]
+                fn le(&self, other: &($($T,)+)) -> bool {
+                    lexical_ord!(le, $(self.$idx, other.$idx),+)
+                }
+                #[inline]
+                fn ge(&self, other: &($($T,)+)) -> bool {
+                    lexical_ord!(ge, $(self.$idx, other.$idx),+)
+                }
+                #[inline]
+                fn gt(&self, other: &($($T,)+)) -> bool {
+                    lexical_ord!(gt, $(self.$idx, other.$idx),+)
+                }
+            }
+
+            #[unstable = "waiting for Ord to stabilize"]
+            impl<$($T:Ord),+> Ord for ($($T,)+) {
+                #[inline]
+                fn cmp(&self, other: &($($T,)+)) -> Ordering {
+                    lexical_cmp!($(self.$idx, other.$idx),+)
+                }
+            }
+
+            #[stable]
+            impl<$($T:Default),+> Default for ($($T,)+) {
+                #[stable]
+                #[inline]
+                fn default() -> ($($T,)+) {
+                    ($({ let x: $T = Default::default(); x},)+)
+                }
+            }
+        )+
+    }
+}
+
+// Constructs an expression that performs a lexical ordering using method $rel.
+// The values are interleaved, so the macro invocation for
+// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_ord!(lt, a1, b1, a2, b2,
+// a3, b3)` (and similarly for `lexical_cmp`)
+macro_rules! lexical_ord {
+    ($rel: ident, $a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+        if $a != $b { lexical_ord!($rel, $a, $b) }
+        else { lexical_ord!($rel, $($rest_a, $rest_b),+) }
+    };
+    ($rel: ident, $a:expr, $b:expr) => { ($a) . $rel (& $b) };
+}
+
+macro_rules! lexical_partial_cmp {
+    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+        match ($a).partial_cmp(&$b) {
+            Some(Equal) => lexical_partial_cmp!($($rest_a, $rest_b),+),
+            ordering   => ordering
+        }
+    };
+    ($a:expr, $b:expr) => { ($a).partial_cmp(&$b) };
+}
+
+macro_rules! lexical_cmp {
+    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+        match ($a).cmp(&$b) {
+            Equal => lexical_cmp!($($rest_a, $rest_b),+),
+            ordering   => ordering
+        }
+    };
+    ($a:expr, $b:expr) => { ($a).cmp(&$b) };
+}
+
+tuple_impls! {
+    Tuple1 {
+        (val0, ref0, mut0, 0) -> A
+    }
+    Tuple2 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+    }
+    Tuple3 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+    }
+    Tuple4 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+    }
+    Tuple5 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+        (val4, ref4, mut4, 4) -> E
+    }
+    Tuple6 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+        (val4, ref4, mut4, 4) -> E
+        (val5, ref5, mut5, 5) -> F
+    }
+    Tuple7 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+        (val4, ref4, mut4, 4) -> E
+        (val5, ref5, mut5, 5) -> F
+        (val6, ref6, mut6, 6) -> G
+    }
+    Tuple8 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+        (val4, ref4, mut4, 4) -> E
+        (val5, ref5, mut5, 5) -> F
+        (val6, ref6, mut6, 6) -> G
+        (val7, ref7, mut7, 7) -> H
+    }
+    Tuple9 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+        (val4, ref4, mut4, 4) -> E
+        (val5, ref5, mut5, 5) -> F
+        (val6, ref6, mut6, 6) -> G
+        (val7, ref7, mut7, 7) -> H
+        (val8, ref8, mut8, 8) -> I
+    }
+    Tuple10 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+        (val4, ref4, mut4, 4) -> E
+        (val5, ref5, mut5, 5) -> F
+        (val6, ref6, mut6, 6) -> G
+        (val7, ref7, mut7, 7) -> H
+        (val8, ref8, mut8, 8) -> I
+        (val9, ref9, mut9, 9) -> J
+    }
+    Tuple11 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+        (val4, ref4, mut4, 4) -> E
+        (val5, ref5, mut5, 5) -> F
+        (val6, ref6, mut6, 6) -> G
+        (val7, ref7, mut7, 7) -> H
+        (val8, ref8, mut8, 8) -> I
+        (val9, ref9, mut9, 9) -> J
+        (val10, ref10, mut10, 10) -> K
+    }
+    Tuple12 {
+        (val0, ref0, mut0, 0) -> A
+        (val1, ref1, mut1, 1) -> B
+        (val2, ref2, mut2, 2) -> C
+        (val3, ref3, mut3, 3) -> D
+        (val4, ref4, mut4, 4) -> E
+        (val5, ref5, mut5, 5) -> F
+        (val6, ref6, mut6, 6) -> G
+        (val7, ref7, mut7, 7) -> H
+        (val8, ref8, mut8, 8) -> I
+        (val9, ref9, mut9, 9) -> J
+        (val10, ref10, mut10, 10) -> K
+        (val11, ref11, mut11, 11) -> L
+    }
+}
+
diff --git a/src/libcore/tuple/mod.rs b/src/libcore/tuple/mod.rs
deleted file mode 100644 (file)
index 5ea84f7..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Operations on tuples
-//!
-//! To access a single element of a tuple one can use the following
-//! methods:
-//!
-//! * `valN` - returns a value of _N_-th element
-//! * `refN` - returns a reference to _N_-th element
-//! * `mutN` - returns a mutable reference to _N_-th element
-//!
-//! Indexing starts from zero, so `val0` returns first value, `val1`
-//! returns second value, and so on. In general, a tuple with _S_
-//! elements provides aforementioned methods suffixed with numbers
-//! from `0` to `S-1`. Traits which contain these methods are
-//! implemented for tuples with up to 12 elements.
-//!
-//! If every type inside a tuple implements one of the following
-//! traits, then a tuple itself also implements it.
-//!
-//! * `Clone`
-//! * `PartialEq`
-//! * `Eq`
-//! * `PartialOrd`
-//! * `Ord`
-//! * `Default`
-//!
-//! # Examples
-//!
-//! Using methods:
-//!
-//! ```
-//! #[allow(deprecated)]
-//! # fn main() {
-//! let pair = ("pi", 3.14f64);
-//! assert_eq!(pair.val0(), "pi");
-//! assert_eq!(pair.val1(), 3.14f64);
-//! # }
-//! ```
-//!
-//! Using traits implemented for tuples:
-//!
-//! ```
-//! use std::default::Default;
-//!
-//! let a = (1i, 2i);
-//! let b = (3i, 4i);
-//! assert!(a != b);
-//!
-//! let c = b.clone();
-//! assert!(b == c);
-//!
-//! let d : (u32, f32) = Default::default();
-//! assert_eq!(d, (0u32, 0.0f32));
-//! ```
-
-#![doc(primitive = "tuple")]
-#![stable]
-
-#[unstable = "this is just a documentation module and should not be part \
-              of the public api"]
-pub use unit;
-
-use clone::Clone;
-use cmp::*;
-use default::Default;
-use option::Option;
-use option::Option::Some;
-
-// FIXME(#19630) Remove this work-around
-macro_rules! e {
-    ($e:expr) => { $e }
-}
-
-// macro for implementing n-ary tuple functions and operations
-macro_rules! tuple_impls {
-    ($(
-        $Tuple:ident {
-            $(($valN:ident, $refN:ident, $mutN:ident, $idx:tt) -> $T:ident)+
-        }
-    )+) => {
-        $(
-            #[allow(missing_docs)]
-            #[deprecated]
-            pub trait $Tuple<$($T),+> {
-                $(
-                    #[deprecated = "use tuple indexing: `tuple.N`"]
-                    fn $valN(self) -> $T;
-                    #[deprecated = "use tuple indexing: `&tuple.N`"]
-                    fn $refN<'a>(&'a self) -> &'a $T;
-                    #[deprecated = "use tuple indexing: `&mut tuple.N`"]
-                    fn $mutN<'a>(&'a mut self) -> &'a mut $T;
-                 )+
-            }
-
-            impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) {
-                $(
-                    #[inline]
-                    #[allow(unused_variables)]
-                    #[deprecated = "use tuple indexing: `tuple.N`"]
-                    fn $valN(self) -> $T {
-                        e!(self.$idx)
-                    }
-
-                    #[inline]
-                    #[allow(unused_variables)]
-                    #[deprecated = "use tuple indexing: `&tuple.N`"]
-                    fn $refN<'a>(&'a self) -> &'a $T {
-                        e!(&self.$idx)
-                    }
-
-                    #[inline]
-                    #[allow(unused_variables)]
-                    #[deprecated = "use tuple indexing: &mut tuple.N"]
-                    fn $mutN<'a>(&'a mut self) -> &'a mut $T {
-                        e!(&mut self.$idx)
-                    }
-                )+
-            }
-
-            #[unstable = "waiting for Clone to stabilize"]
-            impl<$($T:Clone),+> Clone for ($($T,)+) {
-                fn clone(&self) -> ($($T,)+) {
-                    ($(e!(self.$idx.clone()),)+)
-                }
-            }
-
-            #[unstable = "waiting for PartialEq to stabilize"]
-            impl<$($T:PartialEq),+> PartialEq for ($($T,)+) {
-                #[inline]
-                fn eq(&self, other: &($($T,)+)) -> bool {
-                    e!($(self.$idx == other.$idx)&&+)
-                }
-                #[inline]
-                fn ne(&self, other: &($($T,)+)) -> bool {
-                    e!($(self.$idx != other.$idx)||+)
-                }
-            }
-
-            #[unstable = "waiting for Eq to stabilize"]
-            impl<$($T:Eq),+> Eq for ($($T,)+) {}
-
-            #[unstable = "waiting for PartialOrd to stabilize"]
-            impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
-                #[inline]
-                fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
-                    lexical_partial_cmp!($(self.$idx, other.$idx),+)
-                }
-                #[inline]
-                fn lt(&self, other: &($($T,)+)) -> bool {
-                    lexical_ord!(lt, $(self.$idx, other.$idx),+)
-                }
-                #[inline]
-                fn le(&self, other: &($($T,)+)) -> bool {
-                    lexical_ord!(le, $(self.$idx, other.$idx),+)
-                }
-                #[inline]
-                fn ge(&self, other: &($($T,)+)) -> bool {
-                    lexical_ord!(ge, $(self.$idx, other.$idx),+)
-                }
-                #[inline]
-                fn gt(&self, other: &($($T,)+)) -> bool {
-                    lexical_ord!(gt, $(self.$idx, other.$idx),+)
-                }
-            }
-
-            #[unstable = "waiting for Ord to stabilize"]
-            impl<$($T:Ord),+> Ord for ($($T,)+) {
-                #[inline]
-                fn cmp(&self, other: &($($T,)+)) -> Ordering {
-                    lexical_cmp!($(self.$idx, other.$idx),+)
-                }
-            }
-
-            #[stable]
-            impl<$($T:Default),+> Default for ($($T,)+) {
-                #[stable]
-                #[inline]
-                fn default() -> ($($T,)+) {
-                    ($({ let x: $T = Default::default(); x},)+)
-                }
-            }
-        )+
-    }
-}
-
-// Constructs an expression that performs a lexical ordering using method $rel.
-// The values are interleaved, so the macro invocation for
-// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_ord!(lt, a1, b1, a2, b2,
-// a3, b3)` (and similarly for `lexical_cmp`)
-macro_rules! lexical_ord {
-    ($rel: ident, $a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
-        if $a != $b { lexical_ord!($rel, $a, $b) }
-        else { lexical_ord!($rel, $($rest_a, $rest_b),+) }
-    };
-    ($rel: ident, $a:expr, $b:expr) => { ($a) . $rel (& $b) };
-}
-
-macro_rules! lexical_partial_cmp {
-    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
-        match ($a).partial_cmp(&$b) {
-            Some(Equal) => lexical_partial_cmp!($($rest_a, $rest_b),+),
-            ordering   => ordering
-        }
-    };
-    ($a:expr, $b:expr) => { ($a).partial_cmp(&$b) };
-}
-
-macro_rules! lexical_cmp {
-    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
-        match ($a).cmp(&$b) {
-            Equal => lexical_cmp!($($rest_a, $rest_b),+),
-            ordering   => ordering
-        }
-    };
-    ($a:expr, $b:expr) => { ($a).cmp(&$b) };
-}
-
-tuple_impls! {
-    Tuple1 {
-        (val0, ref0, mut0, 0) -> A
-    }
-    Tuple2 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-    }
-    Tuple3 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-    }
-    Tuple4 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-    }
-    Tuple5 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-        (val4, ref4, mut4, 4) -> E
-    }
-    Tuple6 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-        (val4, ref4, mut4, 4) -> E
-        (val5, ref5, mut5, 5) -> F
-    }
-    Tuple7 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-        (val4, ref4, mut4, 4) -> E
-        (val5, ref5, mut5, 5) -> F
-        (val6, ref6, mut6, 6) -> G
-    }
-    Tuple8 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-        (val4, ref4, mut4, 4) -> E
-        (val5, ref5, mut5, 5) -> F
-        (val6, ref6, mut6, 6) -> G
-        (val7, ref7, mut7, 7) -> H
-    }
-    Tuple9 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-        (val4, ref4, mut4, 4) -> E
-        (val5, ref5, mut5, 5) -> F
-        (val6, ref6, mut6, 6) -> G
-        (val7, ref7, mut7, 7) -> H
-        (val8, ref8, mut8, 8) -> I
-    }
-    Tuple10 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-        (val4, ref4, mut4, 4) -> E
-        (val5, ref5, mut5, 5) -> F
-        (val6, ref6, mut6, 6) -> G
-        (val7, ref7, mut7, 7) -> H
-        (val8, ref8, mut8, 8) -> I
-        (val9, ref9, mut9, 9) -> J
-    }
-    Tuple11 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-        (val4, ref4, mut4, 4) -> E
-        (val5, ref5, mut5, 5) -> F
-        (val6, ref6, mut6, 6) -> G
-        (val7, ref7, mut7, 7) -> H
-        (val8, ref8, mut8, 8) -> I
-        (val9, ref9, mut9, 9) -> J
-        (val10, ref10, mut10, 10) -> K
-    }
-    Tuple12 {
-        (val0, ref0, mut0, 0) -> A
-        (val1, ref1, mut1, 1) -> B
-        (val2, ref2, mut2, 2) -> C
-        (val3, ref3, mut3, 3) -> D
-        (val4, ref4, mut4, 4) -> E
-        (val5, ref5, mut5, 5) -> F
-        (val6, ref6, mut6, 6) -> G
-        (val7, ref7, mut7, 7) -> H
-        (val8, ref8, mut8, 8) -> I
-        (val9, ref9, mut9, 9) -> J
-        (val10, ref10, mut10, 10) -> K
-        (val11, ref11, mut11, 11) -> L
-    }
-}
-
diff --git a/src/libcore/tuple/unit.rs b/src/libcore/tuple/unit.rs
deleted file mode 100644 (file)
index 7f89f0e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![doc(primitive = "unit")]
-#![unstable = "this module is purely for documentation and it will likely be \
-               removed from the public api"]
-
-//! The `()` type, sometimes called "unit" or "nil".
-//!
-//! The `()` type has exactly one value `()`, and is used when there
-//! is no other meaningful value that could be returned. `()` is most
-//! commonly seen implicitly: functions without a `-> ...` implicitly
-//! have return type `()`, that is, these are equivalent:
-//!
-//! ```rust
-//! fn long() -> () {}
-//!
-//! fn short() {}
-//! ```
-//!
-//! The semicolon `;` can be used to discard the result of an
-//! expression at the end of a block, making the expression (and thus
-//! the block) evaluate to `()`. For example,
-//!
-//! ```rust
-//! fn returns_i64() -> i64 {
-//!     1i64
-//! }
-//! fn returns_unit() {
-//!     1i64;
-//! }
-//!
-//! let is_i64 = {
-//!     returns_i64()
-//! };
-//! let is_unit = {
-//!     returns_i64();
-//! };
-//! ```
index d640f055388cbd692dff0470ea4e737fcaa9b3c6..9a75890e28321a091c427866d608e35eeb59c04e 100644 (file)
@@ -163,33 +163,24 @@ fn clean(&self, cx: &DocContext) -> Crate {
             };
             let mut tmp = Vec::new();
             for child in m.items.iter_mut() {
-                let inner = match child.inner {
-                    ModuleItem(ref mut m) => m,
+                match child.inner {
+                    ModuleItem(..) => {}
                     _ => continue,
-                };
+                }
                 let prim = match PrimitiveType::find(child.attrs.as_slice()) {
                     Some(prim) => prim,
                     None => continue,
                 };
                 primitives.push(prim);
-                let mut i = Item {
+                tmp.push(Item {
                     source: Span::empty(),
                     name: Some(prim.to_url_str().to_string()),
-                    attrs: Vec::new(),
-                    visibility: None,
+                    attrs: child.attrs.clone(),
+                    visibility: Some(ast::Public),
                     stability: None,
                     def_id: ast_util::local_def(prim.to_node_id()),
                     inner: PrimitiveItem(prim),
-                };
-                // Push one copy to get indexed for the whole crate, and push a
-                // another copy in the proper location which will actually get
-                // documented. The first copy will also serve as a redirect to
-                // the other copy.
-                tmp.push(i.clone());
-                i.visibility = Some(ast::Public);
-                i.attrs = child.attrs.clone();
-                inner.items.push(i);
-
+                });
             }
             m.items.extend(tmp.into_iter());
         }
diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs
new file mode 100644 (file)
index 0000000..bbaab5e
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The boolean type
+
+#![doc(primitive = "bool")]
+#![stable]
+
index e99aba9b673804db7736d9508a4b581286ffb85d..d34fcc9011b4dec200948e82efaa716690416cf6 100644 (file)
 // NB: These reexports are in the order they should be listed in rustdoc
 
 pub use core::any;
-pub use core::bool;
 pub use core::borrow;
 pub use core::cell;
 pub use core::clone;
 pub use core::ptr;
 pub use core::raw;
 pub use core::simd;
-pub use core::tuple;
-// FIXME #15320: primitive documentation needs top-level modules, this
-// should be `std::tuple::unit`.
-pub use core::unit;
 pub use core::result;
 pub use core::option;
 
 pub mod rt;
 mod failure;
 
+// Documentation for primitive types
+
+mod bool;
+mod unit;
+mod tuple;
+
 // A curious inner-module that's not exported that contains the binding
 // 'std' so that macro-expanded references to std::error and such
 // can be resolved within libstd.
index 8b6575b6bc1cc8ae37ca0e6cd827f54138fd0774..f77627711a71f8a1793069c12f6abe4b57c5b301 100644 (file)
@@ -81,9 +81,9 @@
 #[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek, BufferPrelude};
 #[doc(no_inline)] pub use str::{Str, StrVector, StrPrelude};
 #[doc(no_inline)] pub use str::{StrAllocating, UnicodeStrPrelude};
-#[doc(no_inline)] pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
-#[doc(no_inline)] pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
-#[doc(no_inline)] pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
+#[doc(no_inline)] pub use core::prelude::{Tuple1, Tuple2, Tuple3, Tuple4};
+#[doc(no_inline)] pub use core::prelude::{Tuple5, Tuple6, Tuple7, Tuple8};
+#[doc(no_inline)] pub use core::prelude::{Tuple9, Tuple10, Tuple11, Tuple12};
 #[doc(no_inline)] pub use slice::AsSlice;
 #[doc(no_inline)] pub use slice::{VectorVector, PartialEqSliceExt};
 #[doc(no_inline)] pub use slice::{CloneSliceExt, OrdSliceExt, SliceExt};
diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs
new file mode 100644 (file)
index 0000000..5cd60d6
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Operations on tuples
+//!
+//! To access a single element of a tuple one can use the following
+//! methods:
+//!
+//! * `valN` - returns a value of _N_-th element
+//! * `refN` - returns a reference to _N_-th element
+//! * `mutN` - returns a mutable reference to _N_-th element
+//!
+//! Indexing starts from zero, so `val0` returns first value, `val1`
+//! returns second value, and so on. In general, a tuple with _S_
+//! elements provides aforementioned methods suffixed with numbers
+//! from `0` to `S-1`. Traits which contain these methods are
+//! implemented for tuples with up to 12 elements.
+//!
+//! If every type inside a tuple implements one of the following
+//! traits, then a tuple itself also implements it.
+//!
+//! * `Clone`
+//! * `PartialEq`
+//! * `Eq`
+//! * `PartialOrd`
+//! * `Ord`
+//! * `Default`
+//!
+//! # Examples
+//!
+//! Using methods:
+//!
+//! ```
+//! #[allow(deprecated)]
+//! # fn main() {
+//! let pair = ("pi", 3.14f64);
+//! assert_eq!(pair.val0(), "pi");
+//! assert_eq!(pair.val1(), 3.14f64);
+//! # }
+//! ```
+//!
+//! Using traits implemented for tuples:
+//!
+//! ```
+//! use std::default::Default;
+//!
+//! let a = (1i, 2i);
+//! let b = (3i, 4i);
+//! assert!(a != b);
+//!
+//! let c = b.clone();
+//! assert!(b == c);
+//!
+//! let d : (u32, f32) = Default::default();
+//! assert_eq!(d, (0u32, 0.0f32));
+//! ```
+
+#![doc(primitive = "tuple")]
+#![stable]
diff --git a/src/libstd/unit.rs b/src/libstd/unit.rs
new file mode 100644 (file)
index 0000000..012b175
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![doc(primitive = "unit")]
+#![stable]
+
+//! The `()` type, sometimes called "unit" or "nil".
+//!
+//! The `()` type has exactly one value `()`, and is used when there
+//! is no other meaningful value that could be returned. `()` is most
+//! commonly seen implicitly: functions without a `-> ...` implicitly
+//! have return type `()`, that is, these are equivalent:
+//!
+//! ```rust
+//! fn long() -> () {}
+//!
+//! fn short() {}
+//! ```
+//!
+//! The semicolon `;` can be used to discard the result of an
+//! expression at the end of a block, making the expression (and thus
+//! the block) evaluate to `()`. For example,
+//!
+//! ```rust
+//! fn returns_i64() -> i64 {
+//!     1i64
+//! }
+//! fn returns_unit() {
+//!     1i64;
+//! }
+//!
+//! let is_i64 = {
+//!     returns_i64()
+//! };
+//! let is_unit = {
+//!     returns_i64();
+//! };
+//! ```
index a90a1ac1a75f0ed66403f2e1b5c4a0cab1d87816..573d847cbe3b88cbce5ee7fcd1ec5785343b4a65 100644 (file)
@@ -11,5 +11,5 @@
 pub extern crate core; //~ ERROR: `pub` visibility is not allowed
 
 fn main() {
-    pub use std::bool; //~ ERROR: imports in functions are never reachable
+    pub use std::uint; //~ ERROR: imports in functions are never reachable
 }