Skip to content

Commit bb00325

Browse files
committed
---
yaml --- r: 152716 b: refs/heads/try2 c: 6008f2c h: refs/heads/master v: v3
1 parent f3bede1 commit bb00325

File tree

95 files changed

+1339
-1565
lines changed

Some content is hidden

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

95 files changed

+1339
-1565
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: b1646cbfd908dc948b251e362669af421100647a
8+
refs/heads/try2: 6008f2c98276be3b880a5a75a0ac234cd866800e
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: 25 additions & 21 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-
~~~test_harness
7+
~~~
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-
~~~test_harness
40+
~~~
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-
~~~test_harness
58+
~~~
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-
~~~test_harness
83+
~~~
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,22 +204,26 @@ amount.
204204

205205
For example:
206206

207-
~~~test_harness
207+
~~~
208+
# #![allow(unused_imports)]
208209
extern crate test;
209210
211+
use std::slice;
210212
use test::Bencher;
211213
212214
#[bench]
213215
fn bench_sum_1024_ints(b: &mut Bencher) {
214-
let v = Vec::from_fn(1024, |n| n);
215-
b.iter(|| v.iter().fold(0, |old, new| old + *new));
216+
let v = slice::from_fn(1024, |n| n);
217+
b.iter(|| {v.iter().fold(0, |old, new| old + *new);} );
216218
}
217219
218220
#[bench]
219221
fn initialise_a_vector(b: &mut Bencher) {
220-
b.iter(|| Vec::from_elem(1024, 0u64));
222+
b.iter(|| {slice::from_elem(1024, 0u64);} );
221223
b.bytes = 1024 * 8;
222224
}
225+
226+
# fn main() {}
223227
~~~
224228

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

265-
~~~test_harness
269+
~~~
270+
# #![allow(unused_imports)]
266271
extern crate test;
267272
use test::Bencher;
268273
269274
#[bench]
270275
fn bench_xor_1000_ints(b: &mut Bencher) {
271276
b.iter(|| {
272-
range(0, 1000).fold(0, |old, new| old ^ new);
273-
});
277+
range(0, 1000).fold(0, |old, new| old ^ new);
278+
});
274279
}
280+
281+
# fn main() {}
275282
~~~
276283

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

292299
~~~
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-
});
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))
298302
~~~
299303

300304
Or, the other option is to call the generic `test::black_box`
@@ -305,10 +309,10 @@ forces it to consider any argument as used.
305309
extern crate test;
306310
307311
# fn main() {
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-
});
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+
});
312316
# }
313317
~~~
314318

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ 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-
197195
extern crate libc;
198196
use libc::{c_void, size_t, malloc, free};
199197
use std::mem;
@@ -244,12 +242,10 @@ impl<T: Send> Unique<T> {
244242
// A key ingredient for safety, we associate a destructor with
245243
// Unique<T>, making the struct manage the raw pointer: when the
246244
// struct goes out of scope, it will automatically free the raw pointer.
247-
//
248245
// NB: This is an unsafe destructor, because rustc will not normally
249-
// allow destructors to be associated with parameterized types, due to
246+
// allow destructors to be associated with parametrized types, due to
250247
// bad interaction with managed boxes. (With the Send restriction,
251-
// we don't have this problem.) Note that the `#[unsafe_destructor]`
252-
// feature gate is required to use unsafe destructors.
248+
// we don't have this problem.)
253249
#[unsafe_destructor]
254250
impl<T: Send> Drop for Unique<T> {
255251
fn drop(&mut self) {

branches/try2/src/doc/index.md

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

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

70-
# External documentation
70+
# External resources
7171

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/):
72+
* The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/)
8873
* [`#rust`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust) - general discussion
8974
* [`#rust-gamedev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev) - game development
9075
* [`#rust-internals`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals) - compiler and libraries
9176
* [`#rust-osdev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-osdev) - operating system development
92-
77+
* The Rust community on [Reddit](http://reddit.com/r/rust)
78+
* The Rust [wiki](http://github.com/rust-lang/rust/wiki)

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 0 20px 0;
278+
margin: 0;
279279
padding-left: 0px;
280280
}
281281

branches/try2/src/doc/rust.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,13 +1940,12 @@ 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; the `simd` feature gate
1944-
is necessary to use this attribute.
1943+
lower to the target's SIMD instructions, if any.
19451944
- `static_assert` - on statics whose type is `bool`, terminates compilation
19461945
with an error if it is not initialized to `true`.
19471946
- `unsafe_destructor` - allow implementations of the "drop" language item
19481947
where the type it is implemented for does not implement the "send" language
1949-
item; the `unsafe_destructor` feature gate is needed to use this attribute
1948+
item.
19501949
- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
19511950
destructors from being run twice. Destructors might be run multiple times on
19521951
the same object with this attribute.
@@ -2301,28 +2300,43 @@ One can indicate the stability of an API using the following attributes:
23012300
These levels are directly inspired by
23022301
[Node.js' "stability index"](http://nodejs.org/api/documentation.html).
23032302

2304-
There are lints for disallowing items marked with certain levels:
2305-
`deprecated`, `experimental` and `unstable`; the first two will warn
2306-
by default. Items with not marked with a stability are considered to
2307-
be unstable for the purposes of the lint. One can give an optional
2303+
Stability levels are inherited, so an items's stability attribute is the
2304+
default stability for everything nested underneath it.
2305+
2306+
There are lints for disallowing items marked with certain levels: `deprecated`,
2307+
`experimental` and `unstable`. For now, only `deprecated` warns by default, but
2308+
this will change once the standard library has been stabilized.
2309+
Stability levels are meant to be promises at the crate
2310+
level, so these lints only apply when referencing
2311+
items from an _external_ crate, not to items defined within the
2312+
current crate. Items with no stability level are considered
2313+
to be unstable for the purposes of the lint. One can give an optional
23082314
string that will be displayed when the lint flags the use of an item.
23092315

2310-
~~~~ {.ignore}
2311-
#![warn(unstable)]
2316+
For example, if we define one crate called `stability_levels`:
23122317

2318+
~~~~ {.ignore}
23132319
#[deprecated="replaced by `best`"]
2314-
fn bad() {
2320+
pub fn bad() {
23152321
// delete everything
23162322
}
23172323
2318-
fn better() {
2324+
pub fn better() {
23192325
// delete fewer things
23202326
}
23212327
23222328
#[stable]
2323-
fn best() {
2329+
pub fn best() {
23242330
// delete nothing
23252331
}
2332+
~~~~
2333+
2334+
then the lints will work as follows for a client crate:
2335+
2336+
~~~~ {.ignore}
2337+
#![warn(unstable)]
2338+
extern crate stability_levels;
2339+
use stability_levels::{bad, better, best};
23262340
23272341
fn main() {
23282342
bad(); // "warning: use of deprecated item: replaced by `best`"

branches/try2/src/doc/rustdoc.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,6 @@ 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-
186174
Rustdoc also supplies some extra sugar for helping with some tedious
187175
documentation examples. If a line is prefixed with `# `, then the line
188176
will not show up in the HTML documentation, but it will be used when

branches/try2/src/liballoc/lib.rs

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

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

7574
#[phase(plugin, link)]
7675
extern crate core;

branches/try2/src/libarena/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
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)]
3230
#![allow(missing_doc)]
33-
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
3431

3532
use std::cell::{Cell, RefCell};
3633
use std::cmp;

0 commit comments

Comments
 (0)