Skip to content

Commit da11c0a

Browse files
committed
---
yaml --- r: 210366 b: refs/heads/try c: 74d24ad h: refs/heads/master v: v3
1 parent 7a93f9c commit da11c0a

File tree

324 files changed

+12643
-6863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+12643
-6863
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: 4b8098bb193d82d18183a8223507f5908adeeb4c
5+
refs/heads/try: 74d24ad6afc03476c671657ada598450e9a178b9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,14 @@ fi
544544
BOOL_OPTIONS=""
545545
VAL_OPTIONS=""
546546

547-
opt debug 0 "debug mode"
547+
opt debug 0 "debug mode; disables optimization unless \`--enable-optimize\` given"
548548
opt valgrind 0 "run tests with valgrind (memcheck by default)"
549549
opt helgrind 0 "run tests with helgrind instead of memcheck"
550550
opt valgrind-rpass 1 "run rpass-valgrind tests with valgrind"
551551
opt docs 1 "build standard library documentation"
552552
opt compiler-docs 0 "build compiler documentation"
553553
opt optimize-tests 1 "build tests with optimizations"
554+
opt debuginfo-tests 0 "build tests with debugger metadata"
554555
opt libcpp 1 "build with llvm with libc++ instead of libstdc++ when using clang"
555556
opt llvm-assertions 0 "build LLVM with assertions"
556557
opt debug-assertions 0 "build with debugging assertions"

branches/try/mk/crates.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
5858
rustc_data_structures
5959
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
6060
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
61-
TOOLS := compiletest rustdoc rustc rustbook
61+
TOOLS := compiletest rustdoc rustc rustbook error-index-generator
6262

6363
DEPS_core :=
6464
DEPS_libc := core
@@ -107,10 +107,12 @@ TOOL_DEPS_compiletest := test getopts
107107
TOOL_DEPS_rustdoc := rustdoc
108108
TOOL_DEPS_rustc := rustc_driver
109109
TOOL_DEPS_rustbook := std rustdoc
110+
TOOL_DEPS_error-index-generator := rustdoc syntax serialize
110111
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
111112
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
112113
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
113114
TOOL_SOURCE_rustbook := $(S)src/rustbook/main.rs
115+
TOOL_SOURCE_error-index-generator := $(S)src/error-index-generator/main.rs
114116

115117
ONLY_RLIB_core := 1
116118
ONLY_RLIB_libc := 1

branches/try/mk/docs.mk

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ RUSTBOOK_EXE = $(HBIN2_H_$(CFG_BUILD))/rustbook$(X_$(CFG_BUILD))
7171
# ./configure
7272
RUSTBOOK = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(RUSTBOOK_EXE)
7373

74+
# The error-index-generator executable...
75+
ERR_IDX_GEN_EXE = $(HBIN2_H_$(CFG_BUILD))/error-index-generator$(X_$(CFG_BUILD))
76+
ERR_IDX_GEN = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(ERR_IDX_GEN_EXE)
77+
7478
D := $(S)src/doc
7579

76-
DOC_TARGETS := trpl style
80+
DOC_TARGETS := trpl style error-index
7781
COMPILER_DOC_TARGETS :=
7882
DOC_L10N_TARGETS :=
7983

