diff options
26 files changed, 62 insertions, 106 deletions
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index ee69ab7cc52..7c8e7e85e46 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -320,7 +320,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) { let config = &mut config; let DebuggerCommands { commands, check_lines, .. } = parse_debugger_commands(testfile, "gdb"); - let mut cmds = commands.connect("\n").to_string(); + let mut cmds = commands.connect("\n"); // compile test file (it shoud have 'compile-flags:-g' in the header) let compiler_run_result = compile_test(config, props, testfile); @@ -1035,10 +1035,7 @@ fn compose_and_run_compiler( make_compile_args(config, &aux_props, crate_type.append( - extra_link_args.iter() - .map(|x| x.to_string()) - .collect::<Vec<_>>() - .as_slice()), + extra_link_args.as_slice()), |a,b| { let f = make_lib_name(a, b, testfile); ThisDirectory(f.dir_path()) diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 0981820533d..240f5c007fa 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -49,9 +49,7 @@ //! } //! //! fn main() { -//! let args: Vec<String> = os::args().iter() -//! .map(|x| x.to_string()) -//! .collect(); +//! let args: Vec<String> = os::args(); //! //! let program = args.get(0).clone(); //! diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 7a3e912b629..42e699fb691 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -659,7 +659,7 @@ pub fn sanitize(s: &str) -> String { if result.len() > 0u && result.as_slice()[0] != '_' as u8 && ! char::is_XID_start(result.as_slice()[0] as char) { - return format!("_{}", result.as_slice()).to_string(); + return format!("_{}", result.as_slice()); } return result; diff --git a/src/librustc/driver/config.rs b/src/librustc/driver/config.rs index f14efb696c5..558d2ad71f3 100644 --- a/src/librustc/driver/config.rs +++ b/src/librustc/driver/config.rs @@ -650,10 +650,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { } let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m)); - let target = match matches.opt_str("target") { - Some(supplied_target) => supplied_target.to_string(), - None => driver::host_triple().to_string(), - }; + let target = matches.opt_str("target").unwrap_or( + driver::host_triple().to_string()); let opt_level = { if (debugging_opts & NO_OPT) != 0 { No @@ -705,10 +703,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { Path::new(s.as_slice()) }).collect(); - let cfg = parse_cfgspecs(matches.opt_strs("cfg") - .move_iter() - .map(|x| x.to_string()) - .collect()); + let cfg = parse_cfgspecs(matches.opt_strs("cfg")); let test = matches.opt_present("test"); let write_dependency_info = (matches.opt_present("dep-info"), matches.opt_str("dep-info") diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 9a7be85bdd7..978a4310652 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -595,7 +595,7 @@ impl pprust::PpAnn for IdentifiedAnnotation { } pprust::NodeBlock(blk) => { try!(pp::space(&mut s.s)); - s.synth_comment((format!("block {}", blk.id)).to_string()) + s.synth_comment(format!("block {}", blk.id)) } pprust::NodeExpr(expr) => { try!(pp::space(&mut s.s)); @@ -604,7 +604,7 @@ impl pprust::PpAnn for IdentifiedAnnotation { } pprust::NodePat(pat) => { try!(pp::space(&mut s.s)); - s.synth_comment((format!("pat {}", pat.id)).to_string()) + s.synth_comment(format!("pat {}", pat.id)) } } } @@ -752,7 +752,7 @@ fn print_flowgraph<W:io::Writer>(analysis: CrateAnalysis, let cfg = cfg::CFG::new(ty_cx, &*block); let lcfg = LabelledCFG { ast_map: &ty_cx.map, cfg: &cfg, - name: format!("block{}", block.id).to_string(), }; + name: format!("block{}", block.id), }; debug!("cfg: {:?}", cfg); let r = dot::render(&lcfg, &mut out); return expand_err_details(r); diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 0703b1fab60..2cd41cf14ab 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -137,8 +137,6 @@ mod rustc { } pub fn main() { - let args = std::os::args().iter() - .map(|x| x.to_string()) - .collect::<Vec<_>>(); + let args = std::os::args(); std::os::set_exit_status(driver::main_args(args.as_slice())); } diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index ac9cec84715..d6f1bfeb9ef 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1894,7 +1894,7 @@ impl TypeNames { pub fn types_to_str(&self, tys: &[Type]) -> String { let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect(); - format!("[{}]", strs.connect(",").to_string()) + format!("[{}]", strs.connect(",")) } pub fn val_to_str(&self, val: ValueRef) -> String { diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 0b9ed68215a..218fc31f623 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -441,11 +441,11 @@ impl<'a> PluginMetadataReader<'a> { }; let macros = decoder::get_exported_macros(library.metadata.as_slice()); let registrar = decoder::get_plugin_registrar_fn(library.metadata.as_slice()).map(|id| { - decoder::get_symbol(library.metadata.as_slice(), id).to_string() + decoder::get_symbol(library.metadata.as_slice(), id) }); let pc = PluginMetadata { lib: library.dylib.clone(), - macros: macros.move_iter().map(|x| x.to_string()).collect(), + macros: macros, registrar_symbol: registrar, }; if should_link && existing_match(&self.env, &info.crate_id, None).is_none() { diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 0c77e637790..9ab3202b909 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -801,13 +801,13 @@ impl DataFlowOperator for LoanDataFlowOperator { impl Repr for Loan { fn repr(&self, tcx: &ty::ctxt) -> String { - (format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})", + format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})", self.index, self.loan_path.repr(tcx), self.kind, self.gen_scope, self.kill_scope, - self.restricted_paths.repr(tcx))).to_string() + self.restricted_paths.repr(tcx)) } } @@ -815,23 +815,20 @@ impl Repr for LoanPath { fn repr(&self, tcx: &ty::ctxt) -> String { match self { &LpVar(id) => { - (format!("$({})", tcx.map.node_to_str(id))).to_string() + format!("$({})", tcx.map.node_to_str(id)) } &LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => { let s = tcx.map.node_to_str(var_id); - let s = format!("$({} captured by id={})", s, closure_expr_id); - s.to_string() + format!("$({} captured by id={})", s, closure_expr_id) } &LpExtend(ref lp, _, LpDeref(_)) => { - (format!("{}.*", lp.repr(tcx))).to_string() + format!("{}.*", lp.repr(tcx)) } &LpExtend(ref lp, _, LpInterior(ref interior)) => { - (format!("{}.{}", - lp.repr(tcx), - interior.repr(tcx))).to_string() + format!("{}.{}", lp.repr(tcx), interior.repr(tcx)) } } } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 0c0bba992a0..1de6ff8f03b 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -629,7 +629,7 @@ impl Repr for ty::ParamBounds { for t in self.trait_bounds.iter() { res.push(t.repr(tcx)); } - res.connect("+").to_string() + res.connect("+") } } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index ccd11c67611..cfd004c0c83 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -228,12 +228,12 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { }; // Transform the contents of the header into a hyphenated string - let id = (s.as_slice().words().map(|s| { + let id = s.as_slice().words().map(|s| { match s.to_ascii_opt() { Some(s) => s.to_lower().into_str(), None => s.to_string() } - }).collect::<Vec<String>>().connect("-")).to_string(); + }).collect::<Vec<String>>().connect("-"); // This is a terrible hack working around how hoedown gives us rendered // html for text rather than the raw text. @@ -252,7 +252,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { let sec = match opaque.toc_builder { Some(ref mut builder) => { - builder.push(level as u32, s.to_string(), id.clone()) + builder.push(level as u32, s.clone(), id.clone()) } None => {""} }; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 76e604ecfa2..aacb13156b7 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -370,8 +370,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String> search_index.push(IndexItem { ty: shortty(item), name: item.name.clone().unwrap(), - path: fqp.slice_to(fqp.len() - 1).connect("::") - .to_string(), + path: fqp.slice_to(fqp.len() - 1).connect("::"), desc: shorter(item.doc_value()).to_string(), parent: Some(did), }); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 00c5c2a218d..be14ffa87af 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -85,10 +85,7 @@ local_data_key!(pub analysiskey: core::CrateAnalysis) type Output = (clean::Crate, Vec<plugins::PluginJson> ); pub fn main() { - std::os::set_exit_status(main_args(std::os::args().iter() - .map(|x| x.to_string()) - .collect::<Vec<_>>() - .as_slice())); + std::os::set_exit_status(main_args(std::os::args().as_slice())); } pub fn opts() -> Vec<getopts::OptGroup> { @@ -184,17 +181,10 @@ pub fn main_args(args: &[String]) -> int { match (should_test, markdown_input) { (true, true) => { - return markdown::test(input, - libs, - test_args.move_iter().collect()) + return markdown::test(input, libs, test_args) } (true, false) => { - return test::run(input, - cfgs.move_iter() - .map(|x| x.to_string()) - .collect(), - libs, - test_args) + return test::run(input, cfgs, libs, test_args) } (false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")), &matches), @@ -273,10 +263,7 @@ fn acquire_input(input: &str, fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output { let mut default_passes = !matches.opt_present("no-defaults"); let mut passes = matches.opt_strs("passes"); - let mut plugins = matches.opt_strs("plugins") - .move_iter() - .map(|x| x.to_string()) - .collect::<Vec<_>>(); + let mut plugins = matches.opt_strs("plugins"); // First, parse the crate and extract all relevant information. let libs: Vec<Path> = matches.opt_strs("L") @@ -289,7 +276,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output { let (krate, analysis) = std::task::try(proc() { let cr = cr; core::run_core(libs.move_iter().map(|x| x.clone()).collect(), - cfgs.move_iter().map(|x| x.to_string()).collect(), + cfgs, &cr) }).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap(); info!("finished with rustc"); diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 3b6203ef668..76366240f1a 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -93,19 +93,10 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int let (in_header, before_content, after_content) = match (load_external_files(matches.opt_strs("markdown-in-header") - .move_iter() - .map(|x| x.to_string()) - .collect::<Vec<_>>() .as_slice()), load_external_files(matches.opt_strs("markdown-before-content") - .move_iter() - .map(|x| x.to_string()) - .collect::<Vec<_>>() .as_slice()), load_external_files(matches.opt_strs("markdown-after-content") - .move_iter() - .map(|x| x.to_string()) - .collect::<Vec<_>>() .as_slice())) { (Some(a), Some(b), Some(c)) => (a,b,c), _ => return 3 diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index 31eb83cb920..5145a4f254e 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -348,7 +348,7 @@ pub fn unindent(s: &str) -> String { line.slice_from(min_indent).to_string() } }).collect::<Vec<_>>().as_slice()); - unindented.connect("\n").to_string() + unindented.connect("\n") } else { s.to_string() } diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 4d6f8d0888f..ec225a588fc 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -588,7 +588,7 @@ impl GenericPath for Path { } } } - Some(Path::new(comps.connect("\\").into_string())) + Some(Path::new(comps.connect("\\"))) } } diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 828e9ab12c2..1a9a910f38c 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -680,61 +680,55 @@ fn node_id_to_str(map: &Map, id: NodeId) -> String { ItemImpl(..) => "impl", ItemMac(..) => "macro" }; - (format!("{} {} (id={})", item_str, path_str, id)).to_string() + format!("{} {} (id={})", item_str, path_str, id) } Some(NodeForeignItem(item)) => { let path_str = map.path_to_str_with_ident(id, item.ident); - (format!("foreign item {} (id={})", path_str, id)).to_string() + format!("foreign item {} (id={})", path_str, id) } Some(NodeMethod(m)) => { - (format!("method {} in {} (id={})", + format!("method {} in {} (id={})", token::get_ident(m.ident), - map.path_to_str(id), id)).to_string() + map.path_to_str(id), id) } Some(NodeTraitMethod(ref tm)) => { let m = ast_util::trait_method_to_ty_method(&**tm); - (format!("method {} in {} (id={})", + format!("method {} in {} (id={})", token::get_ident(m.ident), - map.path_to_str(id), id)).to_string() + map.path_to_str(id), id) } Some(NodeVariant(ref variant)) => { - (format!("variant {} in {} (id={})", + format!("variant {} in {} (id={})", token::get_ident(variant.node.name), - map.path_to_str(id), id)).to_string() + map.path_to_str(id), id) } Some(NodeExpr(ref expr)) => { - (format!("expr {} (id={})", - pprust::expr_to_str(&**expr), id)).to_string() + format!("expr {} (id={})", pprust::expr_to_str(&**expr), id) } Some(NodeStmt(ref stmt)) => { - (format!("stmt {} (id={})", - pprust::stmt_to_str(&**stmt), id)).to_string() + format!("stmt {} (id={})", pprust::stmt_to_str(&**stmt), id) } Some(NodeArg(ref pat)) => { - (format!("arg {} (id={})", - pprust::pat_to_str(&**pat), id)).to_string() + format!("arg {} (id={})", pprust::pat_to_str(&**pat), id) } Some(NodeLocal(ref pat)) => { - (format!("local {} (id={})", - pprust::pat_to_str(&**pat), id)).to_string() + format!("local {} (id={})", pprust::pat_to_str(&**pat), id) } Some(NodePat(ref pat)) => { - (format!("pat {} (id={})", pprust::pat_to_str(&**pat), id)).to_string() + format!("pat {} (id={})", pprust::pat_to_str(&**pat), id) } Some(NodeBlock(ref block)) => { - (format!("block {} (id={})", - pprust::block_to_str(&**block), id)).to_string() + format!("block {} (id={})", pprust::block_to_str(&**block), id) } Some(NodeStructCtor(_)) => { - (format!("struct_ctor {} (id={})", - map.path_to_str(id), id)).to_string() + format!("struct_ctor {} (id={})", map.path_to_str(id), id) } Some(NodeLifetime(ref l)) => { - (format!("lifetime {} (id={})", - pprust::lifetime_to_str(&**l), id)).to_string() + format!("lifetime {} (id={})", + pprust::lifetime_to_str(&**l), id) } None => { - (format!("unknown node (id={})", id)).to_string() + format!("unknown node (id={})", id) } } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index df8cb328270..2a6f7bdb87e 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -30,7 +30,7 @@ pub fn path_name_i(idents: &[Ident]) -> String { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") idents.iter().map(|i| { token::get_ident(*i).get().to_string() - }).collect::<Vec<String>>().connect("::").to_string() + }).collect::<Vec<String>>().connect("::") } // totally scary function: ignores all but the last element, should have @@ -123,7 +123,7 @@ pub fn int_ty_to_str(t: IntTy, val: Option<i64>) -> String { // cast to a u64 so we can correctly print INT64_MIN. All integral types // are parsed as u64, so we wouldn't want to print an extra negative // sign. - Some(n) => format!("{}{}", n as u64, s).to_string(), + Some(n) => format!("{}{}", n as u64, s), None => s.to_string() } } @@ -150,7 +150,7 @@ pub fn uint_ty_to_str(t: UintTy, val: Option<u64>) -> String { }; match val { - Some(n) => format!("{}{}", n, s).to_string(), + Some(n) => format!("{}{}", n, s), None => s.to_string() } } diff --git a/src/libsyntax/crateid.rs b/src/libsyntax/crateid.rs index a3112cbb8be..b9298cca4f8 100644 --- a/src/libsyntax/crateid.rs +++ b/src/libsyntax/crateid.rs @@ -112,7 +112,7 @@ impl CrateId { } pub fn short_name_with_version(&self) -> String { - (format!("{}-{}", self.name, self.version_or_default())).to_string() + format!("{}-{}", self.name, self.version_or_default()) } pub fn matches(&self, other: &CrateId) -> bool { diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 05269dbb44d..2b97687dbf8 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -1015,7 +1015,7 @@ impl<'a> TraitDef<'a> { to_set.expn_info = Some(box(GC) codemap::ExpnInfo { call_site: to_set, callee: codemap::NameAndSpan { - name: format!("deriving({})", trait_name).to_string(), + name: format!("deriving({})", trait_name), format: codemap::MacroAttribute, span: Some(self.span) } diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index a009955f91a..f00c1ab4455 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -135,7 +135,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { let lines = vertical_trim(lines); let lines = horizontal_trim(lines); - return lines.connect("\n").to_string(); + return lines.connect("\n"); } fail!("not a doc-comment: {}", comment); diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 854aa80ca34..24ab4b38e54 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -111,7 +111,7 @@ impl Token { pub fn tok_str(t: Token) -> String { match t { - String(s, len) => return format!("STR({},{})", s, len).to_string(), + String(s, len) => return format!("STR({},{})", s, len), Break(_) => return "BREAK".to_string(), Begin(_) => return "BEGIN".to_string(), End => return "END".to_string(), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 97e99ca692d..87ed2076d61 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -243,7 +243,7 @@ pub fn arg_to_str(arg: &ast::Arg) -> String { pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String { match vis { - ast::Public => format!("pub {}", s).to_string(), + ast::Public => format!("pub {}", s), ast::Inherited => s.to_string() } } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 34e9dce3960..589f605f8d2 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -403,7 +403,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> { let save_metrics = save_metrics.map(|s| Path::new(s)); let test_shard = matches.opt_str("test-shard"); - let test_shard = opt_shard(test_shard.map(|x| x.to_string())); + let test_shard = opt_shard(test_shard); let mut nocapture = matches.opt_present("nocapture"); if !nocapture { @@ -756,7 +756,7 @@ pub fn fmt_metrics(mm: &MetricMap) -> String { .map(|(k,v)| format!("{}: {} (+/- {})", *k, v.value as f64, v.noise as f64)) .collect(); - v.connect(", ").to_string() + v.connect(", ") } pub fn fmt_bench_samples(bs: &BenchSamples) -> String { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 4db8cfa6565..fd3c4daebdb 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -24,7 +24,7 @@ use std::vec; use std::io::File; fn main() { - let argv = os::args().move_iter().map(|x| x.to_string()).collect::<Vec<String>>(); + let argv = os::args(); let _tests = argv.slice(1, argv.len()); macro_rules! bench ( diff --git a/src/test/run-pass/issue-5666.rs b/src/test/run-pass/issue-5666.rs index 3e6ef1d2163..222e1d54a5d 100644 --- a/src/test/run-pass/issue-5666.rs +++ b/src/test/run-pass/issue-5666.rs @@ -19,7 +19,7 @@ trait Barks { impl Barks for Dog { fn bark(&self) -> String { - return format!("woof! (I'm {})", self.name).to_string(); + return format!("woof! (I'm {})", self.name); } } |
