Skip to content

Commit 3a756cf

Browse files
committed
---
yaml --- r: 152717 b: refs/heads/try2 c: 0ae4b97 h: refs/heads/master i: 152715: f3bede1 v: v3
1 parent bb00325 commit 3a756cf

File tree

84 files changed

+1469
-967
lines changed

Some content is hidden

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

84 files changed

+1469
-967
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: 6008f2c98276be3b880a5a75a0ac234cd866800e
8+
refs/heads/try2: 0ae4b97c09a5b5c230f5dee9bdcef85951b6e00d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
To create test functions, add a `#[test]` attribute like this:
66

7-
~~~
7+
~~~test_harness
88
fn return_two() -> int {
99
2
1010
}
@@ -37,7 +37,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
3737
Rust has built in support for simple unit testing. Functions can be
3838
marked as unit tests using the `test` attribute.
3939

40-
~~~
40+
~~~test_harness
4141
#[test]
4242
fn return_none_if_empty() {
4343
// ... test code ...
@@ -55,7 +55,7 @@ other (`assert_eq`, ...) means, then the test fails.
5555
When compiling a crate with the `--test` flag `--cfg test` is also
5656
implied, so that tests can be conditionally compiled.
5757

58-
~~~
58+
~~~test_harness
5959
#[cfg(test)]
6060
mod tests {
6161
#[test]
@@ -80,11 +80,11 @@ Tests that are intended to fail can be annotated with the
8080
task to fail then the test will be counted as successful; otherwise it
8181
will be counted as a failure. For example:
8282

83-
~~~
83+
~~~test_harness
8484
#[test]
8585
#[should_fail]
8686
fn test_out_of_bounds_failure() {
87-
let v: [int] = [];
87+
let v: &[int] = [];
8888
v[0];
8989
}
9090
~~~
@@ -204,26 +204,22 @@ amount.
204204

205205
For example:
206206

207-
~~~
208-
# #![allow(unused_imports)]
207+
~~~test_harness
209208
extern crate test;
210209
211-
use std::slice;
212210
use test::Bencher;
213211
214212
#[bench]
215213
fn bench_sum_1024_ints(b: &mut Bencher) {
216-
let v = slice::from_fn(1024, |n| n);
217-
b.iter(|| {v.iter().fold(0, |old, new| old + *new);} );
214+
let v = Vec::from_fn(1024, |n| n);
215+
b.iter(|| v.iter().fold(0, |old, new| old + *new));
218216
}
219217
220218
#[bench]
221219
fn initialise_a_vector(b: &mut Bencher) {
222-
b.iter(|| {slice::from_elem(1024, 0u64);} );
220+
b.iter(|| Vec::from_elem(1024, 0u64));
223221
b.bytes = 1024 * 8;
224222
}
225-
226-
# fn main() {}
227223
~~~
228224

229225
The benchmark runner will calibrate measurement of the benchmark
@@ -266,19 +262,16 @@ benchmarking what one expects. For example, the compiler might
266262
recognize that some calculation has no external effects and remove
267263
it entirely.
268264

269-
~~~
270-
# #![allow(unused_imports)]
265+
~~~test_harness
271266
extern crate test;
272267
use test::Bencher;
273268
274269
#[bench]
275270
fn bench_xor_1000_ints(b: &mut Bencher) {
276271
b.iter(|| {
277-
range(0, 1000).fold(0, |old, new| old ^ new);
278-
});
272+
range(0, 1000).fold(0, |old, new| old ^ new);
273+
});
279274
}
280-
281-
# fn main() {}
282275
~~~
283276

284277
gives the following results
@@ -297,8 +290,11 @@ cannot remove the computation entirely. This could be done for the
297290
example above by adjusting the `bh.iter` call to
298291

299292
~~~
300-
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let bh = X;
301-
bh.iter(|| range(0, 1000).fold(0, |old, new| old ^ new))
293+
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let b = X;
294+
b.iter(|| {
295+
// note lack of `;` (could also use an explicit `return`).
296+
range(0, 1000).fold(0, |old, new| old ^ new)
297+
});
302298
~~~
303299

304300
Or, the other option is to call the generic `test::black_box`
@@ -309,10 +305,10 @@ forces it to consider any argument as used.
309305
extern crate test;
310306
311307
# fn main() {
312-
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let bh = X;
313-
bh.iter(|| {
314-
test::black_box(range(0, 1000).fold(0, |old, new| old ^ new));
315-
});
308+
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let b = X;
309+
b.iter(|| {
310+
test::black_box(range(0, 1000).fold(0, |old, new| old ^ new));
311+
});
316312
# }
317313
~~~
318314

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ As an example, we give a reimplementation of owned boxes by wrapping
192192
reimplementation is as safe as the `Box` type.
193193

