Skip to content

Commit 0d59e86

Browse files
committed
core: Remove some uses of 'move'
1 parent 948754b commit 0d59e86

File tree

5 files changed

+112
-112
lines changed

5 files changed

+112
-112
lines changed

src/libcore/at_vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub pure fn build_sized<A>(size: uint,
6161
builder: &fn(push: pure fn(v: A))) -> @[A] {
6262
let mut vec: @[const A] = @[];
6363
unsafe { raw::reserve(&mut vec, size); }
64-
builder(|+x| unsafe { raw::push(&mut vec, move x) });
64+
builder(|+x| unsafe { raw::push(&mut vec, x) });
6565
return unsafe { transmute(vec) };
6666
}
6767

@@ -178,10 +178,10 @@ pub mod raw {
178178
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
179179
let fill = (**repr).unboxed.fill;
180180
if (**repr).unboxed.alloc > fill {
181-
push_fast(v, move initval);
181+
push_fast(v, initval);
182182
}
183183
else {
184-
push_slow(v, move initval);
184+
push_slow(v, initval);
185185
}
186186
}
187187

src/libcore/char.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub pure fn escape_unicode(c: char) -> ~str {
149149
{ str::push_str(&mut out, ~"0"); }
150150
str::push_str(&mut out, s);
151151
}
152-
move out
152+
out
153153
}
154154

