Skip to content

Commit 5985d3a

Browse files
committed
---
yaml --- r: 152359 b: refs/heads/try2 c: ffdb881 h: refs/heads/master i: 152357: 184e6d9 152355: 39dc182 152351: a72aeca v: v3
1 parent 0cec659 commit 5985d3a

File tree

229 files changed

+4334
-3827
lines changed

Some content is hidden

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

229 files changed

+4334
-3827
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 4666792ac600f4e4e1c09a37b88f40f6125b57b8
8+
refs/heads/try2: ffdb881337911e65f25dba2dc6e67aed29ffa4cc
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/crates.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
5353
uuid serialize sync getopts collections num test time rand \
54-
url log regex graphviz core rlibc alloc debug
54+
url log regex graphviz core rlibc alloc debug rustrt
5555
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros
5656
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5757
TOOLS := compiletest rustdoc rustc
@@ -60,7 +60,9 @@ DEPS_core :=
6060
DEPS_rlibc :=
6161
DEPS_alloc := core libc native:jemalloc
6262
DEPS_debug := std
63-
DEPS_std := core rand libc alloc collections native:rustrt native:backtrace
63+
DEPS_rustrt := alloc core libc collections native:rustrt_native
64+
DEPS_std := core libc rand alloc collections rustrt \
65+
native:rust_builtin native:backtrace
6466
DEPS_graphviz := std
6567
DEPS_green := std native:context_switch
6668
DEPS_rustuv := std native:uv native:uv_support

branches/try2/mk/docs.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ L10N_LANGS := ja
4343

4444
# The options are passed to the documentation generators.
4545
RUSTDOC_HTML_OPTS_NO_CSS = --markdown-before-content=doc/version_info.html \
46-
--markdown-in-header=doc/favicon.inc --markdown-after-content=doc/footer.inc
46+
--markdown-in-header=doc/favicon.inc \
47+
--markdown-after-content=doc/footer.inc \
48+
--markdown-playground-url='http://play.rust-lang.org/'
4749

4850
RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css
4951

branches/try2/mk/rt.mk

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
# that's per-target so you're allowed to conditionally add files based on the
3636
# target.
3737
################################################################################
38-
NATIVE_LIBS := rustrt hoedown uv_support morestack miniz context_switch \
39-
rust_test_helpers
38+
NATIVE_LIBS := rust_builtin hoedown uv_support morestack miniz context_switch \
39+
rustrt_native rust_test_helpers
4040

4141
# $(1) is the target triple
4242
define NATIVE_LIBRARIES
@@ -52,8 +52,9 @@ NATIVE_DEPS_hoedown_$(1) := hoedown/src/autolink.c \
5252
hoedown/src/version.c
5353
NATIVE_DEPS_uv_support_$(1) := rust_uv.c
5454
NATIVE_DEPS_miniz_$(1) = miniz.c
55-
NATIVE_DEPS_rustrt_$(1) := rust_builtin.c \
56-
rust_android_dummy.c \
55+
NATIVE_DEPS_rust_builtin_$(1) := rust_builtin.c \
56+
rust_android_dummy.c
57+
NATIVE_DEPS_rustrt_native_$(1) := \
5758
rust_try.ll \
5859
arch/$$(HOST_$(1))/record_sp.S
5960
NATIVE_DEPS_rust_test_helpers_$(1) := rust_test_helpers.c

branches/try2/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ endif
818818
ifeq ($(2),$$(CFG_BUILD))
819819
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)): $$(CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4))
820820
@$$(call E, run doc-crate-$(4) [$(2)])
821-
$$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test \
821+
$$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test --cfg dox \
822822
$$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@
823823
else
824824
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)):

