Skip to content

Commit 43c0724

Browse files
committed
librustc: Fix up fallout from the automatic conversion.
1 parent 3b6e9d4 commit 43c0724

Some content is hidden

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

98 files changed

+1172
-758
lines changed

src/librustc/back/archive.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,17 @@ impl Archive {
9898
let archive = os::make_absolute(&self.dst);
9999
run_ar(self.sess, "x", Some(loc.path()), [&archive,
100100
&Path::new(file)]);
101-
fs::File::open(&loc.path().join(file)).read_to_end().unwrap()
101+
let result: Vec<u8> =
102+
fs::File::open(&loc.path().join(file)).read_to_end()
103+
.unwrap()
104+
.move_iter()
105+
.collect();
106+
result
102107
} else {
103-
run_ar(self.sess, "p", None, [&self.dst, &Path::new(file)]).output
108+
run_ar(self.sess,
109+
"p",
110+
None,
111+
[&self.dst, &Path::new(file)]).output.move_iter().collect()
104112
}
105113
}
106114

@@ -124,7 +132,7 @@ impl Archive {
124132
if lto {
125133
ignore.push(object.as_slice());
126134
}
127-
self.add_archive(rlib, name, ignore)
135+
self.add_archive(rlib, name, ignore.as_slice())
128136
}
129137

130138
/// Adds an arbitrary file to this archive