194194
```
195+
#![feature(unsafe_destructor)]
196+
195197
extern crate libc;
196198
use libc::{c_void, size_t, malloc, free};
197199
use std::mem;
@@ -242,10 +244,12 @@ impl<T: Send> Unique<T> {
242244
// A key ingredient for safety, we associate a destructor with
243245
// Unique<T>, making the struct manage the raw pointer: when the
244246
// struct goes out of scope, it will automatically free the raw pointer.
247+
//
245248
// NB: This is an unsafe destructor, because rustc will not normally
246-
// allow destructors to be associated with parametrized types, due to
249+
// allow destructors to be associated with parameterized types, due to
247250
// bad interaction with managed boxes. (With the Send restriction,
248-
// we don't have this problem.)
251+
// we don't have this problem.) Note that the `#[unsafe_destructor]`
252+
// feature gate is required to use unsafe destructors.
249253
#[unsafe_destructor]
250254
impl<T: Send> Drop for Unique<T> {
251255
fn drop(&mut self) {

branches/try2/src/doc/index.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,26 @@ li {list-style-type: none; }
6767

6868
* [The `rustdoc` manual](rustdoc.html)
6969

70-
# External resources
70+
# External documentation
7171

72-
* The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/)
72+
*Note: While these are great resources for learning Rust, they may
73+
track a particular version of Rust that is likely not exactly the same
74+
as that for which this documentation was generated.*
75+
76+
* [Rust for Rubyists] - An excellent introduction for Rust; not just for Rubyists (tracks the most recent release).
77+
* [Rust by Example] - Short examples of common tasks in Rust (tracks the master branch).
78+
* [The Rust wiki](http://github.com/rust-lang/rust/wiki)
79+
80+
[Rust for Rubyists]: http://www.rustforrubyists.com/
81+
[Rust by Example]: http://rustbyexample.com/
82+
83+
# Community
84+
85+
* [Reddit](http://reddit.com/r/rust)
86+
* [Stack Overflow](http://stackoverflow.com/questions/tagged/rust)
87+
* The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/):
7388
* [`#rust`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust) - general discussion
7489
* [`#rust-gamedev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev) - game development
7590
* [`#rust-internals`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals) - compiler and libraries
7691
* [`#rust-osdev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-osdev) - operating system development
77-
* The Rust community on [Reddit](http://reddit.com/r/rust)
78-
* The Rust [wiki](http://github.com/rust-lang/rust/wiki)
92+

branches/try2/src/doc/rust.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ dd {
275275

276276
nav ul {
277277
list-style-type: none;
278-
margin: 0;
278+
margin: 0 0 20px 0;
279279
padding-left: 0px;
280280
}
281281

branches/try2/src/doc/rust.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,12 +1940,13 @@ interpreted:
19401940
enum representation in C is undefined, and this may be incorrect when the C
19411941
code is compiled with certain flags.
19421942
- `simd` - on certain tuple structs, derive the arithmetic operators, which
1943-
lower to the target's SIMD instructions, if any.
1943+
lower to the target's SIMD instructions, if any; the `simd` feature gate
1944+
is necessary to use this attribute.
19441945
- `static_assert` - on statics whose type is `bool`, terminates compilation
19451946
with an error if it is not initialized to `true`.
19461947
- `unsafe_destructor` - allow implementations of the "drop" language item
19471948
where the type it is implemented for does not implement the "send" language
1948-
item.
1949+
item; the `unsafe_destructor` feature gate is needed to use this attribute
19491950
- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
19501951
destructors from being run twice. Destructors might be run multiple times on
19511952
the same object with this attribute.

branches/try2/src/doc/rustdoc.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ You can specify that the code block should be compiled but not run with the
171171
```
172172
~~~
173173

174+
Lastly, you can specify that a code block be compiled as if `--test`
175+
were passed to the compiler using the `test_harness` directive.
176+
177+
~~~md
178+
```test_harness
179+
#[test]
180+
fn foo() {
181+
fail!("oops! (will run & register as failure)")
182+
}
183+
```
184+
~~~
185+
174186
Rustdoc also supplies some extra sugar for helping with some tedious
175187
documentation examples. If a line is prefixed with `# `, then the line
176188
will not show up in the HTML documentation, but it will be used when

branches/try2/src/liballoc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
html_root_url = "http://doc.rust-lang.org/")]
7070

7171
#![no_std]
72-
#![feature(phase)]
72+
#![feature(phase, unsafe_destructor)]
73+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
7374

7475
#[phase(plugin, link)]
7576
extern crate core;

branches/try2/src/libarena/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2828
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2929
html_root_url = "http://doc.rust-lang.org/")]
30+
31+
#![feature(unsafe_destructor)]
3032
#![allow(missing_doc)]
33+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
3134

3235
use std::cell::{Cell, RefCell};
3336
use std::cmp;

branches/try2/src/libcollections/bitv.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -376,27 +376,6 @@ impl Bitv {
376376
}
377377
}
378378

