Skip to content

Commit 262353e

Browse files
committed
---
yaml --- r: 22062 b: refs/heads/snap-stage3 c: f41cf20 h: refs/heads/master v: v3
1 parent da3cd8f commit 262353e

File tree

5 files changed

+45
-55
lines changed

5 files changed

+45
-55
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e7b8388cb44b24ed53870a4e42306bd1092d1962
4+
refs/heads/snap-stage3: f41cf208b7809bcb5cd12e81970802a52b2c265e
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/box.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,22 @@
77
use cmp::{Eq, Ord};
88
use intrinsic::TyDesc;
99

10-
export ptr_eq, raw;
11-
12-
mod raw {
13-
#[legacy_exports];
14-
15-
struct BoxHeaderRepr {
10+
pub mod raw {
11+
pub struct BoxHeaderRepr {
1612
ref_count: uint,
1713
type_desc: *TyDesc,
1814
prev: *BoxRepr,
1915
next: *BoxRepr,
2016
}
2117

22-
struct BoxRepr {
18+
pub struct BoxRepr {
2319
header: BoxHeaderRepr,
2420
data: u8
2521
}
2622

2723
}
2824

29-
pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
25+
pub pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
3026
//! Determine if two shared boxes point to the same object
3127
unsafe { ptr::addr_of(*a) == ptr::addr_of(*b) }
3228
}

branches/snap-stage3/src/libcore/cast.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
//! Unsafe operations
22
3-
export reinterpret_cast, forget, bump_box_refcount, transmute;
4-
export transmute_mut, transmute_immut, transmute_region, transmute_mut_region;
5-
export transmute_mut_unsafe, transmute_immut_unsafe;
6-
7-
export copy_lifetime, copy_lifetime_vec;
8-
93
#[abi = "rust-intrinsic"]
104
extern mod rusti {
115
#[legacy_exports];
@@ -15,7 +9,7 @@ extern mod rusti {
159

1610
/// Casts the value at `src` to U. The two types must have the same length.
1711
#[inline(always)]
18-
unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
12+
pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
1913
rusti::reinterpret_cast(*src)
2014
}
2115

@@ -28,15 +22,15 @@ unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
2822
* reinterpret_cast on managed pointer types.
2923
*/
3024
#[inline(always)]
31-
unsafe fn forget<T>(-thing: T) { rusti::forget(move thing); }
25+
pub unsafe fn forget<T>(-thing: T) { rusti::forget(move thing); }
3226

3327
/**
3428
* Force-increment the reference count on a shared box. If used
3529
* carelessly, this can leak the box. Use this in conjunction with transmute
3630
* and/or reinterpret_cast when such calls would otherwise scramble a box's
3731
* reference count
3832
*/
39-
unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); }
33+
pub unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); }
4034

