Skip to content

Commit 3e20538

Browse files
committed
---
yaml --- r: 212431 b: refs/heads/master c: 32e96aa h: refs/heads/master i: 212429: d20650e 212427: b09cd9d 212423: 0470838 212415: e831e84 v: v3
1 parent 1175249 commit 3e20538

File tree

37 files changed

+2444
-803
lines changed

37 files changed

+2444
-803
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a3cd5eb1bd53a919bfc76da06e05e0d32c410e5b
2+
refs/heads/master: 32e96aa165d2e3cd7f142a9ed64e38289dc73f1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
55
refs/heads/try: 1864973ae17213c5a58c4dd3f9af6d1b6c7d2e05

trunk/mk/cfg/x86_64-pc-windows-msvc.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ CFG_STATIC_LIB_NAME_x86_64-pc-windows-msvc=$(1).lib
99
CFG_LIB_GLOB_x86_64-pc-windows-msvc=$(1)-*.dll
1010
CFG_LIB_DSYM_GLOB_x86_64-pc-windows-msvc=$(1)-*.dylib.dSYM
1111
CFG_JEMALLOC_CFLAGS_x86_64-pc-windows-msvc :=
12-
CFG_GCCISH_CFLAGS_x86_64-pc-windows-msvc :=
13-
CFG_GCCISH_CXXFLAGS_x86_64-pc-windows-msvc :=
12+
CFG_GCCISH_CFLAGS_x86_64-pc-windows-msvc := -MD
13+
CFG_GCCISH_CXXFLAGS_x86_64-pc-windows-msvc := -MD
1414
CFG_GCCISH_LINK_FLAGS_x86_64-pc-windows-msvc :=
1515
CFG_GCCISH_DEF_FLAG_x86_64-pc-windows-msvc :=
1616
CFG_LLC_FLAGS_x86_64-pc-windows-msvc :=

trunk/mk/docs.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ DOC_TARGETS += doc/not_found.html
169169
doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
170170
@$(call E, rustdoc: $@)
171171
$(Q)$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) \
172+
--markdown-no-toc \
172173
--markdown-css http://doc.rust-lang.org/rust.css $<
173174

174175
define DEF_DOC

trunk/src/doc/grammar.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ type_path_tail : '<' type_expr [ ',' type_expr ] + '>'
281281
## Macros
282282

283283
```antlr
284-
expr_macro_rules : "macro_rules" '!' ident '(' macro_rule * ')' ;
284+
expr_macro_rules : "macro_rules" '!' ident '(' macro_rule * ')' ';'
285+
| "macro_rules" '!' ident '{' macro_rule * '}' ;
285286
macro_rule : '(' matcher * ')' "=>" '(' transcriber * ')' ';' ;
286287
matcher : '(' matcher * ')' | '[' matcher * ']'
287288
| '{' matcher * '}' | '$' ident ':' ident

trunk/src/doc/not_found.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ Looks like you've taken a wrong turn.
1111

1212
Some things that might be helpful to you though:
1313

14-
## Search
14+
# Search
1515

1616
* <form action="https://duckduckgo.com/">
1717
<input type="text" id="site-search" name="q" size="80"></input>
1818
<input type="submit" value="Search DuckDuckGo">
1919
</form>
2020
* Rust doc search: <span id="core-search"></span>
2121

22-
## Reference
22+
# Reference
2323

2424
* [The Rust official site](http://rust-lang.org)
2525
* [The Rust reference](http://doc.rust-lang.org/reference.html)
2626

27-
## Docs
27+
# Docs
2828

2929
* [The standard library](http://doc.rust-lang.org/std/)
3030

trunk/src/doc/reference.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,6 @@ Traits can include default implementations of methods, as in:
13671367
```
13681368
trait Foo {
13691369
fn bar(&self);
1370-
13711370
fn baz(&self) { println!("We called baz."); }
13721371
}
13731372
```

trunk/src/doc/trpl/const-and-static.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ unsafe {
6464

6565
[unsafe]: unsafe.html
6666

67-
Furthermore, any type stored in a `static` must be `Sync`.
67+
Furthermore, any type stored in a `static` must be `Sync`, and may not have
68+
a [`Drop`][drop] implementation.
69+
70+
[drop]: drop.html
6871

6972
# Initializing
7073

@@ -78,7 +81,3 @@ Almost always, if you can choose between the two, choose `const`. It’s pretty
7881
rare that you actually want a memory location associated with your constant,
7982
and using a const allows for optimizations like constant propagation not only
8083
in your crate but downstream crates.
81-
82-
A const can be thought of as a `#define` in C: it has metadata overhead but it
83-
has no runtime overhead. “Should I use a #define or a static in C,” is largely
84-
the same question as whether you should use a const or a static in Rust.

