Skip to content

Commit 103e5c9

Browse files
authored
Auto merge of #34852 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests - Successful merges: #33362, #34768, #34837, #34838, #34847, #34848, #34849 - Failed merges: #33951, #34850
2 parents b5ad277 + 45f8427 commit 103e5c9

File tree

6 files changed

+85
-45
lines changed

6 files changed

+85
-45
lines changed

src/doc/book/no-stdlib.md

+48-25
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ this using our `Cargo.toml` file:
2121

2222
```toml
2323
[dependencies]
24-
libc = { version = "0.2.11", default-features = false }
24+
libc = { version = "0.2.14", default-features = false }
2525
```
2626

2727
Note that the default features have been disabled. This is a critical step -
@@ -36,8 +36,7 @@ or overriding the default shim for the C `main` function with your own.
3636
The function marked `#[start]` is passed the command line parameters
3737
in the same format as C:
3838

39-
```rust
40-
# #![feature(libc)]
39+
```rust,ignore
4140
#![feature(lang_items)]
4241
#![feature(start)]
4342
#![no_std]
@@ -51,53 +50,77 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
5150
0
5251
}
5352
54-
// These functions and traits are used by the compiler, but not
53+
// These functions are used by the compiler, but not
5554
// for a bare-bones hello world. These are normally
5655
// provided by libstd.
57-
#[lang = "eh_personality"] extern fn eh_personality() {}
58-
#[lang = "panic_fmt"] extern fn panic_fmt() -> ! { loop {} }
59-
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
60-
# #[no_mangle] pub extern fn rust_eh_register_frames () {}
61-
# #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
62-
# // fn main() {} tricked you, rustdoc!
56+
#[lang = "eh_personality"]
57+
#[no_mangle]
58+
pub extern fn eh_personality() {
59+
}
60+
61+
#[lang = "panic_fmt"]
62+
#[no_mangle]
63+
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
64+
_file: &'static str,
65+
_line: u32) -> ! {
66+
loop {}
67+
}
6368
```
6469

6570
To override the compiler-inserted `main` shim, one has to disable it
6671
with `#![no_main]` and then create the appropriate symbol with the
6772
correct ABI and the correct name, which requires overriding the
6873
compiler's name mangling too:
6974

70-
```rust
71-
# #![feature(libc)]
75+
```rust,ignore
7276
#![feature(lang_items)]
7377
#![feature(start)]
7478
#![no_std]
7579
#![no_main]
7680
81+
// Pull in the system libc library for what crt0.o likely requires
7782
extern crate libc;
7883
84+
// Entry point for this program
7985
#[no_mangle] // ensure that this symbol is called `main` in the output
80-
pub extern fn main(argc: i32, argv: *const *const u8) -> i32 {
86+
pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
8187
0
8288
}
8389
84-
#[lang = "eh_personality"] extern fn eh_personality() {}
85-
#[lang = "panic_fmt"] extern fn panic_fmt() -> ! { loop {} }
86-
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
87-
# #[no_mangle] pub extern fn rust_eh_register_frames () {}
88-
# #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
89-
# // fn main() {} tricked you, rustdoc!
90+
// These functions and traits are used by the compiler, but not
91+
// for a bare-bones hello world. These are normally
92+
// provided by libstd.
93+
#[lang = "eh_personality"]
94+
#[no_mangle]
95+
pub extern fn eh_personality() {
96+
}
97+
98+
#[lang = "panic_fmt"]
99+
#[no_mangle]
100+
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
101+
_file: &'static str,
102+
_line: u32) -> ! {
103+
loop {}
104+
}
90105
```
91106

92-
The compiler currently makes a few assumptions about symbols which are available
93-
in the executable to call. Normally these functions are provided by the standard
94-
library, but without it you must define your own.
107+
## More about the langauge items
108+
109+
The compiler currently makes a few assumptions about symbols which are
110+
available in the executable to call. Normally these functions are provided by
111+
the standard library, but without it you must define your own. These symbols
112+
are called "language items", and they each have an internal name, and then a
113+
signature that an implementation must conform to.
95114

96115
The first of these two functions, `eh_personality`, is used by the failure
97116
mechanisms of the compiler. This is often mapped to GCC's personality function
98117
(see the [libstd implementation][unwind] for more information), but crates
99118
which do not trigger a panic can be assured that this function is never
100-
called. The second function, `panic_fmt`, is also used by the failure
101-
mechanisms of the compiler.
102-
119+
called. Both the language item and the symbol name are `eh_personality`.
120+
103121
[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs
122+
123+
The second function, `panic_fmt`, is also used by the failure mechanisms of the
124+
compiler. When a panic happens, this controls the message that's displayed on
125+
the screen. While the language item's name is `panic_fmt`, the symbol name is
126+
`rust_begin_panic`.

src/doc/nomicon/phantom-data.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ struct Vec<T> {
5151
```
5252