@@ -288,3 +292,9 @@ doc/style/index.html: $(RUSTBOOK_EXE) $(wildcard $(S)/src/doc/style/*.md) | doc/
288292
@$(call E, rustbook: $@)
289293
$(Q)rm -rf doc/style
290294
$(Q)$(RUSTBOOK) build $(S)src/doc/style doc/style
295+
296+
error-index: doc/error-index.html
297+
298+
doc/error-index.html: $(ERR_IDX_GEN_EXE) | doc/
299+
$(Q)$(call E, error-index-generator: $@)
300+
$(Q)$(ERR_IDX_GEN)

branches/try/mk/prepare.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ define PREPARE_MAN
7070
$(Q)$(PREPARE_MAN_CMD) $(PREPARE_SOURCE_MAN_DIR)/$(1) $(PREPARE_DEST_MAN_DIR)/$(1)
7171
endef
7272

73-
PREPARE_TOOLS = $(filter-out compiletest rustbook, $(TOOLS))
73+
PREPARE_TOOLS = $(filter-out compiletest rustbook error-index-generator, $(TOOLS))
7474

7575

7676
# $(1) is tool

branches/try/mk/tests.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,13 @@ ifndef CFG_DISABLE_OPTIMIZE_TESTS
632632
CTEST_RUSTC_FLAGS += -O
633633
endif
634634

635+
# Analogously to the above, whether to pass `-g` when compiling tests
636+
# is a separate choice from whether to pass `-g` when building the
637+
# compiler and standard library themselves.
638+
CTEST_RUSTC_FLAGS := $$(subst -g,,$$(CTEST_RUSTC_FLAGS))
639+
ifdef CFG_ENABLE_DEBUGINFO_TESTS
640+
CTEST_RUSTC_FLAGS += -g
641+
endif
635642

636643
CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
637644
--compile-lib-path $$(HLIB$(1)_H_$(3)) \

branches/try/src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
269269
run_ignored: config.run_ignored,
270270
logfile: config.logfile.clone(),
271271
run_tests: true,
272-
run_benchmarks: true,
272+
bench_benchmarks: true,
273273
nocapture: env::var("RUST_TEST_NOCAPTURE").is_ok(),
274274
color: test::AutoColor,
275275
}

branches/try/src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ This does mean that indexed access to a Unicode codepoint inside a `str` value i
109109
* Most "character oriented" operations on text only work under very restricted language assumptions sets such as "ASCII-range codepoints only". Outside ASCII-range, you tend to have to use a complex (non-constant-time) algorithm for determining linguistic-unit (glyph, word, paragraph) boundaries anyways. We recommend using an "honest" linguistically-aware, Unicode-approved algorithm.
110110
* The `char` type is UCS4. If you honestly need to do a codepoint-at-a-time algorithm, it's trivial to write a `type wstr = [char]`, and unpack a `str` into it in a single pass, then work with the `wstr`. In other words: the fact that the language is not "decoding to UCS4 by default" shouldn't stop you from decoding (or re-encoding any other way) if you need to work with that encoding.
111111

112-
## Why are strings, vectors etc. built-in types rather than (say) special kinds of trait/impl?
112+
## Why are `str`s, slices, arrays etc. built-in types rather than (say) special kinds of trait/impl?
113113

114114
In each case there is one or more operator, literal constructor, overloaded use or integration with a built-in control structure that makes us think it would be awkward to phrase the type in terms of more-general type constructors. Same as, say, with numbers! But this is partly an aesthetic call, and we'd be willing to look at a worked-out proposal for eliminating or rephrasing these special cases.
115115

branches/try/src/doc/grammar.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,15 @@ excluded from the `ident` rule.
176176

177177
```antlr
178178
lit_suffix : ident;
179-
literal : [ string_lit | char_lit | byte_string_lit | byte_lit | num_lit ] lit_suffix ?;
179+
literal : [ string_lit | char_lit | byte_string_lit | byte_lit | num_lit | bool_lit ] lit_suffix ?;
180180
```
181181

182+
The optional `lit_suffix` production is only used for certain numeric literals,
183+
but is reserved for future extension. That is, the above gives the lexical
184+
grammar, but a Rust parser will reject everything but the 12 special cases
185+
mentioned in [Number literals](reference.html#number-literals) in the
186+
reference.
187+
182188
#### Character and string literals
183189

184190
```antlr
@@ -238,7 +244,9 @@ dec_lit : [ dec_digit | '_' ] + ;
238244

239245
#### Boolean literals
240246

241-
**FIXME:** write grammar
247+
```antlr
248+
bool_lit : [ "true" | "false" ] ;
249+
```
242250

243251
The two values of the boolean type are written `true` and `false`.
244252

@@ -297,7 +305,7 @@ transcriber : '(' transcriber * ')' | '[' transcriber * ']'
297305

298306
```antlr
299307
item : mod_item | fn_item | type_item | struct_item | enum_item
300-
| static_item | trait_item | impl_item | extern_block ;
308+
| const_item | static_item | trait_item | impl_item | extern_block ;
301309
```
302310

303311
### Type Parameters
@@ -369,6 +377,10 @@ path_item : ident | "mod" ;
369377

370378
**FIXME:** grammar?
371379

380+
### Enumerations
381+
382+
**FIXME:** grammar?
383+
372384
### Constant items
373385

374386
```antlr

branches/try/src/doc/not_found.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ function populate_rust_search() {
5757

5858
// #18540, use a single token
5959

60+
var a = document.createElement("a");
61+
a.href = "http://doc.rust-lang.org/core/?search=" + encodeURIComponent(lt);
62+
a.textContent = lt;
6063
var search = document.getElementById('core-search');
61-
search.innerHTML = "<a href=\"http://doc.rust-lang.org/core/?search=" + lt + "\">" + lt + "</a>";
64+
search.innerHTML = "";
65+
search.appendChild(a);
6266
}
6367
populate_site_search();
6468
populate_rust_search();

branches/try/src/doc/reference.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Non-doc comments are interpreted as a form of whitespace.
103103

104104
## Whitespace
105105

106-
Whitespace is any non-empty string containing any the following characters:
106+
Whitespace is any non-empty string containing only the following characters:
107107

108108
- `U+0020` (space, `' '`)
109109
- `U+0009` (tab, `'\t'`)
@@ -130,11 +130,6 @@ of tokens, that immediately and directly denotes the value it evaluates to,
130130
rather than referring to it by name or some other evaluation rule. A literal is
131131
a form of constant expression, so is evaluated (primarily) at compile time.
132132

133-
The optional suffix is only used for certain numeric literals, but is
134-
reserved for future extension, that is, the above gives the lexical
135-
grammar, but a Rust parser will reject everything but the 12 special
136-
cases mentioned in [Number literals](#number-literals) below.
137-
138133
#### Examples
139134

140135
##### Characters and strings
@@ -1562,8 +1557,7 @@ warnings are generated, or otherwise "you used a private item of another module
15621557
and weren't allowed to."
15631558

15641559
By default, everything in Rust is *private*, with one exception. Enum variants
1565-
in a `pub` enum are also public by default. You are allowed to alter this
1566-
default visibility with the `priv` keyword. When an item is declared as `pub`,
1560+
in a `pub` enum are also public by default. When an item is declared as `pub`,
15671561
it can be thought of as being accessible to the outside world. For example:
15681562

15691563
```
@@ -1897,8 +1891,8 @@ release builds.
18971891

18981892
There are two kinds of configuration options, one that is either defined or not
18991893
(`#[cfg(foo)]`), and the other that contains a string that can be checked
1900-
against (`#[cfg(bar = "baz")]` (currently only compiler-defined configuration
1901-
options can have the latter form).
1894+
against (`#[cfg(bar = "baz")]`). Currently, only compiler-defined configuration
1895+
options can have the latter form.
19021896

19031897
```
19041898
// The function is only included in the build when compiling for OSX
@@ -2050,21 +2044,21 @@ A complete list of the built-in language items will be added in the future.
20502044

20512045
### Inline attributes
20522046

2053-
The inline attribute is used to suggest to the compiler to perform an inline
2054-
expansion and place a copy of the function or static in the caller rather than
2055-
generating code to call the function or access the static where it is defined.
2047+
The inline attribute suggests that the compiler should place a copy of
2048+
the function or static in the caller, rather than generating code to
2049+
call the function or access the static where it is defined.
20562050

20572051
The compiler automatically inlines functions based on internal heuristics.
2058-
Incorrectly inlining functions can actually making the program slower, so it
2052+
Incorrectly inlining functions can actually make the program slower, so it
20592053
should be used with care.
20602054

20612055
Immutable statics are always considered inlineable unless marked with
20622056
`#[inline(never)]`. It is undefined whether two different inlineable statics
20632057
have the same memory address. In other words, the compiler is free to collapse
20642058
duplicate inlineable statics together.
20652059

2066-
`#[inline]` and `#[inline(always)]` always causes the function to be serialized
2067-
into crate metadata to allow cross-crate inlining.
2060+
`#[inline]` and `#[inline(always)]` always cause the function to be serialized
2061+
into the crate metadata to allow cross-crate inlining.
20682062

20692063
There are three different types of inline attributes:
20702064

@@ -2431,11 +2425,18 @@ Tuples are written by enclosing zero or more comma-separated expressions in
24312425
parentheses. They are used to create [tuple-typed](#tuple-types) values.
24322426

24332427
```{.tuple}
2434-
(0,);
24352428
(0.0, 4.5);
24362429
("a", 4usize, true);
24372430
```
24382431

2432+
You can disambiguate a single-element tuple from a value in parentheses with a
2433+
comma:
2434+
2435+
```
2436+
(0,); // single-element tuple
2437+
(0); // zero in parentheses
2438+
```
2439+
24392440
### Unit expressions
24402441

24412442
The expression `()` denotes the _unit value_, the only value of the type with

branches/try/src/doc/trpl/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ want to dive in with a project, or ‘Syntax and Semantics’ if you prefer to
4040
start small, and learn a single concept thoroughly before moving onto the next.
4141
Copious cross-linking connects these parts together.
4242

43+
### Contributing
44+
45+
The source files from which this book is generated can be found on Github:
46+
[github.com/rust-lang/rust/tree/master/src/doc/trpl](https://github.com/rust-lang/rust/tree/master/src/doc/trpl)
47+
4348
## A brief introduction to Rust
4449

4550
Is Rust a language you might be interested in? Let’s examine a few small code
@@ -127,7 +132,7 @@ vector. When we try to compile this program, we get an error:
127132

128133
```text
129134
error: cannot borrow `x` as mutable because it is also borrowed as immutable
130-
x.push(4);
135+
x.push("foo");
131136
^
132137
note: previous borrow of `x` occurs here; the immutable borrow prevents
133138
subsequent moves or mutable borrows of `x` until the borrow ends
@@ -190,5 +195,5 @@ fn main() {
190195
We created an inner scope with an additional set of curly braces. `y` will go out of
191196
scope before we call `push()`, and so we’re all good.
192197

193-
This concept of ownership isn’t just good for preventing danging pointers, but an
198+
This concept of ownership isn’t just good for preventing dangling pointers, but an
194199
entire set of related problems, like iterator invalidation, concurrency, and more.

branches/try/src/doc/trpl/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* [Hello, world!](hello-world.md)
66
* [Hello, Cargo!](hello-cargo.md)
77
* [Learn Rust](learn-rust.md)
8+
* [Guessing Game](guessing-game.md)
89
* [Effective Rust](effective-rust.md)
910
* [The Stack and the Heap](the-stack-and-the-heap.md)
1011
* [Testing](testing.md)
@@ -26,7 +27,6 @@
2627
* [References and Borrowing](references-and-borrowing.md)
2728
* [Lifetimes](lifetimes.md)
2829
* [Mutability](mutability.md)
29-
* [Move semantics](move-semantics.md)
3030
* [Enums](enums.md)
3131
* [Match](match.md)
3232
* [Structs](structs.md)
@@ -64,5 +64,6 @@
6464
* [Benchmark Tests](benchmark-tests.md)
6565
* [Box Syntax and Patterns](box-syntax-and-patterns.md)
6666
* [Slice Patterns](slice-patterns.md)
67+
* [Associated Constants](associated-constants.md)
6768
* [Glossary](glossary.md)
6869
* [Academic Research](academic-research.md)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
% Associated Constants
2+
3+
With the `associated_consts` feature, you can define constants like this:
4+
5+
```rust
6+
#![feature(associated_consts)]
7+
8+
trait Foo {
9+
const ID: i32;
10+
}
11+
12+
impl Foo for i32 {
13+
const ID: i32 = 1;
14+
}
15+
16+
fn main() {
17+
assert_eq!(1, i32::ID);
18+
}
19+
```
20+
21+
Any implementor of `Foo` will have to define `ID`. Without the definition:
22+
23+
```rust,ignore
24+
#![feature(associated_consts)]
25+
26+
trait Foo {
27+
const ID: i32;
28+
}
29+
30+
impl Foo for i32 {
31+
}
32+
```
33+
34+
gives
35+
36+
```text
37+
error: not all trait items implemented, missing: `ID` [E0046]
38+
impl Foo for i32 {
39+
}
40+
```
41+
42+
A default value can be implemented as well:
43+
44+
```rust
45+
#![feature(associated_consts)]
46+
47+
trait Foo {
48+
const ID: i32 = 1;
49+
}
50+
51+
impl Foo for i32 {
52+
}
53+
54+
impl Foo for i64 {
55+
const ID: i32 = 5;
56+
}
57+
58+
fn main() {
59+
assert_eq!(1, i32::ID);
60+
assert_eq!(5, i64::ID);
61+
}
62+
```
63+
64+
As you can see, when implementing `Foo`, you can leave it unimplemented, as
65+
with `i32`. It will then use the default value. But, as in `i64`, we can also
66+
add our own definition.
67+
68+
Associated constants don’t have to be associated with a trait. An `impl` block
69+
for a `struct` works fine too:
70+
71+
```rust
72+
#![feature(associated_consts)]
73+
74+
struct Foo;
75+
76+
impl Foo {
77+
pub const FOO: u32 = 3;
78+
}
79+
```

0 commit comments

Comments
 (0)