1
Fork 0

core: rename strbuf::StrBuf to string::String

[breaking-change]
This commit is contained in:
Richo Healey 2014-05-22 16:57:53 -07:00
parent bbb70cdd9c
commit 553074506e
395 changed files with 1766 additions and 1766 deletions

View file

@ -56,10 +56,10 @@ impl fmt::Show for Mode {
#[deriving(Clone)] #[deriving(Clone)]
pub struct Config { pub struct Config {
// The library paths required for running the compiler // The library paths required for running the compiler
pub compile_lib_path: StrBuf, pub compile_lib_path: String,
// The library paths required for running compiled programs // The library paths required for running compiled programs
pub run_lib_path: StrBuf, pub run_lib_path: String,
// The rustc executable // The rustc executable
pub rustc_path: Path, pub rustc_path: Path,
@ -80,7 +80,7 @@ pub struct Config {
pub aux_base: Path, pub aux_base: Path,
// The name of the stage being built (stage1, etc) // The name of the stage being built (stage1, etc)
pub stage_id: StrBuf, pub stage_id: String,
// The test mode, compile-fail, run-fail, run-pass // The test mode, compile-fail, run-fail, run-pass
pub mode: Mode, pub mode: Mode,
@ -113,37 +113,37 @@ pub struct Config {
// A command line to prefix program execution with, // A command line to prefix program execution with,
// for running under valgrind // for running under valgrind
pub runtool: Option<StrBuf>, pub runtool: Option<String>,
// Flags to pass to the compiler when building for the host // Flags to pass to the compiler when building for the host
pub host_rustcflags: Option<StrBuf>, pub host_rustcflags: Option<String>,
// Flags to pass to the compiler when building for the target // Flags to pass to the compiler when building for the target
pub target_rustcflags: Option<StrBuf>, pub target_rustcflags: Option<String>,
// Run tests using the JIT // Run tests using the JIT
pub jit: bool, pub jit: bool,
// Target system to be tested // Target system to be tested
pub target: StrBuf, pub target: String,
// Host triple for the compiler being invoked // Host triple for the compiler being invoked
pub host: StrBuf, pub host: String,
// Path to the android tools // Path to the android tools
pub android_cross_path: Path, pub android_cross_path: Path,
// Extra parameter to run adb on arm-linux-androideabi // Extra parameter to run adb on arm-linux-androideabi
pub adb_path: StrBuf, pub adb_path: String,
// Extra parameter to run test sute on arm-linux-androideabi // Extra parameter to run test sute on arm-linux-androideabi
pub adb_test_dir: StrBuf, pub adb_test_dir: String,
// status whether android device available or not // status whether android device available or not
pub adb_device_status: bool, pub adb_device_status: bool,
// the path containing LLDB's Python module // the path containing LLDB's Python module
pub lldb_python_dir: Option<StrBuf>, pub lldb_python_dir: Option<String>,
// Explain what's going on // Explain what's going on
pub verbose: bool pub verbose: bool

View file

@ -56,7 +56,7 @@ pub fn main() {
run_tests(&config); run_tests(&config);
} }
pub fn parse_config(args: Vec<StrBuf> ) -> Config { pub fn parse_config(args: Vec<String> ) -> Config {
let groups : Vec<getopts::OptGroup> = let groups : Vec<getopts::OptGroup> =
vec!(reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"), vec!(reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
@ -225,14 +225,14 @@ pub fn log_config(config: &Config) {
logv(c, format_strbuf!("\n")); logv(c, format_strbuf!("\n"));
} }
pub fn opt_str<'a>(maybestr: &'a Option<StrBuf>) -> &'a str { pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {
match *maybestr { match *maybestr {
None => "(none)", None => "(none)",
Some(ref s) => s.as_slice(), Some(ref s) => s.as_slice(),
} }
} }
pub fn opt_str2(maybestr: Option<StrBuf>) -> StrBuf { pub fn opt_str2(maybestr: Option<String>) -> String {
match maybestr { match maybestr {
None => "(none)".to_strbuf(), None => "(none)".to_strbuf(),
Some(s) => s, Some(s) => s,
@ -352,7 +352,7 @@ pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName { pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
// Try to elide redundant long paths // Try to elide redundant long paths
fn shorten(path: &Path) -> StrBuf { fn shorten(path: &Path) -> String {
let filename = path.filename_str(); let filename = path.filename_str();
let p = path.dir_path(); let p = path.dir_path();
let dir = p.filename_str(); let dir = p.filename_str();

View file

@ -13,8 +13,8 @@ use regex::Regex;
pub struct ExpectedError { pub struct ExpectedError {
pub line: uint, pub line: uint,
pub kind: StrBuf, pub kind: String,
pub msg: StrBuf, pub msg: String,
} }
pub static EXPECTED_PATTERN : &'static str = r"//~(?P<adjusts>\^*)\s*(?P<kind>\S*)\s*(?P<msg>.*)"; pub static EXPECTED_PATTERN : &'static str = r"//~(?P<adjusts>\^*)\s*(?P<kind>\S*)\s*(?P<msg>.*)";

View file

@ -14,20 +14,20 @@ use util;
pub struct TestProps { pub struct TestProps {
// Lines that should be expected, in order, on standard out // Lines that should be expected, in order, on standard out
pub error_patterns: Vec<StrBuf> , pub error_patterns: Vec<String> ,
// Extra flags to pass to the compiler // Extra flags to pass to the compiler
pub compile_flags: Option<StrBuf>, pub compile_flags: Option<String>,
// Extra flags to pass when the compiled code is run (such as --bench) // Extra flags to pass when the compiled code is run (such as --bench)
pub run_flags: Option<StrBuf>, pub run_flags: Option<String>,
// If present, the name of a file that this test should match when // If present, the name of a file that this test should match when
// pretty-printed // pretty-printed
pub pp_exact: Option<Path>, pub pp_exact: Option<Path>,
// Modules from aux directory that should be compiled // Modules from aux directory that should be compiled
pub aux_builds: Vec<StrBuf> , pub aux_builds: Vec<String> ,
// Environment settings to use during execution // Environment settings to use during execution
pub exec_env: Vec<(StrBuf,StrBuf)> , pub exec_env: Vec<(String,String)> ,
// Lines to check if they appear in the expected debugger output // Lines to check if they appear in the expected debugger output
pub check_lines: Vec<StrBuf> , pub check_lines: Vec<String> ,
// Flag to force a crate to be built with the host architecture // Flag to force a crate to be built with the host architecture
pub force_host: bool, pub force_host: bool,
// Check stdout for error-pattern output as well as stderr // Check stdout for error-pattern output as well as stderr
@ -119,10 +119,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
} }
pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool { pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
fn ignore_target(config: &Config) -> StrBuf { fn ignore_target(config: &Config) -> String {
format_strbuf!("ignore-{}", util::get_os(config.target.as_slice())) format_strbuf!("ignore-{}", util::get_os(config.target.as_slice()))
} }
fn ignore_stage(config: &Config) -> StrBuf { fn ignore_stage(config: &Config) -> String {
format_strbuf!("ignore-{}", format_strbuf!("ignore-{}",
config.stage_id.as_slice().split('-').next().unwrap()) config.stage_id.as_slice().split('-').next().unwrap())
} }
@ -169,23 +169,23 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
return true; return true;
} }
fn parse_error_pattern(line: &str) -> Option<StrBuf> { fn parse_error_pattern(line: &str) -> Option<String> {
parse_name_value_directive(line, "error-pattern".to_strbuf()) parse_name_value_directive(line, "error-pattern".to_strbuf())
} }
fn parse_aux_build(line: &str) -> Option<StrBuf> { fn parse_aux_build(line: &str) -> Option<String> {
parse_name_value_directive(line, "aux-build".to_strbuf()) parse_name_value_directive(line, "aux-build".to_strbuf())
} }
fn parse_compile_flags(line: &str) -> Option<StrBuf> { fn parse_compile_flags(line: &str) -> Option<String> {
parse_name_value_directive(line, "compile-flags".to_strbuf()) parse_name_value_directive(line, "compile-flags".to_strbuf())
} }
fn parse_run_flags(line: &str) -> Option<StrBuf> { fn parse_run_flags(line: &str) -> Option<String> {
parse_name_value_directive(line, "run-flags".to_strbuf()) parse_name_value_directive(line, "run-flags".to_strbuf())
} }
fn parse_check_line(line: &str) -> Option<StrBuf> { fn parse_check_line(line: &str) -> Option<String> {
parse_name_value_directive(line, "check".to_strbuf()) parse_name_value_directive(line, "check".to_strbuf())
} }
@ -205,10 +205,10 @@ fn parse_no_pretty_expanded(line: &str) -> bool {
parse_name_directive(line, "no-pretty-expanded") parse_name_directive(line, "no-pretty-expanded")
} }
fn parse_exec_env(line: &str) -> Option<(StrBuf, StrBuf)> { fn parse_exec_env(line: &str) -> Option<(String, String)> {
parse_name_value_directive(line, "exec-env".to_strbuf()).map(|nv| { parse_name_value_directive(line, "exec-env".to_strbuf()).map(|nv| {
// nv is either FOO or FOO=BAR // nv is either FOO or FOO=BAR
let mut strs: Vec<StrBuf> = nv.as_slice() let mut strs: Vec<String> = nv.as_slice()
.splitn('=', 1) .splitn('=', 1)
.map(|s| s.to_strbuf()) .map(|s| s.to_strbuf())
.collect(); .collect();
@ -241,8 +241,8 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
line.contains(directive) line.contains(directive)
} }
pub fn parse_name_value_directive(line: &str, directive: StrBuf) pub fn parse_name_value_directive(line: &str, directive: String)
-> Option<StrBuf> { -> Option<String> {
let keycolon = format_strbuf!("{}:", directive); let keycolon = format_strbuf!("{}:", directive);
match line.find_str(keycolon.as_slice()) { match line.find_str(keycolon.as_slice()) {
Some(colon) => { Some(colon) => {

View file

@ -13,7 +13,7 @@ use std::str;
use std::io::process::{ProcessExit, Command, Process, ProcessOutput}; use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
use std::unstable::dynamic_lib::DynamicLibrary; use std::unstable::dynamic_lib::DynamicLibrary;
fn target_env(lib_path: &str, prog: &str) -> Vec<(StrBuf, StrBuf)> { fn target_env(lib_path: &str, prog: &str) -> Vec<(String, String)> {
let prog = if cfg!(windows) {prog.slice_to(prog.len() - 4)} else {prog}; let prog = if cfg!(windows) {prog.slice_to(prog.len() - 4)} else {prog};
let mut aux_path = prog.to_strbuf(); let mut aux_path = prog.to_strbuf();
aux_path.push_str(".libaux"); aux_path.push_str(".libaux");
@ -26,7 +26,7 @@ fn target_env(lib_path: &str, prog: &str) -> Vec<(StrBuf, StrBuf)> {
// Remove the previous dylib search path var // Remove the previous dylib search path var
let var = DynamicLibrary::envvar(); let var = DynamicLibrary::envvar();
let mut env: Vec<(StrBuf,StrBuf)> = let mut env: Vec<(String,String)> =
os::env().move_iter().map(|(a,b)|(a.to_strbuf(), b.to_strbuf())).collect(); os::env().move_iter().map(|(a,b)|(a.to_strbuf(), b.to_strbuf())).collect();
match env.iter().position(|&(ref k, _)| k.as_slice() == var) { match env.iter().position(|&(ref k, _)| k.as_slice() == var) {
Some(i) => { env.remove(i); } Some(i) => { env.remove(i); }
@ -40,13 +40,13 @@ fn target_env(lib_path: &str, prog: &str) -> Vec<(StrBuf, StrBuf)> {
return env; return env;
} }
pub struct Result {pub status: ProcessExit, pub out: StrBuf, pub err: StrBuf} pub struct Result {pub status: ProcessExit, pub out: String, pub err: String}
pub fn run(lib_path: &str, pub fn run(lib_path: &str,
prog: &str, prog: &str,
args: &[StrBuf], args: &[String],
env: Vec<(StrBuf, StrBuf)> , env: Vec<(String, String)> ,
input: Option<StrBuf>) -> Option<Result> { input: Option<String>) -> Option<Result> {
let env = env.clone().append(target_env(lib_path, prog).as_slice()); let env = env.clone().append(target_env(lib_path, prog).as_slice());
match Command::new(prog).args(args).env(env.as_slice()).spawn() { match Command::new(prog).args(args).env(env.as_slice()).spawn() {
@ -69,9 +69,9 @@ pub fn run(lib_path: &str,
pub fn run_background(lib_path: &str, pub fn run_background(lib_path: &str,
prog: &str, prog: &str,
args: &[StrBuf], args: &[String],
env: Vec<(StrBuf, StrBuf)> , env: Vec<(String, String)> ,
input: Option<StrBuf>) -> Option<Process> { input: Option<String>) -> Option<Process> {
let env = env.clone().append(target_env(lib_path, prog).as_slice()); let env = env.clone().append(target_env(lib_path, prog).as_slice());
match Command::new(prog).args(args).env(env.as_slice()).spawn() { match Command::new(prog).args(args).env(env.as_slice()).spawn() {

View file

@ -28,11 +28,11 @@ use std::io::timer;
use std::io; use std::io;
use std::os; use std::os;
use std::str; use std::str;
use std::strbuf::StrBuf; use std::string::String;
use std::task; use std::task;
use test::MetricMap; use test::MetricMap;
pub fn run(config: Config, testfile: StrBuf) { pub fn run(config: Config, testfile: String) {
match config.target.as_slice() { match config.target.as_slice() {
@ -49,7 +49,7 @@ pub fn run(config: Config, testfile: StrBuf) {
run_metrics(config, testfile, &mut _mm); run_metrics(config, testfile, &mut _mm);
} }
pub fn run_metrics(config: Config, testfile: StrBuf, mm: &mut MetricMap) { pub fn run_metrics(config: Config, testfile: String, mm: &mut MetricMap) {
if config.verbose { if config.verbose {
// We're going to be dumping a lot of info. Start on a new line. // We're going to be dumping a lot of info. Start on a new line.
print!("\n\n"); print!("\n\n");
@ -231,7 +231,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
fn print_source(config: &Config, fn print_source(config: &Config,
props: &TestProps, props: &TestProps,
testfile: &Path, testfile: &Path,
src: StrBuf, src: String,
pretty_type: &str) -> ProcRes { pretty_type: &str) -> ProcRes {
compose_and_run(config, compose_and_run(config,
testfile, testfile,
@ -247,7 +247,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
fn make_pp_args(config: &Config, fn make_pp_args(config: &Config,
props: &TestProps, props: &TestProps,
testfile: &Path, testfile: &Path,
pretty_type: StrBuf) -> ProcArgs { pretty_type: String) -> ProcArgs {
let aux_dir = aux_output_dir_name(config, testfile); let aux_dir = aux_output_dir_name(config, testfile);
// FIXME (#9639): This needs to handle non-utf8 paths // FIXME (#9639): This needs to handle non-utf8 paths
let mut args = vec!("-".to_strbuf(), let mut args = vec!("-".to_strbuf(),
@ -284,7 +284,7 @@ actual:\n\
} }
fn typecheck_source(config: &Config, props: &TestProps, fn typecheck_source(config: &Config, props: &TestProps,
testfile: &Path, src: StrBuf) -> ProcRes { testfile: &Path, src: String) -> ProcRes {
let args = make_typecheck_args(config, props, testfile); let args = make_typecheck_args(config, props, testfile);
compose_and_run_compiler(config, props, testfile, args, Some(src)) compose_and_run_compiler(config, props, testfile, args, Some(src))
} }
@ -469,11 +469,11 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
// run debugger script with gdb // run debugger script with gdb
#[cfg(windows)] #[cfg(windows)]
fn debugger() -> StrBuf { fn debugger() -> String {
"gdb.exe".to_strbuf() "gdb.exe".to_strbuf()
} }
#[cfg(unix)] #[cfg(unix)]
fn debugger() -> StrBuf { fn debugger() -> String {
"gdb".to_strbuf() "gdb".to_strbuf()
} }
@ -540,7 +540,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
// Write debugger script: // Write debugger script:
// We don't want to hang when calling `quit` while the process is still running // We don't want to hang when calling `quit` while the process is still running
let mut script_str = StrBuf::from_str("settings set auto-confirm true\n"); let mut script_str = String::from_str("settings set auto-confirm true\n");
// Set breakpoints on every line that contains the string "#break" // Set breakpoints on every line that contains the string "#break"
for line in breakpoint_lines.iter() { for line in breakpoint_lines.iter() {
@ -610,8 +610,8 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
} }
struct DebuggerCommands { struct DebuggerCommands {
commands: Vec<StrBuf>, commands: Vec<String>,
check_lines: Vec<StrBuf>, check_lines: Vec<String>,
breakpoint_lines: Vec<uint>, breakpoint_lines: Vec<uint>,
} }
@ -662,7 +662,7 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
} }
} }
fn cleanup_debug_info_options(options: &Option<StrBuf>) -> Option<StrBuf> { fn cleanup_debug_info_options(options: &Option<String>) -> Option<String> {
if options.is_none() { if options.is_none() {
return None; return None;
} }
@ -676,18 +676,18 @@ fn cleanup_debug_info_options(options: &Option<StrBuf>) -> Option<StrBuf> {
let new_options = let new_options =
split_maybe_args(options).move_iter() split_maybe_args(options).move_iter()
.filter(|x| !options_to_remove.contains(x)) .filter(|x| !options_to_remove.contains(x))
.collect::<Vec<StrBuf>>() .collect::<Vec<String>>()
.connect(" ") .connect(" ")
.to_strbuf(); .to_strbuf();
Some(new_options) Some(new_options)
} }
fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[StrBuf]) { fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String]) {
let num_check_lines = check_lines.len(); let num_check_lines = check_lines.len();
if num_check_lines > 0 { if num_check_lines > 0 {
// Allow check lines to leave parts unspecified (e.g., uninitialized // Allow check lines to leave parts unspecified (e.g., uninitialized
// bits in the wrong case of an enum) with the notation "[...]". // bits in the wrong case of an enum) with the notation "[...]".
let check_fragments: Vec<Vec<StrBuf>> = let check_fragments: Vec<Vec<String>> =
check_lines.iter().map(|s| { check_lines.iter().map(|s| {
s.as_slice() s.as_slice()
.trim() .trim()
@ -812,10 +812,10 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
let prefixes = expected_errors.iter().map(|ee| { let prefixes = expected_errors.iter().map(|ee| {
format_strbuf!("{}:{}:", testfile.display(), ee.line) format_strbuf!("{}:{}:", testfile.display(), ee.line)
}).collect::<Vec<StrBuf> >(); }).collect::<Vec<String> >();
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
fn to_lower( s : &str ) -> StrBuf { fn to_lower( s : &str ) -> String {
let i = s.chars(); let i = s.chars();
let c : Vec<char> = i.map( |c| { let c : Vec<char> = i.map( |c| {
if c.is_ascii() { if c.is_ascii() {
@ -966,15 +966,15 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut uint) -> bool {
} }
struct ProcArgs { struct ProcArgs {
prog: StrBuf, prog: String,
args: Vec<StrBuf>, args: Vec<String>,
} }
struct ProcRes { struct ProcRes {
status: ProcessExit, status: ProcessExit,
stdout: StrBuf, stdout: String,
stderr: StrBuf, stderr: String,
cmdline: StrBuf, cmdline: String,
} }
fn compile_test(config: &Config, props: &TestProps, fn compile_test(config: &Config, props: &TestProps,
@ -987,7 +987,7 @@ fn jit_test(config: &Config, props: &TestProps, testfile: &Path) -> ProcRes {
} }
fn compile_test_(config: &Config, props: &TestProps, fn compile_test_(config: &Config, props: &TestProps,
testfile: &Path, extra_args: &[StrBuf]) -> ProcRes { testfile: &Path, extra_args: &[String]) -> ProcRes {
let aux_dir = aux_output_dir_name(config, testfile); let aux_dir = aux_output_dir_name(config, testfile);
// FIXME (#9639): This needs to handle non-utf8 paths // FIXME (#9639): This needs to handle non-utf8 paths
let link_args = vec!("-L".to_strbuf(), let link_args = vec!("-L".to_strbuf(),
@ -1026,7 +1026,7 @@ fn compose_and_run_compiler(
props: &TestProps, props: &TestProps,
testfile: &Path, testfile: &Path,
args: ProcArgs, args: ProcArgs,
input: Option<StrBuf>) -> ProcRes { input: Option<String>) -> ProcRes {
if !props.aux_builds.is_empty() { if !props.aux_builds.is_empty() {
ensure_dir(&aux_output_dir_name(config, testfile)); ensure_dir(&aux_output_dir_name(config, testfile));
@ -1093,9 +1093,9 @@ fn ensure_dir(path: &Path) {
fn compose_and_run(config: &Config, testfile: &Path, fn compose_and_run(config: &Config, testfile: &Path,
ProcArgs{ args, prog }: ProcArgs, ProcArgs{ args, prog }: ProcArgs,
procenv: Vec<(StrBuf, StrBuf)> , procenv: Vec<(String, String)> ,
lib_path: &str, lib_path: &str,
input: Option<StrBuf>) -> ProcRes { input: Option<String>) -> ProcRes {
return program_output(config, testfile, lib_path, return program_output(config, testfile, lib_path,
prog, args, procenv, input); prog, args, procenv, input);
} }
@ -1107,7 +1107,7 @@ enum TargetLocation {
fn make_compile_args(config: &Config, fn make_compile_args(config: &Config,
props: &TestProps, props: &TestProps,
extras: Vec<StrBuf> , extras: Vec<String> ,
xform: |&Config, &Path| -> TargetLocation, xform: |&Config, &Path| -> TargetLocation,
testfile: &Path) testfile: &Path)
-> ProcArgs { -> ProcArgs {
@ -1188,7 +1188,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
}; };
} }
fn split_maybe_args(argstr: &Option<StrBuf>) -> Vec<StrBuf> { fn split_maybe_args(argstr: &Option<String>) -> Vec<String> {
match *argstr { match *argstr {
Some(ref s) => { Some(ref s) => {
s.as_slice() s.as_slice()
@ -1205,9 +1205,9 @@ fn split_maybe_args(argstr: &Option<StrBuf>) -> Vec<StrBuf> {
} }
} }
fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: StrBuf, fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String,
args: Vec<StrBuf> , env: Vec<(StrBuf, StrBuf)> , args: Vec<String> , env: Vec<(String, String)> ,
input: Option<StrBuf>) -> ProcRes { input: Option<String>) -> ProcRes {
let cmdline = let cmdline =
{ {
let cmdline = make_cmdline(lib_path, let cmdline = make_cmdline(lib_path,
@ -1239,12 +1239,12 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: StrBuf
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
fn make_cmdline(_libpath: &str, prog: &str, args: &[StrBuf]) -> StrBuf { fn make_cmdline(_libpath: &str, prog: &str, args: &[String]) -> String {
format_strbuf!("{} {}", prog, args.connect(" ")) format_strbuf!("{} {}", prog, args.connect(" "))
} }
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
fn make_cmdline(libpath: &str, prog: &str, args: &[StrBuf]) -> StrBuf { fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String {
format_strbuf!("{} {} {}", format_strbuf!("{} {} {}",
lib_path_cmd_prefix(libpath), lib_path_cmd_prefix(libpath),
prog, prog,
@ -1254,7 +1254,7 @@ fn make_cmdline(libpath: &str, prog: &str, args: &[StrBuf]) -> StrBuf {
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line // Build the LD_LIBRARY_PATH variable as it would be seen on the command line
// for diagnostic purposes // for diagnostic purposes
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
fn lib_path_cmd_prefix(path: &str) -> StrBuf { fn lib_path_cmd_prefix(path: &str) -> String {
format_strbuf!("{}=\"{}\"", format_strbuf!("{}=\"{}\"",
util::lib_path_env_var(), util::lib_path_env_var(),
util::make_new_path(path)) util::make_new_path(path))
@ -1305,11 +1305,11 @@ fn maybe_dump_to_stdout(config: &Config, out: &str, err: &str) {
} }
} }
fn error(err: StrBuf) { println!("\nerror: {}", err); } fn error(err: String) { println!("\nerror: {}", err); }
fn fatal(err: StrBuf) -> ! { error(err); fail!(); } fn fatal(err: String) -> ! { error(err); fail!(); }
fn fatal_ProcRes(err: StrBuf, proc_res: &ProcRes) -> ! { fn fatal_ProcRes(err: String, proc_res: &ProcRes) -> ! {
print!("\n\ print!("\n\
error: {}\n\ error: {}\n\
status: {}\n\ status: {}\n\
@ -1331,7 +1331,7 @@ stderr:\n\
fn _arm_exec_compiled_test(config: &Config, fn _arm_exec_compiled_test(config: &Config,
props: &TestProps, props: &TestProps,
testfile: &Path, testfile: &Path,
env: Vec<(StrBuf, StrBuf)>) env: Vec<(String, String)>)
-> ProcRes { -> ProcRes {
let args = make_run_args(config, props, testfile); let args = make_run_args(config, props, testfile);
let cmdline = make_cmdline("", let cmdline = make_cmdline("",
@ -1339,7 +1339,7 @@ fn _arm_exec_compiled_test(config: &Config,
args.args.as_slice()); args.args.as_slice());
// get bare program string // get bare program string
let mut tvec: Vec<StrBuf> = args.prog let mut tvec: Vec<String> = args.prog
.as_slice() .as_slice()
.split('/') .split('/')
.map(|ts| ts.to_strbuf()) .map(|ts| ts.to_strbuf())

View file

@ -33,7 +33,7 @@ pub fn get_os(triple: &str) -> &'static str {
} }
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
pub fn make_new_path(path: &str) -> StrBuf { pub fn make_new_path(path: &str) -> String {
// Windows just uses PATH as the library search path, so we have to // Windows just uses PATH as the library search path, so we have to
// maintain the current value while adding our own // maintain the current value while adding our own
@ -46,12 +46,12 @@ pub fn make_new_path(path: &str) -> StrBuf {
} }
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
pub fn lib_path_env_var() -> StrBuf { "PATH".to_strbuf() } pub fn lib_path_env_var() -> String { "PATH".to_strbuf() }
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
pub fn path_div() -> StrBuf { ";".to_strbuf() } pub fn path_div() -> String { ";".to_strbuf() }
pub fn logv(config: &Config, s: StrBuf) { pub fn logv(config: &Config, s: String) {
debug!("{}", s); debug!("{}", s);
if config.verbose { println!("{}", s); } if config.verbose { println!("{}", s); }
} }

View file

@ -8,7 +8,7 @@ Use [`ToStr`](../std/to_str/trait.ToStr.html).
~~~ ~~~
let x: int = 42; let x: int = 42;
let y: StrBuf = x.to_str().to_strbuf(); let y: String = x.to_str().to_strbuf();
~~~ ~~~
**String to int** **String to int**
@ -27,10 +27,10 @@ Use the `format_strbuf!` syntax extension.
~~~ ~~~
let x: int = 42; let x: int = 42;
let y: StrBuf = format_strbuf!("{:t}", x); // binary let y: String = format_strbuf!("{:t}", x); // binary
let y: StrBuf = format_strbuf!("{:o}", x); // octal let y: String = format_strbuf!("{:o}", x); // octal
let y: StrBuf = format_strbuf!("{:x}", x); // lowercase hexadecimal let y: String = format_strbuf!("{:x}", x); // lowercase hexadecimal
let y: StrBuf = format_strbuf!("{:X}", x); // uppercase hexadecimal let y: String = format_strbuf!("{:X}", x); // uppercase hexadecimal
~~~ ~~~
**String to int, in non-base-10** **String to int, in non-base-10**
@ -58,15 +58,15 @@ let x: Option<&str> = str::from_utf8(bytes);
let y: &str = x.unwrap(); let y: &str = x.unwrap();
~~~ ~~~
To return an Owned String (StrBuf) use the str helper function To return an Owned String use the str helper function
[`from_utf8_owned`](../std/str/fn.from_utf8_owned.html). [`from_utf8_owned`](../std/str/fn.from_utf8_owned.html).
~~~ ~~~
use std::str; use std::str;
let x: Option<StrBuf> = let x: Option<String> =
str::from_utf8([ 104u8, 105u8 ]).map(|x| x.to_strbuf()); str::from_utf8([ 104u8, 105u8 ]).map(|x| x.to_strbuf());
let y: StrBuf = x.unwrap(); let y: String = x.unwrap();
~~~ ~~~
To return a [`MaybeOwned`](../std/str/enum.MaybeOwned.html) use the str helper To return a [`MaybeOwned`](../std/str/enum.MaybeOwned.html) use the str helper
@ -198,7 +198,7 @@ enum Closed {}
Phantom types are useful for enforcing state at compile time. For example: Phantom types are useful for enforcing state at compile time. For example:
~~~ ~~~
struct Door<State>(StrBuf); struct Door<State>(String);
struct Open; struct Open;
struct Closed; struct Closed;

View file

@ -85,7 +85,7 @@ To take as an argument a fragment of Rust code, write `$` followed by a name
`foo`.) `foo`.)
* `expr` (an expression. Examples: `2 + 2`; `if true then { 1 } else { 2 }`; * `expr` (an expression. Examples: `2 + 2`; `if true then { 1 } else { 2 }`;
`f(42)`.) `f(42)`.)
* `ty` (a type. Examples: `int`, `~[(char, StrBuf)]`, `&T`.) * `ty` (a type. Examples: `int`, `~[(char, String)]`, `&T`.)
* `pat` (a pattern, usually appearing in a `match` or on the left-hand side of * `pat` (a pattern, usually appearing in a `match` or on the left-hand side of
a declaration. Examples: `Some(t)`; `(17, 'a')`; `_`.) a declaration. Examples: `Some(t)`; `(17, 'a')`; `_`.)
* `block` (a sequence of actions. Example: `{ log(error, "hi"); return 12; }`) * `block` (a sequence of actions. Example: `{ log(error, "hi"); return 12; }`)

View file

@ -463,7 +463,7 @@ Here is the function that implements the child task:
~~~ ~~~
extern crate sync; extern crate sync;
# fn main() { # fn main() {
fn stringifier(channel: &sync::DuplexStream<StrBuf, uint>) { fn stringifier(channel: &sync::DuplexStream<String, uint>) {
let mut value: uint; let mut value: uint;
loop { loop {
value = channel.recv(); value = channel.recv();
@ -488,7 +488,7 @@ Here is the code for the parent task:
extern crate sync; extern crate sync;
# use std::task::spawn; # use std::task::spawn;
# use sync::DuplexStream; # use sync::DuplexStream;
# fn stringifier(channel: &sync::DuplexStream<StrBuf, uint>) { # fn stringifier(channel: &sync::DuplexStream<String, uint>) {
# let mut value: uint; # let mut value: uint;
# loop { # loop {
# value = channel.recv(); # value = channel.recv();

View file

@ -34,7 +34,7 @@ msgstr ""
#, fuzzy #, fuzzy
#| msgid "" #| msgid ""
#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" #| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
msgid "~~~ let x: int = 42; let y: StrBuf = x.to_str(); ~~~" msgid "~~~ let x: int = 42; let y: String = x.to_str(); ~~~"
msgstr "" msgstr ""
"~~~~\n" "~~~~\n"
"let x: f64 = 4.0;\n" "let x: f64 = 4.0;\n"
@ -96,7 +96,7 @@ msgstr ""
#, fuzzy #, fuzzy
#| msgid "" #| msgid ""
#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" #| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
msgid "let x: int = 42; let y: StrBuf = x.to_str_radix(16); ~~~" msgid "let x: int = 42; let y: String = x.to_str_radix(16); ~~~"
msgstr "" msgstr ""
"~~~~\n" "~~~~\n"
"let x: f64 = 4.0;\n" "let x: f64 = 4.0;\n"

View file

@ -1641,7 +1641,7 @@ msgstr "## 最小限の例"
msgid "" msgid ""
"~~~~\n" "~~~~\n"
"trait Printable {\n" "trait Printable {\n"
" fn to_string(&self) -> StrBuf;\n" " fn to_string(&self) -> String;\n"
"}\n" "}\n"
msgstr "" msgstr ""
"~~~~ {.ignore}\n" "~~~~ {.ignore}\n"
@ -1656,7 +1656,7 @@ msgstr ""
#| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~" #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
msgid "" msgid ""
"impl Printable for int {\n" "impl Printable for int {\n"
" fn to_string(&self) -> StrBuf { self.to_str() }\n" " fn to_string(&self) -> String { self.to_str() }\n"
"}\n" "}\n"
msgstr "" msgstr ""
"~~~~ {.ignore}\n" "~~~~ {.ignore}\n"
@ -1702,7 +1702,7 @@ msgstr "# クロージャ"
msgid "" msgid ""
"~~~~\n" "~~~~\n"
"trait Printable {\n" "trait Printable {\n"
" fn make_string(&self) -> StrBuf;\n" " fn make_string(&self) -> String;\n"
"}\n" "}\n"
msgstr "" msgstr ""
"~~~~ {.ignore}\n" "~~~~ {.ignore}\n"
@ -1716,8 +1716,8 @@ msgstr ""
#, fuzzy, no-wrap #, fuzzy, no-wrap
#| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~" #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
msgid "" msgid ""
"impl Printable for StrBuf {\n" "impl Printable for String {\n"
" fn make_string(&self) -> StrBuf {\n" " fn make_string(&self) -> String {\n"
" (*self).clone()\n" " (*self).clone()\n"
" }\n" " }\n"
"}\n" "}\n"

View file

@ -3755,15 +3755,15 @@ msgstr ""
#| msgid "" #| msgid ""
#| "Traits may be implemented for specific types with [impls]. An impl that " #| "Traits may be implemented for specific types with [impls]. An impl that "
#| "implements a trait includes the name of the trait at the start of the " #| "implements a trait includes the name of the trait at the start of the "
#| "definition, as in the following impls of `Printable` for `int` and `StrBuf`." #| "definition, as in the following impls of `Printable` for `int` and `String`."
msgid "" msgid ""
"Traits may be implemented for specific types with [impls]. An impl for a " "Traits may be implemented for specific types with [impls]. An impl for a "
"particular trait gives an implementation of the methods that trait " "particular trait gives an implementation of the methods that trait "
"provides. For instance, the following impls of `Printable` for `int` and " "provides. For instance, the following impls of `Printable` for `int` and "
"`StrBuf` give implementations of the `print` method." "`String` give implementations of the `print` method."
msgstr "" msgstr ""
"[impl][impls] により特定の型にトレイトを実装することができます。トレイトを実" "[impl][impls] により特定の型にトレイトを実装することができます。トレイトを実"
"装する impl は、以下の `Printable` の `int` と `StrBuf` に対する実装のように、" "装する impl は、以下の `Printable` の `int` と `String` に対する実装のように、"
"定義の先頭にトレイトの名前を含みます。" "定義の先頭にトレイトの名前を含みます。"
#. type: Plain text #. type: Plain text
@ -3776,7 +3776,7 @@ msgstr "[impls]: #メソッド"
#, fuzzy, no-wrap #, fuzzy, no-wrap
#| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~" #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
msgid "" msgid ""
"impl Printable for StrBuf {\n" "impl Printable for String {\n"
" fn print(&self) { println!(\"{}\", *self) }\n" " fn print(&self) { println!(\"{}\", *self) }\n"
"}\n" "}\n"
msgstr "" msgstr ""

View file

@ -473,7 +473,7 @@ Two examples of paths with type arguments:
# struct HashMap<K, V>; # struct HashMap<K, V>;
# fn f() { # fn f() {
# fn id<T>(t: T) -> T { t } # fn id<T>(t: T) -> T { t }
type T = HashMap<int,StrBuf>; // Type arguments used in a type expression type T = HashMap<int,String>; // Type arguments used in a type expression
let x = id::<int>(10); // Type arguments used in a call expression let x = id::<int>(10); // Type arguments used in a call expression
# } # }
~~~~ ~~~~
@ -1260,8 +1260,8 @@ Enumeration constructors can have either named or unnamed fields:
~~~~ ~~~~
enum Animal { enum Animal {
Dog (StrBuf, f64), Dog (String, f64),
Cat { name: StrBuf, weight: f64 } Cat { name: String, weight: f64 }
} }
let mut a: Animal = Dog("Cocoa".to_strbuf(), 37.2); let mut a: Animal = Dog("Cocoa".to_strbuf(), 37.2);
@ -2082,7 +2082,7 @@ These are functions:
* `str_eq` * `str_eq`
: Compare two strings (`&str`) for equality. : Compare two strings (`&str`) for equality.
* `uniq_str_eq` * `uniq_str_eq`
: Compare two owned strings (`StrBuf`) for equality. : Compare two owned strings (`String`) for equality.
* `strdup_uniq` * `strdup_uniq`
: Return a new unique string : Return a new unique string
containing a copy of the contents of a unique string. containing a copy of the contents of a unique string.
@ -3310,7 +3310,7 @@ A value of type `str` is a Unicode string,
represented as a vector of 8-bit unsigned bytes holding a sequence of UTF-8 codepoints. represented as a vector of 8-bit unsigned bytes holding a sequence of UTF-8 codepoints.
Since `str` is of unknown size, it is not a _first class_ type, Since `str` is of unknown size, it is not a _first class_ type,
but can only be instantiated through a pointer type, but can only be instantiated through a pointer type,
such as `&str` or `StrBuf`. such as `&str` or `String`.
### Tuple types ### Tuple types
@ -3574,11 +3574,11 @@ An example of an object type:
~~~~ ~~~~
trait Printable { trait Printable {
fn to_string(&self) -> StrBuf; fn to_string(&self) -> String;
} }
impl Printable for int { impl Printable for int {
fn to_string(&self) -> StrBuf { self.to_str().to_strbuf() } fn to_string(&self) -> String { self.to_str().to_strbuf() }
} }
fn print(a: Box<Printable>) { fn print(a: Box<Printable>) {
@ -3619,17 +3619,17 @@ example, in:
~~~~ ~~~~
trait Printable { trait Printable {
fn make_string(&self) -> StrBuf; fn make_string(&self) -> String;
} }
impl Printable for StrBuf { impl Printable for String {
fn make_string(&self) -> StrBuf { fn make_string(&self) -> String {
(*self).clone() (*self).clone()
} }
} }
~~~~ ~~~~
`self` refers to the value of type `StrBuf` that is the receiver for a `self` refers to the value of type `String` that is the receiver for a
call to the method `make_string`. call to the method `make_string`.
## Type kinds ## Type kinds

View file

@ -27,7 +27,7 @@ comments":
pub struct Widget { pub struct Widget {
/// All widgets have a purpose (this is a doc comment, and will show up /// All widgets have a purpose (this is a doc comment, and will show up
/// the field's documentation). /// the field's documentation).
purpose: StrBuf, purpose: String,
/// Humans are not allowed to understand some widgets /// Humans are not allowed to understand some widgets
understandable: bool understandable: bool
} }

View file

@ -1581,7 +1581,7 @@ allocated memory on the heap. A unique vector owns the elements it contains, so
the elements are mutable if the vector is mutable. the elements are mutable if the vector is mutable.
~~~ ~~~
use std::strbuf::StrBuf; use std::string::String;
// A dynamically sized vector (unique vector) // A dynamically sized vector (unique vector)
let mut numbers = vec![1, 2, 3]; let mut numbers = vec![1, 2, 3];
@ -1593,7 +1593,7 @@ let more_numbers: Vec<int> = numbers.move_iter().map(|i| i+1).collect();
// The original `numbers` value can no longer be used, due to move semantics. // The original `numbers` value can no longer be used, due to move semantics.
let mut string = StrBuf::from_str("fo"); let mut string = String::from_str("fo");
string.push_char('o'); string.push_char('o');
~~~ ~~~
@ -2213,7 +2213,7 @@ don't provide any methods.
Traits may be implemented for specific types with [impls]. An impl for Traits may be implemented for specific types with [impls]. An impl for
a particular trait gives an implementation of the methods that a particular trait gives an implementation of the methods that
trait provides. For instance, the following impls of trait provides. For instance, the following impls of
`Printable` for `int` and `StrBuf` give implementations of the `print` `Printable` for `int` and `String` give implementations of the `print`
method. method.
[impls]: #methods [impls]: #methods
@ -2224,7 +2224,7 @@ impl Printable for int {
fn print(&self) { println!("{:?}", *self) } fn print(&self) { println!("{:?}", *self) }
} }
impl Printable for StrBuf { impl Printable for String {
fn print(&self) { println!("{}", *self) } fn print(&self) { println!("{}", *self) }
} }
@ -2270,7 +2270,7 @@ trait Printable {
impl Printable for int {} impl Printable for int {}
impl Printable for StrBuf { impl Printable for String {
fn print(&self) { println!("{}", *self) } fn print(&self) { println!("{}", *self) }
} }
@ -2291,7 +2291,7 @@ provided in the trait definition. Depending on the trait, default
methods can save a great deal of boilerplate code from having to be methods can save a great deal of boilerplate code from having to be
written in impls. Of course, individual impls can still override the written in impls. Of course, individual impls can still override the
default method for `print`, as is being done above in the impl for default method for `print`, as is being done above in the impl for
`StrBuf`. `String`.
## Type-parameterized traits ## Type-parameterized traits

View file

@ -106,7 +106,7 @@ syn keyword rustTrait CloneableVector ImmutableCloneableVector MutableCloneableV
syn keyword rustTrait ImmutableVector MutableVector syn keyword rustTrait ImmutableVector MutableVector
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector MutableTotalOrdVector syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector MutableTotalOrdVector
syn keyword rustTrait Vector VectorVector OwnedVector MutableVectorAllocating syn keyword rustTrait Vector VectorVector OwnedVector MutableVectorAllocating
syn keyword rustTrait StrBuf syn keyword rustTrait String
syn keyword rustTrait Vec syn keyword rustTrait Vec
"syn keyword rustFunction sync_channel channel "syn keyword rustFunction sync_channel channel

View file

@ -538,7 +538,7 @@ mod tests {
} }
struct Noncopy { struct Noncopy {
string: StrBuf, string: String,
array: Vec<int> , array: Vec<int> ,
} }

View file

@ -16,7 +16,7 @@ use std::iter::RandomAccessIterator;
use std::iter::{Enumerate, Repeat, Map, Zip}; use std::iter::{Enumerate, Repeat, Map, Zip};
use std::ops; use std::ops;
use std::slice; use std::slice;
use std::strbuf::StrBuf; use std::string::String;
use std::uint; use std::uint;
#[deriving(Clone)] #[deriving(Clone)]
@ -532,8 +532,8 @@ impl Bitv {
* The resulting string has the same length as `self`, and each * The resulting string has the same length as `self`, and each
* character is either '0' or '1'. * character is either '0' or '1'.
*/ */
pub fn to_str(&self) -> StrBuf { pub fn to_str(&self) -> String {
let mut rs = StrBuf::new(); let mut rs = String::new();
for i in self.iter() { for i in self.iter() {
if i { if i {
rs.push_char('1'); rs.push_char('1');

View file

@ -270,7 +270,7 @@ mod tests {
#[test] #[test]
fn test_put_update() { fn test_put_update() {
let mut cache: LruCache<StrBuf, Vec<u8>> = LruCache::new(1); let mut cache: LruCache<String, Vec<u8>> = LruCache::new(1);
cache.put("1".to_strbuf(), vec![10, 10]); cache.put("1".to_strbuf(), vec![10, 10]);
cache.put("1".to_strbuf(), vec![10, 19]); cache.put("1".to_strbuf(), vec![10, 19]);
assert_opt_eq(cache.get(&"1".to_strbuf()), vec![10, 19]); assert_opt_eq(cache.get(&"1".to_strbuf()), vec![10, 19]);
@ -279,7 +279,7 @@ mod tests {
#[test] #[test]
fn test_expire_lru() { fn test_expire_lru() {
let mut cache: LruCache<StrBuf, StrBuf> = LruCache::new(2); let mut cache: LruCache<String, String> = LruCache::new(2);
cache.put("foo1".to_strbuf(), "bar1".to_strbuf()); cache.put("foo1".to_strbuf(), "bar1".to_strbuf());
cache.put("foo2".to_strbuf(), "bar2".to_strbuf()); cache.put("foo2".to_strbuf(), "bar2".to_strbuf());
cache.put("foo3".to_strbuf(), "bar3".to_strbuf()); cache.put("foo3".to_strbuf(), "bar3".to_strbuf());

View file

@ -636,7 +636,7 @@ mod test {
use char::Char; use char::Char;
use slice::ImmutableVector; use slice::ImmutableVector;
use option::{Some, None}; use option::{Some, None};
use realstd::strbuf::StrBuf; use realstd::string::String;
use realstd::str::{Str, StrAllocating}; use realstd::str::{Str, StrAllocating};
#[test] #[test]
@ -742,8 +742,8 @@ mod test {
#[test] #[test]
fn test_escape_default() { fn test_escape_default() {
fn string(c: char) -> StrBuf { fn string(c: char) -> String {
let mut result = StrBuf::new(); let mut result = String::new();
escape_default(c, |c| { result.push_char(c); }); escape_default(c, |c| { result.push_char(c); });
return result; return result;
} }
@ -777,8 +777,8 @@ mod test {
#[test] #[test]
fn test_escape_unicode() { fn test_escape_unicode() {
fn string(c: char) -> StrBuf { fn string(c: char) -> String {
let mut result = StrBuf::new(); let mut result = String::new();
escape_unicode(c, |c| { result.push_char(c); }); escape_unicode(c, |c| { result.push_char(c); });
return result; return result;
} }

View file

@ -171,7 +171,7 @@ pub trait Ord: Eq {
/// The equivalence relation. Two values may be equivalent even if they are /// The equivalence relation. Two values may be equivalent even if they are
/// of different types. The most common use case for this relation is /// of different types. The most common use case for this relation is
/// container types; e.g. it is often desirable to be able to use `&str` /// container types; e.g. it is often desirable to be able to use `&str`
/// values to look up entries in a container with `StrBuf` keys. /// values to look up entries in a container with `String` keys.
pub trait Equiv<T> { pub trait Equiv<T> {
/// Implement this function to decide equivalent values. /// Implement this function to decide equivalent values.
fn equiv(&self, other: &T) -> bool; fn equiv(&self, other: &T) -> bool;

View file

@ -594,7 +594,7 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,
} }
#[cfg(test)] #[cfg(test)]
pub fn format(args: &Arguments) -> ::realstd::strbuf::StrBuf { pub fn format(args: &Arguments) -> ::realstd::string::String {
use str; use str;
use realstd::str::StrAllocating; use realstd::str::StrAllocating;
use realstd::io::MemWriter; use realstd::io::MemWriter;
@ -614,7 +614,7 @@ pub fn format(args: &Arguments) -> ::realstd::strbuf::StrBuf {
let mut i = MemWriter::new(); let mut i = MemWriter::new();
let _ = write(&mut i, args); let _ = write(&mut i, args);
let mut result = ::realstd::strbuf::StrBuf::new(); let mut result = ::realstd::string::String::new();
result.push_str(str::from_utf8(i.get_ref()).unwrap()); result.push_str(str::from_utf8(i.get_ref()).unwrap());
result result
} }

View file

@ -188,14 +188,14 @@ impl<T> Option<T> {
/// ///
/// # Example /// # Example
/// ///
/// Convert an `Option<StrBuf>` into an `Option<int>`, preserving the original. /// Convert an `Option<String>` into an `Option<int>`, preserving the original.
/// The `map` method takes the `self` argument by value, consuming the original, /// The `map` method takes the `self` argument by value, consuming the original,
/// so this technique uses `as_ref` to first take an `Option` to a reference /// so this technique uses `as_ref` to first take an `Option` to a reference
/// to the value inside the original. /// to the value inside the original.
/// ///
/// ``` /// ```
/// let num_as_str: Option<StrBuf> = Some("10".to_strbuf()); /// let num_as_str: Option<String> = Some("10".to_strbuf());
/// // First, cast `Option<StrBuf>` to `Option<&StrBuf>` with `as_ref`, /// // First, cast `Option<String>` to `Option<&String>` with `as_ref`,
/// // then consume *that* with `map`, leaving `num_as_str` on the stack. /// // then consume *that* with `map`, leaving `num_as_str` on the stack.
/// let num_as_int: Option<uint> = num_as_str.as_ref().map(|n| n.len()); /// let num_as_int: Option<uint> = num_as_str.as_ref().map(|n| n.len());
/// println!("still can print num_as_str: {}", num_as_str); /// println!("still can print num_as_str: {}", num_as_str);
@ -278,10 +278,10 @@ impl<T> Option<T> {
/// ///
/// # Example /// # Example
/// ///
/// Convert an `Option<StrBuf>` into an `Option<uint>`, consuming the original: /// Convert an `Option<String>` into an `Option<uint>`, consuming the original:
/// ///
/// ``` /// ```
/// let num_as_str: Option<StrBuf> = Some("10".to_strbuf()); /// let num_as_str: Option<String> = Some("10".to_strbuf());
/// // `Option::map` takes self *by value*, consuming `num_as_str` /// // `Option::map` takes self *by value*, consuming `num_as_str`
/// let num_as_int: Option<uint> = num_as_str.map(|n| n.len()); /// let num_as_int: Option<uint> = num_as_str.map(|n| n.len());
/// ``` /// ```
@ -596,7 +596,7 @@ pub fn collect<T, Iter: Iterator<Option<T>>, V: FromIterator<T>>(iter: Iter) ->
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use realstd::vec::Vec; use realstd::vec::Vec;
use realstd::strbuf::StrBuf; use realstd::string::String;
use option::collect; use option::collect;
use prelude::*; use prelude::*;
use realstd::str::{Str, StrAllocating}; use realstd::str::{Str, StrAllocating};
@ -760,7 +760,7 @@ mod tests {
#[test] #[test]
#[should_fail] #[should_fail]
fn test_unwrap_fail2() { fn test_unwrap_fail2() {
let x: Option<StrBuf> = None; let x: Option<String> = None;
x.unwrap(); x.unwrap();
} }

View file

@ -170,7 +170,7 @@
//! use std::io::{File, Open, Write, IoError}; //! use std::io::{File, Open, Write, IoError};
//! //!
//! struct Info { //! struct Info {
//! name: StrBuf, //! name: String,
//! age: int, //! age: int,
//! rating: int //! rating: int
//! } //! }
@ -196,7 +196,7 @@
//! use std::io::{File, Open, Write, IoError}; //! use std::io::{File, Open, Write, IoError};
//! //!
//! struct Info { //! struct Info {
//! name: StrBuf, //! name: String,
//! age: int, //! age: int,
//! rating: int //! rating: int
//! } //! }
@ -429,7 +429,7 @@ impl<T, E> Result<T, E> {
/// let mut sum = 0; /// let mut sum = 0;
/// ///
/// while !reader.eof() { /// while !reader.eof() {
/// let line: IoResult<StrBuf> = reader.read_line(); /// let line: IoResult<String> = reader.read_line();
/// // Convert the string line to a number using `map` and `from_str` /// // Convert the string line to a number using `map` and `from_str`
/// let val: IoResult<int> = line.map(|line| { /// let val: IoResult<int> = line.map(|line| {
/// from_str::<int>(line.as_slice()).unwrap_or(0) /// from_str::<int>(line.as_slice()).unwrap_or(0)
@ -637,7 +637,7 @@ pub fn fold_<T,E,Iter:Iterator<Result<T,E>>>(iterator: Iter) -> Result<(),E> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use realstd::vec::Vec; use realstd::vec::Vec;
use realstd::strbuf::StrBuf; use realstd::string::String;
use result::{collect, fold, fold_}; use result::{collect, fold, fold_};
use prelude::*; use prelude::*;

View file

@ -203,7 +203,7 @@ pub struct Parser<'a> {
cur: str::CharOffsets<'a>, cur: str::CharOffsets<'a>,
depth: uint, depth: uint,
/// Error messages accumulated during parsing /// Error messages accumulated during parsing
pub errors: Vec<StrBuf>, pub errors: Vec<String>,
} }
impl<'a> Iterator<Piece<'a>> for Parser<'a> { impl<'a> Iterator<Piece<'a>> for Parser<'a> {
@ -246,7 +246,7 @@ impl<'a> Parser<'a> {
} }
/// Notifies of an error. The message doesn't actually need to be of type /// Notifies of an error. The message doesn't actually need to be of type
/// StrBuf, but I think it does when this eventually uses conditions so it /// String, but I think it does when this eventually uses conditions so it
/// might as well start using it now. /// might as well start using it now.
fn err(&mut self, msg: &str) { fn err(&mut self, msg: &str) {
self.errors.push(msg.to_strbuf()); self.errors.push(msg.to_strbuf());

View file

@ -34,7 +34,7 @@
//! use getopts::{optopt,optflag,getopts,OptGroup}; //! use getopts::{optopt,optflag,getopts,OptGroup};
//! use std::os; //! use std::os;
//! //!
//! fn do_work(inp: &str, out: Option<StrBuf>) { //! fn do_work(inp: &str, out: Option<String>) {
//! println!("{}", inp); //! println!("{}", inp);
//! match out { //! match out {
//! Some(x) => println!("{}", x), //! Some(x) => println!("{}", x),
@ -49,7 +49,7 @@
//! } //! }
//! //!
//! fn main() { //! fn main() {
//! let args: Vec<StrBuf> = os::args().iter() //! let args: Vec<String> = os::args().iter()
//! .map(|x| x.to_strbuf()) //! .map(|x| x.to_strbuf())
//! .collect(); //! .collect();
//! //!
@ -94,14 +94,14 @@
use std::cmp::Eq; use std::cmp::Eq;
use std::result::{Err, Ok}; use std::result::{Err, Ok};
use std::result; use std::result;
use std::strbuf::StrBuf; use std::string::String;
/// Name of an option. Either a string or a single char. /// Name of an option. Either a string or a single char.
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
pub enum Name { pub enum Name {
/// A string representing the long name of an option. /// A string representing the long name of an option.
/// For example: "help" /// For example: "help"
Long(StrBuf), Long(String),
/// A char representing the short name of an option. /// A char representing the short name of an option.
/// For example: 'h' /// For example: 'h'
Short(char), Short(char),
@ -147,13 +147,13 @@ pub struct Opt {
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
pub struct OptGroup { pub struct OptGroup {
/// Short Name of the `OptGroup` /// Short Name of the `OptGroup`
pub short_name: StrBuf, pub short_name: String,
/// Long Name of the `OptGroup` /// Long Name of the `OptGroup`
pub long_name: StrBuf, pub long_name: String,
/// Hint /// Hint
pub hint: StrBuf, pub hint: String,
/// Description /// Description
pub desc: StrBuf, pub desc: String,
/// Whether it has an argument /// Whether it has an argument
pub hasarg: HasArg, pub hasarg: HasArg,
/// How often it can occur /// How often it can occur
@ -163,7 +163,7 @@ pub struct OptGroup {
/// Describes wether an option is given at all or has a value. /// Describes wether an option is given at all or has a value.
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
enum Optval { enum Optval {
Val(StrBuf), Val(String),
Given, Given,
} }
@ -176,7 +176,7 @@ pub struct Matches {
/// Values of the Options that matched /// Values of the Options that matched
vals: Vec<Vec<Optval> > , vals: Vec<Vec<Optval> > ,
/// Free string fragments /// Free string fragments
pub free: Vec<StrBuf>, pub free: Vec<String>,
} }
/// The type returned when the command line does not conform to the /// The type returned when the command line does not conform to the
@ -185,15 +185,15 @@ pub struct Matches {
#[deriving(Clone, Eq, Show)] #[deriving(Clone, Eq, Show)]
pub enum Fail_ { pub enum Fail_ {
/// The option requires an argument but none was passed. /// The option requires an argument but none was passed.
ArgumentMissing(StrBuf), ArgumentMissing(String),
/// The passed option is not declared among the possible options. /// The passed option is not declared among the possible options.
UnrecognizedOption(StrBuf), UnrecognizedOption(String),
/// A required option is not present. /// A required option is not present.
OptionMissing(StrBuf), OptionMissing(String),
/// A single occurrence option is being used multiple times. /// A single occurrence option is being used multiple times.
OptionDuplicated(StrBuf), OptionDuplicated(String),
/// There's an argument being passed to a non-argument option. /// There's an argument being passed to a non-argument option.
UnexpectedArgument(StrBuf), UnexpectedArgument(String),
} }
/// The type of failure that occurred. /// The type of failure that occurred.
@ -219,7 +219,7 @@ impl Name {
} }
} }
fn to_str(&self) -> StrBuf { fn to_str(&self) -> String {
match *self { match *self {
Short(ch) => ch.to_str().to_strbuf(), Short(ch) => ch.to_str().to_strbuf(),
Long(ref s) => s.to_strbuf() Long(ref s) => s.to_strbuf()
@ -299,7 +299,7 @@ impl Matches {
} }
/// Returns true if any of several options were matched. /// Returns true if any of several options were matched.
pub fn opts_present(&self, names: &[StrBuf]) -> bool { pub fn opts_present(&self, names: &[String]) -> bool {
for nm in names.iter() { for nm in names.iter() {
match find_opt(self.opts.as_slice(), match find_opt(self.opts.as_slice(),
Name::from_str(nm.as_slice())) { Name::from_str(nm.as_slice())) {
@ -311,7 +311,7 @@ impl Matches {
} }
/// Returns the string argument supplied to one of several matching options or `None`. /// Returns the string argument supplied to one of several matching options or `None`.
pub fn opts_str(&self, names: &[StrBuf]) -> Option<StrBuf> { pub fn opts_str(&self, names: &[String]) -> Option<String> {
for nm in names.iter() { for nm in names.iter() {
match self.opt_val(nm.as_slice()) { match self.opt_val(nm.as_slice()) {
Some(Val(ref s)) => return Some(s.clone()), Some(Val(ref s)) => return Some(s.clone()),
@ -325,8 +325,8 @@ impl Matches {
/// option. /// option.
/// ///
/// Used when an option accepts multiple values. /// Used when an option accepts multiple values.
pub fn opt_strs(&self, nm: &str) -> Vec<StrBuf> { pub fn opt_strs(&self, nm: &str) -> Vec<String> {
let mut acc: Vec<StrBuf> = Vec::new(); let mut acc: Vec<String> = Vec::new();
let r = self.opt_vals(nm); let r = self.opt_vals(nm);
for v in r.iter() { for v in r.iter() {
match *v { match *v {
@ -338,10 +338,10 @@ impl Matches {
} }
/// Returns the string argument supplied to a matching option or `None`. /// Returns the string argument supplied to a matching option or `None`.
pub fn opt_str(&self, nm: &str) -> Option<StrBuf> { pub fn opt_str(&self, nm: &str) -> Option<String> {
let vals = self.opt_vals(nm); let vals = self.opt_vals(nm);
if vals.is_empty() { if vals.is_empty() {
return None::<StrBuf>; return None::<String>;
} }
match vals.get(0) { match vals.get(0) {
&Val(ref s) => Some((*s).clone()), &Val(ref s) => Some((*s).clone()),
@ -355,7 +355,7 @@ impl Matches {
/// Returns none if the option was not present, `def` if the option was /// Returns none if the option was not present, `def` if the option was
/// present but no argument was provided, and the argument if the option was /// present but no argument was provided, and the argument if the option was
/// present and an argument was provided. /// present and an argument was provided.
pub fn opt_default(&self, nm: &str, def: &str) -> Option<StrBuf> { pub fn opt_default(&self, nm: &str, def: &str) -> Option<String> {
let vals = self.opt_vals(nm); let vals = self.opt_vals(nm);
if vals.is_empty() { if vals.is_empty() {
return None; return None;
@ -496,7 +496,7 @@ pub fn opt(short_name: &str,
impl Fail_ { impl Fail_ {
/// Convert a `Fail_` enum into an error string. /// Convert a `Fail_` enum into an error string.
pub fn to_err_msg(self) -> StrBuf { pub fn to_err_msg(self) -> String {
match self { match self {
ArgumentMissing(ref nm) => { ArgumentMissing(ref nm) => {
format_strbuf!("Argument to option '{}' missing.", *nm) format_strbuf!("Argument to option '{}' missing.", *nm)
@ -522,14 +522,14 @@ impl Fail_ {
/// On success returns `Ok(Opt)`. Use methods such as `opt_present` /// On success returns `Ok(Opt)`. Use methods such as `opt_present`
/// `opt_str`, etc. to interrogate results. Returns `Err(Fail_)` on failure. /// `opt_str`, etc. to interrogate results. Returns `Err(Fail_)` on failure.
/// Use `to_err_msg` to get an error message. /// Use `to_err_msg` to get an error message.
pub fn getopts(args: &[StrBuf], optgrps: &[OptGroup]) -> Result { pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
let opts: Vec<Opt> = optgrps.iter().map(|x| x.long_to_short()).collect(); let opts: Vec<Opt> = optgrps.iter().map(|x| x.long_to_short()).collect();
let n_opts = opts.len(); let n_opts = opts.len();
fn f(_x: uint) -> Vec<Optval> { return Vec::new(); } fn f(_x: uint) -> Vec<Optval> { return Vec::new(); }
let mut vals = Vec::from_fn(n_opts, f); let mut vals = Vec::from_fn(n_opts, f);
let mut free: Vec<StrBuf> = Vec::new(); let mut free: Vec<String> = Vec::new();
let l = args.len(); let l = args.len();
let mut i = 0; let mut i = 0;
while i < l { while i < l {
@ -659,7 +659,7 @@ pub fn getopts(args: &[StrBuf], optgrps: &[OptGroup]) -> Result {
} }
/// Derive a usage message from a set of long options. /// Derive a usage message from a set of long options.
pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf { pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
let desc_sep = format!("\n{}", " ".repeat(24)); let desc_sep = format!("\n{}", " ".repeat(24));
@ -671,7 +671,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
hasarg: hasarg, hasarg: hasarg,
..} = (*optref).clone(); ..} = (*optref).clone();
let mut row = StrBuf::from_owned_str(" ".repeat(4)); let mut row = String::from_owned_str(" ".repeat(4));
// short option // short option
match short_name.len() { match short_name.len() {
@ -717,7 +717,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
} }
// Normalize desc to contain words separated by one space character // Normalize desc to contain words separated by one space character
let mut desc_normalized_whitespace = StrBuf::new(); let mut desc_normalized_whitespace = String::new();
for word in desc.as_slice().words() { for word in desc.as_slice().words() {
desc_normalized_whitespace.push_str(word); desc_normalized_whitespace.push_str(word);
desc_normalized_whitespace.push_char(' '); desc_normalized_whitespace.push_char(' ');
@ -741,11 +741,11 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
format_strbuf!("{}\n\nOptions:\n{}\n", format_strbuf!("{}\n\nOptions:\n{}\n",
brief, brief,
rows.collect::<Vec<StrBuf>>().connect("\n")) rows.collect::<Vec<String>>().connect("\n"))
} }
fn format_option(opt: &OptGroup) -> StrBuf { fn format_option(opt: &OptGroup) -> String {
let mut line = StrBuf::new(); let mut line = String::new();
if opt.occur != Req { if opt.occur != Req {
line.push_char('['); line.push_char('[');
@ -782,11 +782,11 @@ fn format_option(opt: &OptGroup) -> StrBuf {
} }
/// Derive a short one-line usage summary from a set of long options. /// Derive a short one-line usage summary from a set of long options.
pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> StrBuf { pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String {
let mut line = format_strbuf!("Usage: {} ", program_name); let mut line = format_strbuf!("Usage: {} ", program_name);
line.push_str(opts.iter() line.push_str(opts.iter()
.map(format_option) .map(format_option)
.collect::<Vec<StrBuf>>() .collect::<Vec<String>>()
.connect(" ") .connect(" ")
.as_slice()); .as_slice());
line line
@ -898,7 +898,7 @@ fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
#[test] #[test]
fn test_split_within() { fn test_split_within() {
fn t(s: &str, i: uint, u: &[StrBuf]) { fn t(s: &str, i: uint, u: &[String]) {
let mut v = Vec::new(); let mut v = Vec::new();
each_split_within(s, i, |s| { v.push(s.to_strbuf()); true }); each_split_within(s, i, |s| { v.push(s.to_strbuf()); true });
assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b)); assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b));

View file

@ -37,7 +37,7 @@ use std::cell::Cell;
use std::{cmp, os, path}; use std::{cmp, os, path};
use std::io::fs; use std::io::fs;
use std::path::is_sep; use std::path::is_sep;
use std::strbuf::StrBuf; use std::string::String;
/** /**
* An iterator that yields Paths from the filesystem that match a particular * An iterator that yields Paths from the filesystem that match a particular
@ -310,8 +310,8 @@ impl Pattern {
* brackets. The resulting string will, when compiled into a `Pattern`, * brackets. The resulting string will, when compiled into a `Pattern`,
* match the input string and nothing else. * match the input string and nothing else.
*/ */
pub fn escape(s: &str) -> StrBuf { pub fn escape(s: &str) -> String {
let mut escaped = StrBuf::new(); let mut escaped = String::new();
for c in s.chars() { for c in s.chars() {
match c { match c {
// note that ! does not need escaping because it is only special inside brackets // note that ! does not need escaping because it is only special inside brackets
@ -464,8 +464,8 @@ impl Pattern {
fn fill_todo(todo: &mut Vec<(Path, uint)>, patterns: &[Pattern], idx: uint, path: &Path, fn fill_todo(todo: &mut Vec<(Path, uint)>, patterns: &[Pattern], idx: uint, path: &Path,
options: MatchOptions) { options: MatchOptions) {
// convert a pattern that's just many Char(_) to a string // convert a pattern that's just many Char(_) to a string
fn pattern_as_str(pattern: &Pattern) -> Option<StrBuf> { fn pattern_as_str(pattern: &Pattern) -> Option<String> {
let mut s = StrBuf::new(); let mut s = String::new();
for token in pattern.tokens.iter() { for token in pattern.tokens.iter() {
match *token { match *token {
Char(c) => s.push_char(c), Char(c) => s.push_char(c),

View file

@ -424,8 +424,8 @@ impl<'a> LabelText<'a> {
_ => c.escape_default(f) _ => c.escape_default(f)
} }
} }
fn escape_str(s: &str) -> StrBuf { fn escape_str(s: &str) -> String {
let mut out = StrBuf::with_capacity(s.len()); let mut out = String::with_capacity(s.len());
for c in s.chars() { for c in s.chars() {
LabelText::escape_char(c, |c| out.push_char(c)); LabelText::escape_char(c, |c| out.push_char(c));
} }
@ -433,7 +433,7 @@ impl<'a> LabelText<'a> {
} }
/// Renders text as string suitable for a label in a .dot file. /// Renders text as string suitable for a label in a .dot file.
pub fn escape(&self) -> StrBuf { pub fn escape(&self) -> String {
match self { match self {
&LabelStr(ref s) => s.as_slice().escape_default().to_strbuf(), &LabelStr(ref s) => s.as_slice().escape_default().to_strbuf(),
&EscStr(ref s) => LabelText::escape_str(s.as_slice()).to_strbuf(), &EscStr(ref s) => LabelText::escape_str(s.as_slice()).to_strbuf(),
@ -661,7 +661,7 @@ mod tests {
} }
} }
fn test_input(g: LabelledGraph) -> IoResult<StrBuf> { fn test_input(g: LabelledGraph) -> IoResult<String> {
let mut writer = MemWriter::new(); let mut writer = MemWriter::new();
render(&g, &mut writer).unwrap(); render(&g, &mut writer).unwrap();
let mut r = BufReader::new(writer.get_ref()); let mut r = BufReader::new(writer.get_ref());

View file

@ -70,7 +70,7 @@ pub fn macro_registrar(register: |Name, SyntaxExtension|) {
//Check if the literal is valid (as LLVM expects), //Check if the literal is valid (as LLVM expects),
//and return a descriptive error if not. //and return a descriptive error if not.
fn hex_float_lit_err(s: &str) -> Option<(uint, StrBuf)> { fn hex_float_lit_err(s: &str) -> Option<(uint, String)> {
let mut chars = s.chars().peekable(); let mut chars = s.chars().peekable();
let mut i = 0; let mut i = 0;
if chars.peek() == Some(&'-') { chars.next(); i+= 1 } if chars.peek() == Some(&'-') { chars.next(); i+= 1 }

View file

@ -13,7 +13,7 @@ use std::cmp;
#[deriving(Show, Clone)] #[deriving(Show, Clone)]
pub struct LogDirective { pub struct LogDirective {
pub name: Option<StrBuf>, pub name: Option<String>,
pub level: u32, pub level: u32,
} }

View file

@ -23,7 +23,7 @@ use super::IoResult;
use super::file; use super::file;
use super::util; use super::util;
#[cfg(windows)] use std::strbuf::StrBuf; #[cfg(windows)] use std::string::String;
#[cfg(unix)] use super::c; #[cfg(unix)] use super::c;
#[cfg(unix)] use super::retry; #[cfg(unix)] use super::retry;
#[cfg(unix)] use io::helper_thread::Helper; #[cfg(unix)] use io::helper_thread::Helper;
@ -396,8 +396,8 @@ fn zeroed_process_information() -> libc::types::os::arch::extra::PROCESS_INFORMA
} }
#[cfg(windows)] #[cfg(windows)]
fn make_command_line(prog: &CString, args: &[CString]) -> StrBuf { fn make_command_line(prog: &CString, args: &[CString]) -> String {
let mut cmd = StrBuf::new(); let mut cmd = String::new();
append_arg(&mut cmd, prog.as_str() append_arg(&mut cmd, prog.as_str()
.expect("expected program name to be utf-8 encoded")); .expect("expected program name to be utf-8 encoded"));
for arg in args.iter() { for arg in args.iter() {
@ -407,7 +407,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> StrBuf {
} }
return cmd; return cmd;
fn append_arg(cmd: &mut StrBuf, arg: &str) { fn append_arg(cmd: &mut String, arg: &str) {
let quote = arg.chars().any(|c| c == ' ' || c == '\t'); let quote = arg.chars().any(|c| c == ' ' || c == '\t');
if quote { if quote {
cmd.push_char('"'); cmd.push_char('"');
@ -421,7 +421,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> StrBuf {
} }
} }
fn append_char_at(cmd: &mut StrBuf, arg: &Vec<char>, i: uint) { fn append_char_at(cmd: &mut String, arg: &Vec<char>, i: uint) {
match *arg.get(i) { match *arg.get(i) {
'"' => { '"' => {
// Escape quotes. // Escape quotes.
@ -1093,7 +1093,7 @@ mod tests {
use std::c_str::CString; use std::c_str::CString;
use super::make_command_line; use super::make_command_line;
fn test_wrapper(prog: &str, args: &[&str]) -> StrBuf { fn test_wrapper(prog: &str, args: &[&str]) -> String {
make_command_line(&prog.to_c_str(), make_command_line(&prog.to_c_str(),
args.iter() args.iter()
.map(|a| a.to_c_str()) .map(|a| a.to_c_str())

View file

@ -26,7 +26,7 @@ use std::num::CheckedDiv;
use std::num::{Bitwise, ToPrimitive, FromPrimitive}; use std::num::{Bitwise, ToPrimitive, FromPrimitive};
use std::num::{Zero, One, ToStrRadix, FromStrRadix}; use std::num::{Zero, One, ToStrRadix, FromStrRadix};
use rand::Rng; use rand::Rng;
use std::strbuf::StrBuf; use std::string::String;
use std::uint; use std::uint;
use std::{i64, u64}; use std::{i64, u64};
@ -604,7 +604,7 @@ impl_to_biguint!(u32, FromPrimitive::from_u32)
impl_to_biguint!(u64, FromPrimitive::from_u64) impl_to_biguint!(u64, FromPrimitive::from_u64)
impl ToStrRadix for BigUint { impl ToStrRadix for BigUint {
fn to_str_radix(&self, radix: uint) -> StrBuf { fn to_str_radix(&self, radix: uint) -> String {
assert!(1 < radix && radix <= 16); assert!(1 < radix && radix <= 16);
let (base, max_len) = get_radix_base(radix); let (base, max_len) = get_radix_base(radix);
if base == BigDigit::base { if base == BigDigit::base {
@ -627,11 +627,11 @@ impl ToStrRadix for BigUint {
return result; return result;
} }
fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> StrBuf { fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> String {
if v.is_empty() { if v.is_empty() {
return "0".to_strbuf() return "0".to_strbuf()
} }
let mut s = StrBuf::with_capacity(v.len() * l); let mut s = String::with_capacity(v.len() * l);
for n in v.iter().rev() { for n in v.iter().rev() {
let ss = (*n as uint).to_str_radix(radix); let ss = (*n as uint).to_str_radix(radix);
s.push_str("0".repeat(l - ss.len()).as_slice()); s.push_str("0".repeat(l - ss.len()).as_slice());
@ -1211,7 +1211,7 @@ impl_to_bigint!(u64, FromPrimitive::from_u64)
impl ToStrRadix for BigInt { impl ToStrRadix for BigInt {
#[inline] #[inline]
fn to_str_radix(&self, radix: uint) -> StrBuf { fn to_str_radix(&self, radix: uint) -> String {
match self.sign { match self.sign {
Plus => self.data.to_str_radix(radix), Plus => self.data.to_str_radix(radix),
Zero => "0".to_strbuf(), Zero => "0".to_strbuf(),
@ -2029,7 +2029,7 @@ mod biguint_tests {
assert!(((one << 64) + one).is_odd()); assert!(((one << 64) + one).is_odd());
} }
fn to_str_pairs() -> Vec<(BigUint, Vec<(uint, StrBuf)>)> { fn to_str_pairs() -> Vec<(BigUint, Vec<(uint, String)>)> {
let bits = BigDigit::bits; let bits = BigDigit::bits;
vec!(( Zero::zero(), vec!( vec!(( Zero::zero(), vec!(
(2, "0".to_strbuf()), (3, "0".to_strbuf()) (2, "0".to_strbuf()), (3, "0".to_strbuf())

View file

@ -175,7 +175,7 @@ impl<T: fmt::Show + Num + Ord> fmt::Show for Complex<T> {
} }
impl<T: ToStrRadix + Num + Ord> ToStrRadix for Complex<T> { impl<T: ToStrRadix + Num + Ord> ToStrRadix for Complex<T> {
fn to_str_radix(&self, radix: uint) -> StrBuf { fn to_str_radix(&self, radix: uint) -> String {
if self.im < Zero::zero() { if self.im < Zero::zero() {
format_strbuf!("{}-{}i", format_strbuf!("{}-{}i",
self.re.to_str_radix(radix), self.re.to_str_radix(radix),
@ -348,7 +348,7 @@ mod test {
#[test] #[test]
fn test_to_str() { fn test_to_str() {
fn test(c : Complex64, s: StrBuf) { fn test(c : Complex64, s: String) {
assert_eq!(c.to_str().to_strbuf(), s); assert_eq!(c.to_str().to_strbuf(), s);
} }
test(_0_0i, "0+0i".to_strbuf()); test(_0_0i, "0+0i".to_strbuf());

View file

@ -281,7 +281,7 @@ impl<T: fmt::Show> fmt::Show for Ratio<T> {
} }
impl<T: ToStrRadix> ToStrRadix for Ratio<T> { impl<T: ToStrRadix> ToStrRadix for Ratio<T> {
/// Renders as `numer/denom` where the numbers are in base `radix`. /// Renders as `numer/denom` where the numbers are in base `radix`.
fn to_str_radix(&self, radix: uint) -> StrBuf { fn to_str_radix(&self, radix: uint) -> String {
format_strbuf!("{}/{}", format_strbuf!("{}/{}",
self.numer.to_str_radix(radix), self.numer.to_str_radix(radix),
self.denom.to_str_radix(radix)) self.denom.to_str_radix(radix))
@ -557,7 +557,7 @@ mod test {
#[test] #[test]
fn test_to_from_str() { fn test_to_from_str() {
fn test(r: Rational, s: StrBuf) { fn test(r: Rational, s: String) {
assert_eq!(FromStr::from_str(s.as_slice()), Some(r)); assert_eq!(FromStr::from_str(s.as_slice()), Some(r));
assert_eq!(r.to_str().to_strbuf(), s); assert_eq!(r.to_str().to_strbuf(), s);
} }
@ -583,13 +583,13 @@ mod test {
#[test] #[test]
fn test_to_from_str_radix() { fn test_to_from_str_radix() {
fn test(r: Rational, s: StrBuf, n: uint) { fn test(r: Rational, s: String, n: uint) {
assert_eq!(FromStrRadix::from_str_radix(s.as_slice(), n), assert_eq!(FromStrRadix::from_str_radix(s.as_slice(), n),
Some(r)); Some(r));
assert_eq!(r.to_str_radix(n).to_strbuf(), s); assert_eq!(r.to_str_radix(n).to_strbuf(), s);
} }
fn test3(r: Rational, s: StrBuf) { test(r, s, 3) } fn test3(r: Rational, s: String) { test(r, s, 3) }
fn test16(r: Rational, s: StrBuf) { test(r, s, 16) } fn test16(r: Rational, s: String) { test(r, s, 16) }
test3(_1, "1/1".to_strbuf()); test3(_1, "1/1".to_strbuf());
test3(_0, "0/1".to_strbuf()); test3(_0, "0/1".to_strbuf());

View file

@ -86,7 +86,7 @@ println!("{:?}", tuple_ptr)
use std::io::IoResult; use std::io::IoResult;
use std::kinds::marker; use std::kinds::marker;
use std::mem; use std::mem;
use std::strbuf::StrBuf; use std::string::String;
pub use isaac::{IsaacRng, Isaac64Rng}; pub use isaac::{IsaacRng, Isaac64Rng};
pub use os::OSRng; pub use os::OSRng;
@ -260,11 +260,11 @@ pub trait Rng {
/// ///
/// println!("{}", task_rng().gen_ascii_str(10)); /// println!("{}", task_rng().gen_ascii_str(10));
/// ``` /// ```
fn gen_ascii_str(&mut self, len: uint) -> StrBuf { fn gen_ascii_str(&mut self, len: uint) -> String {
static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\ static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz\ abcdefghijklmnopqrstuvwxyz\
0123456789"); 0123456789");
let mut s = StrBuf::with_capacity(len); let mut s = String::with_capacity(len);
for _ in range(0, len) { for _ in range(0, len) {
s.push_char(*self.choose(GEN_ASCII_STR_CHARSET).unwrap() as char) s.push_char(*self.choose(GEN_ASCII_STR_CHARSET).unwrap() as char)
} }

View file

@ -83,12 +83,12 @@ pub struct Program {
/// If the regular expression requires a literal prefix in order to have a /// If the regular expression requires a literal prefix in order to have a
/// match, that prefix is stored here. (It's used in the VM to implement /// match, that prefix is stored here. (It's used in the VM to implement
/// an optimization.) /// an optimization.)
pub prefix: StrBuf, pub prefix: String,
} }
impl Program { impl Program {
/// Compiles a Regex given its AST. /// Compiles a Regex given its AST.
pub fn new(ast: parse::Ast) -> (Program, Vec<Option<StrBuf>>) { pub fn new(ast: parse::Ast) -> (Program, Vec<Option<String>>) {
let mut c = Compiler { let mut c = Compiler {
insts: Vec::with_capacity(100), insts: Vec::with_capacity(100),
names: Vec::with_capacity(10), names: Vec::with_capacity(10),
@ -102,7 +102,7 @@ impl Program {
// Try to discover a literal string prefix. // Try to discover a literal string prefix.
// This is a bit hacky since we have to skip over the initial // This is a bit hacky since we have to skip over the initial
// 'Save' instruction. // 'Save' instruction.
let mut pre = StrBuf::with_capacity(5); let mut pre = String::with_capacity(5);
for inst in c.insts.slice_from(1).iter() { for inst in c.insts.slice_from(1).iter() {
match *inst { match *inst {
OneChar(c, FLAG_EMPTY) => pre.push_char(c), OneChar(c, FLAG_EMPTY) => pre.push_char(c),
@ -135,7 +135,7 @@ impl Program {
struct Compiler<'r> { struct Compiler<'r> {
insts: Vec<Inst>, insts: Vec<Inst>,
names: Vec<Option<StrBuf>>, names: Vec<Option<String>>,
} }
// The compiler implemented here is extremely simple. Most of the complexity // The compiler implemented here is extremely simple. Most of the complexity

View file

@ -32,7 +32,7 @@ pub struct Error {
/// The *approximate* character index of where the error occurred. /// The *approximate* character index of where the error occurred.
pub pos: uint, pub pos: uint,
/// A message describing the error. /// A message describing the error.
pub msg: StrBuf, pub msg: String,
} }
impl fmt::Show for Error { impl fmt::Show for Error {
@ -59,7 +59,7 @@ pub enum Ast {
Begin(Flags), Begin(Flags),
End(Flags), End(Flags),
WordBoundary(Flags), WordBoundary(Flags),
Capture(uint, Option<StrBuf>, Box<Ast>), Capture(uint, Option<String>, Box<Ast>),
// Represent concatenation as a flat vector to avoid blowing the // Represent concatenation as a flat vector to avoid blowing the
// stack in the compiler. // stack in the compiler.
Cat(Vec<Ast>), Cat(Vec<Ast>),
@ -104,7 +104,7 @@ impl Greed {
#[deriving(Show)] #[deriving(Show)]
enum BuildAst { enum BuildAst {
Ast(Ast), Ast(Ast),
Paren(Flags, uint, StrBuf), // '(' Paren(Flags, uint, String), // '('
Bar, // '|' Bar, // '|'
} }
@ -131,7 +131,7 @@ impl BuildAst {
} }
} }
fn capture_name(&self) -> Option<StrBuf> { fn capture_name(&self) -> Option<String> {
match *self { match *self {
Paren(_, 0, _) => None, Paren(_, 0, _) => None,
Paren(_, _, ref name) => { Paren(_, _, ref name) => {
@ -185,7 +185,7 @@ struct Parser<'a> {
// opening a capture group). // opening a capture group).
caps: uint, caps: uint,
// A set of all capture group names used only to detect duplicates. // A set of all capture group names used only to detect duplicates.
names: Vec<StrBuf>, names: Vec<String>,
} }
pub fn parse(s: &str) -> Result<Ast, Error> { pub fn parse(s: &str) -> Result<Ast, Error> {
@ -625,7 +625,7 @@ impl<'a> Parser<'a> {
// character). // character).
fn parse_unicode_name(&mut self) -> Result<Ast, Error> { fn parse_unicode_name(&mut self) -> Result<Ast, Error> {
let negated = if self.cur() == 'P' { FLAG_NEGATED } else { FLAG_EMPTY }; let negated = if self.cur() == 'P' { FLAG_NEGATED } else { FLAG_EMPTY };
let mut name: StrBuf; let mut name: String;
if self.peek_is(1, '{') { if self.peek_is(1, '{') {
try!(self.expect('{')) try!(self.expect('{'))
let closer = let closer =
@ -941,7 +941,7 @@ impl<'a> Parser<'a> {
*self.chars.get(self.chari) *self.chars.get(self.chari)
} }
fn slice(&self, start: uint, end: uint) -> StrBuf { fn slice(&self, start: uint, end: uint) -> String {
str::from_chars(self.chars.as_slice().slice(start, end)).to_strbuf() str::from_chars(self.chars.as_slice().slice(start, end)).to_strbuf()
} }
} }

View file

@ -20,8 +20,8 @@ use vm::{CaptureLocs, MatchKind, Exists, Location, Submatches};
/// Escapes all regular expression meta characters in `text` so that it may be /// Escapes all regular expression meta characters in `text` so that it may be
/// safely used in a regular expression as a literal string. /// safely used in a regular expression as a literal string.
pub fn quote(text: &str) -> StrBuf { pub fn quote(text: &str) -> String {
let mut quoted = StrBuf::with_capacity(text.len()); let mut quoted = String::with_capacity(text.len());
for c in text.chars() { for c in text.chars() {
if parse::is_punct(c) { if parse::is_punct(c) {
quoted.push_char('\\') quoted.push_char('\\')
@ -107,9 +107,9 @@ pub struct Regex {
/// See the comments for the `program` module in `lib.rs` for a more /// See the comments for the `program` module in `lib.rs` for a more
/// detailed explanation for what `regex!` requires. /// detailed explanation for what `regex!` requires.
#[doc(hidden)] #[doc(hidden)]
pub original: StrBuf, pub original: String,
#[doc(hidden)] #[doc(hidden)]
pub names: Vec<Option<StrBuf>>, pub names: Vec<Option<String>>,
#[doc(hidden)] #[doc(hidden)]
pub p: MaybeNative, pub p: MaybeNative,
} }
@ -407,7 +407,7 @@ impl Regex {
/// ``` /// ```
/// ///
/// But anything satisfying the `Replacer` trait will work. For example, /// But anything satisfying the `Replacer` trait will work. For example,
/// a closure of type `|&Captures| -> StrBuf` provides direct access to the /// a closure of type `|&Captures| -> String` provides direct access to the
/// captures corresponding to a match. This allows one to access /// captures corresponding to a match. This allows one to access
/// submatches easily: /// submatches easily:
/// ///
@ -456,7 +456,7 @@ impl Regex {
/// assert_eq!(result.as_slice(), "$2 $last"); /// assert_eq!(result.as_slice(), "$2 $last");
/// # } /// # }
/// ``` /// ```
pub fn replace<R: Replacer>(&self, text: &str, rep: R) -> StrBuf { pub fn replace<R: Replacer>(&self, text: &str, rep: R) -> String {
self.replacen(text, 1, rep) self.replacen(text, 1, rep)
} }
@ -466,7 +466,7 @@ impl Regex {
/// ///
/// See the documentation for `replace` for details on how to access /// See the documentation for `replace` for details on how to access
/// submatches in the replacement string. /// submatches in the replacement string.
pub fn replace_all<R: Replacer>(&self, text: &str, rep: R) -> StrBuf { pub fn replace_all<R: Replacer>(&self, text: &str, rep: R) -> String {
self.replacen(text, 0, rep) self.replacen(text, 0, rep)
} }
@ -477,8 +477,8 @@ impl Regex {
/// See the documentation for `replace` for details on how to access /// See the documentation for `replace` for details on how to access
/// submatches in the replacement string. /// submatches in the replacement string.
pub fn replacen<R: Replacer> pub fn replacen<R: Replacer>
(&self, text: &str, limit: uint, mut rep: R) -> StrBuf { (&self, text: &str, limit: uint, mut rep: R) -> String {
let mut new = StrBuf::with_capacity(text.len()); let mut new = String::with_capacity(text.len());
let mut last_match = 0u; let mut last_match = 0u;
for (i, cap) in self.captures_iter(text).enumerate() { for (i, cap) in self.captures_iter(text).enumerate() {
@ -529,7 +529,7 @@ impl<'t> Replacer for &'t str {
} }
} }
impl<'a> Replacer for |&Captures|: 'a -> StrBuf { impl<'a> Replacer for |&Captures|: 'a -> String {
fn reg_replace<'r>(&'r mut self, caps: &Captures) -> MaybeOwned<'r> { fn reg_replace<'r>(&'r mut self, caps: &Captures) -> MaybeOwned<'r> {
Owned((*self)(caps).into_owned()) Owned((*self)(caps).into_owned())
} }
@ -608,7 +608,7 @@ impl<'r, 't> Iterator<&'t str> for RegexSplitsN<'r, 't> {
pub struct Captures<'t> { pub struct Captures<'t> {
text: &'t str, text: &'t str,
locs: CaptureLocs, locs: CaptureLocs,
named: Option<HashMap<StrBuf, uint>>, named: Option<HashMap<String, uint>>,
} }
impl<'t> Captures<'t> { impl<'t> Captures<'t> {
@ -706,11 +706,11 @@ impl<'t> Captures<'t> {
/// isn't a valid index), then it is replaced with the empty string. /// isn't a valid index), then it is replaced with the empty string.
/// ///
/// To write a literal `$` use `$$`. /// To write a literal `$` use `$$`.
pub fn expand(&self, text: &str) -> StrBuf { pub fn expand(&self, text: &str) -> String {
// How evil can you get? // How evil can you get?
// FIXME: Don't use regexes for this. It's completely unnecessary. // FIXME: Don't use regexes for this. It's completely unnecessary.
let re = Regex::new(r"(^|[^$]|\b)\$(\w+)").unwrap(); let re = Regex::new(r"(^|[^$]|\b)\$(\w+)").unwrap();
let text = re.replace_all(text, |refs: &Captures| -> StrBuf { let text = re.replace_all(text, |refs: &Captures| -> String {
let (pre, name) = (refs.at(1), refs.at(2)); let (pre, name) = (refs.at(1), refs.at(2));
format_strbuf!("{}{}", format_strbuf!("{}{}",
pre, pre,

View file

@ -153,7 +153,7 @@ fn medium() -> Regex { regex!("[XYZ]ABCDEFGHIJKLMNOPQRSTUVWXYZ$") }
fn hard() -> Regex { regex!("[ -~]*ABCDEFGHIJKLMNOPQRSTUVWXYZ$") } fn hard() -> Regex { regex!("[ -~]*ABCDEFGHIJKLMNOPQRSTUVWXYZ$") }
#[allow(deprecated_owned_vector)] #[allow(deprecated_owned_vector)]
fn gen_text(n: uint) -> StrBuf { fn gen_text(n: uint) -> String {
let mut rng = task_rng(); let mut rng = task_rng();
let mut bytes = rng.gen_ascii_str(n).into_bytes(); let mut bytes = rng.gen_ascii_str(n).into_bytes();
for (i, b) in bytes.mut_iter().enumerate() { for (i, b) in bytes.mut_iter().enumerate() {

View file

@ -34,7 +34,7 @@ macro_rules! replace(
#[test] #[test]
fn $name() { fn $name() {
let re = regex!($re); let re = regex!($re);
assert_eq!(re.$which($search, $replace), StrBuf::from_str($result)); assert_eq!(re.$which($search, $replace), String::from_str($result));
} }
); );
) )

View file

@ -105,8 +105,8 @@ struct NfaGen<'a> {
cx: &'a ExtCtxt<'a>, cx: &'a ExtCtxt<'a>,
sp: codemap::Span, sp: codemap::Span,
prog: Program, prog: Program,
names: Vec<Option<StrBuf>>, names: Vec<Option<String>>,
original: StrBuf, original: String,
} }
impl<'a> NfaGen<'a> { impl<'a> NfaGen<'a> {
@ -601,7 +601,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
/// Looks for a single string literal and returns it. /// Looks for a single string literal and returns it.
/// Otherwise, logs an error with cx.span_err and returns None. /// Otherwise, logs an error with cx.span_err and returns None.
fn parse(cx: &mut ExtCtxt, tts: &[ast::TokenTree]) -> Option<StrBuf> { fn parse(cx: &mut ExtCtxt, tts: &[ast::TokenTree]) -> Option<String> {
let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(),
Vec::from_slice(tts)); Vec::from_slice(tts));
let entry = cx.expand_expr(parser.parse_expr()); let entry = cx.expand_expr(parser.parse_expr());

View file

@ -134,7 +134,7 @@ impl<'a> Archive<'a> {
} }
/// Lists all files in an archive /// Lists all files in an archive
pub fn files(&self) -> Vec<StrBuf> { pub fn files(&self) -> Vec<String> {
let output = run_ar(self.sess, "t", None, [&self.dst]); let output = run_ar(self.sess, "t", None, [&self.dst]);
let output = str::from_utf8(output.output.as_slice()).unwrap(); let output = str::from_utf8(output.output.as_slice()).unwrap();
// use lines_any because windows delimits output with `\r\n` instead of // use lines_any because windows delimits output with `\r\n` instead of

View file

@ -13,7 +13,7 @@ use driver::config::cfg_os_to_meta_os;
use metadata::loader::meta_section_name; use metadata::loader::meta_section_name;
use syntax::abi; use syntax::abi;
pub fn get_target_strs(target_triple: StrBuf, target_os: abi::Os) -> target_strs::t { pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
let cc_args = if target_triple.as_slice().contains("thumb") { let cc_args = if target_triple.as_slice().contains("thumb") {
vec!("-mthumb".to_strbuf()) vec!("-mthumb".to_strbuf())
} else { } else {

View file

@ -33,7 +33,7 @@ use std::io::{fs, TempDir, Command};
use std::io; use std::io;
use std::ptr; use std::ptr;
use std::str; use std::str;
use std::strbuf::StrBuf; use std::string::String;
use flate; use flate;
use serialize::hex::ToHex; use serialize::hex::ToHex;
use syntax::abi; use syntax::abi;
@ -54,7 +54,7 @@ pub enum OutputType {
OutputTypeExe, OutputTypeExe,
} }
pub fn llvm_err(sess: &Session, msg: StrBuf) -> ! { pub fn llvm_err(sess: &Session, msg: String) -> ! {
unsafe { unsafe {
let cstr = llvm::LLVMRustGetLastError(); let cstr = llvm::LLVMRustGetLastError();
if cstr == ptr::null() { if cstr == ptr::null() {
@ -541,14 +541,14 @@ pub fn find_crate_id(attrs: &[ast::Attribute], out_filestem: &str) -> CrateId {
match attr::find_crateid(attrs) { match attr::find_crateid(attrs) {
None => from_str(out_filestem).unwrap_or_else(|| { None => from_str(out_filestem).unwrap_or_else(|| {
let mut s = out_filestem.chars().filter(|c| c.is_XID_continue()); let mut s = out_filestem.chars().filter(|c| c.is_XID_continue());
from_str(s.collect::<StrBuf>().as_slice()) from_str(s.collect::<String>().as_slice())
.or(from_str("rust-out")).unwrap() .or(from_str("rust-out")).unwrap()
}), }),
Some(s) => s, Some(s) => s,
} }
} }
pub fn crate_id_hash(crate_id: &CrateId) -> StrBuf { pub fn crate_id_hash(crate_id: &CrateId) -> String {
// This calculates CMH as defined above. Note that we don't use the path of // This calculates CMH as defined above. Note that we don't use the path of
// the crate id in the hash because lookups are only done by (name/vers), // the crate id in the hash because lookups are only done by (name/vers),
// not by path. // not by path.
@ -567,7 +567,7 @@ pub fn build_link_meta(krate: &ast::Crate, out_filestem: &str) -> LinkMeta {
return r; return r;
} }
fn truncated_hash_result(symbol_hasher: &mut Sha256) -> StrBuf { fn truncated_hash_result(symbol_hasher: &mut Sha256) -> String {
let output = symbol_hasher.result_bytes(); let output = symbol_hasher.result_bytes();
// 64 bits should be enough to avoid collisions. // 64 bits should be enough to avoid collisions.
output.slice_to(8).to_hex().to_strbuf() output.slice_to(8).to_hex().to_strbuf()
@ -579,7 +579,7 @@ fn symbol_hash(tcx: &ty::ctxt,
symbol_hasher: &mut Sha256, symbol_hasher: &mut Sha256,
t: ty::t, t: ty::t,
link_meta: &LinkMeta) link_meta: &LinkMeta)
-> StrBuf { -> String {
// NB: do *not* use abbrevs here as we want the symbol names // NB: do *not* use abbrevs here as we want the symbol names
// to be independent of one another in the crate. // to be independent of one another in the crate.
@ -590,12 +590,12 @@ fn symbol_hash(tcx: &ty::ctxt,
symbol_hasher.input_str("-"); symbol_hasher.input_str("-");
symbol_hasher.input_str(encoder::encoded_ty(tcx, t).as_slice()); symbol_hasher.input_str(encoder::encoded_ty(tcx, t).as_slice());
// Prefix with 'h' so that it never blends into adjacent digits // Prefix with 'h' so that it never blends into adjacent digits
let mut hash = StrBuf::from_str("h"); let mut hash = String::from_str("h");
hash.push_str(truncated_hash_result(symbol_hasher).as_slice()); hash.push_str(truncated_hash_result(symbol_hasher).as_slice());
hash hash
} }
fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> StrBuf { fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> String {
match ccx.type_hashcodes.borrow().find(&t) { match ccx.type_hashcodes.borrow().find(&t) {
Some(h) => return h.to_strbuf(), Some(h) => return h.to_strbuf(),
None => {} None => {}
@ -611,8 +611,8 @@ fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> StrBuf {
// Name sanitation. LLVM will happily accept identifiers with weird names, but // Name sanitation. LLVM will happily accept identifiers with weird names, but
// gas doesn't! // gas doesn't!
// gas accepts the following characters in symbols: a-z, A-Z, 0-9, ., _, $ // gas accepts the following characters in symbols: a-z, A-Z, 0-9, ., _, $
pub fn sanitize(s: &str) -> StrBuf { pub fn sanitize(s: &str) -> String {
let mut result = StrBuf::new(); let mut result = String::new();
for c in s.chars() { for c in s.chars() {
match c { match c {
// Escape these with $ sequences // Escape these with $ sequences
@ -637,7 +637,7 @@ pub fn sanitize(s: &str) -> StrBuf {
| '_' | '.' | '$' => result.push_char(c), | '_' | '.' | '$' => result.push_char(c),
_ => { _ => {
let mut tstr = StrBuf::new(); let mut tstr = String::new();
char::escape_unicode(c, |c| tstr.push_char(c)); char::escape_unicode(c, |c| tstr.push_char(c));
result.push_char('$'); result.push_char('$');
result.push_str(tstr.as_slice().slice_from(1)); result.push_str(tstr.as_slice().slice_from(1));
@ -657,7 +657,7 @@ pub fn sanitize(s: &str) -> StrBuf {
pub fn mangle<PI: Iterator<PathElem>>(mut path: PI, pub fn mangle<PI: Iterator<PathElem>>(mut path: PI,
hash: Option<&str>, hash: Option<&str>,
vers: Option<&str>) -> StrBuf { vers: Option<&str>) -> String {
// Follow C++ namespace-mangling style, see // Follow C++ namespace-mangling style, see
// http://en.wikipedia.org/wiki/Name_mangling for more info. // http://en.wikipedia.org/wiki/Name_mangling for more info.
// //
@ -672,9 +672,9 @@ pub fn mangle<PI: Iterator<PathElem>>(mut path: PI,
// To be able to work on all platforms and get *some* reasonable output, we // To be able to work on all platforms and get *some* reasonable output, we
// use C++ name-mangling. // use C++ name-mangling.
let mut n = StrBuf::from_str("_ZN"); // _Z == Begin name-sequence, N == nested let mut n = String::from_str("_ZN"); // _Z == Begin name-sequence, N == nested
fn push(n: &mut StrBuf, s: &str) { fn push(n: &mut String, s: &str) {
let sani = sanitize(s); let sani = sanitize(s);
n.push_str(format!("{}{}", sani.len(), sani).as_slice()); n.push_str(format!("{}{}", sani.len(), sani).as_slice());
} }
@ -697,7 +697,7 @@ pub fn mangle<PI: Iterator<PathElem>>(mut path: PI,
n n
} }
pub fn exported_name(path: PathElems, hash: &str, vers: &str) -> StrBuf { pub fn exported_name(path: PathElems, hash: &str, vers: &str) -> String {
// The version will get mangled to have a leading '_', but it makes more // The version will get mangled to have a leading '_', but it makes more
// sense to lead with a 'v' b/c this is a version... // sense to lead with a 'v' b/c this is a version...
let vers = if vers.len() > 0 && !char::is_XID_start(vers.char_at(0)) { let vers = if vers.len() > 0 && !char::is_XID_start(vers.char_at(0)) {
@ -710,7 +710,7 @@ pub fn exported_name(path: PathElems, hash: &str, vers: &str) -> StrBuf {
} }
pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems, pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems,
t: ty::t, id: ast::NodeId) -> StrBuf { t: ty::t, id: ast::NodeId) -> String {
let mut hash = get_symbol_hash(ccx, t); let mut hash = get_symbol_hash(ccx, t);
// Paths can be completely identical for different nodes, // Paths can be completely identical for different nodes,
@ -738,7 +738,7 @@ pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems,
pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext, pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext,
t: ty::t, t: ty::t,
name: &str) -> StrBuf { name: &str) -> String {
let s = ppaux::ty_to_str(ccx.tcx(), t); let s = ppaux::ty_to_str(ccx.tcx(), t);
let path = [PathName(token::intern(s.as_slice())), let path = [PathName(token::intern(s.as_slice())),
gensym_name(name)]; gensym_name(name)];
@ -746,18 +746,18 @@ pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext,
mangle(ast_map::Values(path.iter()), Some(hash.as_slice()), None) mangle(ast_map::Values(path.iter()), Some(hash.as_slice()), None)
} }
pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> StrBuf { pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> String {
mangle(path.chain(Some(gensym_name(flav)).move_iter()), None, None) mangle(path.chain(Some(gensym_name(flav)).move_iter()), None, None)
} }
pub fn output_lib_filename(id: &CrateId) -> StrBuf { pub fn output_lib_filename(id: &CrateId) -> String {
format_strbuf!("{}-{}-{}", format_strbuf!("{}-{}-{}",
id.name, id.name,
crate_id_hash(id), crate_id_hash(id),
id.version_or_default()) id.version_or_default())
} }
pub fn get_cc_prog(sess: &Session) -> StrBuf { pub fn get_cc_prog(sess: &Session) -> String {
match sess.opts.cg.linker { match sess.opts.cg.linker {
Some(ref linker) => return linker.to_strbuf(), Some(ref linker) => return linker.to_strbuf(),
None => {} None => {}
@ -773,7 +773,7 @@ pub fn get_cc_prog(sess: &Session) -> StrBuf {
}.to_strbuf() }.to_strbuf()
} }
pub fn get_ar_prog(sess: &Session) -> StrBuf { pub fn get_ar_prog(sess: &Session) -> String {
match sess.opts.cg.ar { match sess.opts.cg.ar {
Some(ref ar) => (*ar).clone(), Some(ref ar) => (*ar).clone(),
None => "ar".to_strbuf() None => "ar".to_strbuf()

View file

@ -20,7 +20,7 @@ use libc;
use flate; use flate;
pub fn run(sess: &session::Session, llmod: ModuleRef, pub fn run(sess: &session::Session, llmod: ModuleRef,
tm: TargetMachineRef, reachable: &[StrBuf]) { tm: TargetMachineRef, reachable: &[String]) {
if sess.opts.cg.prefer_dynamic { if sess.opts.cg.prefer_dynamic {
sess.err("cannot prefer dynamic linking when performing LTO"); sess.err("cannot prefer dynamic linking when performing LTO");
sess.note("only 'staticlib' and 'bin' outputs are supported with LTO"); sess.note("only 'staticlib' and 'bin' outputs are supported with LTO");

View file

@ -13,7 +13,7 @@ use driver::config::cfg_os_to_meta_os;
use metadata::loader::meta_section_name; use metadata::loader::meta_section_name;
use syntax::abi; use syntax::abi;
pub fn get_target_strs(target_triple: StrBuf, target_os: abi::Os) -> target_strs::t { pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
return target_strs::t { return target_strs::t {
module_asm: "".to_strbuf(), module_asm: "".to_strbuf(),

View file

@ -22,7 +22,7 @@ fn not_win32(os: abi::Os) -> bool {
os != abi::OsWin32 os != abi::OsWin32
} }
pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<StrBuf> { pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<String> {
let os = sess.targ_cfg.os; let os = sess.targ_cfg.os;
// No rpath on windows // No rpath on windows
@ -56,7 +56,7 @@ pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<StrBuf> {
flags flags
} }
pub fn rpaths_to_flags(rpaths: &[StrBuf]) -> Vec<StrBuf> { pub fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
let mut ret = Vec::new(); let mut ret = Vec::new();
for rpath in rpaths.iter() { for rpath in rpaths.iter() {
ret.push(format!("-Wl,-rpath,{}", (*rpath).as_slice())); ret.push(format!("-Wl,-rpath,{}", (*rpath).as_slice()));
@ -68,7 +68,7 @@ fn get_rpaths(os: abi::Os,
sysroot: &Path, sysroot: &Path,
output: &Path, output: &Path,
libs: &[Path], libs: &[Path],
target_triple: &str) -> Vec<StrBuf> { target_triple: &str) -> Vec<String> {
debug!("sysroot: {}", sysroot.display()); debug!("sysroot: {}", sysroot.display());
debug!("output: {}", output.display()); debug!("output: {}", output.display());
debug!("libs:"); debug!("libs:");
@ -85,7 +85,7 @@ fn get_rpaths(os: abi::Os,
// And a final backup rpath to the global library location. // And a final backup rpath to the global library location.
let fallback_rpaths = vec!(get_install_prefix_rpath(sysroot, target_triple)); let fallback_rpaths = vec!(get_install_prefix_rpath(sysroot, target_triple));
fn log_rpaths(desc: &str, rpaths: &[StrBuf]) { fn log_rpaths(desc: &str, rpaths: &[String]) {
debug!("{} rpaths:", desc); debug!("{} rpaths:", desc);
for rpath in rpaths.iter() { for rpath in rpaths.iter() {
debug!(" {}", *rpath); debug!(" {}", *rpath);
@ -105,14 +105,14 @@ fn get_rpaths(os: abi::Os,
fn get_rpaths_relative_to_output(os: abi::Os, fn get_rpaths_relative_to_output(os: abi::Os,
output: &Path, output: &Path,
libs: &[Path]) -> Vec<StrBuf> { libs: &[Path]) -> Vec<String> {
libs.iter().map(|a| get_rpath_relative_to_output(os, output, a)).collect() libs.iter().map(|a| get_rpath_relative_to_output(os, output, a)).collect()
} }
pub fn get_rpath_relative_to_output(os: abi::Os, pub fn get_rpath_relative_to_output(os: abi::Os,
output: &Path, output: &Path,
lib: &Path) lib: &Path)
-> StrBuf { -> String {
use std::os; use std::os;
assert!(not_win32(os)); assert!(not_win32(os));
@ -137,7 +137,7 @@ pub fn get_rpath_relative_to_output(os: abi::Os,
relative.as_str().expect("non-utf8 component in path")) relative.as_str().expect("non-utf8 component in path"))
} }
pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> StrBuf { pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> String {
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX"); let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
let tlib = filesearch::relative_target_lib_path(sysroot, target_triple); let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
@ -148,7 +148,7 @@ pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> StrBuf {
path.as_str().expect("non-utf8 component in rpath").to_strbuf() path.as_str().expect("non-utf8 component in rpath").to_strbuf()
} }
pub fn minimize_rpaths(rpaths: &[StrBuf]) -> Vec<StrBuf> { pub fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
let mut set = HashSet::new(); let mut set = HashSet::new();
let mut minimized = Vec::new(); let mut minimized = Vec::new();
for rpath in rpaths.iter() { for rpath in rpaths.iter() {

View file

@ -55,7 +55,7 @@ use syntax::visit;
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
pub struct Svh { pub struct Svh {
hash: StrBuf, hash: String,
} }
impl Svh { impl Svh {

View file

@ -11,9 +11,9 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
pub struct t { pub struct t {
pub module_asm: StrBuf, pub module_asm: String,
pub meta_sect_name: StrBuf, pub meta_sect_name: String,
pub data_layout: StrBuf, pub data_layout: String,
pub target_triple: StrBuf, pub target_triple: String,
pub cc_args: Vec<StrBuf> , pub cc_args: Vec<String> ,
} }

View file

@ -14,7 +14,7 @@ use driver::config::cfg_os_to_meta_os;
use metadata::loader::meta_section_name; use metadata::loader::meta_section_name;
use syntax::abi; use syntax::abi;
pub fn get_target_strs(target_triple: StrBuf, target_os: abi::Os) pub fn get_target_strs(target_triple: String, target_os: abi::Os)
-> target_strs::t { -> target_strs::t {
return target_strs::t { return target_strs::t {
module_asm: "".to_strbuf(), module_asm: "".to_strbuf(),

View file

@ -14,7 +14,7 @@ use driver::config::cfg_os_to_meta_os;
use metadata::loader::meta_section_name; use metadata::loader::meta_section_name;
use syntax::abi; use syntax::abi;
pub fn get_target_strs(target_triple: StrBuf, target_os: abi::Os) -> target_strs::t { pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
return target_strs::t { return target_strs::t {
module_asm: "".to_strbuf(), module_asm: "".to_strbuf(),

View file

@ -77,7 +77,7 @@ pub struct Options {
// this. // this.
pub addl_lib_search_paths: RefCell<HashSet<Path>>, pub addl_lib_search_paths: RefCell<HashSet<Path>>,
pub maybe_sysroot: Option<Path>, pub maybe_sysroot: Option<Path>,
pub target_triple: StrBuf, pub target_triple: String,
// User-specified cfg meta items. The compiler itself will add additional // User-specified cfg meta items. The compiler itself will add additional
// items to the crate config, and during parsing the entire crate config // items to the crate config, and during parsing the entire crate config
// will be added to the crate AST node. This should not be used for // will be added to the crate AST node. This should not be used for
@ -250,21 +250,21 @@ macro_rules! cgoptions(
} }
} }
fn parse_opt_string(slot: &mut Option<StrBuf>, v: Option<&str>) -> bool { fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
match v { match v {
Some(s) => { *slot = Some(s.to_strbuf()); true }, Some(s) => { *slot = Some(s.to_strbuf()); true },
None => false, None => false,
} }
} }
fn parse_string(slot: &mut StrBuf, v: Option<&str>) -> bool { fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
match v { match v {
Some(s) => { *slot = s.to_strbuf(); true }, Some(s) => { *slot = s.to_strbuf(); true },
None => false, None => false,
} }
} }
fn parse_list(slot: &mut Vec<StrBuf>, v: Option<&str>) fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
-> bool { -> bool {
match v { match v {
Some(s) => { Some(s) => {
@ -281,19 +281,19 @@ macro_rules! cgoptions(
) ) ) )
cgoptions!( cgoptions!(
ar: Option<StrBuf> = (None, parse_opt_string, ar: Option<String> = (None, parse_opt_string,
"tool to assemble archives with"), "tool to assemble archives with"),
linker: Option<StrBuf> = (None, parse_opt_string, linker: Option<String> = (None, parse_opt_string,
"system linker to link outputs with"), "system linker to link outputs with"),
link_args: Vec<StrBuf> = (Vec::new(), parse_list, link_args: Vec<String> = (Vec::new(), parse_list,
"extra arguments to pass to the linker (space separated)"), "extra arguments to pass to the linker (space separated)"),
target_cpu: StrBuf = ("generic".to_strbuf(), parse_string, target_cpu: String = ("generic".to_strbuf(), parse_string,
"select target processor (llc -mcpu=help for details)"), "select target processor (llc -mcpu=help for details)"),
target_feature: StrBuf = ("".to_strbuf(), parse_string, target_feature: String = ("".to_strbuf(), parse_string,
"target specific attributes (llc -mattr=help for details)"), "target specific attributes (llc -mattr=help for details)"),
passes: Vec<StrBuf> = (Vec::new(), parse_list, passes: Vec<String> = (Vec::new(), parse_list,
"a list of extra LLVM passes to run (space separated)"), "a list of extra LLVM passes to run (space separated)"),
llvm_args: Vec<StrBuf> = (Vec::new(), parse_list, llvm_args: Vec<String> = (Vec::new(), parse_list,
"a list of arguments to pass to llvm (space separated)"), "a list of arguments to pass to llvm (space separated)"),
save_temps: bool = (false, parse_bool, save_temps: bool = (false, parse_bool,
"save all temporary output files during compilation"), "save all temporary output files during compilation"),
@ -311,7 +311,7 @@ cgoptions!(
"prefer dynamic linking to static linking"), "prefer dynamic linking to static linking"),
no_integrated_as: bool = (false, parse_bool, no_integrated_as: bool = (false, parse_bool,
"use an external assembler rather than LLVM's integrated one"), "use an external assembler rather than LLVM's integrated one"),
relocation_model: StrBuf = ("pic".to_strbuf(), parse_string, relocation_model: String = ("pic".to_strbuf(), parse_string,
"choose the relocation model to use (llc -relocation-model for details)"), "choose the relocation model to use (llc -relocation-model for details)"),
) )
@ -555,7 +555,7 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
// Convert strings provided as --cfg [cfgspec] into a crate_cfg // Convert strings provided as --cfg [cfgspec] into a crate_cfg
fn parse_cfgspecs(cfgspecs: Vec<StrBuf> ) -> ast::CrateConfig { fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
cfgspecs.move_iter().map(|s| { cfgspecs.move_iter().map(|s| {
parse::parse_meta_from_source_str("cfgspec".to_strbuf(), parse::parse_meta_from_source_str("cfgspec".to_strbuf(),
s.to_strbuf(), s.to_strbuf(),

View file

@ -105,11 +105,11 @@ pub fn compile_input(sess: Session,
* The name used for source code that doesn't originate in a file * The name used for source code that doesn't originate in a file
* (e.g. source from stdin or a string) * (e.g. source from stdin or a string)
*/ */
pub fn anon_src() -> StrBuf { pub fn anon_src() -> String {
"<anon>".to_strbuf() "<anon>".to_strbuf()
} }
pub fn source_name(input: &Input) -> StrBuf { pub fn source_name(input: &Input) -> String {
match *input { match *input {
// FIXME (#9639): This needs to handle non-utf8 paths // FIXME (#9639): This needs to handle non-utf8 paths
FileInput(ref ifile) => ifile.as_str().unwrap().to_strbuf(), FileInput(ref ifile) => ifile.as_str().unwrap().to_strbuf(),
@ -121,11 +121,11 @@ pub enum Input {
/// Load source from file /// Load source from file
FileInput(Path), FileInput(Path),
/// The string is the source /// The string is the source
StrInput(StrBuf) StrInput(String)
} }
impl Input { impl Input {
fn filestem(&self) -> StrBuf { fn filestem(&self) -> String {
match *self { match *self {
FileInput(ref ifile) => ifile.filestem_str().unwrap().to_strbuf(), FileInput(ref ifile) => ifile.filestem_str().unwrap().to_strbuf(),
StrInput(_) => "rust_out".to_strbuf(), StrInput(_) => "rust_out".to_strbuf(),
@ -360,7 +360,7 @@ pub struct CrateTranslation {
pub metadata_module: ModuleRef, pub metadata_module: ModuleRef,
pub link: LinkMeta, pub link: LinkMeta,
pub metadata: Vec<u8>, pub metadata: Vec<u8>,
pub reachable: Vec<StrBuf>, pub reachable: Vec<String>,
pub crate_formats: dependency_format::Dependencies, pub crate_formats: dependency_format::Dependencies,
pub no_builtins: bool, pub no_builtins: bool,
} }
@ -495,7 +495,7 @@ fn write_out_deps(sess: &Session,
let result = (|| { let result = (|| {
// Build a list of files used to compile the output and // Build a list of files used to compile the output and
// write Makefile-compatible dependency rules // write Makefile-compatible dependency rules
let files: Vec<StrBuf> = sess.codemap().files.borrow() let files: Vec<String> = sess.codemap().files.borrow()
.iter().filter(|fmap| fmap.is_real_file()) .iter().filter(|fmap| fmap.is_real_file())
.map(|fmap| fmap.name.to_strbuf()) .map(|fmap| fmap.name.to_strbuf())
.collect(); .collect();
@ -780,7 +780,7 @@ pub fn collect_crate_types(session: &Session,
pub struct OutputFilenames { pub struct OutputFilenames {
pub out_directory: Path, pub out_directory: Path,
pub out_filestem: StrBuf, pub out_filestem: String,
pub single_output_file: Option<Path>, pub single_output_file: Option<Path>,
} }

View file

@ -35,7 +35,7 @@ pub mod session;
pub mod config; pub mod config;
pub fn main_args(args: &[StrBuf]) -> int { pub fn main_args(args: &[String]) -> int {
let owned_args = args.to_owned(); let owned_args = args.to_owned();
monitor(proc() run_compiler(owned_args)); monitor(proc() run_compiler(owned_args));
0 0
@ -44,7 +44,7 @@ pub fn main_args(args: &[StrBuf]) -> int {
static BUG_REPORT_URL: &'static str = static BUG_REPORT_URL: &'static str =
"http://doc.rust-lang.org/complement-bugreport.html"; "http://doc.rust-lang.org/complement-bugreport.html";
fn run_compiler(args: &[StrBuf]) { fn run_compiler(args: &[String]) {
let matches = match handle_options(Vec::from_slice(args)) { let matches = match handle_options(Vec::from_slice(args)) {
Some(matches) => matches, Some(matches) => matches,
None => return None => return
@ -143,7 +143,7 @@ Available lint options:
for &(_, name) in lint_dict.iter() { for &(_, name) in lint_dict.iter() {
max_key = cmp::max(name.len(), max_key); max_key = cmp::max(name.len(), max_key);
} }
fn padded(max: uint, s: &str) -> StrBuf { fn padded(max: uint, s: &str) -> String {
format!("{}{}", " ".repeat(max - s.len()), s) format!("{}{}", " ".repeat(max - s.len()), s)
} }
println!("\nAvailable lint checks:\n"); println!("\nAvailable lint checks:\n");
@ -192,7 +192,7 @@ fn describe_codegen_flags() {
/// Process command line options. Emits messages as appropirate.If compilation /// Process command line options. Emits messages as appropirate.If compilation
/// should continue, returns a getopts::Matches object parsed from args, otherwise /// should continue, returns a getopts::Matches object parsed from args, otherwise
/// returns None. /// returns None.
pub fn handle_options(mut args: Vec<StrBuf>) -> Option<getopts::Matches> { pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
// Throw away the first argument, the name of the binary // Throw away the first argument, the name of the binary
let _binary = args.shift().unwrap(); let _binary = args.shift().unwrap();

View file

@ -42,7 +42,7 @@ pub struct Session {
// expected to be absolute. `None` means that there is no source file. // expected to be absolute. `None` means that there is no source file.
pub local_crate_source_file: Option<Path>, pub local_crate_source_file: Option<Path>,
pub working_dir: Path, pub working_dir: Path,
pub lints: RefCell<NodeMap<Vec<(lint::Lint, codemap::Span, StrBuf)>>>, pub lints: RefCell<NodeMap<Vec<(lint::Lint, codemap::Span, String)>>>,
pub node_id: Cell<ast::NodeId>, pub node_id: Cell<ast::NodeId>,
pub crate_types: RefCell<Vec<config::CrateType>>, pub crate_types: RefCell<Vec<config::CrateType>>,
pub features: front::feature_gate::Features, pub features: front::feature_gate::Features,
@ -108,7 +108,7 @@ impl Session {
lint: lint::Lint, lint: lint::Lint,
id: ast::NodeId, id: ast::NodeId,
sp: Span, sp: Span,
msg: StrBuf) { msg: String) {
let mut lints = self.lints.borrow_mut(); let mut lints = self.lints.borrow_mut();
match lints.find_mut(&id) { match lints.find_mut(&id) {
Some(arr) => { arr.push((lint, sp, msg)); return; } Some(arr) => { arr.push((lint, sp, msg)); return; }
@ -245,7 +245,7 @@ pub fn build_session_(sopts: config::Options,
} }
// Seems out of place, but it uses session, so I'm putting it here // Seems out of place, but it uses session, so I'm putting it here
pub fn expect<T:Clone>(sess: &Session, opt: Option<T>, msg: || -> StrBuf) pub fn expect<T:Clone>(sess: &Session, opt: Option<T>, msg: || -> String)
-> T { -> T {
diagnostic::expect(sess.diagnostic(), opt, msg) diagnostic::expect(sess.diagnostic(), opt, msg)
} }

View file

@ -1862,7 +1862,7 @@ pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
/* Memory-managed object interface to type handles. */ /* Memory-managed object interface to type handles. */
pub struct TypeNames { pub struct TypeNames {
named_types: RefCell<HashMap<StrBuf, TypeRef>>, named_types: RefCell<HashMap<String, TypeRef>>,
} }
impl TypeNames { impl TypeNames {
@ -1881,7 +1881,7 @@ impl TypeNames {
self.named_types.borrow().find_equiv(&s).map(|x| Type::from_ref(*x)) self.named_types.borrow().find_equiv(&s).map(|x| Type::from_ref(*x))
} }
pub fn type_to_str(&self, ty: Type) -> StrBuf { pub fn type_to_str(&self, ty: Type) -> String {
unsafe { unsafe {
let s = llvm::LLVMTypeToString(ty.to_ref()); let s = llvm::LLVMTypeToString(ty.to_ref());
let ret = from_c_str(s); let ret = from_c_str(s);
@ -1890,12 +1890,12 @@ impl TypeNames {
} }
} }
pub fn types_to_str(&self, tys: &[Type]) -> StrBuf { pub fn types_to_str(&self, tys: &[Type]) -> String {
let strs: Vec<StrBuf> = tys.iter().map(|t| self.type_to_str(*t)).collect(); let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect();
format_strbuf!("[{}]", strs.connect(",").to_strbuf()) format_strbuf!("[{}]", strs.connect(",").to_strbuf())
} }
pub fn val_to_str(&self, val: ValueRef) -> StrBuf { pub fn val_to_str(&self, val: ValueRef) -> String {
unsafe { unsafe {
let s = llvm::LLVMValueToString(val); let s = llvm::LLVMValueToString(val);
let ret = from_c_str(s); let ret = from_c_str(s);

View file

@ -139,7 +139,7 @@ fn visit_view_item(e: &mut Env, i: &ast::ViewItem) {
} }
struct CrateInfo { struct CrateInfo {
ident: StrBuf, ident: String,
crate_id: CrateId, crate_id: CrateId,
id: ast::NodeId, id: ast::NodeId,
should_link: bool, should_link: bool,

View file

@ -33,7 +33,7 @@ pub struct StaticMethodInfo {
pub vis: ast::Visibility, pub vis: ast::Visibility,
} }
pub fn get_symbol(cstore: &cstore::CStore, def: ast::DefId) -> StrBuf { pub fn get_symbol(cstore: &cstore::CStore, def: ast::DefId) -> String {
let cdata = cstore.get_crate_data(def.krate); let cdata = cstore.get_crate_data(def.krate);
decoder::get_symbol(cdata.data(), def.node) decoder::get_symbol(cdata.data(), def.node)
} }
@ -247,7 +247,7 @@ pub fn get_impl_vtables(tcx: &ty::ctxt,
pub fn get_native_libraries(cstore: &cstore::CStore, pub fn get_native_libraries(cstore: &cstore::CStore,
crate_num: ast::CrateNum) crate_num: ast::CrateNum)
-> Vec<(cstore::NativeLibaryKind, StrBuf)> { -> Vec<(cstore::NativeLibaryKind, String)> {
let cdata = cstore.get_crate_data(crate_num); let cdata = cstore.get_crate_data(crate_num);
decoder::get_native_libraries(&*cdata) decoder::get_native_libraries(&*cdata)
} }

View file

@ -38,7 +38,7 @@ pub enum MetadataBlob {
} }
pub struct crate_metadata { pub struct crate_metadata {
pub name: StrBuf, pub name: String,
pub data: MetadataBlob, pub data: MetadataBlob,
pub cnum_map: cnum_map, pub cnum_map: cnum_map,
pub cnum: ast::CrateNum, pub cnum: ast::CrateNum,
@ -71,8 +71,8 @@ pub struct CStore {
metas: RefCell<HashMap<ast::CrateNum, Rc<crate_metadata>>>, metas: RefCell<HashMap<ast::CrateNum, Rc<crate_metadata>>>,
extern_mod_crate_map: RefCell<extern_mod_crate_map>, extern_mod_crate_map: RefCell<extern_mod_crate_map>,
used_crate_sources: RefCell<Vec<CrateSource>>, used_crate_sources: RefCell<Vec<CrateSource>>,
used_libraries: RefCell<Vec<(StrBuf, NativeLibaryKind)>>, used_libraries: RefCell<Vec<(String, NativeLibaryKind)>>,
used_link_args: RefCell<Vec<StrBuf>>, used_link_args: RefCell<Vec<String>>,
pub intr: Rc<IdentInterner>, pub intr: Rc<IdentInterner>,
} }
@ -189,13 +189,13 @@ impl CStore {
libs libs
} }
pub fn add_used_library(&self, lib: StrBuf, kind: NativeLibaryKind) { pub fn add_used_library(&self, lib: String, kind: NativeLibaryKind) {
assert!(!lib.is_empty()); assert!(!lib.is_empty());
self.used_libraries.borrow_mut().push((lib, kind)); self.used_libraries.borrow_mut().push((lib, kind));
} }
pub fn get_used_libraries<'a>(&'a self) pub fn get_used_libraries<'a>(&'a self)
-> &'a RefCell<Vec<(StrBuf, NativeLibaryKind)> > { -> &'a RefCell<Vec<(String, NativeLibaryKind)> > {
&self.used_libraries &self.used_libraries
} }
@ -205,7 +205,7 @@ impl CStore {
} }
} }
pub fn get_used_link_args<'a>(&'a self) -> &'a RefCell<Vec<StrBuf> > { pub fn get_used_link_args<'a>(&'a self) -> &'a RefCell<Vec<String> > {
&self.used_link_args &self.used_link_args
} }

View file

@ -185,7 +185,7 @@ fn item_method_sort(item: ebml::Doc) -> char {
ret ret
} }
fn item_symbol(item: ebml::Doc) -> StrBuf { fn item_symbol(item: ebml::Doc) -> String {
reader::get_doc(item, tag_items_data_item_symbol).as_str().to_strbuf() reader::get_doc(item, tag_items_data_item_symbol).as_str().to_strbuf()
} }
@ -452,7 +452,7 @@ pub fn get_impl_vtables(cdata: Cmd,
} }
pub fn get_symbol(data: &[u8], id: ast::NodeId) -> StrBuf { pub fn get_symbol(data: &[u8], id: ast::NodeId) -> String {
return item_symbol(lookup_item(id, data)); return item_symbol(lookup_item(id, data));
} }
@ -1093,7 +1093,7 @@ pub fn get_crate_deps(data: &[u8]) -> Vec<CrateDep> {
let cratedoc = reader::Doc(data); let cratedoc = reader::Doc(data);
let depsdoc = reader::get_doc(cratedoc, tag_crate_deps); let depsdoc = reader::get_doc(cratedoc, tag_crate_deps);
let mut crate_num = 1; let mut crate_num = 1;
fn docstr(doc: ebml::Doc, tag_: uint) -> StrBuf { fn docstr(doc: ebml::Doc, tag_: uint) -> String {
let d = reader::get_doc(doc, tag_); let d = reader::get_doc(doc, tag_);
d.as_str_slice().to_strbuf() d.as_str_slice().to_strbuf()
} }
@ -1142,7 +1142,7 @@ pub fn maybe_get_crate_id(data: &[u8]) -> Option<CrateId> {
}) })
} }
pub fn get_crate_triple(data: &[u8]) -> StrBuf { pub fn get_crate_triple(data: &[u8]) -> String {
let cratedoc = reader::Doc(data); let cratedoc = reader::Doc(data);
let triple_doc = reader::maybe_get_doc(cratedoc, tag_crate_triple); let triple_doc = reader::maybe_get_doc(cratedoc, tag_crate_triple);
triple_doc.expect("No triple in crate").as_str().to_strbuf() triple_doc.expect("No triple in crate").as_str().to_strbuf()
@ -1238,7 +1238,7 @@ pub fn get_trait_of_method(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
pub fn get_native_libraries(cdata: Cmd) pub fn get_native_libraries(cdata: Cmd)
-> Vec<(cstore::NativeLibaryKind, StrBuf)> { -> Vec<(cstore::NativeLibaryKind, String)> {
let libraries = reader::get_doc(reader::Doc(cdata.data()), let libraries = reader::get_doc(reader::Doc(cdata.data()),
tag_native_libraries); tag_native_libraries);
let mut result = Vec::new(); let mut result = Vec::new();
@ -1259,7 +1259,7 @@ pub fn get_macro_registrar_fn(data: &[u8]) -> Option<ast::NodeId> {
.map(|doc| FromPrimitive::from_u32(reader::doc_as_u32(doc)).unwrap()) .map(|doc| FromPrimitive::from_u32(reader::doc_as_u32(doc)).unwrap())
} }
pub fn get_exported_macros(data: &[u8]) -> Vec<StrBuf> { pub fn get_exported_macros(data: &[u8]) -> Vec<String> {
let macros = reader::get_doc(reader::Doc(data), let macros = reader::get_doc(reader::Doc(data),
tag_exported_macros); tag_exported_macros);
let mut result = Vec::new(); let mut result = Vec::new();

View file

@ -70,7 +70,7 @@ pub struct EncodeParams<'a> {
pub diag: &'a SpanHandler, pub diag: &'a SpanHandler,
pub tcx: &'a ty::ctxt, pub tcx: &'a ty::ctxt,
pub reexports2: &'a middle::resolve::ExportMap2, pub reexports2: &'a middle::resolve::ExportMap2,
pub item_symbols: &'a RefCell<NodeMap<StrBuf>>, pub item_symbols: &'a RefCell<NodeMap<String>>,
pub non_inlineable_statics: &'a RefCell<NodeSet>, pub non_inlineable_statics: &'a RefCell<NodeSet>,
pub link_meta: &'a LinkMeta, pub link_meta: &'a LinkMeta,
pub cstore: &'a cstore::CStore, pub cstore: &'a cstore::CStore,
@ -81,7 +81,7 @@ pub struct EncodeContext<'a> {
pub diag: &'a SpanHandler, pub diag: &'a SpanHandler,
pub tcx: &'a ty::ctxt, pub tcx: &'a ty::ctxt,
pub reexports2: &'a middle::resolve::ExportMap2, pub reexports2: &'a middle::resolve::ExportMap2,
pub item_symbols: &'a RefCell<NodeMap<StrBuf>>, pub item_symbols: &'a RefCell<NodeMap<String>>,
pub non_inlineable_statics: &'a RefCell<NodeSet>, pub non_inlineable_statics: &'a RefCell<NodeSet>,
pub link_meta: &'a LinkMeta, pub link_meta: &'a LinkMeta,
pub cstore: &'a cstore::CStore, pub cstore: &'a cstore::CStore,
@ -139,7 +139,7 @@ fn encode_family(ebml_w: &mut Encoder, c: char) {
ebml_w.end_tag(); ebml_w.end_tag();
} }
pub fn def_to_str(did: DefId) -> StrBuf { pub fn def_to_str(did: DefId) -> String {
format_strbuf!("{}:{}", did.krate, did.node) format_strbuf!("{}:{}", did.krate, did.node)
} }
@ -1715,7 +1715,7 @@ fn encode_dylib_dependency_formats(ebml_w: &mut Encoder, ecx: &EncodeContext) {
cstore::RequireDynamic => "d", cstore::RequireDynamic => "d",
cstore::RequireStatic => "s", cstore::RequireStatic => "s",
})).to_strbuf()) })).to_strbuf())
}).collect::<Vec<StrBuf>>(); }).collect::<Vec<String>>();
ebml_w.writer.write(s.connect(",").as_bytes()); ebml_w.writer.write(s.connect(",").as_bytes());
} }
None => {} None => {}
@ -1877,7 +1877,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
} }
// Get the encoded string for a type // Get the encoded string for a type
pub fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> StrBuf { pub fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> String {
let mut wr = MemWriter::new(); let mut wr = MemWriter::new();
tyencode::enc_ty(&mut wr, &tyencode::ctxt { tyencode::enc_ty(&mut wr, &tyencode::ctxt {
diag: tcx.sess.diagnostic(), diag: tcx.sess.diagnostic(),

View file

@ -186,7 +186,7 @@ static PATH_ENTRY_SEPARATOR: &'static str = ";";
static PATH_ENTRY_SEPARATOR: &'static str = ":"; static PATH_ENTRY_SEPARATOR: &'static str = ":";
/// Returns RUST_PATH as a string, without default paths added /// Returns RUST_PATH as a string, without default paths added
pub fn get_rust_path() -> Option<StrBuf> { pub fn get_rust_path() -> Option<String> {
os::getenv("RUST_PATH").map(|x| x.to_strbuf()) os::getenv("RUST_PATH").map(|x| x.to_strbuf())
} }
@ -236,7 +236,7 @@ pub fn rust_path() -> Vec<Path> {
// The name of the directory rustc expects libraries to be located. // The name of the directory rustc expects libraries to be located.
// On Unix should be "lib", on windows "bin" // On Unix should be "lib", on windows "bin"
#[cfg(unix)] #[cfg(unix)]
fn find_libdir(sysroot: &Path) -> StrBuf { fn find_libdir(sysroot: &Path) -> String {
// FIXME: This is a quick hack to make the rustc binary able to locate // FIXME: This is a quick hack to make the rustc binary able to locate
// Rust libraries in Linux environments where libraries might be installed // Rust libraries in Linux environments where libraries might be installed
// to lib64/lib32. This would be more foolproof by basing the sysroot off // to lib64/lib32. This would be more foolproof by basing the sysroot off
@ -250,27 +250,27 @@ fn find_libdir(sysroot: &Path) -> StrBuf {
} }
#[cfg(target_word_size = "64")] #[cfg(target_word_size = "64")]
fn primary_libdir_name() -> StrBuf { fn primary_libdir_name() -> String {
"lib64".to_strbuf() "lib64".to_strbuf()
} }
#[cfg(target_word_size = "32")] #[cfg(target_word_size = "32")]
fn primary_libdir_name() -> StrBuf { fn primary_libdir_name() -> String {
"lib32".to_strbuf() "lib32".to_strbuf()
} }
fn secondary_libdir_name() -> StrBuf { fn secondary_libdir_name() -> String {
"lib".to_strbuf() "lib".to_strbuf()
} }
} }
#[cfg(windows)] #[cfg(windows)]
fn find_libdir(_sysroot: &Path) -> StrBuf { fn find_libdir(_sysroot: &Path) -> String {
"bin".to_strbuf() "bin".to_strbuf()
} }
// The name of rustc's own place to organize libraries. // The name of rustc's own place to organize libraries.
// Used to be "rustc", now the default is "rustlib" // Used to be "rustc", now the default is "rustlib"
pub fn rustlibdir() -> StrBuf { pub fn rustlibdir() -> String {
"rustlib".to_strbuf() "rustlib".to_strbuf()
} }

View file

@ -61,7 +61,7 @@ pub enum Os {
pub struct CrateMismatch { pub struct CrateMismatch {
path: Path, path: Path,
got: StrBuf, got: String,
} }
pub struct Context<'a> { pub struct Context<'a> {
@ -92,7 +92,7 @@ pub struct ArchiveMetadata {
} }
pub struct CratePaths { pub struct CratePaths {
pub ident: StrBuf, pub ident: String,
pub dylib: Option<Path>, pub dylib: Option<Path>,
pub rlib: Option<Path> pub rlib: Option<Path>
} }
@ -313,7 +313,7 @@ impl<'a> Context<'a> {
// //
// If everything checks out, then `Some(hash)` is returned where `hash` is // If everything checks out, then `Some(hash)` is returned where `hash` is
// the listed hash in the filename itself. // the listed hash in the filename itself.
fn try_match(&self, file: &str, prefix: &str, suffix: &str) -> Option<StrBuf>{ fn try_match(&self, file: &str, prefix: &str, suffix: &str) -> Option<String>{
let middle = file.slice(prefix.len(), file.len() - suffix.len()); let middle = file.slice(prefix.len(), file.len() - suffix.len());
debug!("matching -- {}, middle: {}", file, middle); debug!("matching -- {}, middle: {}", file, middle);
let mut parts = middle.splitn('-', 1); let mut parts = middle.splitn('-', 1);
@ -496,7 +496,7 @@ impl ArchiveMetadata {
} }
// Just a small wrapper to time how long reading metadata takes. // Just a small wrapper to time how long reading metadata takes.
fn get_metadata_section(os: Os, filename: &Path) -> Result<MetadataBlob, StrBuf> { fn get_metadata_section(os: Os, filename: &Path) -> Result<MetadataBlob, String> {
let start = time::precise_time_ns(); let start = time::precise_time_ns();
let ret = get_metadata_section_imp(os, filename); let ret = get_metadata_section_imp(os, filename);
info!("reading {} => {}ms", filename.filename_display(), info!("reading {} => {}ms", filename.filename_display(),
@ -504,7 +504,7 @@ fn get_metadata_section(os: Os, filename: &Path) -> Result<MetadataBlob, StrBuf>
return ret; return ret;
} }
fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, StrBuf> { fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, String> {
if !filename.exists() { if !filename.exists() {
return Err(format_strbuf!("no such file: '{}'", filename.display())); return Err(format_strbuf!("no such file: '{}'", filename.display()));
} }

View file

@ -20,7 +20,7 @@ use middle::ty;
use std::rc::Rc; use std::rc::Rc;
use std::str; use std::str;
use std::strbuf::StrBuf; use std::string::String;
use std::uint; use std::uint;
use syntax::abi; use syntax::abi;
use syntax::ast; use syntax::ast;
@ -267,8 +267,8 @@ fn parse_opt<T>(st: &mut PState, f: |&mut PState| -> T) -> Option<T> {
} }
} }
fn parse_str(st: &mut PState, term: char) -> StrBuf { fn parse_str(st: &mut PState, term: char) -> String {
let mut result = StrBuf::new(); let mut result = String::new();
while peek(st) != term { while peek(st) != term {
unsafe { unsafe {
result.push_bytes([next_byte(st)]) result.push_bytes([next_byte(st)])

View file

@ -31,7 +31,7 @@ macro_rules! mywrite( ($($arg:tt)*) => ({ write!($($arg)*); }) )
pub struct ctxt<'a> { pub struct ctxt<'a> {
pub diag: &'a SpanHandler, pub diag: &'a SpanHandler,
// Def -> str Callback: // Def -> str Callback:
pub ds: fn(DefId) -> StrBuf, pub ds: fn(DefId) -> String,
// The type context. // The type context.
pub tcx: &'a ty::ctxt, pub tcx: &'a ty::ctxt,
pub abbrevs: &'a abbrev_map pub abbrevs: &'a abbrev_map
@ -43,7 +43,7 @@ pub struct ctxt<'a> {
pub struct ty_abbrev { pub struct ty_abbrev {
pos: uint, pos: uint,
len: uint, len: uint,
s: StrBuf s: String
} }
pub type abbrev_map = RefCell<HashMap<ty::t, ty_abbrev>>; pub type abbrev_map = RefCell<HashMap<ty::t, ty_abbrev>>;

View file

@ -38,7 +38,7 @@ use std::io::Seek;
use std::io::MemWriter; use std::io::MemWriter;
use std::mem; use std::mem;
use std::rc::Rc; use std::rc::Rc;
use std::strbuf::StrBuf; use std::string::String;
use serialize::ebml::reader; use serialize::ebml::reader;
use serialize::ebml; use serialize::ebml;
@ -1152,8 +1152,8 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
Ok(ty) Ok(ty)
}).unwrap(); }).unwrap();
fn type_string(doc: ebml::Doc) -> StrBuf { fn type_string(doc: ebml::Doc) -> String {
let mut str = StrBuf::new(); let mut str = String::new();
for i in range(doc.start, doc.end) { for i in range(doc.start, doc.end) {
str.push_char(doc.data[i] as char); str.push_char(doc.data[i] as char);
} }

View file

@ -22,7 +22,7 @@ use util::ppaux::{note_and_explain_region, Repr, UserString};
use std::cell::{Cell}; use std::cell::{Cell};
use std::ops::{BitOr, BitAnd}; use std::ops::{BitOr, BitAnd};
use std::rc::Rc; use std::rc::Rc;
use std::strbuf::StrBuf; use std::string::String;
use syntax::ast; use syntax::ast;
use syntax::ast_map; use syntax::ast_map;
use syntax::ast_util; use syntax::ast_util;
@ -91,7 +91,7 @@ pub fn check_crate(tcx: &ty::ctxt,
make_stat(&bccx, bccx.stats.stable_paths.get())); make_stat(&bccx, bccx.stats.stable_paths.get()));
} }
fn make_stat(bccx: &BorrowckCtxt, stat: uint) -> StrBuf { fn make_stat(bccx: &BorrowckCtxt, stat: uint) -> String {
let stat_f = stat as f64; let stat_f = stat as f64;
let total = bccx.stats.guaranteed_paths.get() as f64; let total = bccx.stats.guaranteed_paths.get() as f64;
format_strbuf!("{} ({:.0f}%)", stat , stat_f * 100.0 / total) format_strbuf!("{} ({:.0f}%)", stat , stat_f * 100.0 / total)
@ -296,7 +296,7 @@ impl BitAnd<RestrictionSet,RestrictionSet> for RestrictionSet {
} }
impl Repr for RestrictionSet { impl Repr for RestrictionSet {
fn repr(&self, _tcx: &ty::ctxt) -> StrBuf { fn repr(&self, _tcx: &ty::ctxt) -> String {
format_strbuf!("RestrictionSet(0x{:x})", self.bits as uint) format_strbuf!("RestrictionSet(0x{:x})", self.bits as uint)
} }
} }
@ -574,7 +574,7 @@ impl<'a> BorrowckCtxt<'a> {
self.tcx.sess.span_end_note(s, m); self.tcx.sess.span_end_note(s, m);
} }
pub fn bckerr_to_str(&self, err: &BckError) -> StrBuf { pub fn bckerr_to_str(&self, err: &BckError) -> String {
match err.code { match err.code {
err_mutbl => { err_mutbl => {
let descr = match opt_loan_path(&err.cmt) { let descr = match opt_loan_path(&err.cmt) {
@ -734,7 +734,7 @@ impl<'a> BorrowckCtxt<'a> {
pub fn append_loan_path_to_str(&self, pub fn append_loan_path_to_str(&self,
loan_path: &LoanPath, loan_path: &LoanPath,
out: &mut StrBuf) { out: &mut String) {
match *loan_path { match *loan_path {
LpVar(id) => { LpVar(id) => {
out.push_str(ty::local_var_name_str(self.tcx, id).get()); out.push_str(ty::local_var_name_str(self.tcx, id).get());
@ -768,7 +768,7 @@ impl<'a> BorrowckCtxt<'a> {
pub fn append_autoderefd_loan_path_to_str(&self, pub fn append_autoderefd_loan_path_to_str(&self,
loan_path: &LoanPath, loan_path: &LoanPath,
out: &mut StrBuf) { out: &mut String) {
match *loan_path { match *loan_path {
LpExtend(ref lp_base, _, LpDeref(_)) => { LpExtend(ref lp_base, _, LpDeref(_)) => {
// For a path like `(*x).f` or `(*x)[3]`, autoderef // For a path like `(*x).f` or `(*x)[3]`, autoderef
@ -783,13 +783,13 @@ impl<'a> BorrowckCtxt<'a> {
} }
} }
pub fn loan_path_to_str(&self, loan_path: &LoanPath) -> StrBuf { pub fn loan_path_to_str(&self, loan_path: &LoanPath) -> String {
let mut result = StrBuf::new(); let mut result = String::new();
self.append_loan_path_to_str(loan_path, &mut result); self.append_loan_path_to_str(loan_path, &mut result);
result result
} }
pub fn cmt_to_str(&self, cmt: &mc::cmt_) -> StrBuf { pub fn cmt_to_str(&self, cmt: &mc::cmt_) -> String {
self.mc().cmt_to_str(cmt) self.mc().cmt_to_str(cmt)
} }
} }
@ -819,7 +819,7 @@ impl DataFlowOperator for LoanDataFlowOperator {
} }
impl Repr for Loan { impl Repr for Loan {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
(format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})", (format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
self.index, self.index,
self.loan_path.repr(tcx), self.loan_path.repr(tcx),
@ -831,7 +831,7 @@ impl Repr for Loan {
} }
impl Repr for Restriction { impl Repr for Restriction {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
(format!("Restriction({}, {:x})", (format!("Restriction({}, {:x})",
self.loan_path.repr(tcx), self.loan_path.repr(tcx),
self.set.bits as uint)).to_strbuf() self.set.bits as uint)).to_strbuf()
@ -839,7 +839,7 @@ impl Repr for Restriction {
} }
impl Repr for LoanPath { impl Repr for LoanPath {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
match self { match self {
&LpVar(id) => { &LpVar(id) => {
(format!("$({})", tcx.map.node_to_str(id))).to_strbuf() (format!("$({})", tcx.map.node_to_str(id))).to_strbuf()

View file

@ -25,10 +25,10 @@ pub type Edge<'a> = &'a cfg::CFGEdge;
pub struct LabelledCFG<'a>{ pub struct LabelledCFG<'a>{
pub ast_map: &'a ast_map::Map, pub ast_map: &'a ast_map::Map,
pub cfg: &'a cfg::CFG, pub cfg: &'a cfg::CFG,
pub name: StrBuf, pub name: String,
} }
fn replace_newline_with_backslash_l(s: StrBuf) -> StrBuf { fn replace_newline_with_backslash_l(s: String) -> String {
// Replacing newlines with \\l causes each line to be left-aligned, // Replacing newlines with \\l causes each line to be left-aligned,
// improving presentation of (long) pretty-printed expressions. // improving presentation of (long) pretty-printed expressions.
if s.as_slice().contains("\n") { if s.as_slice().contains("\n") {
@ -72,7 +72,7 @@ impl<'a> dot::Labeller<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a> {
} }
fn edge_label(&self, e: &Edge<'a>) -> dot::LabelText<'a> { fn edge_label(&self, e: &Edge<'a>) -> dot::LabelText<'a> {
let mut label = StrBuf::new(); let mut label = String::new();
let mut put_one = false; let mut put_one = false;
for (i, &node_id) in e.data.exiting_scopes.iter().enumerate() { for (i, &node_id) in e.data.exiting_scopes.iter().enumerate() {
if put_one { if put_one {

View file

@ -33,7 +33,7 @@ use syntax::visit;
use syntax::print::pprust; use syntax::print::pprust;
fn safe_type_for_static_mut(cx: &ty::ctxt, e: &ast::Expr) -> Option<StrBuf> { fn safe_type_for_static_mut(cx: &ty::ctxt, e: &ast::Expr) -> Option<String> {
let node_ty = ty::node_id_to_type(cx, e.id); let node_ty = ty::node_id_to_type(cx, e.id);
let tcontents = ty::type_contents(cx, node_ty); let tcontents = ty::type_contents(cx, node_ty);
debug!("safe_type_for_static_mut(dtor={}, managed={}, owned={})", debug!("safe_type_for_static_mut(dtor={}, managed={}, owned={})",
@ -62,7 +62,7 @@ pub fn check_crate(tcx: &ty::ctxt, krate: &ast::Crate) {
} }
impl<'a> CheckStaticVisitor<'a> { impl<'a> CheckStaticVisitor<'a> {
fn report_error(&self, span: Span, result: Option<StrBuf>) -> bool { fn report_error(&self, span: Span, result: Option<String>) -> bool {
match result { match result {
None => { false } None => { false }
Some(msg) => { Some(msg) => {

View file

@ -306,8 +306,8 @@ pub fn eval_const_expr(tcx: &ty::ctxt, e: &Expr) -> const_val {
} }
pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr)
-> Result<const_val, StrBuf> { -> Result<const_val, String> {
fn fromb(b: bool) -> Result<const_val, StrBuf> { Ok(const_int(b as i64)) } fn fromb(b: bool) -> Result<const_val, String> { Ok(const_int(b as i64)) }
match e.node { match e.node {
ExprUnary(UnNeg, inner) => { ExprUnary(UnNeg, inner) => {
match eval_const_expr_partial(tcx, inner) { match eval_const_expr_partial(tcx, inner) {

View file

@ -18,7 +18,7 @@
use std::io; use std::io;
use std::strbuf::StrBuf; use std::string::String;
use std::uint; use std::uint;
use syntax::ast; use syntax::ast;
use syntax::ast_util; use syntax::ast_util;
@ -832,12 +832,12 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> {
} }
} }
fn mut_bits_to_str(words: &mut [uint]) -> StrBuf { fn mut_bits_to_str(words: &mut [uint]) -> String {
bits_to_str(words) bits_to_str(words)
} }
fn bits_to_str(words: &[uint]) -> StrBuf { fn bits_to_str(words: &[uint]) -> String {
let mut result = StrBuf::new(); let mut result = String::new();
let mut sep = '['; let mut sep = '[';
// Note: this is a little endian printout of bytes. // Note: this is a little endian printout of bytes.
@ -892,7 +892,7 @@ fn set_bit(words: &mut [uint], bit: uint) -> bool {
oldv != newv oldv != newv
} }
fn bit_str(bit: uint) -> StrBuf { fn bit_str(bit: uint) -> String {
let byte = bit >> 8; let byte = bit >> 8;
let lobits = 1 << (bit & 0xFF); let lobits = 1 << (bit & 0xFF);
format_strbuf!("[{}:{}-{:02x}]", bit, byte, lobits) format_strbuf!("[{}:{}-{:02x}]", bit, byte, lobits)

View file

@ -574,7 +574,7 @@ pub fn check_cast_for_escaping_regions(
} }
// Ensure that `ty` has a statically known size (i.e., it has the `Sized` bound). // Ensure that `ty` has a statically known size (i.e., it has the `Sized` bound).
fn check_sized(tcx: &ty::ctxt, ty: ty::t, name: StrBuf, sp: Span) { fn check_sized(tcx: &ty::ctxt, ty: ty::t, name: String, sp: Span) {
if !ty::type_is_sized(tcx, ty) { if !ty::type_is_sized(tcx, ty) {
tcx.sess.span_err(sp, tcx.sess.span_err(sp,
format!("variable `{}` has dynamically sized type \ format!("variable `{}` has dynamically sized type \

View file

@ -74,7 +74,7 @@ impl LanguageItems {
} }
} }
pub fn require(&self, it: LangItem) -> Result<ast::DefId, StrBuf> { pub fn require(&self, it: LangItem) -> Result<ast::DefId, String> {
match self.items.get(it as uint) { match self.items.get(it as uint) {
&Some(id) => Ok(id), &Some(id) => Ok(id),
&None => { &None => {

View file

@ -150,7 +150,7 @@ enum LiveNodeKind {
ExitNode ExitNode
} }
fn live_node_kind_to_str(lnk: LiveNodeKind, cx: &ty::ctxt) -> StrBuf { fn live_node_kind_to_str(lnk: LiveNodeKind, cx: &ty::ctxt) -> String {
let cm = cx.sess.codemap(); let cm = cx.sess.codemap();
match lnk { match lnk {
FreeVarNode(s) => { FreeVarNode(s) => {
@ -322,7 +322,7 @@ impl<'a> IrMaps<'a> {
} }
} }
fn variable_name(&self, var: Variable) -> StrBuf { fn variable_name(&self, var: Variable) -> String {
match self.var_kinds.get(var.get()) { match self.var_kinds.get(var.get()) {
&Local(LocalInfo { ident: nm, .. }) | &Arg(_, nm) => { &Local(LocalInfo { ident: nm, .. }) | &Arg(_, nm) => {
token::get_ident(nm).get().to_str().to_strbuf() token::get_ident(nm).get().to_str().to_strbuf()
@ -750,7 +750,7 @@ impl<'a> Liveness<'a> {
} }
#[allow(unused_must_use)] #[allow(unused_must_use)]
fn ln_str(&self, ln: LiveNode) -> StrBuf { fn ln_str(&self, ln: LiveNode) -> String {
let mut wr = io::MemWriter::new(); let mut wr = io::MemWriter::new();
{ {
let wr = &mut wr as &mut io::Writer; let wr = &mut wr as &mut io::Writer;
@ -1541,7 +1541,7 @@ impl<'a> Liveness<'a> {
} }
} }
fn should_warn(&self, var: Variable) -> Option<StrBuf> { fn should_warn(&self, var: Variable) -> Option<String> {
let name = self.ir.variable_name(var); let name = self.ir.variable_name(var);
if name.len() == 0 || name.as_slice()[0] == ('_' as u8) { if name.len() == 0 || name.as_slice()[0] == ('_' as u8) {
None None

View file

@ -1093,7 +1093,7 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> {
Ok(()) Ok(())
} }
pub fn cmt_to_str(&self, cmt: &cmt_) -> StrBuf { pub fn cmt_to_str(&self, cmt: &cmt_) -> String {
match cmt.cat { match cmt.cat {
cat_static_item => { cat_static_item => {
"static item".to_strbuf() "static item".to_strbuf()
@ -1249,7 +1249,7 @@ impl cmt_ {
} }
impl Repr for cmt_ { impl Repr for cmt_ {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
format_strbuf!("\\{{} id:{} m:{:?} ty:{}\\}", format_strbuf!("\\{{} id:{} m:{:?} ty:{}\\}",
self.cat.repr(tcx), self.cat.repr(tcx),
self.id, self.id,
@ -1259,7 +1259,7 @@ impl Repr for cmt_ {
} }
impl Repr for categorization { impl Repr for categorization {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
match *self { match *self {
cat_static_item | cat_static_item |
cat_rvalue(..) | cat_rvalue(..) |
@ -1300,7 +1300,7 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
} }
impl Repr for InteriorKind { impl Repr for InteriorKind {
fn repr(&self, _tcx: &ty::ctxt) -> StrBuf { fn repr(&self, _tcx: &ty::ctxt) -> String {
match *self { match *self {
InteriorField(NamedField(fld)) => { InteriorField(NamedField(fld)) => {
token::get_name(fld).get().to_str().to_strbuf() token::get_name(fld).get().to_str().to_strbuf()

View file

@ -45,7 +45,7 @@ pub type PublicItems = NodeSet;
/// Result of a checking operation - None => no errors were found. Some => an /// Result of a checking operation - None => no errors were found. Some => an
/// error and contains the span and message for reporting that error and /// error and contains the span and message for reporting that error and
/// optionally the same for a note about the error. /// optionally the same for a note about the error.
type CheckResult = Option<(Span, StrBuf, Option<(Span, StrBuf)>)>; type CheckResult = Option<(Span, String, Option<(Span, String)>)>;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// The parent visitor, used to determine what's the parent of what (node-wise) /// The parent visitor, used to determine what's the parent of what (node-wise)
@ -356,7 +356,7 @@ enum FieldName {
impl<'a> PrivacyVisitor<'a> { impl<'a> PrivacyVisitor<'a> {
// used when debugging // used when debugging
fn nodestr(&self, id: ast::NodeId) -> StrBuf { fn nodestr(&self, id: ast::NodeId) -> String {
self.tcx.map.node_to_str(id).to_strbuf() self.tcx.map.node_to_str(id).to_strbuf()
} }

View file

@ -35,7 +35,7 @@ use collections::{HashMap, HashSet};
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::mem::replace; use std::mem::replace;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use std::strbuf::StrBuf; use std::string::String;
use std::uint; use std::uint;
// Definition mapping // Definition mapping
@ -57,7 +57,7 @@ pub type TraitMap = NodeMap<Vec<DefId> >;
pub type ExportMap2 = RefCell<NodeMap<Vec<Export2> >>; pub type ExportMap2 = RefCell<NodeMap<Vec<Export2> >>;
pub struct Export2 { pub struct Export2 {
pub name: StrBuf, // The name of the target. pub name: String, // The name of the target.
pub def_id: DefId, // The definition of the target. pub def_id: DefId, // The definition of the target.
} }
@ -221,8 +221,8 @@ enum FallbackSuggestion {
Field, Field,
Method, Method,
TraitMethod, TraitMethod,
StaticMethod(StrBuf), StaticMethod(String),
StaticTraitMethod(StrBuf), StaticTraitMethod(String),
} }
enum TypeParameters<'a> { enum TypeParameters<'a> {
@ -2070,9 +2070,9 @@ impl<'a> Resolver<'a> {
} }
} }
fn idents_to_str(&self, idents: &[Ident]) -> StrBuf { fn idents_to_str(&self, idents: &[Ident]) -> String {
let mut first = true; let mut first = true;
let mut result = StrBuf::new(); let mut result = String::new();
for ident in idents.iter() { for ident in idents.iter() {
if first { if first {
first = false first = false
@ -2084,7 +2084,7 @@ impl<'a> Resolver<'a> {
result result
} }
fn path_idents_to_str(&self, path: &Path) -> StrBuf { fn path_idents_to_str(&self, path: &Path) -> String {
let identifiers: Vec<ast::Ident> = path.segments let identifiers: Vec<ast::Ident> = path.segments
.iter() .iter()
.map(|seg| seg.identifier) .map(|seg| seg.identifier)
@ -2094,7 +2094,7 @@ impl<'a> Resolver<'a> {
fn import_directive_subclass_to_str(&mut self, fn import_directive_subclass_to_str(&mut self,
subclass: ImportDirectiveSubclass) subclass: ImportDirectiveSubclass)
-> StrBuf { -> String {
match subclass { match subclass {
SingleImport(_, source) => { SingleImport(_, source) => {
token::get_ident(source).get().to_strbuf() token::get_ident(source).get().to_strbuf()
@ -2106,7 +2106,7 @@ impl<'a> Resolver<'a> {
fn import_path_to_str(&mut self, fn import_path_to_str(&mut self,
idents: &[Ident], idents: &[Ident],
subclass: ImportDirectiveSubclass) subclass: ImportDirectiveSubclass)
-> StrBuf { -> String {
if idents.is_empty() { if idents.is_empty() {
self.import_directive_subclass_to_str(subclass) self.import_directive_subclass_to_str(subclass)
} else { } else {
@ -5019,7 +5019,7 @@ impl<'a> Resolver<'a> {
} }
fn find_best_match_for_name(&mut self, name: &str, max_distance: uint) fn find_best_match_for_name(&mut self, name: &str, max_distance: uint)
-> Option<StrBuf> { -> Option<String> {
let this = &mut *self; let this = &mut *self;
let mut maybes: Vec<token::InternedString> = Vec::new(); let mut maybes: Vec<token::InternedString> = Vec::new();
@ -5499,7 +5499,7 @@ impl<'a> Resolver<'a> {
// //
/// A somewhat inefficient routine to obtain the name of a module. /// A somewhat inefficient routine to obtain the name of a module.
fn module_to_str(&mut self, module: &Module) -> StrBuf { fn module_to_str(&mut self, module: &Module) -> String {
let mut idents = Vec::new(); let mut idents = Vec::new();
fn collect_mod(idents: &mut Vec<ast::Ident>, module: &Module) { fn collect_mod(idents: &mut Vec<ast::Ident>, module: &Module) {

View file

@ -400,7 +400,7 @@ struct Match<'a, 'b> {
} }
impl<'a, 'b> Repr for Match<'a, 'b> { impl<'a, 'b> Repr for Match<'a, 'b> {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
if tcx.sess.verbose() { if tcx.sess.verbose() {
// for many programs, this just take too long to serialize // for many programs, this just take too long to serialize
self.pats.repr(tcx) self.pats.repr(tcx)

View file

@ -23,7 +23,7 @@ use middle::trans::type_of;
use middle::trans::type_::Type; use middle::trans::type_::Type;
use std::c_str::ToCStr; use std::c_str::ToCStr;
use std::strbuf::StrBuf; use std::string::String;
use syntax::ast; use syntax::ast;
// Take an inline assembly expression and splat it out via LLVM // Take an inline assembly expression and splat it out via LLVM
@ -64,9 +64,9 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
fcx.pop_custom_cleanup_scope(temp_scope); fcx.pop_custom_cleanup_scope(temp_scope);
let mut constraints = let mut constraints =
StrBuf::from_str(constraints.iter() String::from_str(constraints.iter()
.map(|s| s.get().to_strbuf()) .map(|s| s.get().to_strbuf())
.collect::<Vec<StrBuf>>() .collect::<Vec<String>>()
.connect(",") .connect(",")
.as_slice()); .as_slice());
@ -135,12 +135,12 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
#[cfg(target_arch = "arm")] #[cfg(target_arch = "arm")]
#[cfg(target_arch = "mips")] #[cfg(target_arch = "mips")]
fn getClobbers() -> StrBuf { fn getClobbers() -> String {
"".to_strbuf() "".to_strbuf()
} }
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
fn getClobbers() -> StrBuf { fn getClobbers() -> String {
"~{dirflag},~{fpsr},~{flags}".to_strbuf() "~{dirflag},~{fpsr},~{flags}".to_strbuf()
} }

View file

@ -125,13 +125,13 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
pub struct StatRecorder<'a> { pub struct StatRecorder<'a> {
ccx: &'a CrateContext, ccx: &'a CrateContext,
name: Option<StrBuf>, name: Option<String>,
start: u64, start: u64,
istart: uint, istart: uint,
} }
impl<'a> StatRecorder<'a> { impl<'a> StatRecorder<'a> {
pub fn new(ccx: &'a CrateContext, name: StrBuf) -> StatRecorder<'a> { pub fn new(ccx: &'a CrateContext, name: String) -> StatRecorder<'a> {
let start = if ccx.sess().trans_stats() { let start = if ccx.sess().trans_stats() {
time::precise_time_ns() time::precise_time_ns()
} else { } else {
@ -429,7 +429,7 @@ pub fn unset_split_stack(f: ValueRef) {
// Double-check that we never ask LLVM to declare the same symbol twice. It // Double-check that we never ask LLVM to declare the same symbol twice. It
// silently mangles such symbols, breaking our linkage model. // silently mangles such symbols, breaking our linkage model.
pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: StrBuf) { pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: String) {
if ccx.all_llvm_symbols.borrow().contains(&sym) { if ccx.all_llvm_symbols.borrow().contains(&sym) {
ccx.sess().bug(format!("duplicate LLVM symbol: {}", sym).as_slice()); ccx.sess().bug(format!("duplicate LLVM symbol: {}", sym).as_slice());
} }
@ -1626,7 +1626,7 @@ pub fn trans_mod(ccx: &CrateContext, m: &ast::Mod) {
} }
} }
fn finish_register_fn(ccx: &CrateContext, sp: Span, sym: StrBuf, node_id: ast::NodeId, fn finish_register_fn(ccx: &CrateContext, sp: Span, sym: String, node_id: ast::NodeId,
llfn: ValueRef) { llfn: ValueRef) {
ccx.item_symbols.borrow_mut().insert(node_id, sym); ccx.item_symbols.borrow_mut().insert(node_id, sym);
@ -1654,7 +1654,7 @@ fn finish_register_fn(ccx: &CrateContext, sp: Span, sym: StrBuf, node_id: ast::N
fn register_fn(ccx: &CrateContext, fn register_fn(ccx: &CrateContext,
sp: Span, sp: Span,
sym: StrBuf, sym: String,
node_id: ast::NodeId, node_id: ast::NodeId,
node_type: ty::t) node_type: ty::t)
-> ValueRef { -> ValueRef {
@ -1777,7 +1777,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
// only use this for foreign function ABIs and glue, use `register_fn` for Rust functions // only use this for foreign function ABIs and glue, use `register_fn` for Rust functions
pub fn register_fn_llvmty(ccx: &CrateContext, pub fn register_fn_llvmty(ccx: &CrateContext,
sp: Span, sp: Span,
sym: StrBuf, sym: String,
node_id: ast::NodeId, node_id: ast::NodeId,
cc: lib::llvm::CallConv, cc: lib::llvm::CallConv,
llfty: Type) -> ValueRef { llfty: Type) -> ValueRef {
@ -1872,7 +1872,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
} }
fn exported_name(ccx: &CrateContext, id: ast::NodeId, fn exported_name(ccx: &CrateContext, id: ast::NodeId,
ty: ty::t, attrs: &[ast::Attribute]) -> StrBuf { ty: ty::t, attrs: &[ast::Attribute]) -> String {
match attr::first_attr_value_str_by_name(attrs, "export_name") { match attr::first_attr_value_str_by_name(attrs, "export_name") {
// Use provided name // Use provided name
Some(name) => name.get().to_strbuf(), Some(name) => name.get().to_strbuf(),
@ -2279,7 +2279,7 @@ pub fn trans_crate(krate: ast::Crate,
let link_meta = ccx.link_meta.clone(); let link_meta = ccx.link_meta.clone();
let llmod = ccx.llmod; let llmod = ccx.llmod;
let mut reachable: Vec<StrBuf> = ccx.reachable.iter().filter_map(|id| { let mut reachable: Vec<String> = ccx.reachable.iter().filter_map(|id| {
ccx.item_symbols.borrow().find(id).map(|s| s.to_strbuf()) ccx.item_symbols.borrow().find(id).map(|s| s.to_strbuf())
}).collect(); }).collect();

View file

@ -122,7 +122,7 @@ pub fn Invoke(cx: &Block,
terminate(cx, "Invoke"); terminate(cx, "Invoke");
debug!("Invoke({} with arguments ({}))", debug!("Invoke({} with arguments ({}))",
cx.val_to_str(fn_), cx.val_to_str(fn_),
args.iter().map(|a| cx.val_to_str(*a)).collect::<Vec<StrBuf>>().connect(", ")); args.iter().map(|a| cx.val_to_str(*a)).collect::<Vec<String>>().connect(", "));
B(cx).invoke(fn_, args, then, catch, attributes) B(cx).invoke(fn_, args, then, catch, attributes)
} }

View file

@ -21,7 +21,7 @@ use middle::trans::machine::llalign_of_pref;
use middle::trans::type_::Type; use middle::trans::type_::Type;
use collections::HashMap; use collections::HashMap;
use libc::{c_uint, c_ulonglong, c_char}; use libc::{c_uint, c_ulonglong, c_char};
use std::strbuf::StrBuf; use std::string::String;
use syntax::codemap::Span; use syntax::codemap::Span;
pub struct Builder<'a> { pub struct Builder<'a> {
@ -69,7 +69,7 @@ impl<'a> Builder<'a> {
// Pass 2: concat strings for each elt, skipping // Pass 2: concat strings for each elt, skipping
// forwards over any cycles by advancing to rightmost // forwards over any cycles by advancing to rightmost
// occurrence of each element in path. // occurrence of each element in path.
let mut s = StrBuf::from_str("."); let mut s = String::from_str(".");
i = 0u; i = 0u;
while i < len { while i < len {
i = *mm.get(&v[i]); i = *mm.get(&v[i]);
@ -806,7 +806,7 @@ impl<'a> Builder<'a> {
self.ccx.tn.val_to_str(llfn), self.ccx.tn.val_to_str(llfn),
args.iter() args.iter()
.map(|&v| self.ccx.tn.val_to_str(v)) .map(|&v| self.ccx.tn.val_to_str(v))
.collect::<Vec<StrBuf>>() .collect::<Vec<String>>()
.connect(", ")); .connect(", "));
unsafe { unsafe {

View file

@ -756,7 +756,7 @@ impl<'a> CleanupScope<'a> {
self.cleanups.iter().any(|c| c.clean_on_unwind()) self.cleanups.iter().any(|c| c.clean_on_unwind())
} }
fn block_name(&self, prefix: &str) -> StrBuf { fn block_name(&self, prefix: &str) -> String {
/*! /*!
* Returns a suitable name to use for the basic block that * Returns a suitable name to use for the basic block that
* handles this cleanup scope * handles this cleanup scope

View file

@ -104,7 +104,7 @@ pub struct EnvValue {
} }
impl EnvValue { impl EnvValue {
pub fn to_str(&self, ccx: &CrateContext) -> StrBuf { pub fn to_str(&self, ccx: &CrateContext) -> String {
format_strbuf!("{}({})", self.action, self.datum.to_str(ccx)) format_strbuf!("{}({})", self.action, self.datum.to_str(ccx))
} }
} }

View file

@ -173,7 +173,7 @@ pub fn BuilderRef_res(b: BuilderRef) -> BuilderRef_res {
} }
} }
pub type ExternMap = HashMap<StrBuf, ValueRef>; pub type ExternMap = HashMap<String, ValueRef>;
// Here `self_ty` is the real type of the self parameter to this method. It // Here `self_ty` is the real type of the self parameter to this method. It
// will only be set in the case of default methods. // will only be set in the case of default methods.
@ -194,12 +194,12 @@ impl param_substs {
} }
} }
fn param_substs_to_str(this: &param_substs, tcx: &ty::ctxt) -> StrBuf { fn param_substs_to_str(this: &param_substs, tcx: &ty::ctxt) -> String {
format_strbuf!("param_substs({})", this.substs.repr(tcx)) format_strbuf!("param_substs({})", this.substs.repr(tcx))
} }
impl Repr for param_substs { impl Repr for param_substs {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
param_substs_to_str(self, tcx) param_substs_to_str(self, tcx)
} }
} }
@ -442,15 +442,15 @@ impl<'a> Block<'a> {
} }
pub fn sess(&self) -> &'a Session { self.fcx.ccx.sess() } pub fn sess(&self) -> &'a Session { self.fcx.ccx.sess() }
pub fn ident(&self, ident: Ident) -> StrBuf { pub fn ident(&self, ident: Ident) -> String {
token::get_ident(ident).get().to_strbuf() token::get_ident(ident).get().to_strbuf()
} }
pub fn node_id_to_str(&self, id: ast::NodeId) -> StrBuf { pub fn node_id_to_str(&self, id: ast::NodeId) -> String {
self.tcx().map.node_to_str(id).to_strbuf() self.tcx().map.node_to_str(id).to_strbuf()
} }
pub fn expr_to_str(&self, e: &ast::Expr) -> StrBuf { pub fn expr_to_str(&self, e: &ast::Expr) -> String {
e.repr(self.tcx()) e.repr(self.tcx())
} }
@ -464,19 +464,19 @@ impl<'a> Block<'a> {
} }
} }
pub fn val_to_str(&self, val: ValueRef) -> StrBuf { pub fn val_to_str(&self, val: ValueRef) -> String {
self.ccx().tn.val_to_str(val) self.ccx().tn.val_to_str(val)
} }
pub fn llty_str(&self, ty: Type) -> StrBuf { pub fn llty_str(&self, ty: Type) -> String {
self.ccx().tn.type_to_str(ty) self.ccx().tn.type_to_str(ty)
} }
pub fn ty_to_str(&self, t: ty::t) -> StrBuf { pub fn ty_to_str(&self, t: ty::t) -> String {
t.repr(self.tcx()) t.repr(self.tcx())
} }
pub fn to_str(&self) -> StrBuf { pub fn to_str(&self) -> String {
let blk: *Block = self; let blk: *Block = self;
format_strbuf!("[block {}]", blk) format_strbuf!("[block {}]", blk)
} }

View file

@ -45,9 +45,9 @@ pub struct Stats {
pub n_inlines: Cell<uint>, pub n_inlines: Cell<uint>,
pub n_closures: Cell<uint>, pub n_closures: Cell<uint>,
pub n_llvm_insns: Cell<uint>, pub n_llvm_insns: Cell<uint>,
pub llvm_insns: RefCell<HashMap<StrBuf, uint>>, pub llvm_insns: RefCell<HashMap<String, uint>>,
// (ident, time-in-ms, llvm-instructions) // (ident, time-in-ms, llvm-instructions)
pub fn_stats: RefCell<Vec<(StrBuf, uint, uint)> >, pub fn_stats: RefCell<Vec<(String, uint, uint)> >,
} }
pub struct CrateContext { pub struct CrateContext {
@ -60,7 +60,7 @@ pub struct CrateContext {
pub item_vals: RefCell<NodeMap<ValueRef>>, pub item_vals: RefCell<NodeMap<ValueRef>>,
pub exp_map2: resolve::ExportMap2, pub exp_map2: resolve::ExportMap2,
pub reachable: NodeSet, pub reachable: NodeSet,
pub item_symbols: RefCell<NodeMap<StrBuf>>, pub item_symbols: RefCell<NodeMap<String>>,
pub link_meta: LinkMeta, pub link_meta: LinkMeta,
pub drop_glues: RefCell<HashMap<ty::t, ValueRef>>, pub drop_glues: RefCell<HashMap<ty::t, ValueRef>>,
pub tydescs: RefCell<HashMap<ty::t, Rc<tydesc_info>>>, pub tydescs: RefCell<HashMap<ty::t, Rc<tydesc_info>>>,
@ -109,8 +109,8 @@ pub struct CrateContext {
pub llsizingtypes: RefCell<HashMap<ty::t, Type>>, pub llsizingtypes: RefCell<HashMap<ty::t, Type>>,
pub adt_reprs: RefCell<HashMap<ty::t, Rc<adt::Repr>>>, pub adt_reprs: RefCell<HashMap<ty::t, Rc<adt::Repr>>>,
pub symbol_hasher: RefCell<Sha256>, pub symbol_hasher: RefCell<Sha256>,
pub type_hashcodes: RefCell<HashMap<ty::t, StrBuf>>, pub type_hashcodes: RefCell<HashMap<ty::t, String>>,
pub all_llvm_symbols: RefCell<HashSet<StrBuf>>, pub all_llvm_symbols: RefCell<HashSet<String>>,
pub tcx: ty::ctxt, pub tcx: ty::ctxt,
pub stats: Stats, pub stats: Stats,
pub int_type: Type, pub int_type: Type,

View file

@ -624,7 +624,7 @@ impl<K:KindOps> Datum<K> {
} }
#[allow(dead_code)] // useful for debugging #[allow(dead_code)] // useful for debugging
pub fn to_str(&self, ccx: &CrateContext) -> StrBuf { pub fn to_str(&self, ccx: &CrateContext) -> String {
format_strbuf!("Datum({}, {}, {:?})", format_strbuf!("Datum({}, {}, {:?})",
ccx.tn.val_to_str(self.val), ccx.tn.val_to_str(self.val),
ty_to_str(ccx.tcx(), self.ty), ty_to_str(ccx.tcx(), self.ty),

View file

@ -149,7 +149,7 @@ use collections::HashMap;
use collections::HashSet; use collections::HashSet;
use libc::{c_uint, c_ulonglong, c_longlong}; use libc::{c_uint, c_ulonglong, c_longlong};
use std::ptr; use std::ptr;
use std::strbuf::StrBuf; use std::string::String;
use std::sync::atomics; use std::sync::atomics;
use syntax::codemap::{Span, Pos}; use syntax::codemap::{Span, Pos};
use syntax::{abi, ast, codemap, ast_util, ast_map}; use syntax::{abi, ast, codemap, ast_util, ast_map};
@ -178,7 +178,7 @@ pub struct CrateDebugContext {
llcontext: ContextRef, llcontext: ContextRef,
builder: DIBuilderRef, builder: DIBuilderRef,
current_debug_location: Cell<DebugLocation>, current_debug_location: Cell<DebugLocation>,
created_files: RefCell<HashMap<StrBuf, DIFile>>, created_files: RefCell<HashMap<String, DIFile>>,
created_types: RefCell<HashMap<uint, DIType>>, created_types: RefCell<HashMap<uint, DIType>>,
created_enum_disr_types: RefCell<HashMap<ast::DefId, DIType>>, created_enum_disr_types: RefCell<HashMap<ast::DefId, DIType>>,
namespace_map: RefCell<HashMap<Vec<ast::Name>, Rc<NamespaceTreeNode>>>, namespace_map: RefCell<HashMap<Vec<ast::Name>, Rc<NamespaceTreeNode>>>,
@ -719,7 +719,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
}; };
// get_template_parameters() will append a `<...>` clause to the function name if necessary. // get_template_parameters() will append a `<...>` clause to the function name if necessary.
let mut function_name = StrBuf::from_str(token::get_ident(ident).get()); let mut function_name = String::from_str(token::get_ident(ident).get());
let template_parameters = get_template_parameters(cx, let template_parameters = get_template_parameters(cx,
generics, generics,
param_substs, param_substs,
@ -824,7 +824,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
generics: &ast::Generics, generics: &ast::Generics,
param_substs: Option<&param_substs>, param_substs: Option<&param_substs>,
file_metadata: DIFile, file_metadata: DIFile,
name_to_append_suffix_to: &mut StrBuf) name_to_append_suffix_to: &mut String)
-> DIArray { -> DIArray {
let self_type = match param_substs { let self_type = match param_substs {
Some(param_substs) => param_substs.substs.self_ty, Some(param_substs) => param_substs.substs.self_ty,
@ -1454,7 +1454,7 @@ impl GeneralMemberDescriptionFactory {
} }
struct EnumVariantMemberDescriptionFactory { struct EnumVariantMemberDescriptionFactory {
args: Vec<(StrBuf, ty::t)> , args: Vec<(String, ty::t)> ,
discriminant_type_metadata: Option<DIType>, discriminant_type_metadata: Option<DIType>,
span: Span, span: Span,
} }
@ -1525,7 +1525,7 @@ fn describe_enum_variant(cx: &CrateContext,
} }
// Build an array of (field name, field type) pairs to be captured in the factory closure. // Build an array of (field name, field type) pairs to be captured in the factory closure.
let args: Vec<(StrBuf, ty::t)> = arg_names.iter() let args: Vec<(String, ty::t)> = arg_names.iter()
.zip(struct_def.fields.iter()) .zip(struct_def.fields.iter())
.map(|(s, &t)| (s.to_strbuf(), t)) .map(|(s, &t)| (s.to_strbuf(), t))
.collect(); .collect();
@ -1732,7 +1732,7 @@ enum MemberOffset {
} }
struct MemberDescription { struct MemberDescription {
name: StrBuf, name: String,
llvm_type: Type, llvm_type: Type,
type_metadata: DIType, type_metadata: DIType,
offset: MemberOffset, offset: MemberOffset,
@ -2339,7 +2339,7 @@ fn cache_id_for_type(t: ty::t) -> uint {
// Used to avoid LLVM metadata uniquing problems. See `create_struct_stub()` and // Used to avoid LLVM metadata uniquing problems. See `create_struct_stub()` and
// `prepare_enum_metadata()`. // `prepare_enum_metadata()`.
fn generate_unique_type_id(prefix: &'static str) -> StrBuf { fn generate_unique_type_id(prefix: &'static str) -> String {
unsafe { unsafe {
static mut unique_id_counter: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT; static mut unique_id_counter: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
format_strbuf!("{}{}", format_strbuf!("{}{}",
@ -2841,7 +2841,7 @@ fn populate_scope_map(cx: &CrateContext,
ast::ExprInlineAsm(ast::InlineAsm { inputs: ref inputs, ast::ExprInlineAsm(ast::InlineAsm { inputs: ref inputs,
outputs: ref outputs, outputs: ref outputs,
.. }) => { .. }) => {
// inputs, outputs: ~[(StrBuf, @expr)] // inputs, outputs: ~[(String, @expr)]
for &(_, exp) in inputs.iter() { for &(_, exp) in inputs.iter() {
walk_expr(cx, exp, scope_stack, scope_map); walk_expr(cx, exp, scope_stack, scope_map);
} }
@ -2866,8 +2866,8 @@ struct NamespaceTreeNode {
} }
impl NamespaceTreeNode { impl NamespaceTreeNode {
fn mangled_name_of_contained_item(&self, item_name: &str) -> StrBuf { fn mangled_name_of_contained_item(&self, item_name: &str) -> String {
fn fill_nested(node: &NamespaceTreeNode, output: &mut StrBuf) { fn fill_nested(node: &NamespaceTreeNode, output: &mut String) {
match node.parent { match node.parent {
Some(ref parent) => fill_nested(&*parent.upgrade().unwrap(), output), Some(ref parent) => fill_nested(&*parent.upgrade().unwrap(), output),
None => {} None => {}
@ -2877,7 +2877,7 @@ impl NamespaceTreeNode {
output.push_str(string.get()); output.push_str(string.get());
} }
let mut name = StrBuf::from_str("_ZN"); let mut name = String::from_str("_ZN");
fill_nested(self, &mut name); fill_nested(self, &mut name);
name.push_str(format!("{}", item_name.len()).as_slice()); name.push_str(format!("{}", item_name.len()).as_slice());
name.push_str(item_name); name.push_str(item_name);

View file

@ -86,7 +86,7 @@ pub enum Dest {
} }
impl Dest { impl Dest {
pub fn to_str(&self, ccx: &CrateContext) -> StrBuf { pub fn to_str(&self, ccx: &CrateContext) -> String {
match *self { match *self {
SaveIn(v) => format_strbuf!("SaveIn({})", ccx.tn.val_to_str(v)), SaveIn(v) => format_strbuf!("SaveIn({})", ccx.tn.val_to_str(v)),
Ignore => "Ignore".to_strbuf() Ignore => "Ignore".to_strbuf()

View file

@ -496,7 +496,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &ast::ForeignMod) {
pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext, pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
sp: Span, sp: Span,
sym: StrBuf, sym: String,
node_id: ast::NodeId) node_id: ast::NodeId)
-> ValueRef { -> ValueRef {
let _icx = push_ctxt("foreign::register_foreign_fn"); let _icx = push_ctxt("foreign::register_foreign_fn");

View file

@ -13,24 +13,24 @@ use middle::trans::type_::Type;
use lib::llvm::ValueRef; use lib::llvm::ValueRef;
pub trait LlvmRepr { pub trait LlvmRepr {
fn llrepr(&self, ccx: &CrateContext) -> StrBuf; fn llrepr(&self, ccx: &CrateContext) -> String;
} }
impl<'a, T:LlvmRepr> LlvmRepr for &'a [T] { impl<'a, T:LlvmRepr> LlvmRepr for &'a [T] {
fn llrepr(&self, ccx: &CrateContext) -> StrBuf { fn llrepr(&self, ccx: &CrateContext) -> String {
let reprs: Vec<StrBuf> = self.iter().map(|t| t.llrepr(ccx)).collect(); let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
format_strbuf!("[{}]", reprs.connect(",")) format_strbuf!("[{}]", reprs.connect(","))
} }
} }
impl LlvmRepr for Type { impl LlvmRepr for Type {
fn llrepr(&self, ccx: &CrateContext) -> StrBuf { fn llrepr(&self, ccx: &CrateContext) -> String {
ccx.tn.type_to_str(*self) ccx.tn.type_to_str(*self)
} }
} }
impl LlvmRepr for ValueRef { impl LlvmRepr for ValueRef {
fn llrepr(&self, ccx: &CrateContext) -> StrBuf { fn llrepr(&self, ccx: &CrateContext) -> String {
ccx.tn.val_to_str(*self) ccx.tn.val_to_str(*self)
} }
} }

View file

@ -73,7 +73,7 @@ pub struct VecTypes {
} }
impl VecTypes { impl VecTypes {
pub fn to_str(&self, ccx: &CrateContext) -> StrBuf { pub fn to_str(&self, ccx: &CrateContext) -> String {
format_strbuf!("VecTypes \\{unit_ty={}, llunit_ty={}, \ format_strbuf!("VecTypes \\{unit_ty={}, llunit_ty={}, \
llunit_size={}, llunit_alloc_size={}\\}", llunit_size={}, llunit_alloc_size={}\\}",
ty_to_str(ccx.tcx(), self.unit_ty), ty_to_str(ccx.tcx(), self.unit_ty),

View file

@ -302,7 +302,7 @@ pub fn llvm_type_name(cx: &CrateContext,
what: named_ty, what: named_ty,
did: ast::DefId, did: ast::DefId,
tps: &[ty::t]) tps: &[ty::t])
-> StrBuf { -> String {
let name = match what { let name = match what {
a_struct => { "struct" } a_struct => { "struct" }
an_enum => { "enum" } an_enum => { "enum" }

View file

@ -278,7 +278,7 @@ pub struct ctxt {
pub freevars: RefCell<freevars::freevar_map>, pub freevars: RefCell<freevars::freevar_map>,
pub tcache: type_cache, pub tcache: type_cache,
pub rcache: creader_cache, pub rcache: creader_cache,
pub short_names_cache: RefCell<HashMap<t, StrBuf>>, pub short_names_cache: RefCell<HashMap<t, String>>,
pub needs_unwind_cleanup_cache: RefCell<HashMap<t, bool>>, pub needs_unwind_cleanup_cache: RefCell<HashMap<t, bool>>,
pub tc_cache: RefCell<HashMap<uint, TypeContents>>, pub tc_cache: RefCell<HashMap<uint, TypeContents>>,
pub ast_ty_to_ty_cache: RefCell<NodeMap<ast_ty_to_ty_cache_entry>>, pub ast_ty_to_ty_cache: RefCell<NodeMap<ast_ty_to_ty_cache_entry>>,
@ -1540,7 +1540,7 @@ pub fn substs_is_noop(substs: &substs) -> bool {
substs.self_ty.is_none() substs.self_ty.is_none()
} }
pub fn substs_to_str(cx: &ctxt, substs: &substs) -> StrBuf { pub fn substs_to_str(cx: &ctxt, substs: &substs) -> String {
substs.repr(cx) substs.repr(cx)
} }
@ -3201,7 +3201,7 @@ pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
token::get_name(name), token::get_name(name),
fields.iter() fields.iter()
.map(|f| token::get_ident(f.ident).get().to_strbuf()) .map(|f| token::get_ident(f.ident).get().to_strbuf())
.collect::<Vec<StrBuf>>()).as_slice()); .collect::<Vec<String>>()).as_slice());
} }
pub fn method_idx(id: ast::Ident, meths: &[Rc<Method>]) -> Option<uint> { pub fn method_idx(id: ast::Ident, meths: &[Rc<Method>]) -> Option<uint> {
@ -3224,7 +3224,7 @@ pub fn param_tys_in_type(ty: t) -> Vec<param_ty> {
rslt rslt
} }
pub fn ty_sort_str(cx: &ctxt, t: t) -> StrBuf { pub fn ty_sort_str(cx: &ctxt, t: t) -> String {
match get(t).sty { match get(t).sty {
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) |
ty_uint(_) | ty_float(_) | ty_str => { ty_uint(_) | ty_float(_) | ty_str => {
@ -3255,7 +3255,7 @@ pub fn ty_sort_str(cx: &ctxt, t: t) -> StrBuf {
} }
} }
pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> StrBuf { pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
/*! /*!
* *
* Explains the source of a type err in a short, * Explains the source of a type err in a short,
@ -3265,7 +3265,7 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> StrBuf {
* to present additional details, particularly when * to present additional details, particularly when
* it comes to lifetime-related errors. */ * it comes to lifetime-related errors. */
fn tstore_to_closure(s: &TraitStore) -> StrBuf { fn tstore_to_closure(s: &TraitStore) -> String {
match s { match s {
&UniqTraitStore => "proc".to_strbuf(), &UniqTraitStore => "proc".to_strbuf(),
&RegionTraitStore(..) => "closure".to_strbuf() &RegionTraitStore(..) => "closure".to_strbuf()
@ -3708,7 +3708,7 @@ pub fn substd_enum_variants(cx: &ctxt,
}).collect() }).collect()
} }
pub fn item_path_str(cx: &ctxt, id: ast::DefId) -> StrBuf { pub fn item_path_str(cx: &ctxt, id: ast::DefId) -> String {
with_path(cx, id, |path| ast_map::path_to_str(path)).to_strbuf() with_path(cx, id, |path| ast_map::path_to_str(path)).to_strbuf()
} }
@ -4276,14 +4276,14 @@ pub fn each_bound_trait_and_supertraits(tcx: &ctxt,
return true; return true;
} }
pub fn get_tydesc_ty(tcx: &ctxt) -> Result<t, StrBuf> { pub fn get_tydesc_ty(tcx: &ctxt) -> Result<t, String> {
tcx.lang_items.require(TyDescStructLangItem).map(|tydesc_lang_item| { tcx.lang_items.require(TyDescStructLangItem).map(|tydesc_lang_item| {
tcx.intrinsic_defs.borrow().find_copy(&tydesc_lang_item) tcx.intrinsic_defs.borrow().find_copy(&tydesc_lang_item)
.expect("Failed to resolve TyDesc") .expect("Failed to resolve TyDesc")
}) })
} }
pub fn get_opaque_ty(tcx: &ctxt) -> Result<t, StrBuf> { pub fn get_opaque_ty(tcx: &ctxt) -> Result<t, String> {
tcx.lang_items.require(OpaqueStructLangItem).map(|opaque_lang_item| { tcx.lang_items.require(OpaqueStructLangItem).map(|opaque_lang_item| {
tcx.intrinsic_defs.borrow().find_copy(&opaque_lang_item) tcx.intrinsic_defs.borrow().find_copy(&opaque_lang_item)
.expect("Failed to resolve Opaque") .expect("Failed to resolve Opaque")
@ -4291,7 +4291,7 @@ pub fn get_opaque_ty(tcx: &ctxt) -> Result<t, StrBuf> {
} }
pub fn visitor_object_ty(tcx: &ctxt, pub fn visitor_object_ty(tcx: &ctxt,
region: ty::Region) -> Result<(Rc<TraitRef>, t), StrBuf> { region: ty::Region) -> Result<(Rc<TraitRef>, t), String> {
let trait_lang_item = match tcx.lang_items.require(TyVisitorTraitLangItem) { let trait_lang_item = match tcx.lang_items.require(TyVisitorTraitLangItem) {
Ok(id) => id, Ok(id) => id,
Err(s) => { return Err(s); } Err(s) => { return Err(s); }

View file

@ -1495,11 +1495,11 @@ impl<'a> LookupContext<'a> {
self.fcx.tcx() self.fcx.tcx()
} }
fn ty_to_str(&self, t: ty::t) -> StrBuf { fn ty_to_str(&self, t: ty::t) -> String {
self.fcx.infcx().ty_to_str(t) self.fcx.infcx().ty_to_str(t)
} }
fn did_to_str(&self, did: DefId) -> StrBuf { fn did_to_str(&self, did: DefId) -> String {
ty::item_path_str(self.tcx(), did) ty::item_path_str(self.tcx(), did)
} }
@ -1509,7 +1509,7 @@ impl<'a> LookupContext<'a> {
} }
impl Repr for Candidate { impl Repr for Candidate {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
format_strbuf!("Candidate(rcvr_ty={}, rcvr_substs={}, method_ty={}, \ format_strbuf!("Candidate(rcvr_ty={}, rcvr_substs={}, method_ty={}, \
origin={:?})", origin={:?})",
self.rcvr_match_condition.repr(tcx), self.rcvr_match_condition.repr(tcx),
@ -1520,7 +1520,7 @@ impl Repr for Candidate {
} }
impl Repr for RcvrMatchCondition { impl Repr for RcvrMatchCondition {
fn repr(&self, tcx: &ty::ctxt) -> StrBuf { fn repr(&self, tcx: &ty::ctxt) -> String {
match *self { match *self {
RcvrMatchesIfObject(d) => { RcvrMatchesIfObject(d) => {
format_strbuf!("RcvrMatchesIfObject({})", d.repr(tcx)) format_strbuf!("RcvrMatchesIfObject({})", d.repr(tcx))

View file

@ -468,7 +468,7 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
let ret_ty = fn_sig.output; let ret_ty = fn_sig.output;
debug!("check_fn(arg_tys={:?}, ret_ty={:?})", debug!("check_fn(arg_tys={:?}, ret_ty={:?})",
arg_tys.iter().map(|&a| ppaux::ty_to_str(tcx, a)).collect::<Vec<StrBuf>>(), arg_tys.iter().map(|&a| ppaux::ty_to_str(tcx, a)).collect::<Vec<String>>(),
ppaux::ty_to_str(tcx, ret_ty)); ppaux::ty_to_str(tcx, ret_ty));
// Create the function context. This is either derived from scratch or, // Create the function context. This is either derived from scratch or,
@ -1100,7 +1100,7 @@ impl<'a> RegionScope for infer::InferCtxt<'a> {
} }
impl<'a> FnCtxt<'a> { impl<'a> FnCtxt<'a> {
pub fn tag(&self) -> StrBuf { pub fn tag(&self) -> String {
format_strbuf!("{}", self as *FnCtxt) format_strbuf!("{}", self as *FnCtxt)
} }
@ -1176,7 +1176,7 @@ impl<'a> FnCtxt<'a> {
ast_ty_to_ty(self, self.infcx(), ast_t) ast_ty_to_ty(self, self.infcx(), ast_t)
} }
pub fn pat_to_str(&self, pat: &ast::Pat) -> StrBuf { pub fn pat_to_str(&self, pat: &ast::Pat) -> String {
pat.repr(self.tcx()) pat.repr(self.tcx())
} }
@ -1283,7 +1283,7 @@ impl<'a> FnCtxt<'a> {
pub fn type_error_message(&self, pub fn type_error_message(&self,
sp: Span, sp: Span,
mk_msg: |StrBuf| -> StrBuf, mk_msg: |String| -> String,
actual_ty: ty::t, actual_ty: ty::t,
err: Option<&ty::type_err>) { err: Option<&ty::type_err>) {
self.infcx().type_error_message(sp, mk_msg, actual_ty, err); self.infcx().type_error_message(sp, mk_msg, actual_ty, err);
@ -1800,7 +1800,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
}; };
debug!("check_argument_types: formal_tys={:?}", debug!("check_argument_types: formal_tys={:?}",
formal_tys.iter().map(|t| fcx.infcx().ty_to_str(*t)).collect::<Vec<StrBuf>>()); formal_tys.iter().map(|t| fcx.infcx().ty_to_str(*t)).collect::<Vec<String>>());
// Check the arguments. // Check the arguments.
// We do this in a pretty awful way: first we typecheck any arguments // We do this in a pretty awful way: first we typecheck any arguments

View file

@ -71,7 +71,7 @@ use syntax::abi;
pub trait Combine { pub trait Combine {
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a>; fn infcx<'a>(&'a self) -> &'a InferCtxt<'a>;
fn tag(&self) -> StrBuf; fn tag(&self) -> String;
fn a_is_expected(&self) -> bool; fn a_is_expected(&self) -> bool;
fn trace(&self) -> TypeTrace; fn trace(&self) -> TypeTrace;

View file

@ -77,7 +77,7 @@ use middle::typeck::infer::region_inference::SameRegions;
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::char::from_u32; use std::char::from_u32;
use std::rc::Rc; use std::rc::Rc;
use std::strbuf::StrBuf; use std::string::String;
use syntax::ast; use syntax::ast;
use syntax::ast_map; use syntax::ast_map;
use syntax::ast_util; use syntax::ast_util;
@ -103,12 +103,12 @@ pub trait ErrorReporting {
trace: TypeTrace, trace: TypeTrace,
terr: &ty::type_err); terr: &ty::type_err);
fn values_str(&self, values: &ValuePairs) -> Option<StrBuf>; fn values_str(&self, values: &ValuePairs) -> Option<String>;
fn expected_found_str<T:UserString+Resolvable>( fn expected_found_str<T:UserString+Resolvable>(
&self, &self,
exp_found: &ty::expected_found<T>) exp_found: &ty::expected_found<T>)
-> Option<StrBuf>; -> Option<String>;
fn report_concrete_failure(&self, fn report_concrete_failure(&self,
origin: SubregionOrigin, origin: SubregionOrigin,
@ -365,7 +365,7 @@ impl<'a> ErrorReporting for InferCtxt<'a> {
ty::note_and_explain_type_err(self.tcx, terr); ty::note_and_explain_type_err(self.tcx, terr);
} }
fn values_str(&self, values: &ValuePairs) -> Option<StrBuf> { fn values_str(&self, values: &ValuePairs) -> Option<String> {
/*! /*!
* Returns a string of the form "expected `{}` but found `{}`", * Returns a string of the form "expected `{}` but found `{}`",
* or None if this is a derived error. * or None if this is a derived error.
@ -383,7 +383,7 @@ impl<'a> ErrorReporting for InferCtxt<'a> {
fn expected_found_str<T:UserString+Resolvable>( fn expected_found_str<T:UserString+Resolvable>(
&self, &self,
exp_found: &ty::expected_found<T>) exp_found: &ty::expected_found<T>)
-> Option<StrBuf> -> Option<String>
{ {
let expected = exp_found.expected.resolve(self); let expected = exp_found.expected.resolve(self);
if expected.contains_error() { if expected.contains_error() {
@ -1466,7 +1466,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
// LifeGiver is responsible for generating fresh lifetime names // LifeGiver is responsible for generating fresh lifetime names
struct LifeGiver { struct LifeGiver {
taken: HashSet<StrBuf>, taken: HashSet<String>,
counter: Cell<uint>, counter: Cell<uint>,
generated: RefCell<Vec<ast::Lifetime>>, generated: RefCell<Vec<ast::Lifetime>>,
} }
@ -1506,8 +1506,8 @@ impl LifeGiver {
return lifetime; return lifetime;
// 0 .. 25 generates a .. z, 26 .. 51 generates aa .. zz, and so on // 0 .. 25 generates a .. z, 26 .. 51 generates aa .. zz, and so on
fn num_to_str(counter: uint) -> StrBuf { fn num_to_str(counter: uint) -> String {
let mut s = StrBuf::new(); let mut s = String::new();
let (n, r) = (counter/26 + 1, counter % 26); let (n, r) = (counter/26 + 1, counter % 26);
let letter: char = from_u32((r+97) as u32).unwrap(); let letter: char = from_u32((r+97) as u32).unwrap();
for _ in range(0, n) { for _ in range(0, n) {

View file

@ -36,7 +36,7 @@ impl<'f> Glb<'f> {
impl<'f> Combine for Glb<'f> { impl<'f> Combine for Glb<'f> {
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a> { self.get_ref().infcx } fn infcx<'a>(&'a self) -> &'a InferCtxt<'a> { self.get_ref().infcx }
fn tag(&self) -> StrBuf { "glb".to_strbuf() } fn tag(&self) -> String { "glb".to_strbuf() }
fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected } fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected }
fn trace(&self) -> TypeTrace { self.get_ref().trace.clone() } fn trace(&self) -> TypeTrace { self.get_ref().trace.clone() }

Some files were not shown because too many files have changed in this diff Show more