5353
Unlike the previous example it *appears* that everything is exactly as we
54-
want. Every generic argument to Vec shows up in the at least one field.
54+
want. Every generic argument to Vec shows up in at least one field.
5555
Good to go!
5656

5757
Nope.
5858

59-
The drop checker will generously determine that Vec<T> does not own any values
59+
The drop checker will generously determine that `Vec<T>` does not own any values
6060
of type T. This will in turn make it conclude that it doesn't need to worry
6161
about Vec dropping any T's in its destructor for determining drop check
6262
soundness. This will in turn allow people to create unsoundness using
@@ -81,7 +81,7 @@ Raw pointers that own an allocation is such a pervasive pattern that the
8181
standard library made a utility for itself called `Unique<T>` which:
8282

8383
* wraps a `*const T` for variance
84-
* includes a `PhantomData<T>`,
84+
* includes a `PhantomData<T>`
8585
* auto-derives Send/Sync as if T was contained
8686
* marks the pointer as NonZero for the null-pointer optimization
8787

src/doc/reference.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,20 @@ extern crate std; // equivalent to: extern crate std as std;
853853
extern crate std as ruststd; // linking to 'std' under another name
854854
```
855855

856+
When naming Rust crates, hyphens are disallowed. However, Cargo packages may
857+
make use of them. In such case, when `Cargo.toml` doesn't specify a crate name,
858+
Cargo will transparently replace `-` with `_` (Refer to [RFC 940] for more
859+
details).
860+
861+
Here is an example:
862+
863+
```{.ignore}
864+
// Importing the Cargo package hello-world
865+
extern crate hello_world; // hyphen replaced with an underscore
866+
```
867+
868+
[RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md
869+
856870
#### Use declarations
857871

858872
A _use declaration_ creates one or more local name bindings synonymous with
@@ -3744,9 +3758,9 @@ Since `'static` "lives longer" than `'a`, `&'static str` is a subtype of
37443758

37453759
## Type coercions
37463760

3747-
Coercions are defined in [RFC401]. A coercion is implicit and has no syntax.
3761+
Coercions are defined in [RFC 401]. A coercion is implicit and has no syntax.
37483762