155155
/**

src/libcore/cleanup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub unsafe fn annihilate() {
152152
assert (*box).header.prev == null();
153153

154154
debug!("freeing box: %x", box as uint);
155-
rt_free(transmute(move box));
155+
rt_free(transmute(box));
156156
}
157157
}
158158

src/libcore/str.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn push_char(s: &mut ~str, ch: char) {
133133
pub pure fn from_char(ch: char) -> ~str {
134134
let mut buf = ~"";
135135
unsafe { push_char(&mut buf, ch); }
136-
move buf
136+
buf
137137
}
138138

139139
/// Convert a vector of chars to a string
@@ -145,7 +145,7 @@ pub pure fn from_chars(chs: &[char]) -> ~str {
145145
push_char(&mut buf, *ch);
146146
}
147147
}
148-
move buf
148+
buf
149149
}
150150

151151
/// Appends a string slice to the back of a string, without overallocating
@@ -186,11 +186,11 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) {
186186
/// Concatenate two strings together
187187
#[inline(always)]
188188
pub pure fn append(lhs: ~str, rhs: &str) -> ~str {
189-
let mut v = move lhs;
189+
let mut v = lhs;
190190
unsafe {
191191
push_str_no_overallocate(&mut v, rhs);
192192
}
193-
move v
193+
v
194194
}
195195

196196

@@ -200,7 +200,7 @@ pub pure fn concat(v: &[~str]) -> ~str {
200200
for vec::each(v) |ss| {
201201
unsafe { push_str(&mut s, *ss) };
202202
}
203-
move s
203+
s
204204
}
205205

206206
/// Concatenate a vector of strings, placing a given separator between each
@@ -210,14 +210,14 @@ pub pure fn connect(v: &[~str], sep: &str) -> ~str {
210210
if first { first = false; } else { unsafe { push_str(&mut s, sep); } }
211211
unsafe { push_str(&mut s, *ss) };
212212
}
213-
move s
213+
s
214214
}
215215

216216
/// Given a string, make a new string with repeated copies of it
217217
pub fn repeat(ss: &str, nn: uint) -> ~str {
218218
let mut acc = ~"";
219219
for nn.times { acc += ss; }
220-
move acc
220+
acc
221221
}
222222

223223
/*
@@ -359,7 +359,7 @@ Section: Transforming strings
359359
pub pure fn to_bytes(s: &str) -> ~[u8] unsafe {
360360
let mut v: ~[u8] = ::cast::transmute(from_slice(s));
361361
vec::raw::set_len(&mut v, len(s));
362-
move v
362+
v
363363
}
364364

365365
/// Work with the string as a byte slice, not including trailing null.
@@ -379,7 +379,7 @@ pub pure fn chars(s: &str) -> ~[char] {
379379
unsafe { buf.push(ch); }
380380
i = next;
381381
}
382-
move buf
382+
buf
383383
}
384384

385385
/**
@@ -455,7 +455,7 @@ pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool)
455455
if allow_empty || start < l {
456456
unsafe { result.push(raw::slice_bytes(s, start, l) ) };
457457
}
458-
move result
458+
result
459459
} else {
460460
splitn(s, |cur| cur == sep, count)
461461
}
@@ -498,7 +498,7 @@ pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint,
498498
if allow_empty || start < l unsafe {
499499
result.push(unsafe { raw::slice_bytes(s, start, l) });
500500
}
501-
move result
501+
result
502502
}
503503

504504
// See Issue #1932 for why this is a naive search
@@ -552,7 +552,7 @@ pub pure fn split_str(s: &a/str, sep: &b/str) -> ~[~str] {
552552
do iter_between_matches(s, sep) |from, to| {
553553
unsafe { result.push(raw::slice_bytes(s, from, to)); }
554554
}
555-
move result
555+
result
556556
}
557557

558558
pub pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] {
@@ -562,7 +562,7 @@ pub pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] {
562562
unsafe { result.push(raw::slice_bytes(s, from, to)); }
563563
}
564564
}
565-
move result
565+
result
566566
}
567567

568568
/**
@@ -581,7 +581,7 @@ pub pure fn lines_any(s: &str) -> ~[~str] {
581581
if l > 0u && s[l - 1u] == '\r' as u8 {
582582
unsafe { raw::set_len(&mut cp, l - 1u); }
583583
}
584-
move cp
584+
cp
585585
})
586586
}
587587

@@ -609,17 +609,17 @@ pub fn split_within(ss: &str, lim: uint) -> ~[~str] {
609609
// then start a new row
610610
if row.len() + word.len() + 1 > lim {
611611
rows.push(copy row); // save previous row
612-
row = move word; // start a new one
612+
row = word; // start a new one
613613
} else {
614614
if row.len() > 0 { row += ~" " } // separate words
615615
row += word; // append to this row
616616
}
617617
}
618618
619619
// save the last row
620-
if row != ~"" { rows.push(move row); }
620+
if row != ~"" { rows.push(row); }
621621

622-
move rows
622+
rows
623623
}
624624

625625

@@ -661,7 +661,7 @@ pub pure fn replace(s: &str, from: &str, to: &str) -> ~str {
661661
}
662662
unsafe { push_str(&mut result, raw::slice_bytes(s, start, end)); }
663663
}
664-
move result
664+
result
665665
}
666666

667667
/*
@@ -840,7 +840,7 @@ pub pure fn map(ss: &str, ff: fn(char) -> char) -> ~str {
840840
str::push_char(&mut result, ff(cc));
841841
}
842842
}
843-
move result
843+
result
844844
}
845845

846846
/// Iterate over the bytes in a string
@@ -1493,7 +1493,7 @@ pub pure fn to_utf16(s: &str) -> ~[u16] {
14931493
u.push_all(~[w1, w2])
14941494
}
14951495
}
1496-
move u
1496+
u
14971497
}
14981498

14991499
pub pure fn utf16_chars(v: &[u16], f: fn(char)) {
@@ -1527,13 +1527,13 @@ pub pure fn from_utf16(v: &[u16]) -> ~str {
15271527
reserve(&mut buf, vec::len(v));
15281528
utf16_chars(v, |ch| push_char(&mut buf, ch));
15291529
}
1530-
move buf
1530+
buf
15311531
}
15321532

15331533
pub pure fn with_capacity(capacity: uint) -> ~str {
15341534
let mut buf = ~"";
15351535
unsafe { reserve(&mut buf, capacity); }
1536-
move buf
1536+
buf
15371537
}
15381538

15391539
/**
@@ -1921,7 +1921,7 @@ pub pure fn escape_default(s: &str) -> ~str {
19211921
push_str(&mut out, char::escape_default(c));
19221922
}
19231923
}
1924-
move out
1924+
out
19251925
}
19261926

19271927
/// Escape each char in `s` with char::escape_unicode.
@@ -1933,7 +1933,7 @@ pub pure fn escape_unicode(s: &str) -> ~str {
19331933
push_str(&mut out, char::escape_unicode(c));
19341934
}
19351935
}
1936-
move out
1936+
out
19371937
}
19381938

19391939
/// Unsafe operations
@@ -1959,7 +1959,7 @@ pub mod raw {
19591959
v.push(0u8);
19601960

19611961
assert is_utf8(v);
1962-
return ::cast::transmute(move v);
1962+
return ::cast::transmute(v);
19631963
}
19641964

19651965
/// Create a Rust string from a null-terminated C string
@@ -1987,7 +1987,7 @@ pub mod raw {
19871987
f: fn(v: &str) -> T) -> T {
19881988
let v = (buf, len + 1);
19891989
assert is_utf8(::cast::reinterpret_cast(&v));
1990-
f(::cast::transmute(move v))
1990+
f(::cast::transmute(v))
19911991
}
19921992

19931993
/**
@@ -2014,7 +2014,7 @@ pub mod raw {
20142014
}
20152015
vec::raw::set_len(&mut v, end - begin);
20162016
v.push(0u8);
2017-
::cast::transmute(move v)
2017+
::cast::transmute(v)
20182018
}
20192019
}
20202020
}
@@ -2667,13 +2667,13 @@ mod tests {
26672667
let mut i = 0;
26682668
let mut rs = ~"";
26692669
while i < 100000 { push_str(&mut rs, ~"aaaaaaaaaa"); i += 1; }
2670-
move rs
2670+
rs
26712671
}
26722672
fn half_a_million_letter_a() -> ~str {
26732673
let mut i = 0;
26742674
let mut rs = ~"";
26752675
while i < 100000 { push_str(&mut rs, ~"aaaaa"); i += 1; }
2676-
move rs
2676+
rs
26772677
}
26782678
assert half_a_million_letter_a() ==
26792679
raw::slice_bytes(a_million_letter_a(), 0u, 500000);
@@ -2780,13 +2780,13 @@ mod tests {
27802780
push_str(&mut rs, ~"华华华华华华华华华华");
27812781
i += 1;
27822782
}
2783-
move rs
2783+
rs
27842784
}
27852785
fn half_a_million_letter_X() -> ~str {
27862786
let mut i = 0;
27872787
let mut rs = ~"";
27882788
while i < 100000 { push_str(&mut rs, ~"华华华华华"); i += 1; }
2789-
move rs
2789+
rs
27902790
}
27912791
assert half_a_million_letter_X() ==
27922792
slice(a_million_letter_X(), 0u, 3u * 500000u);

0 commit comments

Comments
 (0)