379-
/**
380-
* Compares two bitvectors
381-
*
382-
* Both bitvectors must be the same length. Returns `true` if both
383-
* bitvectors contain identical elements.
384-
*/
385-
#[inline]
386-
pub fn equal(&self, v1: &Bitv) -> bool {
387-
if self.nbits != v1.nbits { return false; }
388-
match self.rep {
389-
Small(ref b) => match v1.rep {
390-
Small(ref b1) => b.equals(b1, self.nbits),
391-
_ => false
392-
},
393-
Big(ref s) => match v1.rep {
394-
Big(ref s1) => s.equals(s1, self.nbits),
395-
Small(_) => return false
396-
}
397-
}
398-
}
399-
400379
/// Set all bits to 0
401380
#[inline]
402381
pub fn clear(&mut self) {
@@ -613,6 +592,25 @@ impl<S: hash::Writer> hash::Hash<S> for Bitv {
613592
}
614593
}
615594

595+
impl cmp::PartialEq for Bitv {
596+
#[inline]
597+
fn eq(&self, other: &Bitv) -> bool {
598+
if self.nbits != other.nbits { return false; }
599+
match self.rep {
600+
Small(ref b) => match other.rep {
601+
Small(ref b1) => b.equals(b1, self.nbits),
602+
_ => false
603+
},
604+
Big(ref s) => match other.rep {
605+
Big(ref s1) => s.equals(s1, self.nbits),
606+
Small(_) => return false
607+
}
608+
}
609+
}
610+
}
611+
612+
impl cmp::Eq for Bitv {}
613+
616614
#[inline]
617615
fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
618616
if bits == 0 {
@@ -841,6 +839,8 @@ impl cmp::PartialEq for BitvSet {
841839
fn ne(&self, other: &BitvSet) -> bool { !self.eq(other) }
842840
}
843841

842+
impl cmp::Eq for BitvSet {}
843+
844844
impl fmt::Show for BitvSet {
845845
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
846846
try!(write!(fmt, "{{"));
@@ -1323,14 +1323,14 @@ mod tests {
13231323
fn test_equal_differing_sizes() {
13241324
let v0 = Bitv::new(10u, false);
13251325
let v1 = Bitv::new(11u, false);
1326-
assert!(!v0.equal(&v1));
1326+
assert!(v0 != v1);
13271327
}
13281328

13291329
#[test]
13301330
fn test_equal_greatly_differing_sizes() {
13311331
let v0 = Bitv::new(10u, false);
13321332
let v1 = Bitv::new(110u, false);
1333-
assert!(!v0.equal(&v1));
1333+
assert!(v0 != v1);
13341334
}
13351335

13361336
#[test]
@@ -1341,7 +1341,7 @@ mod tests {
13411341
let mut b = bitv::Bitv::new(1, true);
13421342
b.set(0, true);
13431343

1344-
assert!(a.equal(&b));
1344+
assert_eq!(a, b);
13451345
}
13461346

13471347
#[test]
@@ -1356,7 +1356,7 @@ mod tests {
13561356
b.set(i, true);
13571357
}
13581358

1359-
assert!(a.equal(&b));
1359+
assert_eq!(a, b);
13601360
}
13611361

13621362
#[test]

branches/try2/src/libcollections/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
html_playground_url = "http://play.rust-lang.org/")]
2323

2424
#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
25+
#![feature(unsafe_destructor)]
2526
#![no_std]
27+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
2628

2729
#[phase(plugin, link)] extern crate core;
2830
extern crate alloc;

branches/try2/src/libcore/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
html_playground_url = "http://play.rust-lang.org/")]
5656

5757
#![no_std]
58-
#![feature(globs, macro_rules, managed_boxes, phase, simd)]
58+
#![feature(globs, macro_rules, managed_boxes, phase, simd, unsafe_destructor)]
5959
#![deny(missing_doc)]
60+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
6061

6162
#[cfg(test)] extern crate realcore = "core";
6263
#[cfg(test)] extern crate libc;

branches/try2/src/libnative/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@
5252
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
5353
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
5454
html_root_url = "http://doc.rust-lang.org/")]
55+
5556
#![deny(unused_result, unused_must_use)]
5657
#![allow(non_camel_case_types)]
5758
#![allow(deprecated)]
59+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
5860
#![feature(default_type_params)]
5961

6062
// NB this crate explicitly does *not* allow glob imports, please seriously
6163
// consider whether they're needed before adding that feature here (the
6264
// answer is that you don't need them)
63-
#![feature(macro_rules)]
65+
#![feature(macro_rules, unsafe_destructor)]
6466

6567
extern crate alloc;
6668
extern crate libc;

0 commit comments

Comments
 (0)