Skip to content

Commit 6426c53

Browse files
committed
---
yaml --- r: 56567 b: refs/heads/auto c: c081ffb h: refs/heads/master i: 56565: c455c7a 56563: 9692ba3 56559: 9dfdd28 v: v3
1 parent 42c18b3 commit 6426c53

File tree

214 files changed

+3999
-3545
lines changed

Some content is hidden

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

214 files changed

+3999
-3545
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 2deefbe847e68c8fa749ae59d7e84e1a80eba452
17+
refs/heads/auto: c081ffbd1e845687202a975ea2e698b623e5722f
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/doc/rust.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@ A loop expression denotes an infinite loop;
21872187
see [Continue expressions](#continue-expressions) for continue expressions.
21882188

21892189
~~~~~~~~{.ebnf .gram}
2190-
loop_expr : "loop" [ ident ':' ] '{' block '}';
2190+
loop_expr : [ lifetime ':' ] "loop" '{' block '}';
21912191
~~~~~~~~
21922192

21932193
A `loop` expression may optionally have a _label_.
@@ -2198,7 +2198,7 @@ See [Break expressions](#break-expressions).
21982198
### Break expressions
21992199

22002200
~~~~~~~~{.ebnf .gram}
2201-
break_expr : "break" [ ident ];
2201+
break_expr : "break" [ lifetime ];
22022202
~~~~~~~~
22032203

22042204
A `break` expression has an optional `label`.
@@ -2211,7 +2211,7 @@ but must enclose it.
22112211
### Continue expressions
22122212

22132213
~~~~~~~~{.ebnf .gram}
2214-
continue_expr : "loop" [ ident ];
2214+
continue_expr : "loop" [ lifetime ];
22152215
~~~~~~~~
22162216

22172217
A continue expression, written `loop`, also has an optional `label`.
@@ -2393,7 +2393,7 @@ variables in the arm's block, and control enters the block.
23932393
An example of an `match` expression:
23942394

23952395

2396-
~~~~
2396+
~~~~ {.xfail-test}
23972397
# fn process_pair(a: int, b: int) { }
23982398
# fn process_ten() { }
23992399

branches/auto/doc/tutorial.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ struct TimeBomb {
19811981
19821982
impl Drop for TimeBomb {
19831983
fn finalize(&self) {
1984-
for iter::repeat(self.explosivity) {
1984+
for old_iter::repeat(self.explosivity) {
19851985
io::println("blam!");
19861986
}
19871987
}
@@ -2056,11 +2056,10 @@ method declarations. So, re-declaring the type parameter
20562056
`T` as an explicit type parameter for `len`, in either the trait or
20572057
the impl, would be a compile-time error.
20582058

2059-
Within a trait definition, `self` is a special type that you can think
2059+
Within a trait definition, `Self` is a special type that you can think
20602060
of as a type parameter. An implementation of the trait for any given
2061-
type `T` replaces the `self` type parameter with `T`. Simply, in a
2062-
trait, `self` is a type, and in an impl, `self` is a value. The
2063-
following trait describes types that support an equality operation:
2061+
type `T` replaces the `Self` type parameter with `T`. The following
2062+
trait describes types that support an equality operation:
20642063

20652064
~~~~
20662065
// In a trait, `self` refers to the self argument.
@@ -2076,7 +2075,7 @@ impl Eq for int {
20762075
~~~~
20772076

20782077
Notice that in the trait definition, `equals` takes a
2079-
second parameter of type `self`.
2078+
second parameter of type `Self`.
20802079
In contrast, in the `impl`, `equals` takes a second parameter of
20812080
type `int`, only using `self` as the name of the receiver.
20822081

branches/auto/src/libcore/at_vec.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
1313
use cast::transmute;
1414
use kinds::Copy;
15-
use iter;
15+
use old_iter;
1616
use option::Option;
17-
use ptr::addr_of;
1817
use sys;
1918
use uint;
2019
use vec;
@@ -40,8 +39,7 @@ pub mod rustrt {
4039
#[inline(always)]
4140
pub fn capacity<T>(v: @[T]) -> uint {
4241
unsafe {
43-
let repr: **raw::VecRepr =
44-
::cast::transmute(addr_of(&v));
42+
let repr: **raw::VecRepr = transmute(&v);
4543
(**repr).unboxed.alloc / sys::size_of::<T>()
4644
}
4745
}
@@ -125,7 +123,7 @@ pub fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
125123
* Creates an immutable vector of size `n_elts` and initializes the elements
126124
* to the value returned by the function `op`.
127125
*/
128-
pub fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
126+
pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> @[T] {
129127
do build_sized(n_elts) |push| {
130128
let mut i: uint = 0u;
131129
while i < n_elts { push(op(i)); i += 1u; }
@@ -187,13 +185,12 @@ pub mod traits {}
187185

188186
pub mod raw {
189187
use at_vec::{capacity, rustrt};
190-
use cast::transmute;
188+
use cast::{transmute, transmute_copy};
191189
use libc;
192-
use unstable::intrinsics::{move_val_init};
193-
use ptr::addr_of;
194190
use ptr;
195191
use sys;
196192
use uint;
193+
use unstable::intrinsics::{move_val_init};
197194
use vec;
198195

199196
pub type VecRepr = vec::raw::VecRepr;
@@ -208,18 +205,17 @@ pub mod raw {
208205
*/
209206
#[inline(always)]
210207
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
211-
let repr: **mut VecRepr = ::cast::transmute(addr_of(&v));
208+
let repr: **mut VecRepr = transmute(&v);
212209
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
213210
}
214211

215212
#[inline(always)]
216213
pub unsafe fn push<T>(v: &mut @[T], initval: T) {
217-
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
214+
let repr: **VecRepr = transmute_copy(&v);
218215
let fill = (**repr).unboxed.fill;
219216
if (**repr).unboxed.alloc > fill {
220217
push_fast(v, initval);
221-
}
222-
else {
218+
} else {
223219
push_slow(v, initval);
224220
}
225221
}
@@ -229,7 +225,7 @@ pub mod raw {
229225
let repr: **mut VecRepr = ::cast::transmute(v);
230226
let fill = (**repr).unboxed.fill;
231227
(**repr).unboxed.fill += sys::size_of::<T>();
232-
let p = addr_of(&((**repr).unboxed.data));
228+
let p = &((**repr).unboxed.data);
233229
let p = ptr::offset(p, fill) as *mut T;
234230
move_val_init(&mut(*p), initval);
235231
}

branches/auto/src/libcore/cast.rs

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,56 @@
1010

1111
//! Unsafe casting functions
1212
13+
use sys;
14+
use unstable;
15+
1316
pub mod rusti {
1417
#[abi = "rust-intrinsic"]
1518
#[link_name = "rusti"]
1619
pub extern "rust-intrinsic" {
1720
fn forget<T>(+x: T);
21+
22+
#[cfg(stage0)]
1823
fn reinterpret_cast<T, U>(&&e: T) -> U;
24+
25+
#[cfg(stage1)]
26+
#[cfg(stage2)]
27+
#[cfg(stage3)]
28+
fn transmute<T,U>(e: T) -> U;
1929
}
2030
}
2131

2232
/// Casts the value at `src` to U. The two types must have the same length.
2333
#[inline(always)]
34+
#[cfg(stage0)]
2435
pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
2536
rusti::reinterpret_cast(*src)
2637
}
2738

39+
/// Unsafely copies and casts the value at `src` to U, even if the value is
40+
/// noncopyable. The two types must have the same length.
41+
#[inline(always)]
42+
#[cfg(stage0)]
43+
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
44+
rusti::reinterpret_cast(*src)
45+
}
46+
47+
#[inline(always)]
48+
#[cfg(stage1)]
49+
#[cfg(stage2)]
50+
#[cfg(stage3)]
51+
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
52+
let mut dest: U = unstable::intrinsics::init();
53+
{
54+
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
55+
let src_ptr: *u8 = rusti::transmute(src);
56+
unstable::intrinsics::memmove64(dest_ptr,
57+
src_ptr,
58+
sys::size_of::<U>() as u64);
59+
}
60+
dest
61+
}
62+
2863
/**
2964
* Move a thing into the void
3065
*
@@ -53,12 +88,21 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
5388
* assert!(transmute("L") == ~[76u8, 0u8]);
5489
*/
5590
#[inline(always)]
91+
#[cfg(stage0)]
5692
pub unsafe fn transmute<L, G>(thing: L) -> G {
5793
let newthing: G = reinterpret_cast(&thing);
5894
forget(thing);
5995
newthing
6096
}
6197

98+
#[inline(always)]
99+
#[cfg(stage1)]
100+
#[cfg(stage2)]
101+
#[cfg(stage3)]
102+
pub unsafe fn transmute<L, G>(thing: L) -> G {
103+
rusti::transmute(thing)
104+
}
105+
62106
/// Coerce an immutable reference to be mutable.
63107
#[inline(always)]
64108
pub unsafe fn transmute_mut<'a,T>(ptr: &'a T) -> &'a mut T { transmute(ptr) }
@@ -112,11 +156,20 @@ pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
112156

113157
#[cfg(test)]
114158
mod tests {
115-
use cast::{bump_box_refcount, reinterpret_cast, transmute};
159+
use cast::{bump_box_refcount, transmute};
116160

117161
#[test]
162+
#[cfg(stage0)]
118163
fn test_reinterpret_cast() {
119-
assert!(1u == unsafe { reinterpret_cast(&1) });
164+
assert!(1u == unsafe { ::cast::reinterpret_cast(&1) });
165+
}
166+
167+
#[test]
168+
#[cfg(stage1)]
169+
#[cfg(stage2)]
170+
#[cfg(stage3)]
171+
fn test_transmute_copy() {
172+
assert!(1u == unsafe { ::cast::transmute_copy(&1) });
120173
}
121174

122175
#[test]
@@ -125,8 +178,8 @@ mod tests {
125178
let box = @~"box box box"; // refcount 1
126179
bump_box_refcount(box); // refcount 2
127180
let ptr: *int = transmute(box); // refcount 2
128-
let _box1: @~str = reinterpret_cast(&ptr);
129-
let _box2: @~str = reinterpret_cast(&ptr);
181+
let _box1: @~str = ::cast::transmute_copy(&ptr);
182+
let _box2: @~str = ::cast::transmute_copy(&ptr);
130183
assert!(*_box1 == ~"box box box");
131184
assert!(*_box2 == ~"box box box");
132185
// Will destroy _box1 and _box2. Without the bump, this would

0 commit comments

Comments
 (0)