Skip to content

Commit 2efcd0b

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 21f278a + f772079 commit 2efcd0b

File tree

14 files changed

+242
-233
lines changed

14 files changed

+242
-233
lines changed

src/doc/reference.md

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

273273
#### Character and string literals
274274

@@ -735,15 +735,26 @@ Rust syntax is restricted in two ways:
735735

736736
# Crates and source files
737737

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

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

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

769782
Each source file contains a sequence of zero or more `item` definitions, and
770-
may optionally begin with any number of `attributes` that apply to the
771-
containing module. Attributes on the anonymous crate module define important
772-
metadata that influences the behavior of the compiler.
783+
may optionally begin with any number of [attributes](#Items and attributes)
784+
that apply to the containing module, most of which influence the behavior of
785+
the compiler. The anonymous crate module can have additional attributes that
786+
apply to the crate as a whole.
773787

774788
```no_run
775-
// Crate name
789+
// Specify the crate name.
776790
#![crate_name = "projx"]
777791
778-
// Specify the output type
792+
// Specify the type of output artifact.
779793
#![crate_type = "lib"]
780794
781-
// Turn on a warning
795+
// Turn on a warning.
796+
// This can be done in any module, not just the anonymous crate module.
782797
#![warn(non_camel_case_types)]
783798
```
784799

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/librustc/middle/astencode.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -1835,29 +1835,31 @@ fn decode_item_ast(par_doc: rbml::Doc) -> ast::Item {
18351835
}
18361836

18371837
#[cfg(test)]
1838-
trait fake_ext_ctxt {
1838+
trait FakeExtCtxt {
1839+
fn call_site(&self) -> codemap::Span;
18391840
fn cfg(&self) -> ast::CrateConfig;
1840-
fn parse_sess<'a>(&'a self) -> &'a parse::ParseSess;
1841-
fn call_site(&self) -> Span;
18421841
fn ident_of(&self, st: &str) -> ast::Ident;
1842+
fn name_of(&self, st: &str) -> ast::Name;
1843+
fn parse_sess(&self) -> &parse::ParseSess;
18431844
}
18441845

18451846
#[cfg(test)]
1846-
impl fake_ext_ctxt for parse::ParseSess {
1847-
fn cfg(&self) -> ast::CrateConfig {
1848-
Vec::new()
1849-
}
1850-
fn parse_sess<'a>(&'a self) -> &'a parse::ParseSess { self }
1851-
fn call_site(&self) -> Span {
1847+
impl FakeExtCtxt for parse::ParseSess {
1848+
fn call_site(&self) -> codemap::Span {
18521849
codemap::Span {
18531850
lo: codemap::BytePos(0),
18541851
hi: codemap::BytePos(0),
1855-
expn_id: codemap::NO_EXPANSION
1852+
expn_id: codemap::NO_EXPANSION,
18561853
}
18571854
}
1855+
fn cfg(&self) -> ast::CrateConfig { Vec::new() }
18581856
fn ident_of(&self, st: &str) -> ast::Ident {
1859-
token::str_to_ident(st)
1857+
parse::token::str_to_ident(st)
1858+
}
1859+
fn name_of(&self, st: &str) -> ast::Name {
1860+
parse::token::intern(st)
18601861
}
1862+
fn parse_sess(&self) -> &parse::ParseSess { self }
18611863
}
18621864

18631865
#[cfg(test)]
@@ -1883,15 +1885,14 @@ fn test_basic() {
18831885
fn foo() {}
18841886
));
18851887
}
1886-
/* NOTE: When there's a snapshot, update this (yay quasiquoter!)
1888+
18871889
#[test]
18881890
fn test_smalltalk() {
18891891
let cx = mk_ctxt();
18901892
roundtrip(quote_item!(&cx,
18911893
fn foo() -> isize { 3 + 4 } // first smalltalk program ever executed.
18921894
));
18931895
}
1894-
*/
18951896

18961897
#[test]
18971898
fn test_more() {

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> {

0 commit comments

Comments
 (0)