Skip to content

Commit fec23d9

Browse files
committed
Auto merge of #27168 - brson:stdprim, r=steveklabnik
This makes the primitive descriptions on the front page read properly as descriptions of types and not of the associated modules. Having the primitive and module docs derived from the same source causes problems, primarily that they can't contain hyperlinks cross-referencing each other. This crates dedicated private modules in `std` to document the primitive types, then for all primitives that have a corresponding module, puts hyperlinks in moth the primitive docs and the module docs cross-linking each other. This should help clear up confusion when readers find themselves on the wrong page. This also removes all the duplicate `#[doc(primitive)]` tags in various places (especially core), so the core docs will no longer attempt to document the primitives for now. Seems like an acceptable tradeoff to get some cleanup for std.
2 parents 2afe47d + 778c89c commit fec23d9

40 files changed

+478
-344
lines changed

src/libcollections/slice.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Utilities for slice manipulation
11+
//! A dynamically-sized view into a contiguous sequence, `[T]`.
1212
//!
13-
//! The `slice` module contains useful code to help work with slice values.
1413
//! Slices are a view into a block of memory represented as a pointer and a
1514
//! length.
1615
//!
@@ -78,7 +77,8 @@
7877
//! iterators.
7978
//! * Further methods that return iterators are `.split()`, `.splitn()`,
8079
//! `.chunks()`, `.windows()` and more.
81-
#![doc(primitive = "slice")]
80+
//!
81+
//! *[See also the slice primitive type](../primitive.slice.html).*
8282
#![stable(feature = "rust1", since = "1.0.0")]
8383

8484
// Many of the usings in this module are only used in the test configuration.

src/libcollections/str.rs

+3-35
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Unicode string manipulation (the `str` type).
11+
//! Unicode string slices
1212
//!
13-
//! Rust's `str` type is one of the core primitive types of the language. `&str`
14-
//! is the borrowed string type. This type of string can only be created from
15-
//! other strings, unless it is a `&'static str` (see below). It is not possible
16-
//! to move out of borrowed strings because they are owned elsewhere.
17-
//!
18-
//! # Examples
19-
//!
20-
//! Here's some code that uses a `&str`:
21-
//!
22-
//! ```
23-
//! let s = "Hello, world.";
24-
//! ```
25-
//!
26-
//! This `&str` is a `&'static str`, which is the type of string literals.
27-
//! They're `'static` because literals are available for the entire lifetime of
28-
//! the program.
29-
//!
30-
//! You can get a non-`'static` `&str` by taking a slice of a `String`:
31-
//!
32-
//! ```
33-
//! let some_string = "Hello, world.".to_string();
34-
//! let s = &some_string;
35-
//! ```
36-
//!
37-
//! # Representation
38-
//!
39-
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as
40-
//! a stream of UTF-8 bytes. All [strings](../../reference.html#literals) are
41-
//! guaranteed to be validly encoded UTF-8 sequences. Additionally, strings are
42-
//! not null-terminated and can thus contain null bytes.
43-
//!
44-
//! The actual representation of `str`s have direct mappings to slices: `&str`
45-
//! is the same as `&[u8]`.
13+
//! *[See also the `str` primitive type](../primitive.str.html).*
14+
4615

47-
#![doc(primitive = "str")]
4816
#![stable(feature = "rust1", since = "1.0.0")]
4917

5018
// Many of the usings in this module are only used in the test configuration.

src/libcore/array.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
//! Implementations of things like `Eq` for fixed-length arrays
1212
//! up to a certain length. Eventually we should able to generalize
1313
//! to all lengths.
14+
//!
15+
//! *[See also the array primitive type](../primitive.array.html).*
1416
15-
#![doc(primitive = "array")]
1617
#![unstable(feature = "fixed_size_array",
1718
reason = "traits and impls are better expressed through generic \
1819
integer constants")]

src/libcore/char.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
//! For more details, see ::rustc_unicode::char (a.k.a. std::char)
1414
1515
#![allow(non_snake_case)]
16-
#![doc(primitive = "char")]
1716
#![stable(feature = "core_char", since = "1.2.0")]
1817

1918
use iter::Iterator;

