Skip to content

Commit 99b33f7

Browse files
committed
librustc: Remove all uses of "copy".
1 parent b4e674f commit 99b33f7

File tree

278 files changed

+3186
-2600
lines changed

Some content is hidden

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

278 files changed

+3186
-2600
lines changed

src/compiletest/compiletest.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ pub fn parse_config(args: ~[~str]) -> config {
117117
mode: str_mode(getopts::opt_str(matches, "mode")),
118118
run_ignored: getopts::opt_present(matches, "ignored"),
119119
filter:
120-
if !matches.free.is_empty() {
121-
Some(copy matches.free[0])
122-
} else { None },
120+
if !matches.free.is_empty() {
121+
Some(matches.free[0].clone())
122+
} else {
123+
None
124+
},
123125
logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),
124126
save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map(|s| Path(*s)),
125127
ratchet_metrics:
@@ -223,9 +225,9 @@ pub fn run_tests(config: &config) {
223225

224226
pub fn test_opts(config: &config) -> test::TestOpts {
225227
test::TestOpts {
226-
filter: copy config.filter,
228+
filter: config.filter.clone(),
227229
run_ignored: config.run_ignored,
228-
logfile: copy config.logfile,
230+
logfile: config.logfile.clone(),
229231
run_tests: true,
230232
run_benchmarks: true,
231233
ratchet_metrics: copy config.ratchet_metrics,
@@ -240,7 +242,7 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
240242
let mut tests = ~[];
241243
let dirs = os::list_dir_path(&config.src_base);
242244
for dirs.iter().advance |file| {
243-
let file = copy *file;
245+
let file = (*file).clone();
244246
debug!("inspecting file %s", file.to_str());
245247
if is_test(config, file) {
246248
let t = do make_test(config, file) {
@@ -306,7 +308,7 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
306308

307309
pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
308310
use std::cell::Cell;
309-
let config = Cell::new(copy *config);
311+
let config = Cell::new((*config).clone());
310312
let testfile = Cell::new(testfile.to_str());
311313
test::DynTestFn(|| { runtest::run(config.take(), testfile.take()) })
312314
}

src/compiletest/procsrv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
2222
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ".libaux";
2323

2424
env = do env.map() |pair| {
25-
let (k,v) = copy *pair;
25+
let (k,v) = (*pair).clone();
2626
if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
2727
else { (k,v) }
2828
};

src/compiletest/runtest.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
150150
let mut round = 0;
151151
while round < rounds {
152152
logv(config, fmt!("pretty-printing round %d", round));
153-
let ProcRes = print_source(config, testfile, copy srcs[round]);
153+
let ProcRes = print_source(config, testfile, srcs[round].clone());
154154

155155
if ProcRes.status != 0 {
156156
fatal_ProcRes(fmt!("pretty-printing failed in round %d", round),
@@ -168,9 +168,9 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
168168
let filepath = testfile.dir_path().push_rel(file);
169169
io::read_whole_file_str(&filepath).get()
170170
}
171-
None => { copy srcs[srcs.len() - 2u] }
171+
None => { srcs[srcs.len() - 2u].clone() }
172172
};
173-
let mut actual = copy srcs[srcs.len() - 1u];
173+
let mut actual = srcs[srcs.len() - 1u].clone();
174174

175175
if props.pp_exact.is_some() {
176176
// Now we have to care about line endings
@@ -243,13 +243,13 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
243243
let mut config = match config.rustcflags {
244244
Some(ref flags) => config {
245245
rustcflags: Some(flags.replace("-O", "")),
246-
.. copy *config
246+
.. (*config).clone()
247247
},
248-
None => copy *config
248+
None => (*config).clone()
249249
};
250250
let config = &mut config;
251251
let cmds = props.debugger_cmds.connect("\n");
252-
let check_lines = copy props.check_lines;
252+
let check_lines = props.check_lines.clone();
253253

254254
// compile test file (it shoud have 'compile-flags:-g' in the header)
255255
let mut ProcRes = compile_test(config, props, testfile);
@@ -498,7 +498,7 @@ fn exec_compiled_test(config: &config, props: &TestProps,
498498
testfile: &Path) -> ProcRes {
499499

500500
// If testing the new runtime then set the RUST_NEWRT env var
501-
let env = copy props.exec_env;
501+
let env = props.exec_env.clone();
502502
let env = if config.newrt { env + &[(~"RUST_NEWRT", ~"1")] } else { env };
503503

504504
match config.target {
@@ -742,7 +742,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
742742

743743
// copy to target
744744
let copy_result = procsrv::run("", config.adb_path,
745-
[~"push", copy args.prog, copy config.adb_test_dir],
745+
[~"push", args.prog.clone(), config.adb_test_dir.clone()],
746746
~[(~"",~"")], Some(~""));
747747

748748
if config.verbose {
@@ -832,7 +832,7 @@ fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
832832
if (file.filetype() == Some(~".so")) {
833833

834834
let copy_result = procsrv::run("", config.adb_path,
835-
[~"push", file.to_str(), copy config.adb_test_dir],
835+
[~"push", file.to_str(), config.adb_test_dir.clone()],
836836
~[(~"",~"")], Some(~""));
837837

838838
if config.verbose {

src/libextra/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ mod tests {
534534

535535
let arc_v : ARC<~[int]> = p.recv();
536536

537-
let v = copy (*arc_v.get());
537+
let v = (*arc_v.get()).clone();
538538
assert_eq!(v[3], 4);
539539
};
540540

src/libextra/base64.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ impl<'self> FromBase64 for &'self [u8] {
211211
let val = byte as u32;
212212

213213
match ch {
214-
'A'..'Z' => buf |= val - 0x41,
215-
'a'..'z' => buf |= val - 0x47,
216-
'0'..'9' => buf |= val + 0x04,
217-
'+'|'-' => buf |= 0x3E,
218-
'/'|'_' => buf |= 0x3F,
214+
'A'..'Z' => buf |= val - 0x41,
215+
'a'..'z' => buf |= val - 0x47,
216+
'0'..'9' => buf |= val + 0x04,
217+
'+'|'-' => buf |= 0x3E,
218+
'/'|'_' => buf |= 0x3F,
219219
'\r'|'\n' => loop,
220-
'=' => break,
221-
_ => return Err(~"Invalid Base64 character")
220+
'=' => break,
221+
_ => return Err(~"Invalid Base64 character")
222222
}
223223

224224
buf <<= 6;

src/libextra/bitv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl Bitv {
266266
else {
267267
let nelems = nbits/uint::bits +
268268
if nbits % uint::bits == 0 {0} else {1};
269-
let elem = if init {!0} else {0};
269+
let elem = if init {!0u} else {0u};
270270
let s = vec::from_elem(nelems, elem);
271271
Big(~BigBitv::new(s))
272272
};
@@ -518,7 +518,7 @@ impl Clone for Bitv {
518518
Bitv{nbits: self.nbits, rep: Small(~SmallBitv{bits: b.bits})}
519519
}
520520
Big(ref b) => {
521-
let mut st = vec::from_elem(self.nbits / uint::bits + 1, 0);
521+
let mut st = vec::from_elem(self.nbits / uint::bits + 1, 0u);
522522
let len = st.len();
523523
for uint::range(0, len) |i| { st[i] = b.storage[i]; };
524524
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: st})}

src/libextra/c_vec.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,19 @@ pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn())
119119
*
120120
* Fails if `ofs` is greater or equal to the length of the vector
121121
*/
122-
pub fn get<T:Copy>(t: CVec<T>, ofs: uint) -> T {
122+
pub fn get<T:Clone>(t: CVec<T>, ofs: uint) -> T {
123123
assert!(ofs < len(t));
124-
return unsafe { copy *ptr::mut_offset(t.base, ofs) };
124+
return unsafe {
125+
(*ptr::mut_offset(t.base, ofs)).clone()
126+
};
125127
}
126128

127129
/**
128130
* Sets the value of an element at a given index
129131
*
130132
* Fails if `ofs` is greater or equal to the length of the vector
131133
*/
132-
pub fn set<T:Copy>(t: CVec<T>, ofs: uint, v: T) {
134+
pub fn set<T>(t: CVec<T>, ofs: uint, v: T) {
133135
assert!(ofs < len(t));
134136
unsafe { *ptr::mut_offset(t.base, ofs) = v };
135137
}

src/libextra/dlist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@ mod tests {
609609
}
610610

611611
#[cfg(test)]
612-
fn list_from<T: Copy>(v: &[T]) -> DList<T> {
613-
v.iter().transform(|x| copy *x).collect()
612+
fn list_from<T: Clone>(v: &[T]) -> DList<T> {
613+
v.iter().transform(|x| (*x).clone()).collect()
614614
}
615615

616616
#[test]

src/libextra/ebml.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct EbmlState {
2929
data_pos: uint,
3030
}
3131

32+
#[deriving(Clone)]
3233
pub struct Doc {
3334
data: @~[u8],
3435
start: uint,
@@ -615,6 +616,7 @@ pub mod writer {
615616
use super::*;
616617

617618
use std::cast;
619+
use std::clone::Clone;
618620
use std::io;
619621

620622
// ebml writing
@@ -623,6 +625,15 @@ pub mod writer {
623625
priv size_positions: ~[uint],
624626
}
625627

628+
impl Clone for Encoder {
629+
fn clone(&self) -> Encoder {
630+
Encoder {
631+
writer: self.writer,
632+
size_positions: self.size_positions.clone(),
633+
}
634+
}
635+
}
636+
626637
fn write_sized_vuint(w: @io::Writer, n: uint, size: uint) {
627638
match size {
628639
1u => w.write(&[0x80u8 | (n as u8)]),

src/libextra/fileinput.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ and `line_num_file` represent the number of lines read in total and in
107107
the current file respectively. `current_path` is `None` if the current
108108
file is `stdin`.
109109
*/
110+
#[deriving(Clone)]
110111
pub struct FileInputState {
111112
current_path: Option<Path>,
112113
line_num: uint,
@@ -223,7 +224,7 @@ impl FileInput {
223224
let path_option = self.fi.files.shift();
224225
let file = match path_option {
225226
None => io::stdin(),
226-
Some(ref path) => io::file_reader(path).get()
227+
Some(ref path) => io::file_reader(path).unwrap()
227228
};
228229

229230
self.fi.current_reader = Some(file);
@@ -259,15 +260,15 @@ impl FileInput {
259260
*/
260261
pub fn each_line_state(&self,
261262
f: &fn(&str, FileInputState) -> bool) -> bool {
262-
self.each_line(|line| f(line, copy self.fi.state))
263+
self.each_line(|line| f(line, self.fi.state.clone()))
263264
}
264265

265266

266267
/**
267268
Retrieve the current `FileInputState` information.
268269
*/
269270
pub fn state(&self) -> FileInputState {
270-
copy self.fi.state
271+
self.fi.state.clone()
271272
}
272273
}
273274

@@ -431,7 +432,7 @@ mod test {
431432
let paths = ~[Some(Path("some/path")),
432433
Some(Path("some/other/path"))];
433434

434-
assert_eq!(pathify(strs, true), copy paths);
435+
assert_eq!(pathify(strs, true), paths.clone());
435436
assert_eq!(pathify(strs, false), paths);
436437

437438
assert_eq!(pathify([~"-"], true), ~[None]);
@@ -449,7 +450,7 @@ mod test {
449450
make_file(filename.get_ref(), [fmt!("%u", i)]);
450451
}
451452
452-
let fi = FileInput::from_vec(copy filenames);
453+
let fi = FileInput::from_vec(filenames.clone());
453454
454455
for "012".iter().enumerate().advance |(line, c)| {
455456
assert_eq!(fi.read_byte(), c as int);
@@ -459,7 +460,7 @@ mod test {
459460
assert_eq!(fi.state().line_num, line + 1);
460461
assert_eq!(fi.state().line_num_file, 1);
461462
462-
assert_eq!(copy fi.state().current_path, copy filenames[line]);
463+
assert_eq!(fi.state().current_path.clone(), filenames[line].clone());
463464
}
464465
465466
assert_eq!(fi.read_byte(), -1);
@@ -542,13 +543,13 @@ mod test {
542543
make_file(filenames[2].get_ref(), [~"3", ~"4"]);
543544
544545
let mut count = 0;
545-
for input_vec_state(copy filenames) |line, state| {
546+
for input_vec_state(filenames.clone()) |line, state| {
546547
let expected_path = match line {
547-
"1" | "2" => copy filenames[0],
548-
"3" | "4" => copy filenames[2],
548+
"1" | "2" => filenames[0].clone(),
549+
"3" | "4" => filenames[2].clone(),
549550
_ => fail!("unexpected line")
550551
};
551-
assert_eq!(copy state.current_path, expected_path);
552+
assert_eq!(state.current_path.clone(), expected_path);
552553
count += 1;
553554
}
554555
assert_eq!(count, 4);

0 commit comments

Comments
 (0)