4135
/**
4236
* Transform a value of one type into a value of another type.
@@ -47,47 +41,53 @@ unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); }
4741
* assert transmute("L") == ~[76u8, 0u8];
4842
*/
4943
#[inline(always)]
50-
unsafe fn transmute<L, G>(-thing: L) -> G {
44+
pub unsafe fn transmute<L, G>(-thing: L) -> G {
5145
let newthing: G = reinterpret_cast(&thing);
5246
forget(move thing);
5347
move newthing
5448
}
5549

5650
/// Coerce an immutable reference to be mutable.
5751
#[inline(always)]
58-
unsafe fn transmute_mut<T>(+ptr: &a/T) -> &a/mut T { transmute(move ptr) }
52+
pub unsafe fn transmute_mut<T>(+ptr: &a/T) -> &a/mut T { transmute(move ptr) }
5953

6054
/// Coerce a mutable reference to be immutable.
6155
#[inline(always)]
62-
unsafe fn transmute_immut<T>(+ptr: &a/mut T) -> &a/T { transmute(move ptr) }
56+
pub unsafe fn transmute_immut<T>(+ptr: &a/mut T) -> &a/T {
57+
transmute(move ptr)
58+
}
6359

6460
/// Coerce a borrowed pointer to have an arbitrary associated region.
6561
#[inline(always)]
66-
unsafe fn transmute_region<T>(+ptr: &a/T) -> &b/T { transmute(move ptr) }
62+
pub unsafe fn transmute_region<T>(+ptr: &a/T) -> &b/T { transmute(move ptr) }
6763

6864
/// Coerce an immutable reference to be mutable.
6965
#[inline(always)]
70-
unsafe fn transmute_mut_unsafe<T>(+ptr: *const T) -> *mut T { transmute(ptr) }
66+
pub unsafe fn transmute_mut_unsafe<T>(+ptr: *const T) -> *mut T {
67+
transmute(ptr)
68+
}
7169

7270
/// Coerce an immutable reference to be mutable.
7371
#[inline(always)]
74-
unsafe fn transmute_immut_unsafe<T>(+ptr: *const T) -> *T { transmute(ptr) }
72+
pub unsafe fn transmute_immut_unsafe<T>(+ptr: *const T) -> *T {
73+
transmute(ptr)
74+
}
7575

7676
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
7777
#[inline(always)]
78-
unsafe fn transmute_mut_region<T>(+ptr: &a/mut T) -> &b/mut T {
78+
pub unsafe fn transmute_mut_region<T>(+ptr: &a/mut T) -> &b/mut T {
7979
transmute(move ptr)
8080
}
8181

8282
/// Transforms lifetime of the second pointer to match the first.
8383
#[inline(always)]
84-
unsafe fn copy_lifetime<S,T>(_ptr: &a/S, ptr: &T) -> &a/T {
84+
pub unsafe fn copy_lifetime<S,T>(_ptr: &a/S, ptr: &T) -> &a/T {
8585
transmute_region(ptr)
8686
}
8787

8888
/// Transforms lifetime of the second pointer to match the first.
8989
#[inline(always)]
90-
unsafe fn copy_lifetime_vec<S,T>(_ptr: &a/[S], ptr: &T) -> &a/T {
90+
pub unsafe fn copy_lifetime_vec<S,T>(_ptr: &a/[S], ptr: &T) -> &a/T {
9191
transmute_region(ptr)
9292
}
9393

@@ -97,16 +97,14 @@ unsafe fn copy_lifetime_vec<S,T>(_ptr: &a/[S], ptr: &T) -> &a/T {
9797
****************************************************************************/
9898

9999
#[cfg(test)]
100-
mod tests {
101-
#[legacy_exports];
102-
100+
pub mod tests {
103101
#[test]
104-
fn test_reinterpret_cast() {
102+
pub fn test_reinterpret_cast() {
105103
assert 1u == unsafe { reinterpret_cast(&1) };
106104
}
107105

108106
#[test]
109-
fn test_bump_box_refcount() {
107+
pub fn test_bump_box_refcount() {
110108
unsafe {
111109
let box = @~"box box box"; // refcount 1
112110
bump_box_refcount(box); // refcount 2
@@ -121,7 +119,7 @@ mod tests {
121119
}
122120

123121
#[test]
124-
fn test_transmute() {
122+
pub fn test_transmute() {
125123
unsafe {
126124
let x = @1;
127125
let x: *int = transmute(x);
@@ -131,7 +129,7 @@ mod tests {
131129
}
132130

133131
#[test]
134-
fn test_transmute2() {
132+
pub fn test_transmute2() {
135133
unsafe {
136134
assert ~[76u8, 0u8] == transmute(~"L");
137135
}

branches/snap-stage3/src/libcore/cmp.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ and `Eq` to overload the `==` and `!=` operators.
1414
#[forbid(deprecated_mode)];
1515
#[forbid(deprecated_pattern)];
1616

17-
use nounittest::*;
18-
use unittest::*;
19-
export Ord;
20-
export Eq;
17+
pub use nounittest::*;
18+
pub use unittest::*;
19+
20+
export Ord, Eq;
2121

2222
/// Interfaces used for comparison.
2323
2424
// Awful hack to work around duplicate lang items in core test.
2525
#[cfg(notest)]
2626
mod nounittest {
27-
#[legacy_exports];
2827
/**
2928
* Trait for values that can be compared for a sort-order.
3029
*
@@ -33,7 +32,7 @@ mod nounittest {
3332
* default implementations.
3433
*/
3534
#[lang="ord"]
36-
trait Ord {
35+
pub trait Ord {
3736
pure fn lt(other: &self) -> bool;
3837
pure fn le(other: &self) -> bool;
3938
pure fn ge(other: &self) -> bool;
@@ -50,7 +49,7 @@ mod nounittest {
5049
* a default implementation.
5150
*/
5251
#[lang="eq"]
53-
trait Eq {
52+
pub trait Eq {
5453
pure fn eq(other: &self) -> bool;
5554
pure fn ne(other: &self) -> bool;
5655
}
@@ -63,14 +62,14 @@ mod nounittest {
6362
#[cfg(test)]
6463
mod unittest {
6564
#[legacy_exports];
66-
trait Ord {
65+
pub trait Ord {
6766
pure fn lt(other: &self) -> bool;
6867
pure fn le(other: &self) -> bool;
6968
pure fn ge(other: &self) -> bool;
7069
pure fn gt(other: &self) -> bool;
7170
}
7271

73-
trait Eq {
72+
pub trait Eq {
7473
pure fn eq(other: &self) -> bool;
7574
pure fn ne(other: &self) -> bool;
7675
}
@@ -80,27 +79,27 @@ mod unittest {
8079
mod unittest {
8180
#[legacy_exports];}
8281

83-
pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
82+
pub pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
8483
(*v1).lt(v2)
8584
}
8685

87-
pure fn le<T: Ord Eq>(v1: &T, v2: &T) -> bool {
86+
pub pure fn le<T: Ord Eq>(v1: &T, v2: &T) -> bool {
8887
(*v1).lt(v2) || (*v1).eq(v2)
8988
}
9089

91-
pure fn eq<T: Eq>(v1: &T, v2: &T) -> bool {
90+
pub pure fn eq<T: Eq>(v1: &T, v2: &T) -> bool {
9291
(*v1).eq(v2)
9392
}
9493

95-
pure fn ne<T: Eq>(v1: &T, v2: &T) -> bool {
94+
pub pure fn ne<T: Eq>(v1: &T, v2: &T) -> bool {
9695
(*v1).ne(v2)
9796
}
9897

99-
pure fn ge<T: Ord>(v1: &T, v2: &T) -> bool {
98+
pub pure fn ge<T: Ord>(v1: &T, v2: &T) -> bool {
10099
(*v1).ge(v2)
101100
}
102101

103-
pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool {
102+
pub pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool {
104103
(*v1).gt(v2)
105104
}
106105

branches/snap-stage3/src/libcore/dlist.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
1212
#[forbid(deprecated_mode)];
1313
#[forbid(deprecated_pattern)];
1414

15-
export DList;
16-
export new_dlist, from_elem, from_vec, extensions;
17-
1815
type DListLink<T> = Option<DListNode<T>>;
1916

2017
enum DListNode<T> = @{
@@ -24,7 +21,7 @@ enum DListNode<T> = @{
2421
mut next: DListLink<T>
2522
};
2623

27-
enum DList<T> {
24+
pub enum DList<T> {
2825
DList_(@{
2926
mut size: uint,
3027
mut hd: DListLink<T>,
@@ -94,13 +91,13 @@ pure fn DList<T>() -> DList<T> {
9491
}
9592

9693
/// Creates a new dlist with a single element
97-
pure fn from_elem<T>(+data: T) -> DList<T> {
94+
pub pure fn from_elem<T>(+data: T) -> DList<T> {
9895
let list = DList();
9996
unsafe { list.push(move data); }
10097
list
10198
}
10299

103-
fn from_vec<T: Copy>(+vec: &[T]) -> DList<T> {
100+
pub fn from_vec<T: Copy>(+vec: &[T]) -> DList<T> {
104101
do vec::foldl(DList(), vec) |list,data| {
105102
list.push(data); // Iterating left-to-right -- add newly to the tail.
106103
list

0 commit comments

Comments
 (0)