diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-10 19:46:38 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-21 23:31:42 -0800 |
| commit | 082bfde412176249dc7328e771a2a15d202824cf (patch) | |
| tree | 4df3816d6ffea2f52bf5fa51fe385806ed529ba7 /src/librustc_driver | |
| parent | 4908017d59da8694b9ceaf743baf1163c1e19086 (diff) | |
| download | rust-082bfde412176249dc7328e771a2a15d202824cf.tar.gz rust-082bfde412176249dc7328e771a2a15d202824cf.zip | |
Fallout of std::str stabilization
Diffstat (limited to 'src/librustc_driver')
| -rw-r--r-- | src/librustc_driver/driver.rs | 30 | ||||
| -rw-r--r-- | src/librustc_driver/lib.rs | 28 | ||||
| -rw-r--r-- | src/librustc_driver/pretty.rs | 30 |
3 files changed, 45 insertions, 43 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 60b890b0370..20bb9c2f4fd 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -58,12 +58,12 @@ pub fn compile_input(sess: Session, let outputs = build_output_filenames(input, outdir, output, - krate.attrs.as_slice(), + krate.attrs[], &sess); - let id = link::find_crate_name(Some(&sess), krate.attrs.as_slice(), + let id = link::find_crate_name(Some(&sess), krate.attrs[], input); let expanded_crate - = match phase_2_configure_and_expand(&sess, krate, id.as_slice(), + = match phase_2_configure_and_expand(&sess, krate, id[], addl_plugins) { None => return, Some(k) => k @@ -75,7 +75,7 @@ pub fn compile_input(sess: Session, let mut forest = ast_map::Forest::new(expanded_crate); let ast_map = assign_node_ids_and_map(&sess, &mut forest); - write_out_deps(&sess, input, &outputs, id.as_slice()); + write_out_deps(&sess, input, &outputs, id[]); if stop_after_phase_2(&sess) { return; } @@ -163,9 +163,9 @@ pub fn phase_2_configure_and_expand(sess: &Session, let time_passes = sess.time_passes(); *sess.crate_types.borrow_mut() = - collect_crate_types(sess, krate.attrs.as_slice()); + collect_crate_types(sess, krate.attrs[]); *sess.crate_metadata.borrow_mut() = - collect_crate_metadata(sess, krate.attrs.as_slice()); + collect_crate_metadata(sess, krate.attrs[]); time(time_passes, "gated feature checking", (), |_| { let (features, unknown_features) = @@ -257,8 +257,8 @@ pub fn phase_2_configure_and_expand(sess: &Session, if cfg!(windows) { _old_path = os::getenv("PATH").unwrap_or(_old_path); let mut new_path = sess.host_filesearch().get_dylib_search_paths(); - new_path.extend(os::split_paths(_old_path.as_slice()).into_iter()); - os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap()); + new_path.extend(os::split_paths(_old_path[]).into_iter()); + os::setenv("PATH", os::join_paths(new_path[]).unwrap()); } let cfg = syntax::ext::expand::ExpansionConfig { crate_name: crate_name.to_string(), @@ -503,7 +503,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session, time(sess.time_passes(), "LLVM passes", (), |_| write::run_passes(sess, trans, - sess.opts.output_types.as_slice(), + sess.opts.output_types[], outputs)); } @@ -517,14 +517,14 @@ pub fn phase_6_link_output(sess: &Session, outputs: &OutputFilenames) { let old_path = os::getenv("PATH").unwrap_or_else(||String::new()); let mut new_path = sess.host_filesearch().get_tools_search_paths(); - new_path.extend(os::split_paths(old_path.as_slice()).into_iter()); - os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap()); + new_path.extend(os::split_paths(old_path[]).into_iter()); + os::setenv("PATH", os::join_paths(new_path[]).unwrap()); time(sess.time_passes(), "linking", (), |_| link::link_binary(sess, trans, outputs, - trans.link.crate_name.as_slice())); + trans.link.crate_name[])); os::setenv("PATH", old_path); } @@ -613,7 +613,7 @@ fn write_out_deps(sess: &Session, // write Makefile-compatible dependency rules let files: Vec<String> = sess.codemap().files.borrow() .iter().filter(|fmap| fmap.is_real_file()) - .map(|fmap| escape_dep_filename(fmap.name.as_slice())) + .map(|fmap| escape_dep_filename(fmap.name[])) .collect(); let mut file = try!(io::File::create(&deps_filename)); for path in out_filenames.iter() { @@ -627,7 +627,7 @@ fn write_out_deps(sess: &Session, Ok(()) => {} Err(e) => { sess.fatal(format!("error writing dependencies to `{}`: {}", - deps_filename.display(), e).as_slice()); + deps_filename.display(), e)[]); } } } @@ -698,7 +698,7 @@ pub fn collect_crate_types(session: &Session, if !res { session.warn(format!("dropping unsupported crate type `{}` \ for target `{}`", - *crate_type, session.opts.target_triple).as_slice()); + *crate_type, session.opts.target_triple)[]); } res diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 6944c733456..1fb90d7860e 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -55,6 +55,7 @@ use rustc::DIAGNOSTICS; use std::any::AnyRefExt; use std::io; +use std::iter::repeat; use std::os; use std::thread; @@ -88,12 +89,12 @@ fn run_compiler(args: &[String]) { let descriptions = diagnostics::registry::Registry::new(&DIAGNOSTICS); match matches.opt_str("explain") { Some(ref code) => { - match descriptions.find_description(code.as_slice()) { + match descriptions.find_description(code[]) { Some(ref description) => { println!("{}", description); } None => { - early_error(format!("no extended information for {}", code).as_slice()); + early_error(format!("no extended information for {}", code)[]); } } return; @@ -119,7 +120,7 @@ fn run_compiler(args: &[String]) { early_error("no input filename given"); } 1u => { - let ifile = matches.free[0].as_slice(); + let ifile = matches.free[0][]; if ifile == "-" { let contents = io::stdin().read_to_end().unwrap(); let src = String::from_utf8(contents).unwrap(); @@ -138,7 +139,7 @@ fn run_compiler(args: &[String]) { } let pretty = matches.opt_default("pretty", "normal").map(|a| { - pretty::parse_pretty(&sess, a.as_slice()) + pretty::parse_pretty(&sess, a[]) }); match pretty.into_iter().next() { Some((ppm, opt_uii)) => { @@ -261,7 +262,8 @@ Available lint options: .map(|&s| s.name.width(true)) .max().unwrap_or(0); let padded = |x: &str| { - let mut s = " ".repeat(max_name_len - x.char_len()); + let mut s = repeat(" ").take(max_name_len - x.chars().count()) + .collect::<String>(); s.push_str(x); s }; @@ -274,7 +276,7 @@ Available lint options: for lint in lints.into_iter() { let name = lint.name_lower().replace("_", "-"); println!(" {} {:7.7} {}", - padded(name.as_slice()), lint.default_level.as_str(), lint.desc); + padded(name[]), lint.default_level.as_str(), lint.desc); } println!("\n"); }; @@ -287,7 +289,8 @@ Available lint options: .map(|&(s, _)| s.width(true)) .max().unwrap_or(0); let padded = |x: &str| { - let mut s = " ".repeat(max_name_len - x.char_len()); + let mut s = repeat(" ").take(max_name_len - x.chars().count()) + .collect::<String>(); s.push_str(x); s }; @@ -303,7 +306,7 @@ Available lint options: let desc = to.into_iter().map(|x| x.as_str().replace("_", "-")) .collect::<Vec<String>>().connect(", "); println!(" {} {}", - padded(name.as_slice()), desc); + padded(name[]), desc); } println!("\n"); }; @@ -367,10 +370,10 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> { } let matches = - match getopts::getopts(args.as_slice(), config::optgroups().as_slice()) { + match getopts::getopts(args[], config::optgroups()[]) { Ok(m) => m, Err(f) => { - early_error(f.to_string().as_slice()); + early_error(f.to_string()[]); } }; @@ -518,7 +521,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) { "run with `RUST_BACKTRACE=1` for a backtrace".to_string(), ]; for note in xs.iter() { - emitter.emit(None, note.as_slice(), None, diagnostic::Note) + emitter.emit(None, note[], None, diagnostic::Note) } match r.read_to_string() { @@ -526,8 +529,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) { Err(e) => { emitter.emit(None, format!("failed to read internal \ - stderr: {}", - e).as_slice(), + stderr: {}", e)[], None, diagnostic::Error) } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 2eb9d2c67a7..4b10ca92e70 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -71,10 +71,10 @@ pub fn parse_pretty(sess: &Session, name: &str) -> (PpMode, Option<UserIdentifie sess.fatal(format!( "argument to `pretty` must be one of `normal`, \ `expanded`, `flowgraph=<nodeid>`, `typed`, `identified`, \ - or `expanded,identified`; got {}", name).as_slice()); + or `expanded,identified`; got {}", name)[]); } }; - let opt_second = opt_second.and_then::<UserIdentifiedItem, _>(from_str); + let opt_second = opt_second.and_then(|s| s.parse::<UserIdentifiedItem>()); (first, opt_second) } @@ -276,7 +276,7 @@ impl<'tcx> pprust::PpAnn for TypedAnnotation<'tcx> { try!(pp::word(&mut s.s, ppaux::ty_to_string( tcx, - ty::expr_ty(tcx, expr)).as_slice())); + ty::expr_ty(tcx, expr))[])); s.pclose() } _ => Ok(()) @@ -311,7 +311,7 @@ pub enum UserIdentifiedItem { impl FromStr for UserIdentifiedItem { fn from_str(s: &str) -> Option<UserIdentifiedItem> { - from_str(s).map(ItemViaNode).or_else(|| { + s.parse().map(ItemViaNode).or_else(|| { let v : Vec<_> = s.split_str("::") .map(|x|x.to_string()) .collect(); @@ -322,7 +322,7 @@ impl FromStr for UserIdentifiedItem { enum NodesMatchingUII<'a, 'ast: 'a> { NodesMatchingDirect(option::IntoIter<ast::NodeId>), - NodesMatchingSuffix(ast_map::NodesMatchingSuffix<'a, 'ast, String>), + NodesMatchingSuffix(ast_map::NodesMatchingSuffix<'a, 'ast>), } impl<'a, 'ast> Iterator<ast::NodeId> for NodesMatchingUII<'a, 'ast> { @@ -348,7 +348,7 @@ impl UserIdentifiedItem { ItemViaNode(node_id) => NodesMatchingDirect(Some(node_id).into_iter()), ItemViaPath(ref parts) => - NodesMatchingSuffix(map.nodes_matching_suffix(parts.as_slice())), + NodesMatchingSuffix(map.nodes_matching_suffix(parts[])), } } @@ -360,7 +360,7 @@ impl UserIdentifiedItem { user_option, self.reconstructed_input(), is_wrong_because); - sess.fatal(message.as_slice()) + sess.fatal(message[]) }; let mut saw_node = ast::DUMMY_NODE_ID; @@ -414,12 +414,12 @@ pub fn pretty_print_input(sess: Session, opt_uii: Option<UserIdentifiedItem>, ofile: Option<Path>) { let krate = driver::phase_1_parse_input(&sess, cfg, input); - let id = link::find_crate_name(Some(&sess), krate.attrs.as_slice(), input); + let id = link::find_crate_name(Some(&sess), krate.attrs[], input); let is_expanded = needs_expansion(&ppm); let compute_ast_map = needs_ast_map(&ppm, &opt_uii); let krate = if compute_ast_map { - match driver::phase_2_configure_and_expand(&sess, krate, id.as_slice(), None) { + match driver::phase_2_configure_and_expand(&sess, krate, id[], None) { None => return, Some(k) => k } @@ -438,7 +438,7 @@ pub fn pretty_print_input(sess: Session, }; let src_name = driver::source_name(input); - let src = sess.codemap().get_filemap(src_name.as_slice()) + let src = sess.codemap().get_filemap(src_name[]) .src.as_bytes().to_vec(); let mut rdr = MemReader::new(src); @@ -499,7 +499,7 @@ pub fn pretty_print_input(sess: Session, debug!("pretty printing flow graph for {}", opt_uii); let uii = opt_uii.unwrap_or_else(|| { sess.fatal(format!("`pretty flowgraph=..` needs NodeId (int) or - unique path suffix (b::c::d)").as_slice()) + unique path suffix (b::c::d)")[]) }); let ast_map = ast_map.expect("--pretty flowgraph missing ast_map"); @@ -507,7 +507,7 @@ pub fn pretty_print_input(sess: Session, let node = ast_map.find(nodeid).unwrap_or_else(|| { sess.fatal(format!("--pretty flowgraph couldn't find id: {}", - nodeid).as_slice()) + nodeid)[]) }); let code = blocks::Code::from_node(node); @@ -526,8 +526,8 @@ pub fn pretty_print_input(sess: Session, // point to what was found, if there's an // accessible span. match ast_map.opt_span(nodeid) { - Some(sp) => sess.span_fatal(sp, message.as_slice()), - None => sess.fatal(message.as_slice()) + Some(sp) => sess.span_fatal(sp, message[]), + None => sess.fatal(message[]) } } } @@ -587,7 +587,7 @@ fn print_flowgraph<W:io::Writer>(variants: Vec<borrowck_dot::Variant>, let m = "graphviz::render failed"; io::IoError { detail: Some(match orig_detail { - None => m.into_string(), + None => m.to_string(), Some(d) => format!("{}: {}", m, d) }), ..ioerr |
