Skip to content

Commit 1930024

Browse files
authored
Merge branch 'master' into Nadrieril-patch-1
2 parents 6b9582a + 9f871ce commit 1930024

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/beneath-std.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ Note that the default features have been disabled. This is a critical step -
1919
disabled.**
2020

2121
Alternatively, we can use the unstable `rustc_private` private feature together
22-
with an `extern crate libc;` declaration as shown in the examples below.
22+
with an `extern crate libc;` declaration as shown in the examples below. Note that
23+
windows-msvc targets do not require a libc, and correspondingly there is no `libc`
24+
crate in their sysroot. We do not need the `extern crate libc;` below, and having it
25+
on a windows-msvc target would be a compile error.
2326

2427
## Writing an executable without `std`
2528

@@ -39,11 +42,12 @@ in the same format as C (aside from the exact integer types being used):
3942
#![allow(internal_features)]
4043
#![no_std]
4144

42-
// Necessary for `panic = "unwind"` builds on some platforms.
45+
// Necessary for `panic = "unwind"` builds on cfg(unix) platforms.
4346
#![feature(panic_unwind)]
4447
extern crate unwind;
4548

4649
// Pull in the system libc library for what crt0.o likely requires.
50+
#[cfg(not(windows))]
4751
extern crate libc;
4852

4953
use core::panic::PanicInfo;
@@ -73,11 +77,12 @@ compiler's name mangling too:
7377
#![no_std]
7478
#![no_main]
7579

76-
// Necessary for `panic = "unwind"` builds on some platforms.
80+
// Necessary for `panic = "unwind"` builds on cfg(unix) platforms.
7781
#![feature(panic_unwind)]
7882
extern crate unwind;
7983

8084
// Pull in the system libc library for what crt0.o likely requires.
85+
#[cfg(not(windows))]
8186
extern crate libc;
8287

8388
use core::ffi::{c_char, c_int};

src/other-reprs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ says they should still consume a byte of space.
4242
difference from a struct is that the fields aren’t named.
4343

4444
* `repr(C)` is equivalent to one of `repr(u*)` (see the next section) for
45-
fieldless enums. The chosen size is the default enum size for the target platform's C
45+
fieldless enums. The chosen size and sign is the default enum size and sign for the target platform's C
4646
application binary interface (ABI). Note that enum representation in C is implementation
4747
defined, so this is really a "best guess". In particular, this may be incorrect
4848
when the C code of interest is compiled with certain flags.
@@ -79,7 +79,7 @@ More details are in the [RFC 1758][rfc-transparent] and the [RFC 2645][rfc-trans
7979

8080
## repr(u*), repr(i*)
8181

82-
These specify the size to make a fieldless enum. If the discriminant overflows
82+
These specify the size and sign to make a fieldless enum. If the discriminant overflows
8383
the integer it has to fit in, it will produce a compile-time error. You can
8484
manually ask Rust to allow this by setting the overflowing element to explicitly
8585
be 0. However Rust will not allow you to create an enum where two variants have
@@ -89,7 +89,7 @@ The term "fieldless enum" only means that the enum doesn't have data in any
8989
of its variants. A fieldless enum without a `repr(u*)` or `repr(C)` is
9090
still a Rust native type, and does not have a stable ABI representation.
9191
Adding a `repr` causes it to be treated exactly like the specified
92-
integer size for ABI purposes.
92+
integer type for ABI purposes.
9393

9494
If the enum has fields, the effect is similar to the effect of `repr(C)`
9595
in that there is a defined layout of the type. This makes it possible to

src/subtyping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ To see why `fn(T) -> U` should be covariant over `U`, consider the following sig
268268
fn get_str() -> &'a str;
269269
```
270270

271-
This function claims to produce a `str` bound by some liftime `'a`. As such, it is perfectly valid to
271+
This function claims to produce a `str` bound by some lifetime `'a`. As such, it is perfectly valid to
272272
provide a function with the following signature instead:
273273

274274
<!-- ignore: simplified code -->

src/what-unsafe-does.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The only things that are different in Unsafe Rust are that you can:
55
* Dereference raw pointers
66
* Call `unsafe` functions (including C functions, compiler intrinsics, and the raw allocator)
77
* Implement `unsafe` traits
8-
* Mutate statics
8+
* Access or modify mutable statics
99
* Access fields of `union`s
1010

1111
That's it. The reason these operations are relegated to Unsafe is that misusing
@@ -41,6 +41,9 @@ language cares about is preventing the following things:
4141
[`NonNull`] that is null. (Requesting custom invalid values is an unstable
4242
feature, but some stable libstd types, like `NonNull`, make use of it.)
4343

44+
For a more detailed explanation about "Undefined Bahavior", you may refer to
45+
[the reference][behavior-considered-undefined].
46+
4447
"Producing" a value happens any time a value is assigned, passed to a
4548
function/primitive operation or returned from a function/primitive operation.
4649

@@ -75,6 +78,8 @@ Rust considers it "safe" to:
7578
* Abort the program
7679
* Delete the production database
7780

81+
For more detailed information, you may refer to [the reference][behavior-not-considered-unsafe].
82+
7883
However any program that actually manages to do such a thing is *probably*
7984
incorrect. Rust provides lots of tools to make these things rare, but
8085
these problems are considered impractical to categorically prevent.
@@ -84,3 +89,5 @@ these problems are considered impractical to categorically prevent.
8489
[race]: races.html
8590
[target features]: ../reference/attributes/codegen.html#the-target_feature-attribute
8691
[`NonNull`]: ../std/ptr/struct.NonNull.html
92+
[behavior-considered-undefined]: ../reference/behavior-considered-undefined.html
93+
[behavior-not-considered-unsafe]: ../reference/behavior-not-considered-unsafe.html

0 commit comments

Comments
 (0)