Skip to content

Commit f78cdcb

Browse files
committed
Removing explicit uses of + mode
This removes most explicit uses of the + argument mode. Pending a snapshot, I had to remove the forbid(deprecated_modes) pragma from a bunch of files. I'll put it back! + mode still has to be used in a few places for functions that get moved (see task.rs) The changes outside core and std are due to the to_bytes trait and making the compiler (with legacy modes on) agree with the libraries (with legacy modes off) about modes.
1 parent a5042d5 commit f78cdcb

38 files changed

+282
-276
lines changed

src/libcore/at_vec.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Managed vectors
22
33
// NB: transitionary, de-mode-ing.
4-
#[forbid(deprecated_mode)];
4+
// tjc: re-forbid deprecated modes after snapshot
55
#[forbid(deprecated_pattern)];
66

77
use cast::transmute;
@@ -48,7 +48,7 @@ pub pure fn capacity<T>(v: @[const T]) -> uint {
4848
*/
4949
#[inline(always)]
5050
pub pure fn build_sized<A>(size: uint,
51-
builder: &fn(push: pure fn(+v: A))) -> @[A] {
51+
builder: &fn(push: pure fn(v: A))) -> @[A] {
5252
let mut vec: @[const A] = @[];
5353
unsafe { raw::reserve(&mut vec, size); }
5454
builder(|+x| unsafe { raw::push(&mut vec, move x) });
@@ -66,7 +66,7 @@ pub pure fn build_sized<A>(size: uint,
6666
* onto the vector being constructed.
6767
*/
6868
#[inline(always)]
69-
pub pure fn build<A>(builder: &fn(push: pure fn(+v: A))) -> @[A] {
69+
pub pure fn build<A>(builder: &fn(push: pure fn(v: A))) -> @[A] {
7070
build_sized(4, builder)
7171
}
7272

@@ -83,8 +83,8 @@ pub pure fn build<A>(builder: &fn(push: pure fn(+v: A))) -> @[A] {
8383
* onto the vector being constructed.
8484
*/
8585
#[inline(always)]
86-
pub pure fn build_sized_opt<A>(+size: Option<uint>,
87-
builder: &fn(push: pure fn(+v: A))) -> @[A] {
86+
pub pure fn build_sized_opt<A>(size: Option<uint>,
87+
builder: &fn(push: pure fn(v: A))) -> @[A] {
8888
build_sized(size.get_default(4), builder)
8989
}
9090

@@ -126,7 +126,7 @@ pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
126126
* Creates an immutable vector of size `n_elts` and initializes the elements
127127
* to the value `t`.
128128
*/
129-
pub pure fn from_elem<T: Copy>(n_elts: uint, +t: T) -> @[T] {
129+
pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
130130
do build_sized(n_elts) |push| {
131131
let mut i: uint = 0u;
132132
while i < n_elts { push(copy t); i += 1u; }
@@ -166,7 +166,7 @@ pub mod raw {
166166
}
167167

168168
#[inline(always)]
169-
pub unsafe fn push<T>(v: &mut @[const T], +initval: T) {
169+
pub unsafe fn push<T>(v: &mut @[const T], initval: T) {
170170
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
171171
let fill = (**repr).unboxed.fill;
172172
if (**repr).unboxed.alloc > fill {
@@ -178,7 +178,7 @@ pub mod raw {
178178
}
179179
// This doesn't bother to make sure we have space.
180180
#[inline(always)] // really pretty please
181-
pub unsafe fn push_fast<T>(v: &mut @[const T], +initval: T) {
181+
pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) {
182182
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
183183
let fill = (**repr).unboxed.fill;
184184
(**repr).unboxed.fill += sys::size_of::<T>();
@@ -187,7 +187,7 @@ pub mod raw {
187187
rusti::move_val_init(*p, move initval);
188188
}
189189

190-
pub unsafe fn push_slow<T>(v: &mut @[const T], +initval: T) {
190+
pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) {
191191
reserve_at_least(v, v.len() + 1u);
192192
push_fast(v, move initval);
193193
}

src/libcore/cast.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
2121
* reinterpret_cast on managed pointer types.
2222
*/
2323
#[inline(always)]
24-
pub unsafe fn forget<T>(+thing: T) { rusti::forget(move thing); }
24+
pub unsafe fn forget<T>(thing: T) { rusti::forget(move thing); }
2525

2626
/**
2727
* Force-increment the reference count on a shared box. If used
2828
* carelessly, this can leak the box. Use this in conjunction with transmute
2929
* and/or reinterpret_cast when such calls would otherwise scramble a box's
3030
* reference count
3131
*/
32-
pub unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); }
32+
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(move t); }
3333

3434
/**
3535
* Transform a value of one type into a value of another type.
@@ -40,41 +40,41 @@ pub unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); }
4040
* assert transmute("L") == ~[76u8, 0u8];
4141
*/
4242
#[inline(always)]
43-
pub unsafe fn transmute<L, G>(+thing: L) -> G {
43+
pub unsafe fn transmute<L, G>(thing: L) -> G {
4444
let newthing: G = reinterpret_cast(&thing);
4545
forget(move thing);
4646
move newthing
4747
}
4848

4949
/// Coerce an immutable reference to be mutable.
5050
#[inline(always)]
51-
pub unsafe fn transmute_mut<T>(+ptr: &a/T) -> &a/mut T { transmute(move ptr) }
51+
pub unsafe fn transmute_mut<T>(ptr: &a/T) -> &a/mut T { transmute(move ptr) }
5252

5353
/// Coerce a mutable reference to be immutable.
5454
#[inline(always)]
55-
pub unsafe fn transmute_immut<T>(+ptr: &a/mut T) -> &a/T {
55+
pub unsafe fn transmute_immut<T>(ptr: &a/mut T) -> &a/T {
5656
transmute(move ptr)
5757
}
5858

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

6363
/// Coerce an immutable reference to be mutable.
6464
#[inline(always)]
65-
pub unsafe fn transmute_mut_unsafe<T>(+ptr: *const T) -> *mut T {
65+
pub unsafe fn transmute_mut_unsafe<T>(ptr: *const T) -> *mut T {
6666
transmute(ptr)
6767
}
6868

6969
/// Coerce an immutable reference to be mutable.
7070
#[inline(always)]
71-
pub unsafe fn transmute_immut_unsafe<T>(+ptr: *const T) -> *T {
71+
pub unsafe fn transmute_immut_unsafe<T>(ptr: *const T) -> *T {
7272
transmute(ptr)
7373
}
7474

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

src/libcore/comm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ will once again be the preferred module for intertask communication.
3232
3333
*/
3434

35-
// NB: transitionary, de-mode-ing.
36-
#[warn(deprecated_mode)];
35+
// NB: transitionary, de-mode-ing
36+
// tjc: re-forbid deprecated modes after snapshot
3737
#[forbid(deprecated_pattern)];
3838

3939
use either::Either;
@@ -75,7 +75,7 @@ pub fn Port<T: Send>() -> Port<T> {
7575
impl<T: Send> Port<T> {
7676

7777
fn chan() -> Chan<T> { Chan(self) }
78-
fn send(+v: T) { self.chan().send(move v) }
78+
fn send(v: T) { self.chan().send(move v) }
7979
fn recv() -> T { recv(self) }
8080
fn peek() -> bool { peek(self) }
8181

@@ -84,7 +84,7 @@ impl<T: Send> Port<T> {
8484
impl<T: Send> Chan<T> {
8585

8686
fn chan() -> Chan<T> { self }
87-
fn send(+v: T) { send(self, move v) }
87+
fn send(v: T) { send(self, move v) }
8888
fn recv() -> T { recv_chan(self) }
8989
fn peek() -> bool { peek_chan(self) }
9090

@@ -174,7 +174,7 @@ pub fn Chan<T: Send>(&&p: Port<T>) -> Chan<T> {
174174
* Sends data over a channel. The sent data is moved into the channel,
175175
* whereupon the caller loses access to it.
176176
*/
177-
pub fn send<T: Send>(ch: Chan<T>, +data: T) {
177+
pub fn send<T: Send>(ch: Chan<T>, data: T) {
178178
let Chan_(p) = ch;
179179
let data_ptr = ptr::addr_of(&data) as *();
180180
let res = rustrt::rust_port_id_send(p, data_ptr);

src/libcore/dlist.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
99
*/
1010

1111
// NB: transitionary, de-mode-ing.
12-
#[forbid(deprecated_mode)];
12+
// tjc: re-forbid deprecated modes after snapshot
1313
#[forbid(deprecated_pattern)];
1414

1515
type DListLink<T> = Option<DListNode<T>>;
@@ -80,7 +80,7 @@ impl<T> DListNode<T> {
8080
}
8181

8282
/// Creates a new dlist node with the given data.
83-
pure fn new_dlist_node<T>(+data: T) -> DListNode<T> {
83+
pure fn new_dlist_node<T>(data: T) -> DListNode<T> {
8484
DListNode(@{data: move data, mut linked: false,
8585
mut prev: None, mut next: None})
8686
}
@@ -91,13 +91,13 @@ pure fn DList<T>() -> DList<T> {
9191
}
9292

9393
/// Creates a new dlist with a single element
94-
pub pure fn from_elem<T>(+data: T) -> DList<T> {
94+
pub pure fn from_elem<T>(data: T) -> DList<T> {
9595
let list = DList();
9696
unsafe { list.push(move data); }
9797
list
9898
}
9999

100-
pub fn from_vec<T: Copy>(+vec: &[T]) -> DList<T> {
100+
pub fn from_vec<T: Copy>(vec: &[T]) -> DList<T> {
101101
do vec::foldl(DList(), vec) |list,data| {
102102
list.push(*data); // Iterating left-to-right -- add newly to the tail.
103103
list
@@ -115,7 +115,7 @@ fn concat<T>(lists: DList<DList<T>>) -> DList<T> {
115115
}
116116

117117
priv impl<T> DList<T> {
118-
pure fn new_link(+data: T) -> DListLink<T> {
118+
pure fn new_link(data: T) -> DListLink<T> {
119119
Some(DListNode(@{data: move data, mut linked: true,
120120
mut prev: None, mut next: None}))
121121
}
@@ -142,7 +142,7 @@ priv impl<T> DList<T> {
142142
// Link two nodes together. If either of them are 'none', also sets
143143
// the head and/or tail pointers appropriately.
144144
#[inline(always)]
145-
fn link(+before: DListLink<T>, +after: DListLink<T>) {
145+
fn link(before: DListLink<T>, after: DListLink<T>) {
146146
match before {
147147
Some(neighbour) => neighbour.next = after,
148148
None => self.hd = after
@@ -163,12 +163,12 @@ priv impl<T> DList<T> {
163163
self.size -= 1;
164164
}
165165
166-
fn add_head(+nobe: DListLink<T>) {
166+
fn add_head(nobe: DListLink<T>) {
167167
self.link(nobe, self.hd); // Might set tail too.
168168
self.hd = nobe;
169169
self.size += 1;
170170
}
171-
fn add_tail(+nobe: DListLink<T>) {
171+
fn add_tail(nobe: DListLink<T>) {
172172
self.link(self.tl, nobe); // Might set head too.
173173
self.tl = nobe;
174174
self.size += 1;
@@ -198,27 +198,27 @@ impl<T> DList<T> {
198198
pure fn is_not_empty() -> bool { self.len() != 0 }
199199
200200
/// Add data to the head of the list. O(1).
201-
fn push_head(+data: T) {
201+
fn push_head(data: T) {
202202
self.add_head(self.new_link(move data));
203203
}
204204
/**
205205
* Add data to the head of the list, and get the new containing
206206
* node. O(1).
207207
*/
208-
fn push_head_n(+data: T) -> DListNode<T> {
208+
fn push_head_n(data: T) -> DListNode<T> {
209209
let mut nobe = self.new_link(move data);
210210
self.add_head(nobe);
211211
option::get(&nobe)
212212
}
213213
/// Add data to the tail of the list. O(1).
214-
fn push(+data: T) {
214+
fn push(data: T) {
215215
self.add_tail(self.new_link(move data));
216216
}
217217
/**
218218
* Add data to the tail of the list, and get the new containing
219219
* node. O(1).
220220
*/
221-
fn push_n(+data: T) -> DListNode<T> {
221+
fn push_n(data: T) -> DListNode<T> {
222222
let mut nobe = self.new_link(move data);
223223
self.add_tail(nobe);
224224
option::get(&nobe)
@@ -227,7 +227,7 @@ impl<T> DList<T> {
227227
* Insert data into the middle of the list, left of the given node.
228228
* O(1).
229229
*/
230-
fn insert_before(+data: T, neighbour: DListNode<T>) {
230+
fn insert_before(data: T, neighbour: DListNode<T>) {
231231
self.insert_left(self.new_link(move data), neighbour);
232232
}
233233
/**
@@ -242,7 +242,7 @@ impl<T> DList<T> {
242242
* Insert data in the middle of the list, left of the given node,
243243
* and get its containing node. O(1).
244244
*/
245-
fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
245+
fn insert_before_n(data: T, neighbour: DListNode<T>) -> DListNode<T> {
246246
let mut nobe = self.new_link(move data);
247247
self.insert_left(nobe, neighbour);
248248
option::get(&nobe)
@@ -251,7 +251,7 @@ impl<T> DList<T> {
251251
* Insert data into the middle of the list, right of the given node.
252252
* O(1).
253253
*/
254-
fn insert_after(+data: T, neighbour: DListNode<T>) {
254+
fn insert_after(data: T, neighbour: DListNode<T>) {
255255
self.insert_right(neighbour, self.new_link(move data));
256256
}
257257
/**
@@ -266,7 +266,7 @@ impl<T> DList<T> {
266266
* Insert data in the middle of the list, right of the given node,
267267
* and get its containing node. O(1).
268268
*/
269-
fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
269+
fn insert_after_n(data: T, neighbour: DListNode<T>) -> DListNode<T> {
270270
let mut nobe = self.new_link(move data);
271271
self.insert_right(neighbour, nobe);
272272
option::get(&nobe)

0 commit comments

Comments
 (0)