branches/try2/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ fn disassemble_extract(config: &Config, _props: &TestProps,
15451545
fn count_extracted_lines(p: &Path) -> uint {
15461546
let x = File::open(&p.with_extension("ll")).read_to_end().unwrap();
15471547
let x = str::from_utf8(x.as_slice()).unwrap();
1548-
x.lines().len()
1548+
x.lines().count()
15491549
}
15501550

15511551

branches/try2/src/doc/footer.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ or the <a href="http://opensource.org/licenses/MIT">MIT license</a>, at your opt
55
</p><p>
66
This file may not be copied, modified, or distributed except according to those terms.
77
</p></footer>
8+
<script type="text/javascript" src="jquery.js"></script>
9+
<script type="text/javascript" src="playpen.js"></script>

branches/try2/src/doc/guide-macros.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ which both pattern-match on their input and both return early in one case,
1111
doing nothing otherwise:
1212

1313
~~~~
14-
# enum T { SpecialA(uint), SpecialB(uint) };
14+
# enum T { SpecialA(uint), SpecialB(uint) }
1515
# fn f() -> uint {
1616
# let input_1 = SpecialA(0);
1717
# let input_2 = SpecialA(0);
@@ -37,7 +37,8 @@ lightweight custom syntax extensions, themselves defined using the
3737
the pattern in the above code:
3838

3939
~~~~
40-
# enum T { SpecialA(uint), SpecialB(uint) };
40+
# #![feature(macro_rules)]
41+
# enum T { SpecialA(uint), SpecialB(uint) }
4142
# fn f() -> uint {
4243
# let input_1 = SpecialA(0);
4344
# let input_2 = SpecialA(0);
@@ -55,6 +56,7 @@ early_return!(input_1 SpecialA);
5556
early_return!(input_2 SpecialB);
5657
# return 0;
5758
# }
59+
# fn main() {}
5860
~~~~
5961

6062
Macros are defined in pattern-matching style: in the above example, the text
@@ -155,7 +157,8 @@ separator token (a comma-separated list could be written `$(...),*`), and `+`
155157
instead of `*` to mean "at least one".
156158

157159
~~~~
158-
# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)};
160+
# #![feature(macro_rules)]
161+
# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)}
159162
# fn f() -> uint {
160163
# let input_1 = SpecialA(0);
161164
# let input_2 = SpecialA(0);
@@ -175,6 +178,7 @@ early_return!(input_1, [SpecialA|SpecialC|SpecialD]);
175178
early_return!(input_2, [SpecialB]);
176179
# return 0;
177180
# }
181+
# fn main() {}
178182
~~~~
179183

180184
### Transcription
@@ -215,9 +219,10 @@ solves the problem.
215219
Now consider code like the following:
216220

217221
~~~~
218-
# enum T1 { Good1(T2, uint), Bad1};
222+
# #![feature(macro_rules)]
223+
# enum T1 { Good1(T2, uint), Bad1}
219224
# struct T2 { body: T3 }
220-
# enum T3 { Good2(uint), Bad2};
225+
# enum T3 { Good2(uint), Bad2}
221226
# fn f(x: T1) -> uint {
222227
match x {
223228
Good1(g1, val) => {
@@ -232,6 +237,7 @@ match x {
232237
_ => return 0 // default value
233238
}
234239
# }
240+
# fn main() {}
235241
~~~~
236242

237243
All the complicated stuff is deeply indented, and the error-handling code is
@@ -240,6 +246,7 @@ a match, but with a syntax that suits the problem better. The following macro
240246
can solve the problem:
241247

242248
~~~~
249+
# #![feature(macro_rules)]
243250
macro_rules! biased_match (
244251
// special case: `let (x) = ...` is illegal, so use `let x = ...` instead
245252
( ($e:expr) ~ ($p:pat) else $err:stmt ;
@@ -261,9 +268,9 @@ macro_rules! biased_match (
261268
)
262269
)
263270
264-
# enum T1 { Good1(T2, uint), Bad1};
271+
# enum T1 { Good1(T2, uint), Bad1}
265272
# struct T2 { body: T3 }
266-
# enum T3 { Good2(uint), Bad2};
273+
# enum T3 { Good2(uint), Bad2}
267274
# fn f(x: T1) -> uint {
268275
biased_match!((x) ~ (Good1(g1, val)) else { return 0 };
269276
binds g1, val )
@@ -273,13 +280,16 @@ biased_match!((g1.body) ~ (Good2(result) )
273280
// complicated stuff goes here
274281
return result + val;
275282
# }
283+
# fn main() {}
276284
~~~~
277285

278286
This solves the indentation problem. But if we have a lot of chained matches
279287
like this, we might prefer to write a single macro invocation. The input
280288
pattern we want is clear:
281289

282290
~~~~
291+
# #![feature(macro_rules)]
292+
# fn main() {}
283293
# macro_rules! b(
284294
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
285295
binds $( $bind_res:ident ),*
@@ -301,14 +311,18 @@ process the semicolon-terminated lines, one-by-one. So, we want the following
301311
input patterns:
302312

303313
~~~~
314+
# #![feature(macro_rules)]
304315
# macro_rules! b(
305316
( binds $( $bind_res:ident ),* )
306317
# => (0))
318+
# fn main() {}
307319
~~~~
308320

309321
...and:
310322

311323
~~~~
324+
# #![feature(macro_rules)]
325+
# fn main() {}
312326
# macro_rules! b(
313327
( ($e :expr) ~ ($p :pat) else $err :stmt ;
314328
$( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
@@ -322,6 +336,8 @@ The resulting macro looks like this. Note that the separation into
322336
piece of syntax (the `let`) which we only want to transcribe once.
323337

324338
~~~~
339+
# #![feature(macro_rules)]
340+
# fn main() {
325341
326342
macro_rules! biased_match_rec (
327343
// Handle the first layer
@@ -365,9 +381,9 @@ macro_rules! biased_match (
365381
)
366382
367383
368-
# enum T1 { Good1(T2, uint), Bad1};
384+
# enum T1 { Good1(T2, uint), Bad1}
369385
# struct T2 { body: T3 }
370-
# enum T3 { Good2(uint), Bad2};
386+
# enum T3 { Good2(uint), Bad2}
371387
# fn f(x: T1) -> uint {
372388
biased_match!(
373389
(x) ~ (Good1(g1, val)) else { return 0 };
@@ -376,6 +392,7 @@ biased_match!(
376392
// complicated stuff goes here
377393
return result + val;
378394
# }
395+
# }
379396
~~~~
380397

381398
This technique applies to many cases where transcribing a result all at once is not possible.

branches/try2/src/doc/guide-unsafe.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ vectors provided from C, using idiomatic Rust practices.
523523

524524
```
525525
#![no_std]
526+
#![feature(globs)]
526527
527528
# extern crate libc;
528529
extern crate core;

branches/try2/src/doc/rust.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,19 @@ table th {
313313
padding: 5px;
314314
}
315315

316+
/* Code snippets */
317+
318+
.rusttest { display: none; }
319+
pre.rust { position: relative; }
320+
pre.rust a { transform: scaleX(-1); }
321+
.test-arrow {
322+
display: inline-block;
323+
position: absolute;
324+
top: 0;
325+
right: 10px;
326+
font-size: 150%;
327+
}
328+
316329
@media (min-width: 1170px) {
317330
pre {
318331
font-size: 15px;

branches/try2/src/doc/rust.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,13 +1260,16 @@ a = Cat;
12601260
Enumeration constructors can have either named or unnamed fields:
12611261

12621262
~~~~
1263+
# #![feature(struct_variant)]
1264+
# fn main() {
12631265
enum Animal {
12641266
Dog (String, f64),
12651267
Cat { name: String, weight: f64 }
12661268
}
12671269
12681270
let mut a: Animal = Dog("Cocoa".to_string(), 37.2);
12691271
a = Cat { name: "Spotty".to_string(), weight: 2.7 };
1272+
# }
12701273
~~~~
12711274

12721275
In this example, `Cat` is a _struct-like enum variant_,
@@ -2524,10 +2527,10 @@ Note that for a given *unit-like* structure type, this will always be the same v
25242527

25252528
A structure expression can terminate with the syntax `..` followed by an expression to denote a functional update.
25262529
The expression following `..` (the base) must have the same structure type as the new structure type being formed.
2527-
The entire expression denotes the result of allocating a new structure
2530+
The entire expression denotes the result of constructing a new structure
25282531
(with the same type as the base expression)
25292532
with the given values for the fields that were explicitly specified
2530-
and the values in the base record for all other fields.
2533+
and the values in the base expression for all other fields.
25312534

25322535
~~~~
25332536
# struct Point3d { x: int, y: int, z: int }
@@ -2575,15 +2578,15 @@ when not immediately followed by a parenthesized expression-list (the latter is
25752578
A field expression denotes a field of a [structure](#structure-types).
25762579

25772580
~~~~ {.ignore .field}
2578-
myrecord.myfield;
2581+
mystruct.myfield;
25792582
foo().x;
25802583
(Struct {a: 10, b: 20}).a;
25812584
~~~~
25822585

2583-
A field access on a record is an [lvalue](#lvalues-rvalues-and-temporaries) referring to the value of that field.
2584-
When the field is mutable, it can be [assigned](#assignment-expressions) to.
2586+
A field access is an [lvalue](#lvalues-rvalues-and-temporaries) referring to the value of that field.
2587+
When the type providing the field inherits mutabilty, it can be [assigned](#assignment-expressions) to.
25852588

2586-
When the type of the expression to the left of the dot is a pointer to a record or structure,
2589+
Also, if the type of the expression to the left of the dot is a pointer,
25872590
it is automatically dereferenced to make the field access possible.
25882591

25892592
### Vector expressions
@@ -3038,7 +3041,7 @@ match_pat : pat [ '|' pat ] * [ "if" expr ] ? ;
30383041

30393042
A `match` expression branches on a *pattern*. The exact form of matching that
30403043
occurs depends on the pattern. Patterns consist of some combination of
3041-
literals, destructured vectors or enum constructors, structures, records and
3044+
literals, destructured vectors or enum constructors, structures and
30423045
tuples, variable binding specifications, wildcards (`..`), and placeholders
30433046
(`_`). A `match` expression has a *head expression*, which is the value to
30443047
compare to the patterns. The type of the patterns must equal the type of the
@@ -3315,17 +3318,16 @@ such as `&str` or `String`.
33153318

33163319
### Tuple types
33173320

3318-
The tuple type-constructor forms a new heterogeneous product of values similar
3319-
to the record type-constructor. The differences are as follows:
3320-
3321-
* tuple elements cannot be mutable, unlike record fields
3322-
* tuple elements are not named and can be accessed only by pattern-matching
3321+
A tuple *type* is a heterogeneous product of other types, called the *elements*
3322+
of the tuple. It has no nominal name and is instead structurally typed.
33233323

33243324
Tuple types and values are denoted by listing the types or values of their
33253325
elements, respectively, in a parenthesized, comma-separated
33263326
list.
33273327

3328-
The members of a tuple are laid out in memory contiguously, like a record, in
3328+
Because tuple elements don't have a name, they can only be accessed by pattern-matching.
3329+
3330+
The members of a tuple are laid out in memory contiguously, in
33293331
order specified by the tuple type.
33303332

33313333
An example of a tuple type and its use:
@@ -3377,12 +3379,13 @@ of the type.[^structtype]
33773379

33783380
New instances of a `struct` can be constructed with a [struct expression](#structure-expressions).
33793381

3380-
The memory order of fields in a `struct` is given by the item defining it.
3381-
Fields may be given in any order in a corresponding struct *expression*;
3382-
the resulting `struct` value will always be laid out in memory in the order specified by the corresponding *item*.
3382+
The memory layout of a `struct` is undefined by default to allow for compiler optimziations like
3383+
field reordering, but it can be fixed with the `#[repr(...)]` attribute.
3384+
In either case, fields may be given in any order in a corresponding struct *expression*;
3385+
the resulting `struct` value will always have the same memory layout.
33833386

33843387
The fields of a `struct` may be qualified by [visibility modifiers](#re-exporting-and-visibility),
3385-
to restrict access to implementation-private data in a structure.
3388+
to allow access to data in a structure outside a module.
33863389

33873390
A _tuple struct_ type is just like a structure type, except that the fields are anonymous.
33883391

@@ -3933,7 +3936,7 @@ The runtime provides C and Rust code to assist with various built-in types,
39333936
such as vectors, strings, and the low level communication system (ports,
39343937
channels, tasks).
39353938

3936-
Support for other built-in types such as simple types, tuples, records, and
3939+
Support for other built-in types such as simple types, tuples and
39373940
enums is open-coded by the Rust compiler.
39383941

39393942
### Task scheduling and communication

branches/try2/src/doc/tutorial.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ fn point_from_direction(dir: Direction) -> Point {
774774
Enum variants may also be structs. For example:
775775

776776
~~~~
777+
# #![feature(struct_variant)]
777778
use std::f64;
778779
# struct Point { x: f64, y: f64 }
779780
# fn square(x: f64) -> f64 { x * x }
@@ -789,6 +790,7 @@ fn area(sh: Shape) -> f64 {
789790
}
790791
}
791792
}
793+
# fn main() {}
792794
~~~~
793795

794796
> *Note:* This feature of the compiler is currently gated behind the
@@ -3046,6 +3048,7 @@ use farm::{chicken, cow};
30463048
2. Import everything in a module with a wildcard:
30473049

30483050
~~~
3051+
# #![feature(globs)]
30493052
use farm::*;
30503053
# mod farm {
30513054
# pub fn cow() { println!("Bat-chicken? What a stupid name!") }

0 commit comments

Comments
 (0)