Skip to content

Commit ccb6439

Browse files
committed
---
yaml --- r: 98222 b: refs/heads/master c: c0578b4 h: refs/heads/master v: v3
1 parent 045aa3f commit ccb6439

Some content is hidden

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

67 files changed

+954
-849
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: f52bd5e4b75c48d94876e3909c7bf6f8f0a1c26a
2+
refs/heads/master: c0578b4a4132c3c3117fe33a4e3c9e0b134ccaff
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b6400f998497c3958f40997a71756ead344a776d
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36

trunk/doc/guide-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ be distributed on the available cores.
290290
fn partial_sum(start: uint) -> f64 {
291291
let mut local_sum = 0f64;
292292
for num in range(start*100000, (start+1)*100000) {
293-
local_sum += (num as f64 + 1.0).pow(&-2.0);
293+
local_sum += (num as f64 + 1.0).powf(&-2.0);
294294
}
295295
local_sum
296296
}
@@ -326,7 +326,7 @@ a single large vector of floats. Each task needs the full vector to perform its
326326
use extra::arc::Arc;
327327
328328
fn pnorm(nums: &~[f64], p: uint) -> f64 {
329-
nums.iter().fold(0.0, |a,b| a+(*b).pow(&(p as f64)) ).pow(&(1.0 / (p as f64)))
329+
nums.iter().fold(0.0, |a,b| a+(*b).powf(&(p as f64)) ).powf(&(1.0 / (p as f64)))
330330
}
331331
332332
fn main() {

trunk/doc/guide-testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ mod tests {
6363
}
6464
~~~
6565

66-
Additionally #[test] items behave as if they also have the
67-
#[cfg(test)] attribute, and will not be compiled when the --test flag
66+
Additionally `#[test]` items behave as if they also have the
67+
`#[cfg(test)]` attribute, and will not be compiled when the --test flag
6868
is not used.
6969

7070
Tests that should not be run can be annotated with the 'ignore'

trunk/doc/rust.md

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,12 +2211,9 @@ dereferences (`*expr`), [indexing expressions](#index-expressions)
22112211
(`expr[expr]`), and [field references](#field-expressions) (`expr.f`).
22122212
All other expressions are rvalues.
22132213

2214-
The left operand of an [assignment](#assignment-expressions),
2215-
[binary move](#binary-move-expressions) or
2214+
The left operand of an [assignment](#assignment-expressions) or
22162215
[compound-assignment](#compound-assignment-expressions) expression is an lvalue context,
2217-
as is the single operand of a unary [borrow](#unary-operator-expressions),
2218-
or [move](#unary-move-expressions) expression,
2219-
and _both_ operands of a [swap](#swap-expressions) expression.
2216+
as is the single operand of a unary [borrow](#unary-operator-expressions).
22202217
All other expression contexts are rvalue contexts.
22212218

22222219
When an lvalue is evaluated in an _lvalue context_, it denotes a memory location;
@@ -2229,9 +2226,8 @@ A temporary's lifetime equals the largest lifetime of any reference that points
22292226

22302227
When a [local variable](#memory-slots) is used
22312228
as an [rvalue](#lvalues-rvalues-and-temporaries)
2232-
the variable will either be [moved](#move-expressions) or copied,
2233-
depending on its type.
2234-
For types that contain [owning pointers](#owning-pointers)
2229+
the variable will either be moved or copied, depending on its type.
2230+
For types that contain [owning pointers](#pointer-types)
22352231
or values that implement the special trait `Drop`,
22362232
the variable is moved.
22372233
All other types are copied.
@@ -2890,16 +2886,26 @@ match x {
28902886

28912887
The first pattern matches lists constructed by applying `Cons` to any head value, and a
28922888
tail value of `~Nil`. The second pattern matches _any_ list constructed with `Cons`,
2893-
ignoring the values of its arguments. The difference between `_` and `*` is that the pattern `C(_)` is only type-correct if
2894-
`C` has exactly one argument, while the pattern `C(..)` is type-correct for any enum variant `C`, regardless of how many arguments `C` has.
2895-
2896-
To execute an `match` expression, first the head expression is evaluated, then
2897-
its value is sequentially compared to the patterns in the arms until a match
2889+
ignoring the values of its arguments. The difference between `_` and `*` is that the pattern
2890+
`C(_)` is only type-correct if `C` has exactly one argument, while the pattern `C(..)` is
2891+
type-correct for any enum variant `C`, regardless of how many arguments `C` has.
2892+
2893+
A `match` behaves differently depending on whether or not the head expression
2894+
is an [lvalue or an rvalue](#lvalues-rvalues-and-temporaries).
2895+
If the head expression is an rvalue, it is
2896+
first evaluated into a temporary location, and the resulting value
2897+
is sequentially compared to the patterns in the arms until a match
28982898
is found. The first arm with a matching pattern is chosen as the branch target
28992899
of the `match`, any variables bound by the pattern are assigned to local
29002900
variables in the arm's block, and control enters the block.
29012901

2902-
An example of an `match` expression:
2902+
When the head expression is an lvalue, the match does not allocate a
2903+
temporary location (however, a by-value binding may copy or move from
2904+
the lvalue). When possible, it is preferable to match on lvalues, as the
2905+
lifetime of these matches inherits the lifetime of the lvalue, rather
2906+
than being restricted to the inside of the match.
2907+
2908+
An example of a `match` expression:
29032909

29042910
~~~~
29052911
# fn process_pair(a: int, b: int) { }
@@ -2929,19 +2935,31 @@ Patterns that bind variables
29292935
default to binding to a copy or move of the matched value
29302936
(depending on the matched value's type).
29312937
This can be changed to bind to a reference by
2932-
using the ```ref``` keyword,
2933-
or to a mutable reference using ```ref mut```.
2934-
2935-
A pattern that's just an identifier,
2936-
like `Nil` in the previous answer,
2937-
could either refer to an enum variant that's in scope,
2938-
or bind a new variable.
2939-
The compiler resolves this ambiguity by forbidding variable bindings that occur in ```match``` patterns from shadowing names of variants that are in scope.
2940-
For example, wherever ```List``` is in scope,
2941-
a ```match``` pattern would not be able to bind ```Nil``` as a new name.
2942-
The compiler interprets a variable pattern `x` as a binding _only_ if there is no variant named `x` in scope.
2943-
A convention you can use to avoid conflicts is simply to name variants with upper-case letters,
2944-
and local variables with lower-case letters.
2938+
using the `ref` keyword,
2939+
or to a mutable reference using `ref mut`.
2940+
2941+
Patterns can also dereference pointers by using the `&`,
2942+
`~` or `@` symbols, as appropriate. For example, these two matches
2943+
on `x: &int` are equivalent:
2944+
2945+
~~~~
2946+
# let x = &3;
2947+
let y = match *x { 0 => "zero", _ => "some" };
2948+
let z = match x { &0 => "zero", _ => "some" };
2949+
2950+
assert_eq!(y, z);
2951+
~~~~
2952+
2953+
A pattern that's just an identifier, like `Nil` in the previous answer,
2954+
could either refer to an enum variant that's in scope, or bind a new variable.
2955+
The compiler resolves this ambiguity by forbidding variable bindings that occur
2956+
in `match` patterns from shadowing names of variants that are in scope.
2957+
For example, wherever `List` is in scope,
2958+
a `match` pattern would not be able to bind `Nil` as a new name.
2959+
The compiler interprets a variable pattern `x` as a binding _only_ if there is
2960+
no variant named `x` in scope.
2961+
A convention you can use to avoid conflicts is simply to name variants with
2962+
upper-case letters, and local variables with lower-case letters.
29452963

29462964
Multiple match patterns may be joined with the `|` operator.
29472965
A range of values may be specified with `..`.
@@ -3122,19 +3140,20 @@ A `struct` *type* is a heterogeneous product of other types, called the *fields*
31223140
the *record* types of the ML family,
31233141
or the *structure* types of the Lisp family.]
31243142

3125-
New instances of a `struct` can be constructed with a [struct expression](#struct-expressions).
3143+
New instances of a `struct` can be constructed with a [struct expression](#structure-expressions).
31263144

31273145
The memory order of fields in a `struct` is given by the item defining it.
31283146
Fields may be given in any order in a corresponding struct *expression*;
31293147
the resulting `struct` value will always be laid out in memory in the order specified by the corresponding *item*.
31303148

3131-
The fields of a `struct` may be qualified by [visibility modifiers](#visibility-modifiers),
3149+
The fields of a `struct` may be qualified by [visibility modifiers](#re-exporting-and-visibility),
31323150
to restrict access to implementation-private data in a structure.
31333151

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

31363154
A _unit-like struct_ type is like a structure type, except that it has no fields.
3137-
The one value constructed by the associated [structure expression](#structure-expression) is the only value that inhabits such a type.
3155+
The one value constructed by the associated [structure expression](#structure-expressions)
3156+
is the only value that inhabits such a type.
31383157

31393158
### Enumerated types
31403159

@@ -3805,7 +3824,7 @@ over the output format of a Rust crate.
38053824
### Logging system
38063825

38073826
The runtime contains a system for directing [logging
3808-
expressions](#log-expressions) to a logging console and/or internal logging
3827+
expressions](#logging-expressions) to a logging console and/or internal logging
38093828
buffers. Logging can be enabled per module.
38103829

38113830
Logging output is enabled by setting the `RUST_LOG` environment

trunk/mk/docs.mk

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ CDOCS :=
1717
DOCS_L10N :=
1818
HTML_DEPS :=
1919

20-
BASE_DOC_OPTS := --include-before-body=doc/version_info.html --standalone \
21-
--toc --number-sections
22-
HTML_OPTS = $(BASE_DOC_OPTS) --to=html5 --section-divs --css=rust.css \
23-
--include-in-header=doc/favicon.inc
24-
TEX_OPTS = $(BASE_DOC_OPTS) --to=latex
20+
BASE_DOC_OPTS := --standalone --toc --number-sections
21+
HTML_OPTS = $(BASE_DOC_OPTS) --to=html5 --section-divs --css=rust.css \
22+
--include-before-body=doc/version_info.html --include-in-header=doc/favicon.inc
23+
TEX_OPTS = $(BASE_DOC_OPTS) --include-before-body=doc/version.md --to=latex
2524
EPUB_OPTS = $(BASE_DOC_OPTS) --to=epub
2625

2726
######################################################################
2827
# Rust version
2928
######################################################################
29+
3030
doc/version.md: $(MKFILE_DEPS) $(wildcard $(S)doc/*.*)
3131
@$(call E, version-stamp: $@)
3232
$(Q)echo "$(CFG_VERSION)" >$@
@@ -84,7 +84,7 @@ doc/rust.tex: rust.md doc/version.md
8484
$(CFG_PANDOC) $(TEX_OPTS) --output=$@
8585

8686
DOCS += doc/rust.epub
87-
doc/rust.epub: rust.md doc/version_info.html doc/rust.css
87+
doc/rust.epub: rust.md
8888
@$(call E, pandoc: $@)
8989
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
9090
$(CFG_PANDOC) $(EPUB_OPTS) --output=$@
@@ -114,7 +114,7 @@ doc/tutorial.tex: tutorial.md doc/version.md
114114
$(CFG_PANDOC) $(TEX_OPTS) --output=$@
115115

116116
DOCS += doc/tutorial.epub
117-
doc/tutorial.epub: tutorial.md doc/version_info.html doc/rust.css
117+
doc/tutorial.epub: tutorial.md
118118
@$(call E, pandoc: $@)
119119
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
120120
$(CFG_PANDOC) $(EPUB_OPTS) --output=$@
@@ -265,6 +265,7 @@ endif # No pandoc / node
265265
######################################################################
266266
# LLnextgen (grammar analysis from refman)
267267
######################################################################
268+
268269
ifeq ($(CFG_LLNEXTGEN),)
269270
$(info cfg: no llnextgen found, omitting grammar-verification)
270271
else

trunk/mk/tests.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,10 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
626626
--aux-base $$(S)src/test/auxiliary/ \
627627
--stage-id stage$(1)-$(2) \
628628
--target $(2) \
629+
--host $(3) \
629630
--adb-path=$(CFG_ADB) \
630631
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
631-
--rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) --target=$(2)" \
632+
--rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS)" \
632633
$$(CTEST_TESTARGS)
633634

634635
CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)

trunk/src/compiletest/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ pub struct config {
8686
// Target system to be tested
8787
target: ~str,
8888

89+
// Host triple for the compiler being invoked
90+
host: ~str,
91+
8992
// Extra parameter to run adb on arm-linux-androideabi
9093
adb_path: ~str,
9194

trunk/src/compiletest/compiletest.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub fn parse_config(args: ~[~str]) -> config {
7373
"percent change in metrics to consider noise", "N"),
7474
optflag("", "jit", "run tests under the JIT"),
7575
optopt("", "target", "the target to build for", "TARGET"),
76+
optopt("", "host", "the host to build for", "HOST"),
7677
optopt("", "adb-path", "path to the android debugger", "PATH"),
7778
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
7879
optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite", "A.B"),
@@ -134,6 +135,7 @@ pub fn parse_config(args: ~[~str]) -> config {
134135
rustcflags: matches.opt_str("rustcflags"),
135136
jit: matches.opt_present("jit"),
136137
target: opt_str2(matches.opt_str("target")).to_str(),
138+
host: opt_str2(matches.opt_str("host")).to_str(),
137139
adb_path: opt_str2(matches.opt_str("adb-path")).to_str(),
138140
adb_test_dir:
139141
opt_str2(matches.opt_str("adb-test-dir")).to_str(),
@@ -167,6 +169,7 @@ pub fn log_config(config: &config) {
167169
logv(c, format!("rustcflags: {}", opt_str(&config.rustcflags)));
168170
logv(c, format!("jit: {}", config.jit));
169171
logv(c, format!("target: {}", config.target));
172+
logv(c, format!("host: {}", config.host));
170173
logv(c, format!("adb_path: {}", config.adb_path));
171174
logv(c, format!("adb_test_dir: {}", config.adb_test_dir));
172175
logv(c, format!("adb_device_status: {}", config.adb_device_status));

trunk/src/compiletest/header.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub struct TestProps {
2828
debugger_cmds: ~[~str],
2929
// Lines to check if they appear in the expected debugger output
3030
check_lines: ~[~str],
31+
// Flag to force a crate to be built with the host architecture
32+
force_host: bool,
3133
}
3234

3335
// Load any test directives embedded in the file
@@ -39,6 +41,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
3941
let mut pp_exact = None;
4042
let mut debugger_cmds = ~[];
4143
let mut check_lines = ~[];
44+
let mut force_host = false;
4245
iter_header(testfile, |ln| {
4346
match parse_error_pattern(ln) {
4447
Some(ep) => error_patterns.push(ep),
@@ -53,6 +56,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
5356
pp_exact = parse_pp_exact(ln, testfile);
5457
}
5558

59+
if !force_host {
60+
force_host = parse_force_host(ln);
61+
}
62+
5663
match parse_aux_build(ln) {
5764
Some(ab) => { aux_builds.push(ab); }
5865
None => {}
@@ -82,7 +89,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
8289
aux_builds: aux_builds,
8390
exec_env: exec_env,
8491
debugger_cmds: debugger_cmds,
85-
check_lines: check_lines
92+
check_lines: check_lines,
93+
force_host: force_host,
8694
};
8795
}
8896

@@ -141,6 +149,10 @@ fn parse_check_line(line: &str) -> Option<~str> {
141149
parse_name_value_directive(line, ~"check")
142150
}
143151

152+
fn parse_force_host(line: &str) -> bool {
153+
parse_name_directive(line, "force-host")
154+
}
155+
144156
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
145157
parse_name_value_directive(line, ~"exec-env").map(|nv| {
146158
// nv is either FOO or FOO=BAR

trunk/src/compiletest/runtest.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,9 @@ fn compose_and_run_compiler(
691691

692692
for rel_ab in props.aux_builds.iter() {
693693
let abs_ab = config.aux_base.join(rel_ab.as_slice());
694+
let aux_props = load_props(&abs_ab);
694695
let aux_args =
695-
make_compile_args(config, props, ~[~"--lib"] + extra_link_args,
696+
make_compile_args(config, &aux_props, ~[~"--lib"] + extra_link_args,
696697
|a,b| make_lib_name(a, b, testfile), &abs_ab);
697698
let auxres = compose_and_run(config, &abs_ab, aux_args, ~[],
698699
config.compile_lib_path, None);
@@ -738,10 +739,16 @@ fn make_compile_args(config: &config,
738739
testfile: &Path)
739740
-> ProcArgs {
740741
let xform_file = xform(config, testfile);
742+
let target = if props.force_host {
743+
config.host.as_slice()
744+
} else {
745+
config.target.as_slice()
746+
};
741747
// FIXME (#9639): This needs to handle non-utf8 paths
742748
let mut args = ~[testfile.as_str().unwrap().to_owned(),
743749
~"-o", xform_file.as_str().unwrap().to_owned(),
744-
~"-L", config.build_base.as_str().unwrap().to_owned()]
750+
~"-L", config.build_base.as_str().unwrap().to_owned(),
751+
~"--target=" + target]
745752
+ extras;
746753
args.push_all_move(split_maybe_args(&config.rustcflags));
747754
args.push_all_move(split_maybe_args(&props.compile_flags));

0 commit comments

Comments
 (0)