Skip to content

Commit f191f92

Browse files
committed
Auto merge of #24758 - Manishearth:rollup, r=Manishearth
- Successful merges: #24523, #24698, #24699, #24700, #24706, #24717, #24718, #24721, #24727 - Failed merges:
2 parents 9d439b4 + 1447ee4 commit f191f92

File tree

8 files changed

+71
-30
lines changed

8 files changed

+71
-30
lines changed

src/doc/reference.md

+26-11
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ cases mentioned in [Number literals](#number-literals) below.
271271
##### Suffixes
272272
| Integer | Floating-point |
273273
|---------|----------------|
274-
| `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `is` (`isize`), `us` (`usize`) | `f32`, `f64` |
274+
| `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `isize`, `usize` | `f32`, `f64` |
275275

276276
#### Character and string literals
277277

@@ -738,15 +738,26 @@ Rust syntax is restricted in two ways:
738738

739739
# Crates and source files
740740

741-
Rust is a *compiled* language. Its semantics obey a *phase distinction* between
742-
compile-time and run-time. Those semantic rules that have a *static
741+
Although Rust, like any other language, can be implemented by an interpreter as
742+
well as a compiler, the only existing implementation is a compiler —
743+
from now on referred to as *the* Rust compiler — and the language has
744+
always been designed to be compiled. For these reasons, this section assumes a
745+
compiler.
746+
747+
Rust's semantics obey a *phase distinction* between compile-time and
748+
run-time.[^phase-distinction] Those semantic rules that have a *static
743749
interpretation* govern the success or failure of compilation. Those semantics
744750
that have a *dynamic interpretation* govern the behavior of the program at
745751
run-time.
746752

753+
[^phase-distinction]: This distinction would also exist in an interpreter.
754+
Static checks like syntactic analysis, type checking, and lints should
755+
happen before the program is executed regardless of when it is executed.
756+
747757
The compilation model centers on artifacts called _crates_. Each compilation
748758
processes a single crate in source form, and if successful, produces a single
749-
crate in binary form: either an executable or a library.[^cratesourcefile]
759+
crate in binary form: either an executable or some sort of
760+
library.[^cratesourcefile]
750761

751762
[^cratesourcefile]: A crate is somewhat analogous to an *assembly* in the
752763
ECMA-335 CLI model, a *library* in the SML/NJ Compilation Manager, a *unit*
@@ -767,21 +778,25 @@ extension `.rs`.
767778
A Rust source file describes a module, the name and location of which —
768779
in the module tree of the current crate — are defined from outside the
769780
source file: either by an explicit `mod_item` in a referencing source file, or
770-
by the name of the crate itself.
781+
by the name of the crate itself. Every source file is a module, but not every
782+
module needs its own source file: [module definitions](#modules) can be nested
783+
within one file.
771784

772785
Each source file contains a sequence of zero or more `item` definitions, and
773-
may optionally begin with any number of `attributes` that apply to the
774-
containing module. Attributes on the anonymous crate module define important
775-
metadata that influences the behavior of the compiler.
786+
may optionally begin with any number of [attributes](#Items and attributes)
787+
that apply to the containing module, most of which influence the behavior of
788+
the compiler. The anonymous crate module can have additional attributes that
789+
apply to the crate as a whole.
776790

777791
```no_run
778-
// Crate name
792+
// Specify the crate name.
779793
#![crate_name = "projx"]
780794
781-
// Specify the output type
795+
// Specify the type of output artifact.
782796
#![crate_type = "lib"]
783797
784-
// Turn on a warning
798+
// Turn on a warning.
799+
// This can be done in any module, not just the anonymous crate module.
785800
#![warn(non_camel_case_types)]
786801
```
787802

src/doc/trpl/SUMMARY.md

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* [Learn Rust](learn-rust.md)
88
* [Effective Rust](effective-rust.md)
99
* [The Stack and the Heap](the-stack-and-the-heap.md)
10-
* [Debug and Display](debug-and-display.md)
1110
* [Testing](testing.md)
1211
* [Conditional Compilation](conditional-compilation.md)
1312
* [Documentation](documentation.md)

src/doc/trpl/debug-and-display.md

-3
This file was deleted.

src/libcore/raw.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<T> Clone for Slice<T> {
8080
/// `TraitObject` is guaranteed to match layouts, but it is not the
8181
/// type of trait objects (e.g. the fields are not directly accessible
8282
/// on a `&SomeTrait`) nor does it control that layout (changing the
83-
/// definition will not change the layout of a `&SometTrait`). It is
83+
/// definition will not change the layout of a `&SomeTrait`). It is
8484
/// only designed to be used by unsafe code that needs to manipulate
8585
/// the low-level details.
8686
///

src/librustc/diagnostics.rs

+33-3
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ the following is invalid as it requires the entire Option<String> to be moved
7575
into a variable called `op_string` while simultaneously requiring the inner
7676
String to be moved into a variable called `s`.
7777
78+
```
7879
let x = Some("s".to_string());
7980
match x {
8081
op_string @ Some(s) => ...
8182
None => ...
8283
}
84+
```
8385
8486
See also Error 303.
8587
"##,
@@ -90,10 +92,12 @@ name is bound by move in a pattern, it should also be moved to wherever it is
9092
referenced in the pattern guard code. Doing so however would prevent the name
9193
from being available in the body of the match arm. Consider the following:
9294
95+
```
9396
match Some("hi".to_string()) {
9497
Some(s) if s.len() == 0 => // use s.
9598
...
9699
}
100+
```
97101
98102
The variable `s` has type String, and its use in the guard is as a variable of
99103
type String. The guard code effectively executes in a separate scope to the body
@@ -102,11 +106,13 @@ become unavailable in the body of the arm. Although this example seems
102106
innocuous, the problem is most clear when considering functions that take their
103107
argument by value.
104108
109+
```
105110
match Some("hi".to_string()) {
106111
Some(s) if { drop(s); false } => (),
107112
Some(s) => // use s.
108113
...
109114
}
115+
```
110116
111117
The value would be dropped in the guard then become unavailable not only in the
112118
body of that arm but also in all subsequent arms! The solution is to bind by
@@ -219,8 +225,10 @@ them yourself.
219225
You can build a free-standing crate by adding `#![no_std]` to the crate
220226
attributes:
221227
228+
```
222229
#![feature(no_std)]
223230
#![no_std]
231+
```
224232
225233
See also https://doc.rust-lang.org/book/no-stdlib.html
226234
"##,
@@ -236,11 +244,13 @@ mutex can be declared `static` as well.
236244
237245
If you want to match against a `static`, consider using a guard instead:
238246
247+
```
239248
static FORTY_TWO: i32 = 42;
240249
match Some(42) {
241250
Some(x) if x == FORTY_TWO => ...
242251
...
243252
}
253+
```
244254
"##,
245255

246256
E0161: r##"
@@ -256,6 +266,7 @@ An if-let pattern attempts to match the pattern, and enters the body if the
256266
match was succesful. If the match is irrefutable (when it cannot fail to match),
257267
use a regular `let`-binding instead. For instance:
258268
269+
```
259270
struct Irrefutable(i32);
260271
let irr = Irrefutable(0);
261272
@@ -268,13 +279,15 @@ if let Irrefutable(x) = irr {
268279
// Try this instead:
269280
let Irrefutable(x) = irr;
270281
foo(x);
282+
```
271283
"##,
272284

273285
E0165: r##"
274286
A while-let pattern attempts to match the pattern, and enters the body if the
275287
match was succesful. If the match is irrefutable (when it cannot fail to match),
276288
use a regular `let`-binding inside a `loop` instead. For instance:
277289
290+
```
278291
struct Irrefutable(i32);
279292
let irr = Irrefutable(0);
280293
@@ -288,22 +301,27 @@ loop {
288301
let Irrefutable(x) = irr;
289302
...
290303
}
304+
```
291305
"##,
292306

293307
E0170: r##"
294308
Enum variants are qualified by default. For example, given this type:
295309
310+
```
296311
enum Method {
297312
GET,
298313
POST
299314
}
315+
```
300316
301317
you would match it using:
302318
319+
```
303320
match m {
304321
Method::GET => ...
305322
Method::POST => ...
306323
}
324+
```
307325
308326
If you don't qualify the names, the code will bind new variables named "GET" and
309327
"POST" instead. This behavior is likely not what you want, so rustc warns when
@@ -312,8 +330,10 @@ that happens.
312330
Qualified names are good practice, and most code works well with them. But if
313331
you prefer them unqualified, you can import the variants into scope:
314332
333+
```
315334
use Method::*;
316335
enum Method { GET, POST }
336+
```
317337
"##,
318338

319339
E0267: r##"
@@ -333,7 +353,9 @@ E0296: r##"
333353
This error indicates that the given recursion limit could not be parsed. Ensure
334354
that the value provided is a positive integer between quotes, like so:
335355
356+
```
336357
#![recursion_limit="1000"]
358+
```
337359
"##,
338360

339361
E0297: r##"
@@ -342,6 +364,7 @@ that a name will be extracted in all cases. Instead of pattern matching the
342364
loop variable, consider using a `match` or `if let` inside the loop body. For
343365
instance:
344366
367+
```
345368
// This fails because `None` is not covered.
346369
for Some(x) in xs {
347370
...
@@ -361,6 +384,7 @@ for item in xs {
361384
...
362385
}
363386
}
387+
```
364388
"##,
365389

366390
E0301: r##"
@@ -370,11 +394,13 @@ on which the match depends in such a way, that the match would not be
370394
exhaustive. For instance, the following would not match any arm if mutable
371395
borrows were allowed:
372396
397+
```
373398
match Some(()) {
374399
None => { },
375400
option if option.take().is_none() => { /* impossible, option is `Some` */ },
376401
Some(_) => { } // When the previous match failed, the option became `None`.
377402
}
403+
```
378404
"##,
379405

380406
E0302: r##"
@@ -384,21 +410,24 @@ on which the match depends in such a way, that the match would not be
384410
exhaustive. For instance, the following would not match any arm if assignments
385411
were allowed:
386412
413+
```
387414
match Some(()) {
388415
None => { },
389416
option if { option = None; false } { },
390417
Some(_) => { } // When the previous match failed, the option became `None`.
391418
}
419+
```
392420
"##,
393421

394422
E0303: r##"
395423
In certain cases it is possible for sub-bindings to violate memory safety.
396424
Updates to the borrow checker in a future version of Rust may remove this
397425
restriction, but for now patterns must be rewritten without sub-bindings.
398426
399-
// Before.
400-
match Some("hi".to_string()) {
401-
ref op_string_ref @ Some(ref s) => ...
427+
```
428+
// Code like this...
429+
match Some(5) {
430+
ref op_num @ Some(num) => ...
402431
None => ...
403432
}
404433
@@ -410,6 +439,7 @@ match Some("hi".to_string()) {
410439
}
411440
None => ...
412441
}
442+
```
413443
414444
The `op_string_ref` binding has type &Option<&String> in both cases.
415445

src/librustdoc/html/static/main.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,9 @@
828828
$(document).on("click", ".collapse-toggle", function() {
829829
var toggle = $(this);
830830
var relatedDoc = toggle.parent().next();
831+
if (relatedDoc.is(".stability")) {
832+
relatedDoc = relatedDoc.next();
833+
}
831834
if (relatedDoc.is(".docblock")) {
832835
if (relatedDoc.is(":visible")) {
833836
relatedDoc.slideUp({duration:'fast', easing:'linear'});
@@ -848,9 +851,10 @@
848851
.html("[<span class='inner'>-</span>]");
849852

850853
$(".method").each(function() {
851-
if ($(this).next().is(".docblock")) {
852-
$(this).children().first().after(toggle.clone());
853-
}
854+
if ($(this).next().is(".docblock") ||
855+
($(this).next().is(".stability") && $(this).next().next().is(".docblock"))) {
856+
$(this).children().first().after(toggle.clone());
857+
}
854858
});
855859

856860
var mainToggle =

src/libstd/dynamic_lib.rs

-8
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ impl Drop for DynamicLibrary {
4040
}
4141

4242
impl DynamicLibrary {
43-
// FIXME (#12938): Until DST lands, we cannot decompose &str into
44-
// & and str, so we cannot usefully take ToCStr arguments by
45-
// reference (without forcing an additional & around &str). So we
46-
// are instead temporarily adding an instance for &Path, so that
47-
// we can take ToCStr as owned. When DST lands, the &Path instance
48-
// should be removed, and arguments bound by ToCStr should be
49-
// passed by reference. (Here: in the `open` method.)
50-
5143
/// Lazily open a dynamic library. When passed None it gives a
5244
/// handle to the calling process
5345
pub fn open(filename: Option<&Path>) -> Result<DynamicLibrary, String> {

src/libstd/io/stdio.rs

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ impl Write for StderrRaw {
9595
///
9696
/// This handle implements the `Read` trait, but beware that concurrent reads
9797
/// of `Stdin` must be executed with care.
98+
///
99+
/// Created by the function `io::stdin()`.
98100
#[stable(feature = "rust1", since = "1.0.0")]
99101
pub struct Stdin {
100102
inner: Arc<Mutex<BufReader<StdinRaw>>>,
@@ -206,6 +208,8 @@ const OUT_MAX: usize = ::usize::MAX;
206208
/// Each handle shares a global buffer of data to be written to the standard
207209
/// output stream. Access is also synchronized via a lock and explicit control
208210
/// over locking is available via the `lock` method.
211+
///
212+
/// Created by the function `io::stdout()`.
209213
#[stable(feature = "rust1", since = "1.0.0")]
210214
pub struct Stdout {
211215
// FIXME: this should be LineWriter or BufWriter depending on the state of

0 commit comments

Comments
 (0)