trunk/src/doc/trpl/dining-philosophers.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,13 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
674674

675675
Finally, inside of our `map()`/`collect()` loop, we call `table.clone()`. The
676676
`clone()` method on `Arc<T>` is what bumps up the reference count, and when it
677-
goes out of scope, it decrements the count. You’ll notice we can introduce a
678-
new binding to `table` here, and it will shadow the old one. This is often used
679-
so that you don’t need to come up with two unique names.
677+
goes out of scope, it decrements the count. This is needed so that we know how
678+
many references to `table` exist across our threads. If we didn’t have a count,
679+
we wouldn’t know how to deallocate it.
680+
681+
You’ll notice we can introduce a new binding to `table` here, and it will
682+
shadow the old one. This is often used so that you don’t need to come up with
683+
two unique names.
680684

681685
With this, our program works! Only two philosophers can eat at any one time,
682686
and so you’ll get some output like this:

trunk/src/doc/trpl/enums.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,45 @@ equality yet, but we’ll find out in the [`traits`][traits] section.
6464
[match]: match.html
6565
[if-let]: if-let.html
6666
[traits]: traits.html
67+
68+
# Constructors as functions
69+
70+
An enum’s constructors can also be used like functions. For example:
71+
72+
```rust
73+
# enum Message {
74+
# Write(String),
75+
# }
76+
let m = Message::Write("Hello, world".to_string());
77+
```
78+
79+
Is the same as
80+
81+
```rust
82+
# enum Message {
83+
# Write(String),
84+
# }
85+
fn foo(x: String) -> Message {
86+
Message::Write(x)
87+
}
88+
89+
let x = foo("Hello, world".to_string());
90+
```
91+
92+
This is not immediately useful to us, but when we get to
93+
[`closures`][closures], we’ll talk about passing functions as arguments to
94+
other functions. For example, with [`iterators`][iterators], we can do this
95+
to convert a vector of `String`s into a vector of `Message::Write`s:
96+
97+
```rust
98+
# enum Message {
99+
# Write(String),
100+
# }
101+
102+
let v = vec!["Hello".to_string(), "World".to_string()];
103+
104+
let v1: Vec<Message> = v.into_iter().map(Message::Write).collect();
105+
```
106+
107+
[closures]: closures.html
108+
[iterators]: iterators.html

trunk/src/doc/trpl/ffi.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ Note that frameworks are only available on OSX targets.
342342
The different `kind` values are meant to differentiate how the native library
343343
participates in linkage. From a linkage perspective, the rust compiler creates
344344
two flavors of artifacts: partial (rlib/staticlib) and final (dylib/binary).
345-
Native dynamic libraries and frameworks are propagated to the final artifact
346-
boundary, while static libraries are not propagated at all.
345+
Native dynamic library and framework dependencies are propagated to the final
346+
artifact boundary, while static library dependencies are not propagated at
347+
all, because the static libraries are integrated directly into the subsequent
348+
artifact.
347349
348350
A few examples of how this model can be used are:
349351