src/libcore/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,6 @@ pub mod str;
154154
pub mod hash;
155155
pub mod fmt;
156156

157-
#[doc(primitive = "bool")]
158-
mod bool {
159-
}
160-
161157
// note: does not need to be public
162158
mod tuple;
163159

src/libcore/num/f32.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
//! Operations and constants for 32-bits floats (`f32` type)
1212
13-
#![doc(primitive = "f32")]
1413
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
1514
#![allow(overflowing_literals)]
1615

src/libcore/num/f64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
//! Operations and constants for 64-bits floats (`f64` type)
1212
13-
#![doc(primitive = "f64")]
1413
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
1514
#![allow(overflowing_literals)]
1615

src/libcore/num/i16.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for signed 16-bits integers (`i16` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "i16")]
1514

1615
int_module! { i16, 16 }

src/libcore/num/i32.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for signed 32-bits integers (`i32` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "i32")]
1514

1615
int_module! { i32, 32 }

src/libcore/num/i64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for signed 64-bits integers (`i64` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "i64")]
1514

1615
int_module! { i64, 64 }

src/libcore/num/i8.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for signed 8-bits integers (`i8` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "i8")]
1514

1615
int_module! { i8, 8 }

src/libcore/num/isize.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! Operations and constants for pointer-sized signed integers (`isize` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "isize")]
1514

1615
#[cfg(target_pointer_width = "32")]
1716
int_module! { isize, 32 }

src/libcore/num/u16.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for unsigned 16-bits integers (`u16` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "u16")]
1514

1615
uint_module! { u16, i16, 16 }

src/libcore/num/u32.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for unsigned 32-bits integers (`u32` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "u32")]
1514

1615
uint_module! { u32, i32, 32 }

src/libcore/num/u64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for unsigned 64-bits integer (`u64` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "u64")]
1514

1615
uint_module! { u64, i64, 64 }

src/libcore/num/u8.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for unsigned 8-bits integers (`u8` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "u8")]
1514

1615
uint_module! { u8, i8, 8 }

src/libcore/num/usize.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
//! Operations and constants for pointer-sized unsigned integers (`usize` type)
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
14-
#![doc(primitive = "usize")]
1514

1615
uint_module! { usize, isize, ::isize::BITS }

src/libcore/ptr.rs

+2-75
Original file line numberDiff line numberDiff line change
@@ -10,84 +10,11 @@
1010

1111
// FIXME: talk about offset, copy_memory, copy_nonoverlapping_memory
1212

13-
//! Operations on raw pointers, `*const T`, and `*mut T`.
13+
//! Raw, unsafe pointers, `*const T`, and `*mut T`
1414
//!
15-
//! Working with raw pointers in Rust is uncommon,
16-
//! typically limited to a few patterns.
17-
//!
18-
//! Use the `null` function to create null pointers, and the `is_null` method
19-
//! of the `*const T` type to check for null. The `*const T` type also defines
20-
//! the `offset` method, for pointer math.
21-
//!
22-
//! # Common ways to create raw pointers
23-
//!
24-
//! ## 1. Coerce a reference (`&T`) or mutable reference (`&mut T`).
25-
//!
26-
//! ```
27-
//! let my_num: i32 = 10;
28-
//! let my_num_ptr: *const i32 = &my_num;
29-
//! let mut my_speed: i32 = 88;
30-
//! let my_speed_ptr: *mut i32 = &mut my_speed;
31-
//! ```
32-
//!
33-
//! To get a pointer to a boxed value, dereference the box:
34-
//!
35-
//! ```
36-
//! let my_num: Box<i32> = Box::new(10);
37-
//! let my_num_ptr: *const i32 = &*my_num;
38-
//! let mut my_speed: Box<i32> = Box::new(88);
39-
//! let my_speed_ptr: *mut i32 = &mut *my_speed;
40-
//! ```
41-
//!
42-
//! This does not take ownership of the original allocation
43-
//! and requires no resource management later,
44-
//! but you must not use the pointer after its lifetime.
45-
//!
46-
//! ## 2. Consume a box (`Box<T>`).
47-
//!
48-
//! The `into_raw` function consumes a box and returns
49-
//! the raw pointer. It doesn't destroy `T` or deallocate any memory.
50-
//!
51-
//! ```
52-
//! # #![feature(box_raw)]
53-
//! let my_speed: Box<i32> = Box::new(88);
54-
//! let my_speed: *mut i32 = Box::into_raw(my_speed);
55-
//!
56-
//! // By taking ownership of the original `Box<T>` though
57-
//! // we are obligated to put it together later to be destroyed.
58-
//! unsafe {
59-
//! drop(Box::from_raw(my_speed));
60-
//! }
61-
//! ```
62-
//!
63-
//! Note that here the call to `drop` is for clarity - it indicates
64-
//! that we are done with the given value and it should be destroyed.
65-
//!
66-
//! ## 3. Get it from C.
67-
//!
68-
//! ```
69-
//! # #![feature(libc)]
70-
//! extern crate libc;
71-
//!
72-
//! use std::mem;
73-
//!
74-
//! fn main() {
75-
//! unsafe {
76-
//! let my_num: *mut i32 = libc::malloc(mem::size_of::<i32>() as libc::size_t) as *mut i32;
77-
//! if my_num.is_null() {
78-
//! panic!("failed to allocate memory");
79-
//! }
80-
//! libc::free(my_num as *mut libc::c_void);
81-
//! }
82-
//! }
83-
//! ```
84-
//!
85-
//! Usually you wouldn't literally use `malloc` and `free` from Rust,
86-
//! but C APIs hand out a lot of pointers generally, so are a common source
87-
//! of raw pointers in Rust.
15+
//! *[See also the pointer primitive types](../primitive.pointer.html).*
8816
8917
#![stable(feature = "rust1", since = "1.0.0")]
90-
#![doc(primitive = "pointer")]
9118

