Skip to content

Commit faa30ac

Browse files
committed
---
yaml --- r: 98262 b: refs/heads/master c: dac3c53 h: refs/heads/master v: v3
1 parent 508a7bb commit faa30ac

Some content is hidden

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

83 files changed

+628
-1115
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: e83e5769ee01ab7b8ede809618131517aaafe72c
2+
refs/heads/master: dac3c53ee1e5dfaea674a9345b8d357c0e4d0f37
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b6400f998497c3958f40997a71756ead344a776d
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36

trunk/doc/guide-testing.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
3333
# Unit testing in Rust
3434

3535
Rust has built in support for simple unit testing. Functions can be
36-
marked as unit tests using the `test` attribute.
36+
marked as unit tests using the 'test' attribute.
3737

3838
~~~
3939
#[test]
@@ -44,13 +44,13 @@ fn return_none_if_empty() {
4444

4545
A test function's signature must have no arguments and no return
4646
value. To run the tests in a crate, it must be compiled with the
47-
`--test` flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
47+
'--test' flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
4848
the resulting executable will run all the tests in the crate. A test
4949
is considered successful if its function returns; if the task running
5050
the test fails, through a call to `fail!`, a failed `check` or
5151
`assert`, or some other (`assert_eq`, ...) means, then the test fails.
5252

53-
When compiling a crate with the `--test` flag `--cfg test` is also
53+
When compiling a crate with the '--test' flag '--cfg test' is also
5454
implied, so that tests can be conditionally compiled.
5555

5656
~~~
@@ -64,17 +64,17 @@ mod tests {
6464
~~~
6565

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

70-
Tests that should not be run can be annotated with the `ignore`
70+
Tests that should not be run can be annotated with the 'ignore'
7171
attribute. The existence of these tests will be noted in the test
7272
runner output, but the test will not be run. Tests can also be ignored
7373
by configuration so, for example, to ignore a test on windows you can
7474
write `#[ignore(cfg(target_os = "win32"))]`.
7575

7676
Tests that are intended to fail can be annotated with the
77-
`should_fail` attribute. The test will be run, and if it causes its
77+
'should_fail' attribute. The test will be run, and if it causes its
7878
task to fail then the test will be counted as successful; otherwise it
7979
will be counted as a failure. For example:
8080

@@ -87,11 +87,11 @@ fn test_out_of_bounds_failure() {
8787
}
8888
~~~
8989

90-
A test runner built with the `--test` flag supports a limited set of
90+
A test runner built with the '--test' flag supports a limited set of
9191
arguments to control which tests are run: the first free argument
9292
passed to a test runner specifies a filter used to narrow down the set
93-
of tests being run; the `--ignored` flag tells the test runner to run
94-
only tests with the `ignore` attribute.
93+
of tests being run; the '--ignored' flag tells the test runner to run
94+
only tests with the 'ignore' attribute.
9595

9696
## Parallelism
9797

trunk/doc/rust.md

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,9 +2211,12 @@ 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) or
2214+
The left operand of an [assignment](#assignment-expressions),
2215+
[binary move](#binary-move-expressions) or
22152216
[compound-assignment](#compound-assignment-expressions) expression is an lvalue context,
2216-
as is the single operand of a unary [borrow](#unary-operator-expressions).
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.
22172220
All other expression contexts are rvalue contexts.
22182221

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

22272230
When a [local variable](#memory-slots) is used
22282231
as an [rvalue](#lvalues-rvalues-and-temporaries)
2229-
the variable will either be moved or copied, depending on its type.
2230-
For types that contain [owning pointers](#pointer-types)
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)
22312235
or values that implement the special trait `Drop`,
22322236
the variable is moved.
22332237
All other types are copied.
@@ -2886,26 +2890,16 @@ match x {
28862890

28872891
The first pattern matches lists constructed by applying `Cons` to any head value, and a
28882892
tail value of `~Nil`. The second pattern matches _any_ list constructed with `Cons`,
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
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
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-
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:
2902+
An example of an `match` expression:
29092903

29102904
~~~~
29112905
# fn process_pair(a: int, b: int) { }
@@ -2935,31 +2929,19 @@ Patterns that bind variables
29352929
default to binding to a copy or move of the matched value
29362930
(depending on the matched value's type).
29372931
This can be changed to bind to a reference by
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.
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.
29632945

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

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

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

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

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

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

31583139
### Enumerated types
31593140

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

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

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

trunk/doc/tutorial.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,15 +1020,10 @@ being destroyed along with the owner. Since the `list` variable above is
10201020
immutable, the whole list is immutable. The memory allocation itself is the
10211021
box, while the owner holds onto a pointer to it:
10221022

1023-
List box List box List box List box
1024-
+--------------+ +--------------+ +--------------+ +--------------+
1025-
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
1026-
+--------------+ +--------------+ +--------------+ +--------------+
1027-
1028-
> Note: the above diagram shows the logical contents of the enum. The actual
1029-
> memory layout of the enum may vary. For example, for the `List` enum shown
1030-
> above, Rust guarantees that there will be no enum tag field in the actual
1031-
> structure. See the language reference for more details.
1023+
Cons cell Cons cell Cons cell
1024+
+-----------+ +-----+-----+ +-----+-----+
1025+
| 1 | ~ | -> | 2 | ~ | -> | 3 | ~ | -> Nil
1026+
+-----------+ +-----+-----+ +-----+-----+
10321027

10331028
An owned box is a common example of a type with a destructor. The allocated
10341029
memory is cleaned up when the box is destroyed.

trunk/mk/docs.mk

Lines changed: 7 additions & 8 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 := --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
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
2425
EPUB_OPTS = $(BASE_DOC_OPTS) --to=epub
2526

2627
######################################################################
2728
# Rust version
2829
######################################################################
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
87+
doc/rust.epub: rust.md doc/version_info.html doc/rust.css
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
117+
doc/tutorial.epub: tutorial.md doc/version_info.html doc/rust.css
118118
@$(call E, pandoc: $@)
119119
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
120120
$(CFG_PANDOC) $(EPUB_OPTS) --output=$@
@@ -265,7 +265,6 @@ endif # No pandoc / node
265265
######################################################################
266266
# LLnextgen (grammar analysis from refman)
267267
######################################################################
268-
269268
ifeq ($(CFG_LLNEXTGEN),)
270269
$(info cfg: no llnextgen found, omitting grammar-verification)
271270
else

trunk/src/compiletest/runtest.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,9 @@ actual:\n\
237237

238238
fn make_typecheck_args(config: &config, props: &TestProps, testfile: &Path) -> ProcArgs {
239239
let aux_dir = aux_output_dir_name(config, testfile);
240-
let target = if props.force_host {
241-
config.host.as_slice()
242-
} else {
243-
config.target.as_slice()
244-
};
245240
// FIXME (#9639): This needs to handle non-utf8 paths
246241
let mut args = ~[~"-",
247242
~"--no-trans", ~"--lib",
248-
~"--target=" + target,
249243
~"-L", config.build_base.as_str().unwrap().to_owned(),
250244
~"-L",
251245
aux_dir.as_str().unwrap().to_owned()];

trunk/src/etc/vim/syntax/rust.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: 2014 Jan 4
6+
" Last Change: 2013 Dec 10
77

88
if version < 600
99
syntax clear
@@ -147,8 +147,8 @@ syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustFail
147147
syn match rustSpecialError display contained /\\./
148148
syn match rustSpecial display contained /\\\([nrt0\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)/
149149
syn match rustStringContinuation display contained /\\\n\s*/
150-
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustSpecial,rustSpecialError,rustStringContinuation,@Spell
151-
syn region rustString start='r\z(#*\)"' end='"\z1' contains=@Spell
150+
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustSpecial,rustSpecialError,rustStringContinuation
151+
syn region rustString start='r\z(#*\)"' end='"\z1'
152152

153153
syn region rustAttribute start="#\[" end="\]" contains=rustString,rustDeriving
154154
syn region rustDeriving start="deriving(" end=")" contained contains=rustTrait
@@ -179,10 +179,10 @@ syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit
179179
syn match rustCharacter /'\([^'\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustSpecial,rustSpecialError
180180

181181
syn cluster rustComment contains=rustCommentLine,rustCommentLineDoc,rustCommentBlock,rustCommentBlockDoc
182-
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
183-
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
184-
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
185-
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
182+
syn region rustCommentLine start="//" end="$" contains=rustTodo
183+
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo
184+
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment keepend extend
185+
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment keepend extend
186186
" FIXME: this is a really ugly and not fully correct implementation. Most
187187
" importantly, a case like ``/* */*`` should have the final ``*`` not being in
188188
" a comment, but in practice at present it leaves comments open two levels

trunk/src/libextra/base64.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,8 @@ impl<'a> FromBase64 for &'a str {
237237
}
238238

239239
for (idx, byte) in it {
240-
match byte as char {
241-
'='|'\r'|'\n' => continue,
242-
_ => return Err(InvalidBase64Character(self.char_at(idx), idx)),
240+
if (byte as char) != '=' {
241+
return Err(InvalidBase64Character(self.char_at(idx), idx));
243242
}
244243
}
245244

@@ -311,8 +310,6 @@ mod test {
311310
fn test_from_base64_newlines() {
312311
assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(),
313312
"foobar".as_bytes().to_owned());
314-
assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(),
315-
"foob".as_bytes().to_owned());
316313
}
317314
318315
#[test]

trunk/src/libextra/bitv.rs

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -269,23 +269,14 @@ impl Bitv {
269269

270270
impl Bitv {
271271
pub fn new(nbits: uint, init: bool) -> Bitv {
272-
let rep = if nbits < uint::bits {
273-
Small(SmallBitv::new(if init {(1<<nbits)-1} else {0}))
274-
} else if nbits == uint::bits {
272+
let rep = if nbits <= uint::bits {
275273
Small(SmallBitv::new(if init {!0} else {0}))
276-
} else {
277-
let exact = nbits % uint::bits == 0;
278-
let nelems = nbits/uint::bits + if exact {0} else {1};
279-
let s =
280-
if init {
281-
if exact {
282-
vec::from_elem(nelems, !0u)
283-
} else {
284-
let mut v = vec::from_elem(nelems-1, !0u);
285-
v.push((1<<nbits % uint::bits)-1);
286-
v
287-
}
288-
} else { vec::from_elem(nelems, 0u)};
274+
}
275+
else {
276+
let nelems = nbits/uint::bits +
277+
if nbits % uint::bits == 0 {0} else {1};
278+
let elem = if init {!0u} else {0u};
279+
let s = vec::from_elem(nelems, elem);
289280
Big(BigBitv::new(s))
290281
};
291282
Bitv {rep: rep, nbits: nbits}
@@ -1338,20 +1329,6 @@ mod tests {
13381329
assert_eq!(idxs, ~[0, 2, 3]);
13391330
}
13401331
1341-
#[test]
1342-
fn test_bitv_set_frombitv_init() {
1343-
let bools = [true, false];
1344-
let lengths = [10, 64, 100];
1345-
for &b in bools.iter() {
1346-
for &l in lengths.iter() {
1347-
let bitset = BitvSet::from_bitv(Bitv::new(l, b));
1348-
assert_eq!(bitset.contains(&1u), b)
1349-
assert_eq!(bitset.contains(&(l-1u)), b)
1350-
assert!(!bitset.contains(&l))
1351-
}
1352-
}
1353-
}
1354-
13551332
#[test]
13561333
fn test_small_difference() {
13571334
let mut b1 = Bitv::new(3, false);

0 commit comments

Comments
 (0)