src/librustc/back/link.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use std::str;
3434
use std::io;
3535
use std::io::Process;
3636
use std::io::fs;
37+
use std::vec_ng::Vec;
3738
use flate;
3839
use serialize::hex::ToHex;
3940
use extra::tempfile::TempDir;
@@ -106,6 +107,7 @@ pub mod write {
106107
use std::io::Process;
107108
use std::libc::{c_uint, c_int};
108109
use std::str;
110+
use std::vec_ng::Vec;
109111

110112
// On android, we by default compile for armv7 processors. This enables
111113
// things like double word CAS instructions (rather than emulating them)
@@ -222,7 +224,7 @@ pub mod write {
222224

223225
if sess.lto() {
224226
time(sess.time_passes(), "all lto passes", (), |()|
225-
lto::run(sess, llmod, tm, trans.reachable));
227+
lto::run(sess, llmod, tm, trans.reachable.as_slice()));
226228

227229
if sess.opts.cg.save_temps {
228230
output.with_extension("lto.bc").with_c_str(|buf| {
@@ -931,7 +933,8 @@ fn link_rlib(sess: Session,
931933
// the same filename for metadata (stomping over one another)
932934
let tmpdir = TempDir::new("rustc").expect("needs a temp dir");
933935
let metadata = tmpdir.path().join(METADATA_FILENAME);
934-
match fs::File::create(&metadata).write(trans.metadata) {
936+
match fs::File::create(&metadata).write(trans.metadata
937+
.as_slice()) {
935938
Ok(..) => {}
936939
Err(e) => {
937940
sess.err(format!("failed to write {}: {}",
@@ -1035,7 +1038,7 @@ fn link_natively(sess: Session, dylib: bool, obj_filename: &Path,
10351038
// Invoke the system linker
10361039
debug!("{} {}", cc_prog, cc_args.connect(" "));
10371040
let prog = time(sess.time_passes(), "running linker", (), |()|
1038-
Process::output(cc_prog, cc_args));
1041+
Process::output(cc_prog, cc_args.as_slice()));
10391042
match prog {
10401043
Ok(prog) => {
10411044
if !prog.status.success() {
@@ -1198,7 +1201,7 @@ fn link_args(sess: Session,
11981201
// where extern libraries might live, based on the
11991202
// addl_lib_search_paths
12001203
if !sess.opts.cg.no_rpath {
1201-
args.push_all(rpath::get_rpath_flags(sess, out_filename));
1204+
args.push_all(rpath::get_rpath_flags(sess, out_filename).as_slice());
12021205
}
12031206

12041207
// Stack growth requires statically linking a __morestack function
@@ -1210,7 +1213,7 @@ fn link_args(sess: Session,
12101213

12111214
// Finally add all the linker arguments provided on the command line along
12121215
// with any #[link_args] attributes found inside the crate
1213-
args.push_all(sess.opts.cg.link_args);
1216+
args.push_all(sess.opts.cg.link_args.as_slice());
12141217
let used_link_args = sess.cstore.get_used_link_args();
12151218
let used_link_args = used_link_args.borrow();
12161219
for arg in used_link_args.get().iter() {

src/librustc/back/mips.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use back::target_strs;
1212
use driver::session::sess_os_to_meta_os;
1313
use metadata::loader::meta_section_name;
14+
use std::vec_ng::Vec;
1415
use syntax::abi;
1516

1617
pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::t {

src/librustc/back/rpath.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use metadata::filesearch;
1515

1616
use collections::HashSet;
1717
use std::{os, vec};
18+
use std::vec_ng::Vec;
1819
use syntax::abi;
1920

2021
fn not_win32(os: abi::Os) -> bool {
@@ -49,7 +50,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> Vec<~str>
4950

5051
let rpaths = get_rpaths(os, sysroot, output, libs,
5152
sess.opts.target_triple);
52-
flags.push_all(rpaths_to_flags(rpaths));
53+
flags.push_all(rpaths_to_flags(rpaths.as_slice()).as_slice());
5354
flags
5455
}
5556

@@ -100,16 +101,16 @@ fn get_rpaths(os: abi::Os,
100101
}
101102
}
102103

103-
log_rpaths("relative", rel_rpaths);
104-
log_rpaths("absolute", abs_rpaths);
105-
log_rpaths("fallback", fallback_rpaths);
104+
log_rpaths("relative", rel_rpaths.as_slice());
105+
log_rpaths("absolute", abs_rpaths.as_slice());
106+
log_rpaths("fallback", fallback_rpaths.as_slice());
106107

107108
let mut rpaths = rel_rpaths;
108-
rpaths.push_all(abs_rpaths);
109-
rpaths.push_all(fallback_rpaths);
109+
rpaths.push_all(abs_rpaths.as_slice());
110+
rpaths.push_all(fallback_rpaths.as_slice());
110111

111112
// Remove duplicates
112-
let rpaths = minimize_rpaths(rpaths);
113+
let rpaths = minimize_rpaths(rpaths.as_slice());
113114
return rpaths;
114115
}
115116

src/librustc/back/target_strs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#[allow(non_camel_case_types)];
1212

13+
use std::vec_ng::Vec;
14+
1315
pub struct t {
1416
module_asm: ~str,
1517
meta_sect_name: ~str,

src/librustc/driver/driver.rs

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
use back::link;
1313
use back::{arm, x86, x86_64, mips};
14-
use driver::session::{Aggressive, CrateTypeExecutable, FullDebugInfo, LimitedDebugInfo,
15-
NoDebugInfo};
14+
use driver::session::{Aggressive, CrateTypeExecutable, CrateType,
15+
FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
1616
use driver::session::{Session, Session_, No, Less, Default};
1717
use driver::session;
1818
use front;
@@ -36,7 +36,6 @@ use std::io;
3636
use std::io::fs;
3737
use std::io::MemReader;
3838
use std::os;
39-
use std::vec;
4039
use std::vec_ng::Vec;
4140
use std::vec_ng;
4241
use collections::HashMap;
@@ -434,7 +433,7 @@ pub fn phase_5_run_llvm_passes(sess: Session,
434433
time(sess.time_passes(), "LLVM passes", (), |_|
435434
link::write::run_passes(sess,
436435
trans,
437-
sess.opts.output_types,
436+
sess.opts.output_types.as_slice(),
438437
outputs));
439438
}
440439
}
@@ -767,18 +766,21 @@ pub fn host_triple() -> ~str {
767766

768767
pub fn build_session_options(matches: &getopts::Matches)
769768
-> @session::Options {
770-
let crate_types = matches.opt_strs("crate-type").flat_map(|s| {
771-
s.split(',').map(|part| {
772-
match part {
769+
let mut crate_types: Vec<CrateType> = Vec::new();
770+
let unparsed_crate_types = matches.opt_strs("crate-type");
771+
for unparsed_crate_type in unparsed_crate_types.iter() {
772+
for part in unparsed_crate_type.split(',') {
773+
let new_part = match part {
773774
"lib" => session::default_lib_output(),
774775
"rlib" => session::CrateTypeRlib,
775776
"staticlib" => session::CrateTypeStaticlib,
776777
"dylib" => session::CrateTypeDylib,
777778
"bin" => session::CrateTypeExecutable,
778779
_ => early_error(format!("unknown crate type: `{}`", part))
779-
}
780-
}).collect()
781-
});
780+
};
781+
crate_types.push(new_part)
782+
}
783+
}
782784

783785
let parse_only = matches.opt_present("parse-only");
784786
let no_trans = matches.opt_present("no-trans");
@@ -793,8 +795,10 @@ pub fn build_session_options(matches: &getopts::Matches)
793795

794796
let level_short = level_name.slice_chars(0, 1);
795797
let level_short = level_short.to_ascii().to_upper().into_str();
796-
let flags = vec_ng::append(matches.opt_strs(level_short),
797-
matches.opt_strs(level_name));
798+
let flags = vec_ng::append(matches.opt_strs(level_short)
799+
.move_iter()
800+
.collect(),
801+
matches.opt_strs(level_name));
798802
for lint_name in flags.iter() {
799803
let lint_name = lint_name.replace("-", "_");
800804
match lint_dict.find_equiv(&lint_name) {
@@ -828,23 +832,24 @@ pub fn build_session_options(matches: &getopts::Matches)
828832
unsafe { llvm::LLVMSetDebug(1); }
829833
}
830834

831-
let mut output_types = if parse_only || no_trans {
832-
Vec::new()
833-
} else {
834-
matches.opt_strs("emit").flat_map(|s| {
835-
s.split(',').map(|part| {
836-
match part.as_slice() {
835+
let mut output_types = Vec::new();
836+
if !parse_only && !no_trans {
837+
let unparsed_output_types = matches.opt_strs("emit");
838+
for unparsed_output_type in unparsed_output_types.iter() {
839+
for part in unparsed_output_type.split(',') {
840+
let output_type = match part.as_slice() {
837841
"asm" => link::OutputTypeAssembly,
838842
"ir" => link::OutputTypeLlvmAssembly,
839843
"bc" => link::OutputTypeBitcode,
840844
"obj" => link::OutputTypeObject,
841845
"link" => link::OutputTypeExe,
842846
_ => early_error(format!("unknown emission type: `{}`", part))
843-
}
844-
}).collect()
845-
})
847+
};
848+
output_types.push(output_type)
849+
}
850+
}
846851
};
847-
output_types.sort();
852+
output_types.as_mut_slice().sort();
848853
output_types.dedup();
849854
if output_types.len() == 0 {
850855
output_types.push(link::OutputTypeExe);
@@ -890,7 +895,7 @@ pub fn build_session_options(matches: &getopts::Matches)
890895
Path::new(s.as_slice())
891896
}).move_iter().collect();
892897

893-
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
898+
let cfg = parse_cfgspecs(matches.opt_strs("cfg").move_iter().collect());
894899
let test = matches.opt_present("test");
895900
let write_dependency_info = (matches.opt_present("dep-info"),
896901
matches.opt_str("dep-info").map(|p| Path::new(p)));
@@ -1187,7 +1192,7 @@ mod test {
11871192
#[test]
11881193
fn test_switch_implies_cfg_test() {
11891194
let matches =
1190-
&match getopts([~"--test"], optgroups()) {
1195+
&match getopts([~"--test"], optgroups().as_slice()) {
11911196
Ok(m) => m,
11921197
Err(f) => fail!("test_switch_implies_cfg_test: {}", f.to_err_msg())
11931198
};
@@ -1202,7 +1207,8 @@ mod test {
12021207
#[test]
12031208
fn test_switch_implies_cfg_test_unless_cfg_test() {
12041209
let matches =
1205-
&match getopts([~"--test", ~"--cfg=test"], optgroups()) {
1210+
&match getopts([~"--test", ~"--cfg=test"],
1211+
optgroups().as_slice()) {
12061212
Ok(m) => m,
12071213
Err(f) => {
12081214
fail!("test_switch_implies_cfg_test_unless_cfg_test: {}",

src/librustc/driver/session.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -320,19 +320,9 @@ pub fn basic_options() -> @Options {
320320
crate_types: Vec::new(),
321321
gc: false,
322322
optimize: No,
323-
<<<<<<< HEAD
324323
debuginfo: NoDebugInfo,
325-
lint_opts: ~[],
326-
output_types: ~[],
327-
||||||| merged common ancestors
328-
debuginfo: false,
329-
lint_opts: ~[],
330-
output_types: ~[],
331-
=======
332-
debuginfo: false,
333324
lint_opts: Vec::new(),
334325
output_types: Vec::new(),
335-
>>>>>>> librustc: Automatically change uses of `~[T]` to `Vec<T>` in rustc.
336326
addl_lib_search_paths: @RefCell::new(HashSet::new()),
337327
maybe_sysroot: None,
338328
target_triple: host_triple(),
@@ -403,7 +393,8 @@ macro_rules! cgoptions(
403393
}
404394
}
405395

406-
fn parse_list(slot: &mut Vec<~str> , v: Option<&str>) -> bool {
396+
fn parse_list(slot: &mut ::std::vec_ng::Vec<~str>, v: Option<&str>)
397+
-> bool {
407398
match v {
408399
Some(s) => {
409400
for s in s.words() {
@@ -489,7 +480,7 @@ pub fn collect_crate_types(session: &Session,
489480
// If we're generating a test executable, then ignore all other output
490481
// styles at all other locations
491482
if session.opts.test {
492-
return Vec<CrateTypeExecutable> ;
483+
return vec!(CrateTypeExecutable)
493484
}
494485
let mut base = session.opts.crate_types.clone();
495486
let mut iter = attrs.iter().filter_map(|a| {
@@ -525,7 +516,7 @@ pub fn collect_crate_types(session: &Session,
525516
if base.len() == 0 {
526517
base.push(CrateTypeExecutable);
527518
}
528-
base.sort();
519+
base.as_mut_slice().sort();
529520
base.dedup();
530521
return base;
531522
}

src/librustc/front/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
11+
use std::vec_ng::Vec;
1212
use syntax::fold::Folder;
1313
use syntax::{ast, fold, attr};
1414
use syntax::codemap;

src/librustc/front/feature_gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use syntax::parse::token;
3131
use driver::session::Session;
3232

3333
use std::cell::Cell;
34+
use std::vec_ng::Vec;
3435

3536
/// This is a list of all known features since the beginning of time. This list
3637
/// can never shrink, it may only be expanded (in order to prevent old programs

src/librustc/front/test.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
9393
path.get().push(i.ident);
9494
}
9595
debug!("current path: {}",
96-
ast_util::path_name_i(self.cx.path.get()));
96+
ast_util::path_name_i(self.cx.path.get().as_slice()));
9797

9898
if is_test_fn(&self.cx, i) || is_bench_fn(i) {
9999
match i.node {
@@ -432,11 +432,12 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
432432
let span = test.span;
433433
let path = test.path.clone();
434434

435-
debug!("encoding {}", ast_util::path_name_i(path));
435+
debug!("encoding {}", ast_util::path_name_i(path.as_slice()));
436436

437437
let name_lit: ast::Lit =
438438
nospan(ast::LitStr(token::intern_and_get_ident(
439-
ast_util::path_name_i(path)), ast::CookedStr));
439+
ast_util::path_name_i(path.as_slice())),
440+
ast::CookedStr));
440441

441442
let name_expr = @ast::Expr {
442443
id: ast::DUMMY_NODE_ID,

0 commit comments

Comments
 (0)