trunk/src/doc/trpl/method-syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl Circle {
8686
# Chaining method calls
8787

8888
So, now we know how to call a method, such as `foo.bar()`. But what about our
89-
original example, `foo.bar().baz()`? This is called ‘method chaining’, and we
90-
can do it by returning `self`.
89+
original example, `foo.bar().baz()`? This is called ‘method chaining’. Let’s
90+
look at an example:
9191

9292
```rust
9393
struct Circle {

trunk/src/doc/trpl/patterns.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,31 @@ match x {
154154

155155
This prints `Got an int!`.
156156

157+
If you’re using `if` with multiple patterns, the `if` applies to both sides:
158+
159+
```rust
160+
let x = 4;
161+
let y = false;
162+
163+
match x {
164+
4 | 5 if y => println!("yes"),
165+
_ => println!("no"),
166+
}
167+
```
168+
169+
This prints `no`, because the `if` applies to the whole of `4 | 5`, and not to
170+
just the `5`, In other words, the the precedence of `if` behaves like this:
171+
172+
```text
173+
(4 | 5) if y => ...
174+
```
175+
176+
not this:
177+
178+
```text
179+
4 | (5 if y) => ...
180+
```
181+
157182
# ref and ref mut
158183

159184
If you want to get a [reference][ref], use the `ref` keyword:

trunk/src/doc/trpl/references-and-borrowing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ As it turns out, there are rules.
151151

152152
Here’s the rules about borrowing in Rust:
153153

154-
First, any borrow must last for a smaller scope than the owner. Second, you may
155-
have one or the other of these two kinds of borrows, but not both at the same
156-
time:
154+
First, any borrow must last for a scope no greater than that of the owner.
155+
Second, you may have one or the other of these two kinds of borrows, but not
156+
both at the same time:
157157

158158
* one or more references (`&T`) to a resource.
159159
* exactly one mutable reference (`&mut T`)

trunk/src/etc/unicode.py

Lines changed: 72 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ def is_surrogate(n):
7272
def load_unicode_data(f):
7373
fetch(f)
7474
gencats = {}
75-
upperlower = {}
76-
lowerupper = {}
75+
to_lower = {}
76+
to_upper = {}
77+
to_title = {}
7778
combines = {}
7879
canon_decomp = {}
7980
compat_decomp = {}
@@ -103,12 +104,16 @@ def load_unicode_data(f):
103104

104105
# generate char to char direct common and simple conversions
105106
# uppercase to lowercase
106-
if gencat == "Lu" and lowcase != "" and code_org != lowcase:
107-
upperlower[code] = int(lowcase, 16)
107+
if lowcase != "" and code_org != lowcase:
108+
to_lower[code] = (int(lowcase, 16), 0, 0)
108109

109110
# lowercase to uppercase
110-
if gencat == "Ll" and upcase != "" and code_org != upcase:
111-
lowerupper[code] = int(upcase, 16)
111+
if upcase != "" and code_org != upcase:
112+
to_upper[code] = (int(upcase, 16), 0, 0)
113+
114+
# title case
115+
if titlecase.strip() != "" and code_org != titlecase:
116+
to_title[code] = (int(titlecase, 16), 0, 0)
112117

113118
# store decomposition, if given
114119
if decomp != "":
@@ -144,7 +149,32 @@ def load_unicode_data(f):
144149
gencats = group_cats(gencats)
145150
combines = to_combines(group_cats(combines))
146151

147-
return (canon_decomp, compat_decomp, gencats, combines, lowerupper, upperlower)
152+
return (canon_decomp, compat_decomp, gencats, combines, to_upper, to_lower, to_title)
153+
154+
def load_special_casing(f, to_upper, to_lower, to_title):
155+
fetch(f)
156+
for line in fileinput.input(f):
157+
data = line.split('#')[0].split(';')
158+
if len(data) == 5:
159+
code, lower, title, upper, _comment = data
160+
elif len(data) == 6:
161+
code, lower, title, upper, condition, _comment = data
162+
if condition.strip(): # Only keep unconditional mappins
163+
continue
164+
else:
165+
continue
166+
code = code.strip()
167+
lower = lower.strip()
168+
title = title.strip()
169+
upper = upper.strip()
170+
key = int(code, 16)
171+
for (map_, values) in [(to_lower, lower), (to_upper, upper), (to_title, title)]:
172+
if values != code:
173+
values = [int(i, 16) for i in values.split()]
174+
for _ in range(len(values), 3):
175+
values.append(0)
176+
assert len(values) == 3
177+
map_[key] = values
148178

149179
def group_cats(cats):
150180
cats_out = {}
@@ -279,7 +309,7 @@ def load_east_asian_width(want_widths, except_cats):
279309
return widths
280310

281311
def escape_char(c):
282-
return "'\\u{%x}'" % c
312+
return "'\\u{%x}'" % c if c != 0 else "'\\0'"
283313

284314
def emit_bsearch_range_table(f):
285315
f.write("""
@@ -319,7 +349,7 @@ def emit_property_module(f, mod, tbl, emit):
319349
f.write(" }\n\n")
320350
f.write("}\n\n")
321351

322-
def emit_conversions_module(f, lowerupper, upperlower):
352+
def emit_conversions_module(f, to_upper, to_lower, to_title):
323353
f.write("pub mod conversions {")
324354
f.write("""
325355
use core::cmp::Ordering::{Equal, Less, Greater};
@@ -328,21 +358,28 @@ def emit_conversions_module(f, lowerupper, upperlower):
328358
use core::option::Option::{Some, None};
329359
use core::result::Result::{Ok, Err};
330360
331-
pub fn to_lower(c: char) -> char {
332-
match bsearch_case_table(c, LuLl_table) {
333-
None => c,
334-
Some(index) => LuLl_table[index].1
361+
pub fn to_lower(c: char) -> [char; 3] {
362+
match bsearch_case_table(c, to_lowercase_table) {
363+
None => [c, '\\0', '\\0'],
364+
Some(index) => to_lowercase_table[index].1
365+
}
366+
}
367+
368+
pub fn to_upper(c: char) -> [char; 3] {
369+
match bsearch_case_table(c, to_uppercase_table) {
370+
None => [c, '\\0', '\\0'],
371+
Some(index) => to_uppercase_table[index].1
335372
}
336373
}
337374
338-
pub fn to_upper(c: char) -> char {
339-
match bsearch_case_table(c, LlLu_table) {
340-
None => c,
341-
Some(index) => LlLu_table[index].1
375+
pub fn to_title(c: char) -> [char; 3] {
376+
match bsearch_case_table(c, to_titlecase_table) {
377+
None => [c, '\\0', '\\0'],
378+
Some(index) => to_titlecase_table[index].1
342379
}
343380
}
344381
345-
fn bsearch_case_table(c: char, table: &'static [(char, char)]) -> Option<usize> {
382+
fn bsearch_case_table(c: char, table: &'static [(char, [char; 3])]) -> Option<usize> {
346383
match table.binary_search_by(|&(key, _)| {
347384
if c == key { Equal }
348385
else if key < c { Less }
@@ -354,10 +391,18 @@ def emit_conversions_module(f, lowerupper, upperlower):
354391
}
355392
356393
""")
357-
emit_table(f, "LuLl_table",
358-
sorted(upperlower.iteritems(), key=operator.itemgetter(0)), is_pub=False)
359-
emit_table(f, "LlLu_table",
360-
sorted(lowerupper.iteritems(), key=operator.itemgetter(0)), is_pub=False)
394+
t_type = "&'static [(char, [char; 3])]"
395+
pfun = lambda x: "(%s,[%s,%s,%s])" % (
396+
escape_char(x[0]), escape_char(x[1][0]), escape_char(x[1][1]), escape_char(x[1][2]))
397+
emit_table(f, "to_lowercase_table",
398+
sorted(to_lower.iteritems(), key=operator.itemgetter(0)),
399+
is_pub=False, t_type = t_type, pfun=pfun)
400+
emit_table(f, "to_uppercase_table",
401+
sorted(to_upper.iteritems(), key=operator.itemgetter(0)),
402+
is_pub=False, t_type = t_type, pfun=pfun)
403+
emit_table(f, "to_titlecase_table",
404+
sorted(to_title.iteritems(), key=operator.itemgetter(0)),
405+
is_pub=False, t_type = t_type, pfun=pfun)
361406
f.write("}\n\n")
362407

363408
def emit_grapheme_module(f, grapheme_table, grapheme_cats):
@@ -591,8 +636,10 @@ def optimize_width_table(wtable):
591636
pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
592637
""" % unicode_version)
593638
(canon_decomp, compat_decomp, gencats, combines,
594-
lowerupper, upperlower) = load_unicode_data("UnicodeData.txt")
595-
want_derived = ["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"]
639+
to_upper, to_lower, to_title) = load_unicode_data("UnicodeData.txt")
640+
load_special_casing("SpecialCasing.txt", to_upper, to_lower, to_title)
641+
want_derived = ["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase",
642+
"Cased", "Case_Ignorable"]
596643
derived = load_properties("DerivedCoreProperties.txt", want_derived)
597644
scripts = load_properties("Scripts.txt", [])
598645
props = load_properties("PropList.txt",
@@ -611,7 +658,7 @@ def optimize_width_table(wtable):
611658

612659
# normalizations and conversions module
613660
emit_norm_module(rf, canon_decomp, compat_decomp, combines, norm_props)
614-
emit_conversions_module(rf, lowerupper, upperlower)
661+
emit_conversions_module(rf, to_upper, to_lower, to_title)
615662

616663
### character width module
617664
width_table = []

0 commit comments

Comments
 (0)