3749-
[RFC401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
3763+
[RFC 401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
37503764

37513765
### Coercion sites
37523766

@@ -3886,7 +3900,7 @@ Coercion is allowed between the following types:
38863900

38873901
In the future, coerce_inner will be recursively extended to tuples and
38883902
structs. In addition, coercions from sub-traits to super-traits will be
3889-
added. See [RFC401] for more details.
3903+
added. See [RFC 401] for more details.
38903904

38913905
# Special traits
38923906

src/libcore/hash/sip.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use ptr;
1818
/// An implementation of SipHash 1-3.
1919
///
2020
/// See: https://131002.net/siphash/
21-
#[unstable(feature = "sip_hash_13", issue = "29754")]
21+
#[unstable(feature = "sip_hash_13", issue = "34767")]
2222
#[derive(Debug, Clone, Default)]
2323
pub struct SipHasher13 {
2424
hasher: Hasher<Sip13Rounds>,
@@ -27,7 +27,7 @@ pub struct SipHasher13 {
2727
/// An implementation of SipHash 2-4.
2828
///
2929
/// See: https://131002.net/siphash/
30-
#[unstable(feature = "sip_hash_13", issue = "29754")]
30+
#[unstable(feature = "sip_hash_13", issue = "34767")]
3131
#[derive(Debug, Clone, Default)]
3232
pub struct SipHasher24 {
3333
hasher: Hasher<Sip24Rounds>,
@@ -154,14 +154,14 @@ impl SipHasher {
154154
impl SipHasher13 {
155155
/// Creates a new `SipHasher13` with the two initial keys set to 0.
156156
#[inline]
157-
#[unstable(feature = "sip_hash_13", issue = "29754")]
157+
#[unstable(feature = "sip_hash_13", issue = "34767")]
158158
pub fn new() -> SipHasher13 {
159159
SipHasher13::new_with_keys(0, 0)
160160
}
161161

162162
/// Creates a `SipHasher13` that is keyed off the provided keys.
163163
#[inline]
164-
#[unstable(feature = "sip_hash_13", issue = "29754")]
164+
#[unstable(feature = "sip_hash_13", issue = "34767")]
165165
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher13 {
166166
SipHasher13 {
167167
hasher: Hasher::new_with_keys(key0, key1)
@@ -172,14 +172,14 @@ impl SipHasher13 {
172172
impl SipHasher24 {
173173
/// Creates a new `SipHasher24` with the two initial keys set to 0.
174174
#[inline]
175-
#[unstable(feature = "sip_hash_13", issue = "29754")]
175+
#[unstable(feature = "sip_hash_13", issue = "34767")]
176176
pub fn new() -> SipHasher24 {
177177
SipHasher24::new_with_keys(0, 0)
178178
}
179179

180180
/// Creates a `SipHasher24` that is keyed off the provided keys.
181181
#[inline]
182-
#[unstable(feature = "sip_hash_13", issue = "29754")]
182+
#[unstable(feature = "sip_hash_13", issue = "34767")]
183183
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher24 {
184184
SipHasher24 {
185185
hasher: Hasher::new_with_keys(key0, key1)
@@ -232,7 +232,7 @@ impl super::Hasher for SipHasher {
232232
}
233233
}
234234

235-
#[unstable(feature = "sip_hash_13", issue = "29754")]
235+
#[unstable(feature = "sip_hash_13", issue = "34767")]
236236
impl super::Hasher for SipHasher13 {
237237
#[inline]
238238
fn write(&mut self, msg: &[u8]) {
@@ -245,7 +245,7 @@ impl super::Hasher for SipHasher13 {
245245
}
246246
}
247247

248-
#[unstable(feature = "sip_hash_13", issue = "29754")]
248+
#[unstable(feature = "sip_hash_13", issue = "34767")]
249249
impl super::Hasher for SipHasher24 {
250250
#[inline]
251251
fn write(&mut self, msg: &[u8]) {

src/libcore/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
//!
2626
//! # How to use the core library
2727
//!
28+
//! Please note that all of these details are currently not considered stable.
29+
//!
2830
// FIXME: Fill me in with more detail when the interface settles
2931
//! This library is built on the assumption of a few existing symbols:
3032
//!
@@ -34,11 +36,12 @@
3436
//! These functions are often provided by the system libc, but can also be
3537
//! provided by the [rlibc crate](https://crates.io/crates/rlibc).
3638
//!
37-
//! * `rust_begin_unwind` - This function takes three arguments, a
38-
//! `fmt::Arguments`, a `&str`, and a `u32`. These three arguments dictate
39-
//! the panic message, the file at which panic was invoked, and the line.
40-
//! It is up to consumers of this core library to define this panic
41-
//! function; it is only required to never return.
39+
//! * `rust_begin_panic` - This function takes three arguments, a
40+
//! `fmt::Arguments`, a `&'static str`, and a `u32`. These three arguments
41+
//! dictate the panic message, the file at which panic was invoked, and the
42+
//! line. It is up to consumers of this core library to define this panic
43+
//! function; it is only required to never return. This requires a `lang`
44+
//! attribute named `panic_fmt`.
4245
4346
// Since libcore defines many fundamental lang items, all tests live in a
4447
// separate crate, libcoretest, to avoid bizarre issues.

src/libcore/num/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,7 @@ impl usize {
23182318
/// let num = 12.4_f32;
23192319
/// let inf = f32::INFINITY;
23202320
/// let zero = 0f32;
2321-
/// let sub: f32 = 0.000000000000000000000000000000000000011754942;
2321+
/// let sub: f32 = 1.1754942e-38;
23222322
/// let nan = f32::NAN;
23232323
///
23242324
/// assert_eq!(num.classify(), FpCategory::Normal);

0 commit comments

Comments
 (0)