Skip to content

Commit cecd2e4

Browse files
committed
---
yaml --- r: 196109 b: refs/heads/beta c: 00d929d h: refs/heads/master i: 196107: fa4b568 v: v3
1 parent 694bb64 commit cecd2e4

File tree

369 files changed

+2980
-4981
lines changed

Some content is hidden

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

369 files changed

+2980
-4981
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3030
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3131
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
32-
refs/heads/beta: cf00fc4da984481a75229ce1e40f339f292d2166
32+
refs/heads/beta: 00d929dcb33d0d4f734d85f7ad32716022de53cd
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3535
refs/heads/tmp: 9de34a84bb300bab1bf0227f577331620cd60511

branches/beta/RELEASES.md

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,3 @@
1-
Version 1.0.0-beta (April 2015)
2-
-------------------------------------
3-
4-
* ~1100 changes, numerous bugfixes
5-
6-
* Highlights
7-
8-
* The big news is that the vast majority of the standard library
9-
is now `#[stable]` -- 75% of the non-deprecated API surface at
10-
last count. Numerous crates are now running on stable
11-
Rust. Starting with this release, it is not possible to use
12-
unstable features on a stable build.
13-
* Arithmetic on basic integer types now
14-
[checks for overflow in debug builds][overflow].
15-
16-
* Language
17-
18-
* [`Send` no longer implies `'static`][send-rfc], which made
19-
possible the [`thread::scoped` API][scoped]. Scoped threads can
20-
borrow data from their parent's stack frame -- safely!
21-
* [UFCS now supports trait-less associated paths][moar-ufcs] like
22-
`MyType::default()`.
23-
* Primitive types [now have inherent methods][prim-inherent],
24-
obviating the need for extension traits like `SliceExt`.
25-
* Methods with `Self: Sized` in their `where` clause are
26-
[considered object-safe][self-sized], allowing many extension
27-
traits like `IteratorExt` to be merged into the traits they
28-
extended.
29-
* You can now [refer to associated types][assoc-where] whose
30-
corresponding trait bounds appear only in a `where` clause.
31-
* The final bits of [OIBIT landed][oibit-final], meaning that
32-
traits like `Send` and `Sync` are now library-defined.
33-
* A [Reflect trait][reflect] was introduced, which means that
34-
downcasting via the `Any` trait is effectively limited to
35-
concrete types. This helps retain the potentially-important
36-
"parametricity" property: generic code cannot behave differently
37-
for different type arguments except in minor ways.
38-
* The `unsafe_destructor` feature is now deprecated in favor of
39-
the [new `dropck`][dropck]. This change is a major reduction in
40-
unsafe code.
41-
* Trait coherence was [revised again][fundamental], this time with
42-
an eye toward API evolution over time.
43-
44-
* Libraries
45-
46-
* The new path and IO modules are complete and `#[stable]`. This
47-
was the major library focus for this cycle.
48-
* The path API was [revised][path-normalize] to normalize `.`,
49-
adjusting the tradeoffs in favor of the most common usage.
50-
* A large number of remaining APIs in `std` were also stabilized
51-
during this cycle; about 75% of the non-deprecated API surface
52-
is now stable.
53-
* The new [string pattern API][string-pattern] landed, which makes
54-
the string slice API much more internally consistent and flexible.
55-
* A shiny [framework for Debug implementations][debug-builder] landed.
56-
This makes it possible to opt in to "pretty-printed" debugging output.
57-
* A new set of [generic conversion traits][conversion] replaced
58-
many existing ad hoc traits.
59-
* Generic numeric traits were
60-
[completely removed][num-traits]. This was made possible thanks
61-
to inherent methods for primitive types, and the removal gives
62-
maximal flexibility for designing a numeric hierarchy in the future.
63-
* The `Fn` traits are now related via [inheritance][fn-inherit]
64-
and provide ergonomic [blanket implementations][fn-blanket].
65-
* The `Index` and `IndexMut` traits were changed to
66-
[take the index by value][index-value], enabling code like
67-
`hash_map["string"]` to work.
68-
* `Copy` now [inherits][copy-clone] from `Clone`, meaning that all
69-
`Copy` data is known to be `Clone` as well.
70-
71-
* Infrastructure
72-
73-
* Metadata was tuned, shrinking binaries [by 27%][metadata-shrink].
74-
* Much headway was made on ecosystem-wide CI, making it possible
75-
to [compare builds for breakage][ci-compare].
76-
77-
[send-rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0458-send-improvements.md
78-
[scoped]: http://static.rust-lang.org/doc/master/std/thread/fn.scoped.html
79-
[moar-ufcs]: https://github.com/rust-lang/rust/pull/22172
80-
[prim-inherent]: https://github.com/rust-lang/rust/pull/23104
81-
[overflow]: https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md
82-
[metadata-shrink]: https://github.com/rust-lang/rust/pull/22971
83-
[self-sized]: https://github.com/rust-lang/rust/pull/22301
84-
[assoc-where]: https://github.com/rust-lang/rust/pull/22512
85-
[string-pattern]: https://github.com/rust-lang/rust/pull/22466
86-
[oibit-final]: https://github.com/rust-lang/rust/pull/21689
87-
[reflect]: https://github.com/rust-lang/rust/pull/23712
88-
[debug-builder]: https://github.com/rust-lang/rfcs/blob/master/text/0640-debug-improvements.md
89-
[conversion]: https://github.com/rust-lang/rfcs/pull/529
90-
[num-traits]: https://github.com/rust-lang/rust/pull/23549
91-
[index-value]: https://github.com/rust-lang/rust/pull/23601
92-
[dropck]: https://github.com/rust-lang/rfcs/pull/769
93-
[fundamental]: https://github.com/rust-lang/rfcs/pull/1023
94-
[ci-compare]: https://gist.github.com/brson/a30a77836fbec057cbee
95-
[fn-inherit]: https://github.com/rust-lang/rust/pull/23282
96-
[fn-blanket]: https://github.com/rust-lang/rust/pull/23895
97-
[copy-clone]: https://github.com/rust-lang/rust/pull/23860
98-
[path-normalize]: https://github.com/rust-lang/rust/pull/23229
99-
1001
Version 1.0.0-alpha.2 (February 2015)
1012
-------------------------------------
1023

branches/beta/src/compiletest/compiletest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern crate log;
3131
use std::env;
3232
use std::fs;
3333
use std::path::{Path, PathBuf};
34+
use std::thunk::Thunk;
3435
use getopts::{optopt, optflag, reqopt};
3536
use common::Config;
3637
use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Codegen};
@@ -350,7 +351,7 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
350351
pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
351352
let config = (*config).clone();
352353
let testfile = testfile.to_path_buf();
353-
test::DynTestFn(Box::new(move || {
354+
test::DynTestFn(Thunk::new(move || {
354355
runtest::run(config, &testfile)
355356
}))
356357
}

branches/beta/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
311311
parse_name_value_directive(line, "exec-env").map(|nv| {
312312
// nv is either FOO or FOO=BAR
313313
let mut strs: Vec<String> = nv
314-
.splitn(2, '=')
314+
.splitn(1, '=')
315315
.map(|s| s.to_string())
316316
.collect();
317317

branches/beta/src/doc/reference.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ specific type.
16481648
Implementations are defined with the keyword `impl`.
16491649

16501650
```
1651-
# #[derive(Copy, Clone)]
1651+
# #[derive(Copy)]
16521652
# struct Point {x: f64, y: f64};
16531653
# type Surface = i32;
16541654
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
@@ -1661,10 +1661,6 @@ struct Circle {
16611661
16621662
impl Copy for Circle {}
16631663
1664-
impl Clone for Circle {
1665-
fn clone(&self) -> Circle { *self }
1666-
}
1667-
16681664
impl Shape for Circle {
16691665
fn draw(&self, s: Surface) { do_draw_circle(s, *self); }
16701666
fn bounding_box(&self) -> BoundingBox {

branches/beta/src/doc/trpl/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@
4343
* [Lang items](lang-items.md)
4444
* [Link args](link-args.md)
4545
* [Benchmark Tests](benchmark-tests.md)
46+
* [Box Syntax and Patterns](box-syntax-and-patterns.md)
4647
* [Conclusion](conclusion.md)
4748
* [Glossary](glossary.md)
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
% Box Syntax and Patterns
2+
3+
Currently the only stable way to create a `Box` is via the `Box::new` method.
4+
Also it is not possible in stable Rust to destructure a `Box` in a match
5+
pattern. The unstable `box` keyword can be used to both create and destructure
6+
a `Box`. An example usage would be:
7+
8+
```
9+
#![feature(box_syntax, box_patterns)]
10+
11+
fn main() {
12+
let b = Some(box 5);
13+
match b {
14+
Some(box n) if n < 0 => {
15+
println!("Box contains negative number {}", n);
16+
},
17+
Some(box n) if n >= 0 => {
18+
println!("Box contains non-negative number {}", n);
19+
},
20+
None => {
21+
println!("No box");
22+
},
23+
_ => unreachable!()
24+
}
25+
}
26+
```
27+
28+
Note that these features are currently hidden behind the `box_syntax` (box
29+
creation) and `box_patterns` (destructuring and pattern matching) gates
30+
because the syntax may still change in the future.
31+
32+
# Returning Pointers
33+
34+
In many languages with pointers, you'd return a pointer from a function
35+
so as to avoid copying a large data structure. For example:
36+
37+
```{rust}
38+
struct BigStruct {
39+
one: i32,
40+
two: i32,
41+
// etc
42+
one_hundred: i32,
43+
}
44+
45+
fn foo(x: Box<BigStruct>) -> Box<BigStruct> {
46+
Box::new(*x)
47+
}
48+
49+
fn main() {
50+
let x = Box::new(BigStruct {
51+
one: 1,
52+
two: 2,
53+
one_hundred: 100,
54+
});
55+
56+
let y = foo(x);
57+
}
58+
```
59+
60+
The idea is that by passing around a box, you're only copying a pointer, rather
61+
than the hundred `int`s that make up the `BigStruct`.
62+
63+
This is an antipattern in Rust. Instead, write this:
64+
65+
```rust
66+
#![feature(box_syntax)]
67+
68+
struct BigStruct {
69+
one: i32,
70+
two: i32,
71+
// etc
72+
one_hundred: i32,
73+
}
74+
75+
fn foo(x: Box<BigStruct>) -> BigStruct {
76+
*x
77+
}
78+
79+
fn main() {
80+
let x = Box::new(BigStruct {
81+
one: 1,
82+
two: 2,
83+
one_hundred: 100,
84+
});
85+
86+
let y: Box<BigStruct> = box foo(x);
87+
}
88+
```
89+
90+
This gives you flexibility without sacrificing performance.
91+
92+
You may think that this gives us terrible performance: return a value and then
93+
immediately box it up ?! Isn't this pattern the worst of both worlds? Rust is
94+
smarter than that. There is no copy in this code. `main` allocates enough room
95+
for the `box`, passes a pointer to that memory into `foo` as `x`, and then
96+
`foo` writes the value straight into the `Box<T>`.
97+
98+
This is important enough that it bears repeating: pointers are not for
99+
optimizing returning values from your code. Allow the caller to choose how they
100+
want to use your output.

0 commit comments

Comments
 (0)