9219
use mem;
9320
use clone::Clone;

src/libcore/slice.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
//! For more details `std::slice`.
1414
1515
#![stable(feature = "rust1", since = "1.0.0")]
16-
#![doc(primitive = "slice")]
1716

1817
// How this module is organized.
1918
//

src/libcore/str/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//!
1313
//! For more details, see std::str
1414
15-
#![doc(primitive = "str")]
1615
#![stable(feature = "rust1", since = "1.0.0")]
1716

1817
use self::pattern::Pattern;

src/libcore/tuple.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Operations on tuples
11+
//! A finite heterogeneous sequence, `(T, U, ..)`
1212
//!
1313
//! To access a single element of a tuple one can use the `.0`
1414
//! field access syntax.
@@ -28,7 +28,6 @@
2828
//! * `Default`
2929
3030
#![stable(feature = "rust1", since = "1.0.0")]
31-
#![doc(primitive = "tuple")]
3231

3332
use clone::Clone;
3433
use cmp::*;

src/librustc_unicode/char.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,26 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Character manipulation (`char` type, Unicode Scalar Value)
11+
//! A Unicode scalar value
1212
//!
1313
//! This module provides the `CharExt` trait, as well as its
1414
//! implementation for the primitive `char` type, in order to allow
1515
//! basic character manipulation.
1616
//!
17-
//! A `char` actually represents a
18-
//! *[Unicode Scalar
19-
//! Value](http://www.unicode.org/glossary/#unicode_scalar_value)*, as it can
17+
//! A `char` represents a
18+
//! *[Unicode scalar
19+
//! value](http://www.unicode.org/glossary/#unicode_scalar_value)*, as it can
2020
//! contain any Unicode code point except high-surrogate and low-surrogate code
2121
//! points.
2222
//!
2323
//! As such, only values in the ranges \[0x0,0xD7FF\] and \[0xE000,0x10FFFF\]
2424
//! (inclusive) are allowed. A `char` can always be safely cast to a `u32`;
2525
//! however the converse is not always true due to the above range limits
2626
//! and, as such, should be performed via the `from_u32` function.
27+
//!
28+
//! *[See also the `char` primitive type](../primitive.char.html).*
2729
2830
#![stable(feature = "rust1", since = "1.0.0")]
29-
#![doc(primitive = "char")]
3031

3132
use core::char::CharExt as C;
3233
use core::option::Option::{self, Some, None};

src/libstd/array.rs

-55
This file was deleted.

0 commit comments

Comments
 (0)