mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
core: rename strbuf::StrBuf to string::String
[breaking-change]
This commit is contained in:
parent
bbb70cdd9c
commit
553074506e
@ -56,10 +56,10 @@ impl fmt::Show for Mode {
|
||||
#[deriving(Clone)]
|
||||
pub struct Config {
|
||||
// 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
|
||||
pub run_lib_path: StrBuf,
|
||||
pub run_lib_path: String,
|
||||
|
||||
// The rustc executable
|
||||
pub rustc_path: Path,
|
||||
@ -80,7 +80,7 @@ pub struct Config {
|
||||
pub aux_base: Path,
|
||||
|
||||
// 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
|
||||
pub mode: Mode,
|
||||
@ -113,37 +113,37 @@ pub struct Config {
|
||||
|
||||
// A command line to prefix program execution with,
|
||||
// for running under valgrind
|
||||
pub runtool: Option<StrBuf>,
|
||||
pub runtool: Option<String>,
|
||||
|
||||
// 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
|
||||
pub target_rustcflags: Option<StrBuf>,
|
||||
pub target_rustcflags: Option<String>,
|
||||
|
||||
// Run tests using the JIT
|
||||
pub jit: bool,
|
||||
|
||||
// Target system to be tested
|
||||
pub target: StrBuf,
|
||||
pub target: String,
|
||||
|
||||
// Host triple for the compiler being invoked
|
||||
pub host: StrBuf,
|
||||
pub host: String,
|
||||
|
||||
// Path to the android tools
|
||||
pub android_cross_path: Path,
|
||||
|
||||
// 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
|
||||
pub adb_test_dir: StrBuf,
|
||||
pub adb_test_dir: String,
|
||||
|
||||
// status whether android device available or not
|
||||
pub adb_device_status: bool,
|
||||
|
||||
// the path containing LLDB's Python module
|
||||
pub lldb_python_dir: Option<StrBuf>,
|
||||
pub lldb_python_dir: Option<String>,
|
||||
|
||||
// Explain what's going on
|
||||
pub verbose: bool
|
||||
|
@ -56,7 +56,7 @@ pub fn main() {
|
||||
run_tests(&config);
|
||||
}
|
||||
|
||||
pub fn parse_config(args: Vec<StrBuf> ) -> Config {
|
||||
pub fn parse_config(args: Vec<String> ) -> Config {
|
||||
|
||||
let groups : Vec<getopts::OptGroup> =
|
||||
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"));
|
||||
}
|
||||
|
||||
pub fn opt_str<'a>(maybestr: &'a Option<StrBuf>) -> &'a str {
|
||||
pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {
|
||||
match *maybestr {
|
||||
None => "(none)",
|
||||
Some(ref s) => s.as_slice(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn opt_str2(maybestr: Option<StrBuf>) -> StrBuf {
|
||||
pub fn opt_str2(maybestr: Option<String>) -> String {
|
||||
match maybestr {
|
||||
None => "(none)".to_strbuf(),
|
||||
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 {
|
||||
|
||||
// Try to elide redundant long paths
|
||||
fn shorten(path: &Path) -> StrBuf {
|
||||
fn shorten(path: &Path) -> String {
|
||||
let filename = path.filename_str();
|
||||
let p = path.dir_path();
|
||||
let dir = p.filename_str();
|
||||
|
@ -13,8 +13,8 @@ use regex::Regex;
|
||||
|
||||
pub struct ExpectedError {
|
||||
pub line: uint,
|
||||
pub kind: StrBuf,
|
||||
pub msg: StrBuf,
|
||||
pub kind: String,
|
||||
pub msg: String,
|
||||
}
|
||||
|
||||
pub static EXPECTED_PATTERN : &'static str = r"//~(?P<adjusts>\^*)\s*(?P<kind>\S*)\s*(?P<msg>.*)";
|
||||
|
@ -14,20 +14,20 @@ use util;
|
||||
|
||||
pub struct TestProps {
|
||||
// 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
|
||||
pub compile_flags: Option<StrBuf>,
|
||||
pub compile_flags: Option<String>,
|
||||
// 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
|
||||
// pretty-printed
|
||||
pub pp_exact: Option<Path>,
|
||||
// Modules from aux directory that should be compiled
|
||||
pub aux_builds: Vec<StrBuf> ,
|
||||
pub aux_builds: Vec<String> ,
|
||||
// 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
|
||||
pub check_lines: Vec<StrBuf> ,
|
||||
pub check_lines: Vec<String> ,
|
||||
// Flag to force a crate to be built with the host architecture
|
||||
pub force_host: bool,
|
||||
// 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 {
|
||||
fn ignore_target(config: &Config) -> StrBuf {
|
||||
fn ignore_target(config: &Config) -> String {
|
||||
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-{}",
|
||||
config.stage_id.as_slice().split('-').next().unwrap())
|
||||
}
|
||||
@ -169,23 +169,23 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
|
||||
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())
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
fn parse_check_line(line: &str) -> Option<StrBuf> {
|
||||
fn parse_check_line(line: &str) -> Option<String> {
|
||||
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")
|
||||
}
|
||||
|
||||
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| {
|
||||
// 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)
|
||||
.map(|s| s.to_strbuf())
|
||||
.collect();
|
||||
@ -241,8 +241,8 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
|
||||
line.contains(directive)
|
||||
}
|
||||
|
||||
pub fn parse_name_value_directive(line: &str, directive: StrBuf)
|
||||
-> Option<StrBuf> {
|
||||
pub fn parse_name_value_directive(line: &str, directive: String)
|
||||
-> Option<String> {
|
||||
let keycolon = format_strbuf!("{}:", directive);
|
||||
match line.find_str(keycolon.as_slice()) {
|
||||
Some(colon) => {
|
||||
|
@ -13,7 +13,7 @@ use std::str;
|
||||
use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
|
||||
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 mut aux_path = prog.to_strbuf();
|
||||
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
|
||||
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();
|
||||
match env.iter().position(|&(ref k, _)| k.as_slice() == var) {
|
||||
Some(i) => { env.remove(i); }
|
||||
@ -40,13 +40,13 @@ fn target_env(lib_path: &str, prog: &str) -> Vec<(StrBuf, StrBuf)> {
|
||||
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,
|
||||
prog: &str,
|
||||
args: &[StrBuf],
|
||||
env: Vec<(StrBuf, StrBuf)> ,
|
||||
input: Option<StrBuf>) -> Option<Result> {
|
||||
args: &[String],
|
||||
env: Vec<(String, String)> ,
|
||||
input: Option<String>) -> Option<Result> {
|
||||
|
||||
let env = env.clone().append(target_env(lib_path, prog).as_slice());
|
||||
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,
|
||||
prog: &str,
|
||||
args: &[StrBuf],
|
||||
env: Vec<(StrBuf, StrBuf)> ,
|
||||
input: Option<StrBuf>) -> Option<Process> {
|
||||
args: &[String],
|
||||
env: Vec<(String, String)> ,
|
||||
input: Option<String>) -> Option<Process> {
|
||||
|
||||
let env = env.clone().append(target_env(lib_path, prog).as_slice());
|
||||
match Command::new(prog).args(args).env(env.as_slice()).spawn() {
|
||||
|
@ -28,11 +28,11 @@ use std::io::timer;
|
||||
use std::io;
|
||||
use std::os;
|
||||
use std::str;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use std::task;
|
||||
use test::MetricMap;
|
||||
|
||||
pub fn run(config: Config, testfile: StrBuf) {
|
||||
pub fn run(config: Config, testfile: String) {
|
||||
|
||||
match config.target.as_slice() {
|
||||
|
||||
@ -49,7 +49,7 @@ pub fn run(config: Config, testfile: StrBuf) {
|
||||
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 {
|
||||
// We're going to be dumping a lot of info. Start on a new line.
|
||||
print!("\n\n");
|
||||
@ -231,7 +231,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
fn print_source(config: &Config,
|
||||
props: &TestProps,
|
||||
testfile: &Path,
|
||||
src: StrBuf,
|
||||
src: String,
|
||||
pretty_type: &str) -> ProcRes {
|
||||
compose_and_run(config,
|
||||
testfile,
|
||||
@ -247,7 +247,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
fn make_pp_args(config: &Config,
|
||||
props: &TestProps,
|
||||
testfile: &Path,
|
||||
pretty_type: StrBuf) -> ProcArgs {
|
||||
pretty_type: String) -> ProcArgs {
|
||||
let aux_dir = aux_output_dir_name(config, testfile);
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let mut args = vec!("-".to_strbuf(),
|
||||
@ -284,7 +284,7 @@ actual:\n\
|
||||
}
|
||||
|
||||
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);
|
||||
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
|
||||
#[cfg(windows)]
|
||||
fn debugger() -> StrBuf {
|
||||
fn debugger() -> String {
|
||||
"gdb.exe".to_strbuf()
|
||||
}
|
||||
#[cfg(unix)]
|
||||
fn debugger() -> StrBuf {
|
||||
fn debugger() -> String {
|
||||
"gdb".to_strbuf()
|
||||
}
|
||||
|
||||
@ -540,7 +540,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
|
||||
// Write debugger script:
|
||||
// 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"
|
||||
for line in breakpoint_lines.iter() {
|
||||
@ -610,8 +610,8 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
}
|
||||
|
||||
struct DebuggerCommands {
|
||||
commands: Vec<StrBuf>,
|
||||
check_lines: Vec<StrBuf>,
|
||||
commands: Vec<String>,
|
||||
check_lines: Vec<String>,
|
||||
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() {
|
||||
return None;
|
||||
}
|
||||
@ -676,18 +676,18 @@ fn cleanup_debug_info_options(options: &Option<StrBuf>) -> Option<StrBuf> {
|
||||
let new_options =
|
||||
split_maybe_args(options).move_iter()
|
||||
.filter(|x| !options_to_remove.contains(x))
|
||||
.collect::<Vec<StrBuf>>()
|
||||
.collect::<Vec<String>>()
|
||||
.connect(" ")
|
||||
.to_strbuf();
|
||||
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();
|
||||
if num_check_lines > 0 {
|
||||
// Allow check lines to leave parts unspecified (e.g., uninitialized
|
||||
// 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| {
|
||||
s.as_slice()
|
||||
.trim()
|
||||
@ -812,10 +812,10 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||
|
||||
let prefixes = expected_errors.iter().map(|ee| {
|
||||
format_strbuf!("{}:{}:", testfile.display(), ee.line)
|
||||
}).collect::<Vec<StrBuf> >();
|
||||
}).collect::<Vec<String> >();
|
||||
|
||||
#[cfg(target_os = "win32")]
|
||||
fn to_lower( s : &str ) -> StrBuf {
|
||||
fn to_lower( s : &str ) -> String {
|
||||
let i = s.chars();
|
||||
let c : Vec<char> = i.map( |c| {
|
||||
if c.is_ascii() {
|
||||
@ -966,15 +966,15 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut uint) -> bool {
|
||||
}
|
||||
|
||||
struct ProcArgs {
|
||||
prog: StrBuf,
|
||||
args: Vec<StrBuf>,
|
||||
prog: String,
|
||||
args: Vec<String>,
|
||||
}
|
||||
|
||||
struct ProcRes {
|
||||
status: ProcessExit,
|
||||
stdout: StrBuf,
|
||||
stderr: StrBuf,
|
||||
cmdline: StrBuf,
|
||||
stdout: String,
|
||||
stderr: String,
|
||||
cmdline: String,
|
||||
}
|
||||
|
||||
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,
|
||||
testfile: &Path, extra_args: &[StrBuf]) -> ProcRes {
|
||||
testfile: &Path, extra_args: &[String]) -> ProcRes {
|
||||
let aux_dir = aux_output_dir_name(config, testfile);
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let link_args = vec!("-L".to_strbuf(),
|
||||
@ -1026,7 +1026,7 @@ fn compose_and_run_compiler(
|
||||
props: &TestProps,
|
||||
testfile: &Path,
|
||||
args: ProcArgs,
|
||||
input: Option<StrBuf>) -> ProcRes {
|
||||
input: Option<String>) -> ProcRes {
|
||||
|
||||
if !props.aux_builds.is_empty() {
|
||||
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,
|
||||
ProcArgs{ args, prog }: ProcArgs,
|
||||
procenv: Vec<(StrBuf, StrBuf)> ,
|
||||
procenv: Vec<(String, String)> ,
|
||||
lib_path: &str,
|
||||
input: Option<StrBuf>) -> ProcRes {
|
||||
input: Option<String>) -> ProcRes {
|
||||
return program_output(config, testfile, lib_path,
|
||||
prog, args, procenv, input);
|
||||
}
|
||||
@ -1107,7 +1107,7 @@ enum TargetLocation {
|
||||
|
||||
fn make_compile_args(config: &Config,
|
||||
props: &TestProps,
|
||||
extras: Vec<StrBuf> ,
|
||||
extras: Vec<String> ,
|
||||
xform: |&Config, &Path| -> TargetLocation,
|
||||
testfile: &Path)
|
||||
-> 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 {
|
||||
Some(ref s) => {
|
||||
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,
|
||||
args: Vec<StrBuf> , env: Vec<(StrBuf, StrBuf)> ,
|
||||
input: Option<StrBuf>) -> ProcRes {
|
||||
fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String,
|
||||
args: Vec<String> , env: Vec<(String, String)> ,
|
||||
input: Option<String>) -> ProcRes {
|
||||
let cmdline =
|
||||
{
|
||||
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 = "macos")]
|
||||
#[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(" "))
|
||||
}
|
||||
|
||||
#[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!("{} {} {}",
|
||||
lib_path_cmd_prefix(libpath),
|
||||
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
|
||||
// for diagnostic purposes
|
||||
#[cfg(target_os = "win32")]
|
||||
fn lib_path_cmd_prefix(path: &str) -> StrBuf {
|
||||
fn lib_path_cmd_prefix(path: &str) -> String {
|
||||
format_strbuf!("{}=\"{}\"",
|
||||
util::lib_path_env_var(),
|
||||
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\
|
||||
error: {}\n\
|
||||
status: {}\n\
|
||||
@ -1331,7 +1331,7 @@ stderr:\n\
|
||||
fn _arm_exec_compiled_test(config: &Config,
|
||||
props: &TestProps,
|
||||
testfile: &Path,
|
||||
env: Vec<(StrBuf, StrBuf)>)
|
||||
env: Vec<(String, String)>)
|
||||
-> ProcRes {
|
||||
let args = make_run_args(config, props, testfile);
|
||||
let cmdline = make_cmdline("",
|
||||
@ -1339,7 +1339,7 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
args.args.as_slice());
|
||||
|
||||
// get bare program string
|
||||
let mut tvec: Vec<StrBuf> = args.prog
|
||||
let mut tvec: Vec<String> = args.prog
|
||||
.as_slice()
|
||||
.split('/')
|
||||
.map(|ts| ts.to_strbuf())
|
||||
|
@ -33,7 +33,7 @@ pub fn get_os(triple: &str) -> &'static str {
|
||||
}
|
||||
|
||||
#[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
|
||||
// maintain the current value while adding our own
|
||||
@ -46,12 +46,12 @@ pub fn make_new_path(path: &str) -> StrBuf {
|
||||
}
|
||||
|
||||
#[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")]
|
||||
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);
|
||||
if config.verbose { println!("{}", s); }
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ Use [`ToStr`](../std/to_str/trait.ToStr.html).
|
||||
|
||||
~~~
|
||||
let x: int = 42;
|
||||
let y: StrBuf = x.to_str().to_strbuf();
|
||||
let y: String = x.to_str().to_strbuf();
|
||||
~~~
|
||||
|
||||
**String to int**
|
||||
@ -27,10 +27,10 @@ Use the `format_strbuf!` syntax extension.
|
||||
|
||||
~~~
|
||||
let x: int = 42;
|
||||
let y: StrBuf = format_strbuf!("{:t}", x); // binary
|
||||
let y: StrBuf = format_strbuf!("{:o}", x); // octal
|
||||
let y: StrBuf = format_strbuf!("{:x}", x); // lowercase hexadecimal
|
||||
let y: StrBuf = format_strbuf!("{:X}", x); // uppercase hexadecimal
|
||||
let y: String = format_strbuf!("{:t}", x); // binary
|
||||
let y: String = format_strbuf!("{:o}", x); // octal
|
||||
let y: String = format_strbuf!("{:x}", x); // lowercase hexadecimal
|
||||
let y: String = format_strbuf!("{:X}", x); // uppercase hexadecimal
|
||||
~~~
|
||||
|
||||
**String to int, in non-base-10**
|
||||
@ -58,15 +58,15 @@ let x: Option<&str> = str::from_utf8(bytes);
|
||||
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).
|
||||
|
||||
~~~
|
||||
use std::str;
|
||||
|
||||
let x: Option<StrBuf> =
|
||||
let x: Option<String> =
|
||||
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
|
||||
@ -198,7 +198,7 @@ enum Closed {}
|
||||
Phantom types are useful for enforcing state at compile time. For example:
|
||||
|
||||
~~~
|
||||
struct Door<State>(StrBuf);
|
||||
struct Door<State>(String);
|
||||
|
||||
struct Open;
|
||||
struct Closed;
|
||||
|
@ -1,3 +1,3 @@
|
||||
<link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico">
|
||||
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:400'
|
||||
rel='stylesheet' type='text/css'>
|
||||
rel='stylesheet' type='text/css'>
|
||||
|
@ -85,7 +85,7 @@ To take as an argument a fragment of Rust code, write `$` followed by a name
|
||||
`foo`.)
|
||||
* `expr` (an expression. Examples: `2 + 2`; `if true then { 1 } else { 2 }`;
|
||||
`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
|
||||
a declaration. Examples: `Some(t)`; `(17, 'a')`; `_`.)
|
||||
* `block` (a sequence of actions. Example: `{ log(error, "hi"); return 12; }`)
|
||||
|
@ -463,7 +463,7 @@ Here is the function that implements the child task:
|
||||
~~~
|
||||
extern crate sync;
|
||||
# fn main() {
|
||||
fn stringifier(channel: &sync::DuplexStream<StrBuf, uint>) {
|
||||
fn stringifier(channel: &sync::DuplexStream<String, uint>) {
|
||||
let mut value: uint;
|
||||
loop {
|
||||
value = channel.recv();
|
||||
@ -488,7 +488,7 @@ Here is the code for the parent task:
|
||||
extern crate sync;
|
||||
# use std::task::spawn;
|
||||
# use sync::DuplexStream;
|
||||
# fn stringifier(channel: &sync::DuplexStream<StrBuf, uint>) {
|
||||
# fn stringifier(channel: &sync::DuplexStream<String, uint>) {
|
||||
# let mut value: uint;
|
||||
# loop {
|
||||
# value = channel.recv();
|
||||
|
@ -34,7 +34,7 @@ msgstr ""
|
||||
#, fuzzy
|
||||
#| msgid ""
|
||||
#| "~~~~ 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 ""
|
||||
"~~~~\n"
|
||||
"let x: f64 = 4.0;\n"
|
||||
@ -96,7 +96,7 @@ msgstr ""
|
||||
#, fuzzy
|
||||
#| msgid ""
|
||||
#| "~~~~ 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 ""
|
||||
"~~~~\n"
|
||||
"let x: f64 = 4.0;\n"
|
||||
|
@ -1641,7 +1641,7 @@ msgstr "## 最小限の例"
|
||||
msgid ""
|
||||
"~~~~\n"
|
||||
"trait Printable {\n"
|
||||
" fn to_string(&self) -> StrBuf;\n"
|
||||
" fn to_string(&self) -> String;\n"
|
||||
"}\n"
|
||||
msgstr ""
|
||||
"~~~~ {.ignore}\n"
|
||||
@ -1656,7 +1656,7 @@ msgstr ""
|
||||
#| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
|
||||
msgid ""
|
||||
"impl Printable for int {\n"
|
||||
" fn to_string(&self) -> StrBuf { self.to_str() }\n"
|
||||
" fn to_string(&self) -> String { self.to_str() }\n"
|
||||
"}\n"
|
||||
msgstr ""
|
||||
"~~~~ {.ignore}\n"
|
||||
@ -1702,7 +1702,7 @@ msgstr "# クロージャ"
|
||||
msgid ""
|
||||
"~~~~\n"
|
||||
"trait Printable {\n"
|
||||
" fn make_string(&self) -> StrBuf;\n"
|
||||
" fn make_string(&self) -> String;\n"
|
||||
"}\n"
|
||||
msgstr ""
|
||||
"~~~~ {.ignore}\n"
|
||||
@ -1716,8 +1716,8 @@ msgstr ""
|
||||
#, fuzzy, no-wrap
|
||||
#| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
|
||||
msgid ""
|
||||
"impl Printable for StrBuf {\n"
|
||||
" fn make_string(&self) -> StrBuf {\n"
|
||||
"impl Printable for String {\n"
|
||||
" fn make_string(&self) -> String {\n"
|
||||
" (*self).clone()\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
|
@ -3755,15 +3755,15 @@ msgstr ""
|
||||
#| msgid ""
|
||||
#| "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 "
|
||||
#| "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 ""
|
||||
"Traits may be implemented for specific types with [impls]. An impl for a "
|
||||
"particular trait gives an implementation of the methods that trait "
|
||||
"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 ""
|
||||
"[impl][impls] により特定の型にトレイトを実装することができます。トレイトを実"
|
||||
"装する impl は、以下の `Printable` の `int` と `StrBuf` に対する実装のように、"
|
||||
"装する impl は、以下の `Printable` の `int` と `String` に対する実装のように、"
|
||||
"定義の先頭にトレイトの名前を含みます。"
|
||||
|
||||
#. type: Plain text
|
||||
@ -3776,7 +3776,7 @@ msgstr "[impls]: #メソッド"
|
||||
#, fuzzy, no-wrap
|
||||
#| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
|
||||
msgid ""
|
||||
"impl Printable for StrBuf {\n"
|
||||
"impl Printable for String {\n"
|
||||
" fn print(&self) { println!(\"{}\", *self) }\n"
|
||||
"}\n"
|
||||
msgstr ""
|
||||
|
@ -473,7 +473,7 @@ Two examples of paths with type arguments:
|
||||
# struct HashMap<K, V>;
|
||||
# fn f() {
|
||||
# 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
|
||||
# }
|
||||
~~~~
|
||||
@ -1260,8 +1260,8 @@ Enumeration constructors can have either named or unnamed fields:
|
||||
|
||||
~~~~
|
||||
enum Animal {
|
||||
Dog (StrBuf, f64),
|
||||
Cat { name: StrBuf, weight: f64 }
|
||||
Dog (String, f64),
|
||||
Cat { name: String, weight: f64 }
|
||||
}
|
||||
|
||||
let mut a: Animal = Dog("Cocoa".to_strbuf(), 37.2);
|
||||
@ -2082,7 +2082,7 @@ These are functions:
|
||||
* `str_eq`
|
||||
: Compare two strings (`&str`) for equality.
|
||||
* `uniq_str_eq`
|
||||
: Compare two owned strings (`StrBuf`) for equality.
|
||||
: Compare two owned strings (`String`) for equality.
|
||||
* `strdup_uniq`
|
||||
: Return a new 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.
|
||||
Since `str` is of unknown size, it is not a _first class_ type,
|
||||
but can only be instantiated through a pointer type,
|
||||
such as `&str` or `StrBuf`.
|
||||
such as `&str` or `String`.
|
||||
|
||||
### Tuple types
|
||||
|
||||
@ -3574,11 +3574,11 @@ An example of an object type:
|
||||
|
||||
~~~~
|
||||
trait Printable {
|
||||
fn to_string(&self) -> StrBuf;
|
||||
fn to_string(&self) -> String;
|
||||
}
|
||||
|
||||
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>) {
|
||||
@ -3619,17 +3619,17 @@ example, in:
|
||||
|
||||
~~~~
|
||||
trait Printable {
|
||||
fn make_string(&self) -> StrBuf;
|
||||
fn make_string(&self) -> String;
|
||||
}
|
||||
|
||||
impl Printable for StrBuf {
|
||||
fn make_string(&self) -> StrBuf {
|
||||
impl Printable for String {
|
||||
fn make_string(&self) -> String {
|
||||
(*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`.
|
||||
|
||||
## Type kinds
|
||||
|
@ -27,7 +27,7 @@ comments":
|
||||
pub struct Widget {
|
||||
/// All widgets have a purpose (this is a doc comment, and will show up
|
||||
/// the field's documentation).
|
||||
purpose: StrBuf,
|
||||
purpose: String,
|
||||
/// Humans are not allowed to understand some widgets
|
||||
understandable: bool
|
||||
}
|
||||
|
@ -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.
|
||||
|
||||
~~~
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
|
||||
// A dynamically sized vector (unique vector)
|
||||
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.
|
||||
|
||||
let mut string = StrBuf::from_str("fo");
|
||||
let mut string = String::from_str("fo");
|
||||
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
|
||||
a particular trait gives an implementation of the methods that
|
||||
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.
|
||||
|
||||
[impls]: #methods
|
||||
@ -2224,7 +2224,7 @@ impl Printable for int {
|
||||
fn print(&self) { println!("{:?}", *self) }
|
||||
}
|
||||
|
||||
impl Printable for StrBuf {
|
||||
impl Printable for String {
|
||||
fn print(&self) { println!("{}", *self) }
|
||||
}
|
||||
|
||||
@ -2270,7 +2270,7 @@ trait Printable {
|
||||
|
||||
impl Printable for int {}
|
||||
|
||||
impl Printable for StrBuf {
|
||||
impl Printable for String {
|
||||
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
|
||||
written in impls. Of course, individual impls can still override the
|
||||
default method for `print`, as is being done above in the impl for
|
||||
`StrBuf`.
|
||||
`String`.
|
||||
|
||||
## Type-parameterized traits
|
||||
|
||||
|
@ -58,4 +58,4 @@ begin
|
||||
UnInstallOldVersion();
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -106,7 +106,7 @@ syn keyword rustTrait CloneableVector ImmutableCloneableVector MutableCloneableV
|
||||
syn keyword rustTrait ImmutableVector MutableVector
|
||||
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector MutableTotalOrdVector
|
||||
syn keyword rustTrait Vector VectorVector OwnedVector MutableVectorAllocating
|
||||
syn keyword rustTrait StrBuf
|
||||
syn keyword rustTrait String
|
||||
syn keyword rustTrait Vec
|
||||
|
||||
"syn keyword rustFunction sync_channel channel
|
||||
|
@ -513,4 +513,4 @@
|
||||
fun:uv__loop_init
|
||||
fun:uv_loop_new
|
||||
...
|
||||
}
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ mod tests {
|
||||
}
|
||||
|
||||
struct Noncopy {
|
||||
string: StrBuf,
|
||||
string: String,
|
||||
array: Vec<int> ,
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ use std::iter::RandomAccessIterator;
|
||||
use std::iter::{Enumerate, Repeat, Map, Zip};
|
||||
use std::ops;
|
||||
use std::slice;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use std::uint;
|
||||
|
||||
#[deriving(Clone)]
|
||||
@ -532,8 +532,8 @@ impl Bitv {
|
||||
* The resulting string has the same length as `self`, and each
|
||||
* character is either '0' or '1'.
|
||||
*/
|
||||
pub fn to_str(&self) -> StrBuf {
|
||||
let mut rs = StrBuf::new();
|
||||
pub fn to_str(&self) -> String {
|
||||
let mut rs = String::new();
|
||||
for i in self.iter() {
|
||||
if i {
|
||||
rs.push_char('1');
|
||||
|
@ -270,7 +270,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
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, 19]);
|
||||
assert_opt_eq(cache.get(&"1".to_strbuf()), vec![10, 19]);
|
||||
@ -279,7 +279,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
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("foo2".to_strbuf(), "bar2".to_strbuf());
|
||||
cache.put("foo3".to_strbuf(), "bar3".to_strbuf());
|
||||
|
@ -636,7 +636,7 @@ mod test {
|
||||
use char::Char;
|
||||
use slice::ImmutableVector;
|
||||
use option::{Some, None};
|
||||
use realstd::strbuf::StrBuf;
|
||||
use realstd::string::String;
|
||||
use realstd::str::{Str, StrAllocating};
|
||||
|
||||
#[test]
|
||||
@ -742,8 +742,8 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_escape_default() {
|
||||
fn string(c: char) -> StrBuf {
|
||||
let mut result = StrBuf::new();
|
||||
fn string(c: char) -> String {
|
||||
let mut result = String::new();
|
||||
escape_default(c, |c| { result.push_char(c); });
|
||||
return result;
|
||||
}
|
||||
@ -777,8 +777,8 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_escape_unicode() {
|
||||
fn string(c: char) -> StrBuf {
|
||||
let mut result = StrBuf::new();
|
||||
fn string(c: char) -> String {
|
||||
let mut result = String::new();
|
||||
escape_unicode(c, |c| { result.push_char(c); });
|
||||
return result;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ pub trait Ord: Eq {
|
||||
/// The equivalence relation. Two values may be equivalent even if they are
|
||||
/// 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`
|
||||
/// 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> {
|
||||
/// Implement this function to decide equivalent values.
|
||||
fn equiv(&self, other: &T) -> bool;
|
||||
|
@ -594,7 +594,7 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn format(args: &Arguments) -> ::realstd::strbuf::StrBuf {
|
||||
pub fn format(args: &Arguments) -> ::realstd::string::String {
|
||||
use str;
|
||||
use realstd::str::StrAllocating;
|
||||
use realstd::io::MemWriter;
|
||||
@ -614,7 +614,7 @@ pub fn format(args: &Arguments) -> ::realstd::strbuf::StrBuf {
|
||||
let mut i = MemWriter::new();
|
||||
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
|
||||
}
|
||||
|
@ -188,14 +188,14 @@ impl<T> Option<T> {
|
||||
///
|
||||
/// # 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,
|
||||
/// so this technique uses `as_ref` to first take an `Option` to a reference
|
||||
/// to the value inside the original.
|
||||
///
|
||||
/// ```
|
||||
/// let num_as_str: Option<StrBuf> = Some("10".to_strbuf());
|
||||
/// // First, cast `Option<StrBuf>` to `Option<&StrBuf>` with `as_ref`,
|
||||
/// let num_as_str: Option<String> = Some("10".to_strbuf());
|
||||
/// // First, cast `Option<String>` to `Option<&String>` with `as_ref`,
|
||||
/// // 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());
|
||||
/// println!("still can print num_as_str: {}", num_as_str);
|
||||
@ -278,10 +278,10 @@ impl<T> Option<T> {
|
||||
///
|
||||
/// # 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`
|
||||
/// 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)]
|
||||
mod tests {
|
||||
use realstd::vec::Vec;
|
||||
use realstd::strbuf::StrBuf;
|
||||
use realstd::string::String;
|
||||
use option::collect;
|
||||
use prelude::*;
|
||||
use realstd::str::{Str, StrAllocating};
|
||||
@ -760,7 +760,7 @@ mod tests {
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn test_unwrap_fail2() {
|
||||
let x: Option<StrBuf> = None;
|
||||
let x: Option<String> = None;
|
||||
x.unwrap();
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@
|
||||
//! use std::io::{File, Open, Write, IoError};
|
||||
//!
|
||||
//! struct Info {
|
||||
//! name: StrBuf,
|
||||
//! name: String,
|
||||
//! age: int,
|
||||
//! rating: int
|
||||
//! }
|
||||
@ -196,7 +196,7 @@
|
||||
//! use std::io::{File, Open, Write, IoError};
|
||||
//!
|
||||
//! struct Info {
|
||||
//! name: StrBuf,
|
||||
//! name: String,
|
||||
//! age: int,
|
||||
//! rating: int
|
||||
//! }
|
||||
@ -429,7 +429,7 @@ impl<T, E> Result<T, E> {
|
||||
/// let mut sum = 0;
|
||||
///
|
||||
/// 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`
|
||||
/// let val: IoResult<int> = line.map(|line| {
|
||||
/// 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)]
|
||||
mod tests {
|
||||
use realstd::vec::Vec;
|
||||
use realstd::strbuf::StrBuf;
|
||||
use realstd::string::String;
|
||||
|
||||
use result::{collect, fold, fold_};
|
||||
use prelude::*;
|
||||
|
@ -203,7 +203,7 @@ pub struct Parser<'a> {
|
||||
cur: str::CharOffsets<'a>,
|
||||
depth: uint,
|
||||
/// Error messages accumulated during parsing
|
||||
pub errors: Vec<StrBuf>,
|
||||
pub errors: Vec<String>,
|
||||
}
|
||||
|
||||
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
|
||||
/// 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.
|
||||
fn err(&mut self, msg: &str) {
|
||||
self.errors.push(msg.to_strbuf());
|
||||
|
@ -34,7 +34,7 @@
|
||||
//! use getopts::{optopt,optflag,getopts,OptGroup};
|
||||
//! use std::os;
|
||||
//!
|
||||
//! fn do_work(inp: &str, out: Option<StrBuf>) {
|
||||
//! fn do_work(inp: &str, out: Option<String>) {
|
||||
//! println!("{}", inp);
|
||||
//! match out {
|
||||
//! Some(x) => println!("{}", x),
|
||||
@ -49,7 +49,7 @@
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let args: Vec<StrBuf> = os::args().iter()
|
||||
//! let args: Vec<String> = os::args().iter()
|
||||
//! .map(|x| x.to_strbuf())
|
||||
//! .collect();
|
||||
//!
|
||||
@ -94,14 +94,14 @@
|
||||
use std::cmp::Eq;
|
||||
use std::result::{Err, Ok};
|
||||
use std::result;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
|
||||
/// Name of an option. Either a string or a single char.
|
||||
#[deriving(Clone, Eq)]
|
||||
pub enum Name {
|
||||
/// A string representing the long name of an option.
|
||||
/// For example: "help"
|
||||
Long(StrBuf),
|
||||
Long(String),
|
||||
/// A char representing the short name of an option.
|
||||
/// For example: 'h'
|
||||
Short(char),
|
||||
@ -147,13 +147,13 @@ pub struct Opt {
|
||||
#[deriving(Clone, Eq)]
|
||||
pub struct OptGroup {
|
||||
/// Short Name of the `OptGroup`
|
||||
pub short_name: StrBuf,
|
||||
pub short_name: String,
|
||||
/// Long Name of the `OptGroup`
|
||||
pub long_name: StrBuf,
|
||||
pub long_name: String,
|
||||
/// Hint
|
||||
pub hint: StrBuf,
|
||||
pub hint: String,
|
||||
/// Description
|
||||
pub desc: StrBuf,
|
||||
pub desc: String,
|
||||
/// Whether it has an argument
|
||||
pub hasarg: HasArg,
|
||||
/// How often it can occur
|
||||
@ -163,7 +163,7 @@ pub struct OptGroup {
|
||||
/// Describes wether an option is given at all or has a value.
|
||||
#[deriving(Clone, Eq)]
|
||||
enum Optval {
|
||||
Val(StrBuf),
|
||||
Val(String),
|
||||
Given,
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ pub struct Matches {
|
||||
/// Values of the Options that matched
|
||||
vals: Vec<Vec<Optval> > ,
|
||||
/// Free string fragments
|
||||
pub free: Vec<StrBuf>,
|
||||
pub free: Vec<String>,
|
||||
}
|
||||
|
||||
/// The type returned when the command line does not conform to the
|
||||
@ -185,15 +185,15 @@ pub struct Matches {
|
||||
#[deriving(Clone, Eq, Show)]
|
||||
pub enum Fail_ {
|
||||
/// The option requires an argument but none was passed.
|
||||
ArgumentMissing(StrBuf),
|
||||
ArgumentMissing(String),
|
||||
/// The passed option is not declared among the possible options.
|
||||
UnrecognizedOption(StrBuf),
|
||||
UnrecognizedOption(String),
|
||||
/// A required option is not present.
|
||||
OptionMissing(StrBuf),
|
||||
OptionMissing(String),
|
||||
/// A single occurrence option is being used multiple times.
|
||||
OptionDuplicated(StrBuf),
|
||||
OptionDuplicated(String),
|
||||
/// There's an argument being passed to a non-argument option.
|
||||
UnexpectedArgument(StrBuf),
|
||||
UnexpectedArgument(String),
|
||||
}
|
||||
|
||||
/// The type of failure that occurred.
|
||||
@ -219,7 +219,7 @@ impl Name {
|
||||
}
|
||||
}
|
||||
|
||||
fn to_str(&self) -> StrBuf {
|
||||
fn to_str(&self) -> String {
|
||||
match *self {
|
||||
Short(ch) => ch.to_str().to_strbuf(),
|
||||
Long(ref s) => s.to_strbuf()
|
||||
@ -299,7 +299,7 @@ impl Matches {
|
||||
}
|
||||
|
||||
/// 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() {
|
||||
match find_opt(self.opts.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`.
|
||||
pub fn opts_str(&self, names: &[StrBuf]) -> Option<StrBuf> {
|
||||
pub fn opts_str(&self, names: &[String]) -> Option<String> {
|
||||
for nm in names.iter() {
|
||||
match self.opt_val(nm.as_slice()) {
|
||||
Some(Val(ref s)) => return Some(s.clone()),
|
||||
@ -325,8 +325,8 @@ impl Matches {
|
||||
/// option.
|
||||
///
|
||||
/// Used when an option accepts multiple values.
|
||||
pub fn opt_strs(&self, nm: &str) -> Vec<StrBuf> {
|
||||
let mut acc: Vec<StrBuf> = Vec::new();
|
||||
pub fn opt_strs(&self, nm: &str) -> Vec<String> {
|
||||
let mut acc: Vec<String> = Vec::new();
|
||||
let r = self.opt_vals(nm);
|
||||
for v in r.iter() {
|
||||
match *v {
|
||||
@ -338,10 +338,10 @@ impl Matches {
|
||||
}
|
||||
|
||||
/// 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);
|
||||
if vals.is_empty() {
|
||||
return None::<StrBuf>;
|
||||
return None::<String>;
|
||||
}
|
||||
match vals.get(0) {
|
||||
&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
|
||||
/// present but no argument was provided, and the argument if the option was
|
||||
/// 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);
|
||||
if vals.is_empty() {
|
||||
return None;
|
||||
@ -496,7 +496,7 @@ pub fn opt(short_name: &str,
|
||||
|
||||
impl Fail_ {
|
||||
/// Convert a `Fail_` enum into an error string.
|
||||
pub fn to_err_msg(self) -> StrBuf {
|
||||
pub fn to_err_msg(self) -> String {
|
||||
match self {
|
||||
ArgumentMissing(ref 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`
|
||||
/// `opt_str`, etc. to interrogate results. Returns `Err(Fail_)` on failure.
|
||||
/// 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 n_opts = opts.len();
|
||||
|
||||
fn f(_x: uint) -> Vec<Optval> { return Vec::new(); }
|
||||
|
||||
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 mut i = 0;
|
||||
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.
|
||||
pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
|
||||
pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
|
||||
|
||||
let desc_sep = format!("\n{}", " ".repeat(24));
|
||||
|
||||
@ -671,7 +671,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
|
||||
hasarg: hasarg,
|
||||
..} = (*optref).clone();
|
||||
|
||||
let mut row = StrBuf::from_owned_str(" ".repeat(4));
|
||||
let mut row = String::from_owned_str(" ".repeat(4));
|
||||
|
||||
// short option
|
||||
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
|
||||
let mut desc_normalized_whitespace = StrBuf::new();
|
||||
let mut desc_normalized_whitespace = String::new();
|
||||
for word in desc.as_slice().words() {
|
||||
desc_normalized_whitespace.push_str(word);
|
||||
desc_normalized_whitespace.push_char(' ');
|
||||
@ -741,11 +741,11 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
|
||||
|
||||
format_strbuf!("{}\n\nOptions:\n{}\n",
|
||||
brief,
|
||||
rows.collect::<Vec<StrBuf>>().connect("\n"))
|
||||
rows.collect::<Vec<String>>().connect("\n"))
|
||||
}
|
||||
|
||||
fn format_option(opt: &OptGroup) -> StrBuf {
|
||||
let mut line = StrBuf::new();
|
||||
fn format_option(opt: &OptGroup) -> String {
|
||||
let mut line = String::new();
|
||||
|
||||
if opt.occur != Req {
|
||||
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.
|
||||
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);
|
||||
line.push_str(opts.iter()
|
||||
.map(format_option)
|
||||
.collect::<Vec<StrBuf>>()
|
||||
.collect::<Vec<String>>()
|
||||
.connect(" ")
|
||||
.as_slice());
|
||||
line
|
||||
@ -898,7 +898,7 @@ fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
|
||||
|
||||
#[test]
|
||||
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();
|
||||
each_split_within(s, i, |s| { v.push(s.to_strbuf()); true });
|
||||
assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b));
|
||||
|
@ -37,7 +37,7 @@ use std::cell::Cell;
|
||||
use std::{cmp, os, path};
|
||||
use std::io::fs;
|
||||
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
|
||||
@ -310,8 +310,8 @@ impl Pattern {
|
||||
* brackets. The resulting string will, when compiled into a `Pattern`,
|
||||
* match the input string and nothing else.
|
||||
*/
|
||||
pub fn escape(s: &str) -> StrBuf {
|
||||
let mut escaped = StrBuf::new();
|
||||
pub fn escape(s: &str) -> String {
|
||||
let mut escaped = String::new();
|
||||
for c in s.chars() {
|
||||
match c {
|
||||
// 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,
|
||||
options: MatchOptions) {
|
||||
// convert a pattern that's just many Char(_) to a string
|
||||
fn pattern_as_str(pattern: &Pattern) -> Option<StrBuf> {
|
||||
let mut s = StrBuf::new();
|
||||
fn pattern_as_str(pattern: &Pattern) -> Option<String> {
|
||||
let mut s = String::new();
|
||||
for token in pattern.tokens.iter() {
|
||||
match *token {
|
||||
Char(c) => s.push_char(c),
|
||||
|
@ -424,8 +424,8 @@ impl<'a> LabelText<'a> {
|
||||
_ => c.escape_default(f)
|
||||
}
|
||||
}
|
||||
fn escape_str(s: &str) -> StrBuf {
|
||||
let mut out = StrBuf::with_capacity(s.len());
|
||||
fn escape_str(s: &str) -> String {
|
||||
let mut out = String::with_capacity(s.len());
|
||||
for c in s.chars() {
|
||||
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.
|
||||
pub fn escape(&self) -> StrBuf {
|
||||
pub fn escape(&self) -> String {
|
||||
match self {
|
||||
&LabelStr(ref s) => s.as_slice().escape_default().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();
|
||||
render(&g, &mut writer).unwrap();
|
||||
let mut r = BufReader::new(writer.get_ref());
|
||||
|
@ -70,7 +70,7 @@ pub fn macro_registrar(register: |Name, SyntaxExtension|) {
|
||||
|
||||
//Check if the literal is valid (as LLVM expects),
|
||||
//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 i = 0;
|
||||
if chars.peek() == Some(&'-') { chars.next(); i+= 1 }
|
||||
|
@ -13,7 +13,7 @@ use std::cmp;
|
||||
|
||||
#[deriving(Show, Clone)]
|
||||
pub struct LogDirective {
|
||||
pub name: Option<StrBuf>,
|
||||
pub name: Option<String>,
|
||||
pub level: u32,
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ use super::IoResult;
|
||||
use super::file;
|
||||
use super::util;
|
||||
|
||||
#[cfg(windows)] use std::strbuf::StrBuf;
|
||||
#[cfg(windows)] use std::string::String;
|
||||
#[cfg(unix)] use super::c;
|
||||
#[cfg(unix)] use super::retry;
|
||||
#[cfg(unix)] use io::helper_thread::Helper;
|
||||
@ -396,8 +396,8 @@ fn zeroed_process_information() -> libc::types::os::arch::extra::PROCESS_INFORMA
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn make_command_line(prog: &CString, args: &[CString]) -> StrBuf {
|
||||
let mut cmd = StrBuf::new();
|
||||
fn make_command_line(prog: &CString, args: &[CString]) -> String {
|
||||
let mut cmd = String::new();
|
||||
append_arg(&mut cmd, prog.as_str()
|
||||
.expect("expected program name to be utf-8 encoded"));
|
||||
for arg in args.iter() {
|
||||
@ -407,7 +407,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> StrBuf {
|
||||
}
|
||||
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');
|
||||
if quote {
|
||||
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) {
|
||||
'"' => {
|
||||
// Escape quotes.
|
||||
@ -1093,7 +1093,7 @@ mod tests {
|
||||
use std::c_str::CString;
|
||||
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(),
|
||||
args.iter()
|
||||
.map(|a| a.to_c_str())
|
||||
|
@ -26,7 +26,7 @@ use std::num::CheckedDiv;
|
||||
use std::num::{Bitwise, ToPrimitive, FromPrimitive};
|
||||
use std::num::{Zero, One, ToStrRadix, FromStrRadix};
|
||||
use rand::Rng;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use std::uint;
|
||||
use std::{i64, u64};
|
||||
|
||||
@ -604,7 +604,7 @@ impl_to_biguint!(u32, FromPrimitive::from_u32)
|
||||
impl_to_biguint!(u64, FromPrimitive::from_u64)
|
||||
|
||||
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);
|
||||
let (base, max_len) = get_radix_base(radix);
|
||||
if base == BigDigit::base {
|
||||
@ -627,11 +627,11 @@ impl ToStrRadix for BigUint {
|
||||
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() {
|
||||
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() {
|
||||
let ss = (*n as uint).to_str_radix(radix);
|
||||
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 {
|
||||
#[inline]
|
||||
fn to_str_radix(&self, radix: uint) -> StrBuf {
|
||||
fn to_str_radix(&self, radix: uint) -> String {
|
||||
match self.sign {
|
||||
Plus => self.data.to_str_radix(radix),
|
||||
Zero => "0".to_strbuf(),
|
||||
@ -2029,7 +2029,7 @@ mod biguint_tests {
|
||||
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;
|
||||
vec!(( Zero::zero(), vec!(
|
||||
(2, "0".to_strbuf()), (3, "0".to_strbuf())
|
||||
|
@ -175,7 +175,7 @@ impl<T: fmt::Show + Num + Ord> fmt::Show 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() {
|
||||
format_strbuf!("{}-{}i",
|
||||
self.re.to_str_radix(radix),
|
||||
@ -348,7 +348,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_to_str() {
|
||||
fn test(c : Complex64, s: StrBuf) {
|
||||
fn test(c : Complex64, s: String) {
|
||||
assert_eq!(c.to_str().to_strbuf(), s);
|
||||
}
|
||||
test(_0_0i, "0+0i".to_strbuf());
|
||||
|
@ -281,7 +281,7 @@ impl<T: fmt::Show> fmt::Show for Ratio<T> {
|
||||
}
|
||||
impl<T: ToStrRadix> ToStrRadix for Ratio<T> {
|
||||
/// 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!("{}/{}",
|
||||
self.numer.to_str_radix(radix),
|
||||
self.denom.to_str_radix(radix))
|
||||
@ -557,7 +557,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
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!(r.to_str().to_strbuf(), s);
|
||||
}
|
||||
@ -583,13 +583,13 @@ mod test {
|
||||
|
||||
#[test]
|
||||
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),
|
||||
Some(r));
|
||||
assert_eq!(r.to_str_radix(n).to_strbuf(), s);
|
||||
}
|
||||
fn test3(r: Rational, s: StrBuf) { test(r, s, 3) }
|
||||
fn test16(r: Rational, s: StrBuf) { test(r, s, 16) }
|
||||
fn test3(r: Rational, s: String) { test(r, s, 3) }
|
||||
fn test16(r: Rational, s: String) { test(r, s, 16) }
|
||||
|
||||
test3(_1, "1/1".to_strbuf());
|
||||
test3(_0, "0/1".to_strbuf());
|
||||
|
@ -86,7 +86,7 @@ println!("{:?}", tuple_ptr)
|
||||
use std::io::IoResult;
|
||||
use std::kinds::marker;
|
||||
use std::mem;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
|
||||
pub use isaac::{IsaacRng, Isaac64Rng};
|
||||
pub use os::OSRng;
|
||||
@ -260,11 +260,11 @@ pub trait Rng {
|
||||
///
|
||||
/// 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\
|
||||
abcdefghijklmnopqrstuvwxyz\
|
||||
0123456789");
|
||||
let mut s = StrBuf::with_capacity(len);
|
||||
let mut s = String::with_capacity(len);
|
||||
for _ in range(0, len) {
|
||||
s.push_char(*self.choose(GEN_ASCII_STR_CHARSET).unwrap() as char)
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ pub struct Program {
|
||||
/// 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
|
||||
/// an optimization.)
|
||||
pub prefix: StrBuf,
|
||||
pub prefix: String,
|
||||
}
|
||||
|
||||
impl Program {
|
||||
/// 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 {
|
||||
insts: Vec::with_capacity(100),
|
||||
names: Vec::with_capacity(10),
|
||||
@ -102,7 +102,7 @@ impl Program {
|
||||
// Try to discover a literal string prefix.
|
||||
// This is a bit hacky since we have to skip over the initial
|
||||
// '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() {
|
||||
match *inst {
|
||||
OneChar(c, FLAG_EMPTY) => pre.push_char(c),
|
||||
@ -135,7 +135,7 @@ impl Program {
|
||||
|
||||
struct Compiler<'r> {
|
||||
insts: Vec<Inst>,
|
||||
names: Vec<Option<StrBuf>>,
|
||||
names: Vec<Option<String>>,
|
||||
}
|
||||
|
||||
// The compiler implemented here is extremely simple. Most of the complexity
|
||||
|
@ -32,7 +32,7 @@ pub struct Error {
|
||||
/// The *approximate* character index of where the error occurred.
|
||||
pub pos: uint,
|
||||
/// A message describing the error.
|
||||
pub msg: StrBuf,
|
||||
pub msg: String,
|
||||
}
|
||||
|
||||
impl fmt::Show for Error {
|
||||
@ -59,7 +59,7 @@ pub enum Ast {
|
||||
Begin(Flags),
|
||||
End(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
|
||||
// stack in the compiler.
|
||||
Cat(Vec<Ast>),
|
||||
@ -104,7 +104,7 @@ impl Greed {
|
||||
#[deriving(Show)]
|
||||
enum BuildAst {
|
||||
Ast(Ast),
|
||||
Paren(Flags, uint, StrBuf), // '('
|
||||
Paren(Flags, uint, String), // '('
|
||||
Bar, // '|'
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ impl BuildAst {
|
||||
}
|
||||
}
|
||||
|
||||
fn capture_name(&self) -> Option<StrBuf> {
|
||||
fn capture_name(&self) -> Option<String> {
|
||||
match *self {
|
||||
Paren(_, 0, _) => None,
|
||||
Paren(_, _, ref name) => {
|
||||
@ -185,7 +185,7 @@ struct Parser<'a> {
|
||||
// opening a capture group).
|
||||
caps: uint,
|
||||
// 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> {
|
||||
@ -625,7 +625,7 @@ impl<'a> Parser<'a> {
|
||||
// character).
|
||||
fn parse_unicode_name(&mut self) -> Result<Ast, Error> {
|
||||
let negated = if self.cur() == 'P' { FLAG_NEGATED } else { FLAG_EMPTY };
|
||||
let mut name: StrBuf;
|
||||
let mut name: String;
|
||||
if self.peek_is(1, '{') {
|
||||
try!(self.expect('{'))
|
||||
let closer =
|
||||
@ -941,7 +941,7 @@ impl<'a> Parser<'a> {
|
||||
*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()
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ use vm::{CaptureLocs, MatchKind, Exists, Location, Submatches};
|
||||
|
||||
/// Escapes all regular expression meta characters in `text` so that it may be
|
||||
/// safely used in a regular expression as a literal string.
|
||||
pub fn quote(text: &str) -> StrBuf {
|
||||
let mut quoted = StrBuf::with_capacity(text.len());
|
||||
pub fn quote(text: &str) -> String {
|
||||
let mut quoted = String::with_capacity(text.len());
|
||||
for c in text.chars() {
|
||||
if parse::is_punct(c) {
|
||||
quoted.push_char('\\')
|
||||
@ -107,9 +107,9 @@ pub struct Regex {
|
||||
/// See the comments for the `program` module in `lib.rs` for a more
|
||||
/// detailed explanation for what `regex!` requires.
|
||||
#[doc(hidden)]
|
||||
pub original: StrBuf,
|
||||
pub original: String,
|
||||
#[doc(hidden)]
|
||||
pub names: Vec<Option<StrBuf>>,
|
||||
pub names: Vec<Option<String>>,
|
||||
#[doc(hidden)]
|
||||
pub p: MaybeNative,
|
||||
}
|
||||
@ -407,7 +407,7 @@ impl Regex {
|
||||
/// ```
|
||||
///
|
||||
/// 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
|
||||
/// submatches easily:
|
||||
///
|
||||
@ -456,7 +456,7 @@ impl Regex {
|
||||
/// 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)
|
||||
}
|
||||
|
||||
@ -466,7 +466,7 @@ impl Regex {
|
||||
///
|
||||
/// See the documentation for `replace` for details on how to access
|
||||
/// 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)
|
||||
}
|
||||
|
||||
@ -477,8 +477,8 @@ impl Regex {
|
||||
/// See the documentation for `replace` for details on how to access
|
||||
/// submatches in the replacement string.
|
||||
pub fn replacen<R: Replacer>
|
||||
(&self, text: &str, limit: uint, mut rep: R) -> StrBuf {
|
||||
let mut new = StrBuf::with_capacity(text.len());
|
||||
(&self, text: &str, limit: uint, mut rep: R) -> String {
|
||||
let mut new = String::with_capacity(text.len());
|
||||
let mut last_match = 0u;
|
||||
|
||||
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> {
|
||||
Owned((*self)(caps).into_owned())
|
||||
}
|
||||
@ -608,7 +608,7 @@ impl<'r, 't> Iterator<&'t str> for RegexSplitsN<'r, 't> {
|
||||
pub struct Captures<'t> {
|
||||
text: &'t str,
|
||||
locs: CaptureLocs,
|
||||
named: Option<HashMap<StrBuf, uint>>,
|
||||
named: Option<HashMap<String, uint>>,
|
||||
}
|
||||
|
||||
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.
|
||||
///
|
||||
/// To write a literal `$` use `$$`.
|
||||
pub fn expand(&self, text: &str) -> StrBuf {
|
||||
pub fn expand(&self, text: &str) -> String {
|
||||
// How evil can you get?
|
||||
// FIXME: Don't use regexes for this. It's completely unnecessary.
|
||||
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));
|
||||
format_strbuf!("{}{}",
|
||||
pre,
|
||||
|
@ -153,7 +153,7 @@ fn medium() -> Regex { regex!("[XYZ]ABCDEFGHIJKLMNOPQRSTUVWXYZ$") }
|
||||
fn hard() -> Regex { regex!("[ -~]*ABCDEFGHIJKLMNOPQRSTUVWXYZ$") }
|
||||
|
||||
#[allow(deprecated_owned_vector)]
|
||||
fn gen_text(n: uint) -> StrBuf {
|
||||
fn gen_text(n: uint) -> String {
|
||||
let mut rng = task_rng();
|
||||
let mut bytes = rng.gen_ascii_str(n).into_bytes();
|
||||
for (i, b) in bytes.mut_iter().enumerate() {
|
||||
|
@ -34,7 +34,7 @@ macro_rules! replace(
|
||||
#[test]
|
||||
fn $name() {
|
||||
let re = regex!($re);
|
||||
assert_eq!(re.$which($search, $replace), StrBuf::from_str($result));
|
||||
assert_eq!(re.$which($search, $replace), String::from_str($result));
|
||||
}
|
||||
);
|
||||
)
|
||||
|
@ -105,8 +105,8 @@ struct NfaGen<'a> {
|
||||
cx: &'a ExtCtxt<'a>,
|
||||
sp: codemap::Span,
|
||||
prog: Program,
|
||||
names: Vec<Option<StrBuf>>,
|
||||
original: StrBuf,
|
||||
names: Vec<Option<String>>,
|
||||
original: String,
|
||||
}
|
||||
|
||||
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.
|
||||
/// 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(),
|
||||
Vec::from_slice(tts));
|
||||
let entry = cx.expand_expr(parser.parse_expr());
|
||||
|
@ -134,7 +134,7 @@ impl<'a> Archive<'a> {
|
||||
}
|
||||
|
||||
/// 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 = str::from_utf8(output.output.as_slice()).unwrap();
|
||||
// use lines_any because windows delimits output with `\r\n` instead of
|
||||
|
@ -13,7 +13,7 @@ use driver::config::cfg_os_to_meta_os;
|
||||
use metadata::loader::meta_section_name;
|
||||
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") {
|
||||
vec!("-mthumb".to_strbuf())
|
||||
} else {
|
||||
|
@ -33,7 +33,7 @@ use std::io::{fs, TempDir, Command};
|
||||
use std::io;
|
||||
use std::ptr;
|
||||
use std::str;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use flate;
|
||||
use serialize::hex::ToHex;
|
||||
use syntax::abi;
|
||||
@ -54,7 +54,7 @@ pub enum OutputType {
|
||||
OutputTypeExe,
|
||||
}
|
||||
|
||||
pub fn llvm_err(sess: &Session, msg: StrBuf) -> ! {
|
||||
pub fn llvm_err(sess: &Session, msg: String) -> ! {
|
||||
unsafe {
|
||||
let cstr = llvm::LLVMRustGetLastError();
|
||||
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) {
|
||||
None => from_str(out_filestem).unwrap_or_else(|| {
|
||||
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()
|
||||
}),
|
||||
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
|
||||
// the crate id in the hash because lookups are only done by (name/vers),
|
||||
// not by path.
|
||||
@ -567,7 +567,7 @@ pub fn build_link_meta(krate: &ast::Crate, out_filestem: &str) -> LinkMeta {
|
||||
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();
|
||||
// 64 bits should be enough to avoid collisions.
|
||||
output.slice_to(8).to_hex().to_strbuf()
|
||||
@ -579,7 +579,7 @@ fn symbol_hash(tcx: &ty::ctxt,
|
||||
symbol_hasher: &mut Sha256,
|
||||
t: ty::t,
|
||||
link_meta: &LinkMeta)
|
||||
-> StrBuf {
|
||||
-> String {
|
||||
// NB: do *not* use abbrevs here as we want the symbol names
|
||||
// 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(encoder::encoded_ty(tcx, t).as_slice());
|
||||
// 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
|
||||
}
|
||||
|
||||
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) {
|
||||
Some(h) => return h.to_strbuf(),
|
||||
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
|
||||
// gas doesn't!
|
||||
// gas accepts the following characters in symbols: a-z, A-Z, 0-9, ., _, $
|
||||
pub fn sanitize(s: &str) -> StrBuf {
|
||||
let mut result = StrBuf::new();
|
||||
pub fn sanitize(s: &str) -> String {
|
||||
let mut result = String::new();
|
||||
for c in s.chars() {
|
||||
match c {
|
||||
// Escape these with $ sequences
|
||||
@ -637,7 +637,7 @@ pub fn sanitize(s: &str) -> StrBuf {
|
||||
| '_' | '.' | '$' => result.push_char(c),
|
||||
|
||||
_ => {
|
||||
let mut tstr = StrBuf::new();
|
||||
let mut tstr = String::new();
|
||||
char::escape_unicode(c, |c| tstr.push_char(c));
|
||||
result.push_char('$');
|
||||
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,
|
||||
hash: Option<&str>,
|
||||
vers: Option<&str>) -> StrBuf {
|
||||
vers: Option<&str>) -> String {
|
||||
// Follow C++ namespace-mangling style, see
|
||||
// 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
|
||||
// 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);
|
||||
n.push_str(format!("{}{}", sani.len(), sani).as_slice());
|
||||
}
|
||||
@ -697,7 +697,7 @@ pub fn mangle<PI: Iterator<PathElem>>(mut path: PI,
|
||||
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
|
||||
// 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)) {
|
||||
@ -710,7 +710,7 @@ pub fn exported_name(path: PathElems, hash: &str, vers: &str) -> StrBuf {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// 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,
|
||||
t: ty::t,
|
||||
name: &str) -> StrBuf {
|
||||
name: &str) -> String {
|
||||
let s = ppaux::ty_to_str(ccx.tcx(), t);
|
||||
let path = [PathName(token::intern(s.as_slice())),
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
pub fn output_lib_filename(id: &CrateId) -> StrBuf {
|
||||
pub fn output_lib_filename(id: &CrateId) -> String {
|
||||
format_strbuf!("{}-{}-{}",
|
||||
id.name,
|
||||
crate_id_hash(id),
|
||||
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 {
|
||||
Some(ref linker) => return linker.to_strbuf(),
|
||||
None => {}
|
||||
@ -773,7 +773,7 @@ pub fn get_cc_prog(sess: &Session) -> StrBuf {
|
||||
}.to_strbuf()
|
||||
}
|
||||
|
||||
pub fn get_ar_prog(sess: &Session) -> StrBuf {
|
||||
pub fn get_ar_prog(sess: &Session) -> String {
|
||||
match sess.opts.cg.ar {
|
||||
Some(ref ar) => (*ar).clone(),
|
||||
None => "ar".to_strbuf()
|
||||
|
@ -20,7 +20,7 @@ use libc;
|
||||
use flate;
|
||||
|
||||
pub fn run(sess: &session::Session, llmod: ModuleRef,
|
||||
tm: TargetMachineRef, reachable: &[StrBuf]) {
|
||||
tm: TargetMachineRef, reachable: &[String]) {
|
||||
if sess.opts.cg.prefer_dynamic {
|
||||
sess.err("cannot prefer dynamic linking when performing LTO");
|
||||
sess.note("only 'staticlib' and 'bin' outputs are supported with LTO");
|
||||
|
@ -13,7 +13,7 @@ use driver::config::cfg_os_to_meta_os;
|
||||
use metadata::loader::meta_section_name;
|
||||
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 {
|
||||
module_asm: "".to_strbuf(),
|
||||
|
||||
|
@ -22,7 +22,7 @@ fn not_win32(os: abi::Os) -> bool {
|
||||
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;
|
||||
|
||||
// No rpath on windows
|
||||
@ -56,7 +56,7 @@ pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<StrBuf> {
|
||||
flags
|
||||
}
|
||||
|
||||
pub fn rpaths_to_flags(rpaths: &[StrBuf]) -> Vec<StrBuf> {
|
||||
pub fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
|
||||
let mut ret = Vec::new();
|
||||
for rpath in rpaths.iter() {
|
||||
ret.push(format!("-Wl,-rpath,{}", (*rpath).as_slice()));
|
||||
@ -68,7 +68,7 @@ fn get_rpaths(os: abi::Os,
|
||||
sysroot: &Path,
|
||||
output: &Path,
|
||||
libs: &[Path],
|
||||
target_triple: &str) -> Vec<StrBuf> {
|
||||
target_triple: &str) -> Vec<String> {
|
||||
debug!("sysroot: {}", sysroot.display());
|
||||
debug!("output: {}", output.display());
|
||||
debug!("libs:");
|
||||
@ -85,7 +85,7 @@ fn get_rpaths(os: abi::Os,
|
||||
// And a final backup rpath to the global library location.
|
||||
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);
|
||||
for rpath in rpaths.iter() {
|
||||
debug!(" {}", *rpath);
|
||||
@ -105,14 +105,14 @@ fn get_rpaths(os: abi::Os,
|
||||
|
||||
fn get_rpaths_relative_to_output(os: abi::Os,
|
||||
output: &Path,
|
||||
libs: &[Path]) -> Vec<StrBuf> {
|
||||
libs: &[Path]) -> Vec<String> {
|
||||
libs.iter().map(|a| get_rpath_relative_to_output(os, output, a)).collect()
|
||||
}
|
||||
|
||||
pub fn get_rpath_relative_to_output(os: abi::Os,
|
||||
output: &Path,
|
||||
lib: &Path)
|
||||
-> StrBuf {
|
||||
-> String {
|
||||
use std::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"))
|
||||
}
|
||||
|
||||
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 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()
|
||||
}
|
||||
|
||||
pub fn minimize_rpaths(rpaths: &[StrBuf]) -> Vec<StrBuf> {
|
||||
pub fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
|
||||
let mut set = HashSet::new();
|
||||
let mut minimized = Vec::new();
|
||||
for rpath in rpaths.iter() {
|
||||
|
@ -55,7 +55,7 @@ use syntax::visit;
|
||||
|
||||
#[deriving(Clone, Eq)]
|
||||
pub struct Svh {
|
||||
hash: StrBuf,
|
||||
hash: String,
|
||||
}
|
||||
|
||||
impl Svh {
|
||||
|
@ -11,9 +11,9 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub struct t {
|
||||
pub module_asm: StrBuf,
|
||||
pub meta_sect_name: StrBuf,
|
||||
pub data_layout: StrBuf,
|
||||
pub target_triple: StrBuf,
|
||||
pub cc_args: Vec<StrBuf> ,
|
||||
pub module_asm: String,
|
||||
pub meta_sect_name: String,
|
||||
pub data_layout: String,
|
||||
pub target_triple: String,
|
||||
pub cc_args: Vec<String> ,
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use driver::config::cfg_os_to_meta_os;
|
||||
use metadata::loader::meta_section_name;
|
||||
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 {
|
||||
return target_strs::t {
|
||||
module_asm: "".to_strbuf(),
|
||||
|
@ -14,7 +14,7 @@ use driver::config::cfg_os_to_meta_os;
|
||||
use metadata::loader::meta_section_name;
|
||||
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 {
|
||||
module_asm: "".to_strbuf(),
|
||||
|
||||
|
@ -77,7 +77,7 @@ pub struct Options {
|
||||
// this.
|
||||
pub addl_lib_search_paths: RefCell<HashSet<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
|
||||
// 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
|
||||
@ -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 {
|
||||
Some(s) => { *slot = Some(s.to_strbuf()); true },
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_string(slot: &mut StrBuf, v: Option<&str>) -> bool {
|
||||
fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => { *slot = s.to_strbuf(); true },
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_list(slot: &mut Vec<StrBuf>, v: Option<&str>)
|
||||
fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
|
||||
-> bool {
|
||||
match v {
|
||||
Some(s) => {
|
||||
@ -281,19 +281,19 @@ macro_rules! cgoptions(
|
||||
) )
|
||||
|
||||
cgoptions!(
|
||||
ar: Option<StrBuf> = (None, parse_opt_string,
|
||||
ar: Option<String> = (None, parse_opt_string,
|
||||
"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"),
|
||||
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)"),
|
||||
target_cpu: StrBuf = ("generic".to_strbuf(), parse_string,
|
||||
target_cpu: String = ("generic".to_strbuf(), parse_string,
|
||||
"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)"),
|
||||
passes: Vec<StrBuf> = (Vec::new(), parse_list,
|
||||
passes: Vec<String> = (Vec::new(), parse_list,
|
||||
"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)"),
|
||||
save_temps: bool = (false, parse_bool,
|
||||
"save all temporary output files during compilation"),
|
||||
@ -311,7 +311,7 @@ cgoptions!(
|
||||
"prefer dynamic linking to static linking"),
|
||||
no_integrated_as: bool = (false, parse_bool,
|
||||
"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)"),
|
||||
)
|
||||
|
||||
@ -555,7 +555,7 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
|
||||
|
||||
|
||||
// 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| {
|
||||
parse::parse_meta_from_source_str("cfgspec".to_strbuf(),
|
||||
s.to_strbuf(),
|
||||
|
@ -105,11 +105,11 @@ pub fn compile_input(sess: Session,
|
||||
* The name used for source code that doesn't originate in a file
|
||||
* (e.g. source from stdin or a string)
|
||||
*/
|
||||
pub fn anon_src() -> StrBuf {
|
||||
pub fn anon_src() -> String {
|
||||
"<anon>".to_strbuf()
|
||||
}
|
||||
|
||||
pub fn source_name(input: &Input) -> StrBuf {
|
||||
pub fn source_name(input: &Input) -> String {
|
||||
match *input {
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
FileInput(ref ifile) => ifile.as_str().unwrap().to_strbuf(),
|
||||
@ -121,11 +121,11 @@ pub enum Input {
|
||||
/// Load source from file
|
||||
FileInput(Path),
|
||||
/// The string is the source
|
||||
StrInput(StrBuf)
|
||||
StrInput(String)
|
||||
}
|
||||
|
||||
impl Input {
|
||||
fn filestem(&self) -> StrBuf {
|
||||
fn filestem(&self) -> String {
|
||||
match *self {
|
||||
FileInput(ref ifile) => ifile.filestem_str().unwrap().to_strbuf(),
|
||||
StrInput(_) => "rust_out".to_strbuf(),
|
||||
@ -360,7 +360,7 @@ pub struct CrateTranslation {
|
||||
pub metadata_module: ModuleRef,
|
||||
pub link: LinkMeta,
|
||||
pub metadata: Vec<u8>,
|
||||
pub reachable: Vec<StrBuf>,
|
||||
pub reachable: Vec<String>,
|
||||
pub crate_formats: dependency_format::Dependencies,
|
||||
pub no_builtins: bool,
|
||||
}
|
||||
@ -495,7 +495,7 @@ fn write_out_deps(sess: &Session,
|
||||
let result = (|| {
|
||||
// Build a list of files used to compile the output and
|
||||
// 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())
|
||||
.map(|fmap| fmap.name.to_strbuf())
|
||||
.collect();
|
||||
@ -780,7 +780,7 @@ pub fn collect_crate_types(session: &Session,
|
||||
|
||||
pub struct OutputFilenames {
|
||||
pub out_directory: Path,
|
||||
pub out_filestem: StrBuf,
|
||||
pub out_filestem: String,
|
||||
pub single_output_file: Option<Path>,
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ pub mod session;
|
||||
pub mod config;
|
||||
|
||||
|
||||
pub fn main_args(args: &[StrBuf]) -> int {
|
||||
pub fn main_args(args: &[String]) -> int {
|
||||
let owned_args = args.to_owned();
|
||||
monitor(proc() run_compiler(owned_args));
|
||||
0
|
||||
@ -44,7 +44,7 @@ pub fn main_args(args: &[StrBuf]) -> int {
|
||||
static BUG_REPORT_URL: &'static str =
|
||||
"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)) {
|
||||
Some(matches) => matches,
|
||||
None => return
|
||||
@ -143,7 +143,7 @@ Available lint options:
|
||||
for &(_, name) in lint_dict.iter() {
|
||||
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)
|
||||
}
|
||||
println!("\nAvailable lint checks:\n");
|
||||
@ -192,7 +192,7 @@ fn describe_codegen_flags() {
|
||||
/// Process command line options. Emits messages as appropirate.If compilation
|
||||
/// should continue, returns a getopts::Matches object parsed from args, otherwise
|
||||
/// 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
|
||||
let _binary = args.shift().unwrap();
|
||||
|
||||
|
@ -42,7 +42,7 @@ pub struct Session {
|
||||
// expected to be absolute. `None` means that there is no source file.
|
||||
pub local_crate_source_file: Option<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 crate_types: RefCell<Vec<config::CrateType>>,
|
||||
pub features: front::feature_gate::Features,
|
||||
@ -108,7 +108,7 @@ impl Session {
|
||||
lint: lint::Lint,
|
||||
id: ast::NodeId,
|
||||
sp: Span,
|
||||
msg: StrBuf) {
|
||||
msg: String) {
|
||||
let mut lints = self.lints.borrow_mut();
|
||||
match lints.find_mut(&id) {
|
||||
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
|
||||
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 {
|
||||
diagnostic::expect(sess.diagnostic(), opt, msg)
|
||||
}
|
||||
|
@ -1862,7 +1862,7 @@ pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
|
||||
/* Memory-managed object interface to type handles. */
|
||||
|
||||
pub struct TypeNames {
|
||||
named_types: RefCell<HashMap<StrBuf, TypeRef>>,
|
||||
named_types: RefCell<HashMap<String, TypeRef>>,
|
||||
}
|
||||
|
||||
impl TypeNames {
|
||||
@ -1881,7 +1881,7 @@ impl TypeNames {
|
||||
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 {
|
||||
let s = llvm::LLVMTypeToString(ty.to_ref());
|
||||
let ret = from_c_str(s);
|
||||
@ -1890,12 +1890,12 @@ impl TypeNames {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn types_to_str(&self, tys: &[Type]) -> StrBuf {
|
||||
let strs: Vec<StrBuf> = tys.iter().map(|t| self.type_to_str(*t)).collect();
|
||||
pub fn types_to_str(&self, tys: &[Type]) -> String {
|
||||
let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect();
|
||||
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 {
|
||||
let s = llvm::LLVMValueToString(val);
|
||||
let ret = from_c_str(s);
|
||||
|
@ -139,7 +139,7 @@ fn visit_view_item(e: &mut Env, i: &ast::ViewItem) {
|
||||
}
|
||||
|
||||
struct CrateInfo {
|
||||
ident: StrBuf,
|
||||
ident: String,
|
||||
crate_id: CrateId,
|
||||
id: ast::NodeId,
|
||||
should_link: bool,
|
||||
|
@ -33,7 +33,7 @@ pub struct StaticMethodInfo {
|
||||
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);
|
||||
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,
|
||||
crate_num: ast::CrateNum)
|
||||
-> Vec<(cstore::NativeLibaryKind, StrBuf)> {
|
||||
-> Vec<(cstore::NativeLibaryKind, String)> {
|
||||
let cdata = cstore.get_crate_data(crate_num);
|
||||
decoder::get_native_libraries(&*cdata)
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ pub enum MetadataBlob {
|
||||
}
|
||||
|
||||
pub struct crate_metadata {
|
||||
pub name: StrBuf,
|
||||
pub name: String,
|
||||
pub data: MetadataBlob,
|
||||
pub cnum_map: cnum_map,
|
||||
pub cnum: ast::CrateNum,
|
||||
@ -71,8 +71,8 @@ pub struct CStore {
|
||||
metas: RefCell<HashMap<ast::CrateNum, Rc<crate_metadata>>>,
|
||||
extern_mod_crate_map: RefCell<extern_mod_crate_map>,
|
||||
used_crate_sources: RefCell<Vec<CrateSource>>,
|
||||
used_libraries: RefCell<Vec<(StrBuf, NativeLibaryKind)>>,
|
||||
used_link_args: RefCell<Vec<StrBuf>>,
|
||||
used_libraries: RefCell<Vec<(String, NativeLibaryKind)>>,
|
||||
used_link_args: RefCell<Vec<String>>,
|
||||
pub intr: Rc<IdentInterner>,
|
||||
}
|
||||
|
||||
@ -189,13 +189,13 @@ impl CStore {
|
||||
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());
|
||||
self.used_libraries.borrow_mut().push((lib, kind));
|
||||
}
|
||||
|
||||
pub fn get_used_libraries<'a>(&'a self)
|
||||
-> &'a RefCell<Vec<(StrBuf, NativeLibaryKind)> > {
|
||||
-> &'a RefCell<Vec<(String, NativeLibaryKind)> > {
|
||||
&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
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ fn item_method_sort(item: ebml::Doc) -> char {
|
||||
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()
|
||||
}
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
@ -1093,7 +1093,7 @@ pub fn get_crate_deps(data: &[u8]) -> Vec<CrateDep> {
|
||||
let cratedoc = reader::Doc(data);
|
||||
let depsdoc = reader::get_doc(cratedoc, tag_crate_deps);
|
||||
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_);
|
||||
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 triple_doc = reader::maybe_get_doc(cratedoc, tag_crate_triple);
|
||||
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)
|
||||
-> Vec<(cstore::NativeLibaryKind, StrBuf)> {
|
||||
-> Vec<(cstore::NativeLibaryKind, String)> {
|
||||
let libraries = reader::get_doc(reader::Doc(cdata.data()),
|
||||
tag_native_libraries);
|
||||
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())
|
||||
}
|
||||
|
||||
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),
|
||||
tag_exported_macros);
|
||||
let mut result = Vec::new();
|
||||
|
@ -70,7 +70,7 @@ pub struct EncodeParams<'a> {
|
||||
pub diag: &'a SpanHandler,
|
||||
pub tcx: &'a ty::ctxt,
|
||||
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 link_meta: &'a LinkMeta,
|
||||
pub cstore: &'a cstore::CStore,
|
||||
@ -81,7 +81,7 @@ pub struct EncodeContext<'a> {
|
||||
pub diag: &'a SpanHandler,
|
||||
pub tcx: &'a ty::ctxt,
|
||||
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 link_meta: &'a LinkMeta,
|
||||
pub cstore: &'a cstore::CStore,
|
||||
@ -139,7 +139,7 @@ fn encode_family(ebml_w: &mut Encoder, c: char) {
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1715,7 +1715,7 @@ fn encode_dylib_dependency_formats(ebml_w: &mut Encoder, ecx: &EncodeContext) {
|
||||
cstore::RequireDynamic => "d",
|
||||
cstore::RequireStatic => "s",
|
||||
})).to_strbuf())
|
||||
}).collect::<Vec<StrBuf>>();
|
||||
}).collect::<Vec<String>>();
|
||||
ebml_w.writer.write(s.connect(",").as_bytes());
|
||||
}
|
||||
None => {}
|
||||
@ -1877,7 +1877,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
|
||||
}
|
||||
|
||||
// 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();
|
||||
tyencode::enc_ty(&mut wr, &tyencode::ctxt {
|
||||
diag: tcx.sess.diagnostic(),
|
||||
|
@ -186,7 +186,7 @@ static PATH_ENTRY_SEPARATOR: &'static str = ";";
|
||||
static PATH_ENTRY_SEPARATOR: &'static str = ":";
|
||||
|
||||
/// 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())
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ pub fn rust_path() -> Vec<Path> {
|
||||
// The name of the directory rustc expects libraries to be located.
|
||||
// On Unix should be "lib", on windows "bin"
|
||||
#[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
|
||||
// Rust libraries in Linux environments where libraries might be installed
|
||||
// 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")]
|
||||
fn primary_libdir_name() -> StrBuf {
|
||||
fn primary_libdir_name() -> String {
|
||||
"lib64".to_strbuf()
|
||||
}
|
||||
|
||||
#[cfg(target_word_size = "32")]
|
||||
fn primary_libdir_name() -> StrBuf {
|
||||
fn primary_libdir_name() -> String {
|
||||
"lib32".to_strbuf()
|
||||
}
|
||||
|
||||
fn secondary_libdir_name() -> StrBuf {
|
||||
fn secondary_libdir_name() -> String {
|
||||
"lib".to_strbuf()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn find_libdir(_sysroot: &Path) -> StrBuf {
|
||||
fn find_libdir(_sysroot: &Path) -> String {
|
||||
"bin".to_strbuf()
|
||||
}
|
||||
|
||||
// The name of rustc's own place to organize libraries.
|
||||
// Used to be "rustc", now the default is "rustlib"
|
||||
pub fn rustlibdir() -> StrBuf {
|
||||
pub fn rustlibdir() -> String {
|
||||
"rustlib".to_strbuf()
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ pub enum Os {
|
||||
|
||||
pub struct CrateMismatch {
|
||||
path: Path,
|
||||
got: StrBuf,
|
||||
got: String,
|
||||
}
|
||||
|
||||
pub struct Context<'a> {
|
||||
@ -92,7 +92,7 @@ pub struct ArchiveMetadata {
|
||||
}
|
||||
|
||||
pub struct CratePaths {
|
||||
pub ident: StrBuf,
|
||||
pub ident: String,
|
||||
pub dylib: 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
|
||||
// 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());
|
||||
debug!("matching -- {}, middle: {}", file, middle);
|
||||
let mut parts = middle.splitn('-', 1);
|
||||
@ -496,7 +496,7 @@ impl ArchiveMetadata {
|
||||
}
|
||||
|
||||
// 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 ret = get_metadata_section_imp(os, filename);
|
||||
info!("reading {} => {}ms", filename.filename_display(),
|
||||
@ -504,7 +504,7 @@ fn get_metadata_section(os: Os, filename: &Path) -> Result<MetadataBlob, StrBuf>
|
||||
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() {
|
||||
return Err(format_strbuf!("no such file: '{}'", filename.display()));
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use middle::ty;
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use std::uint;
|
||||
use syntax::abi;
|
||||
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 {
|
||||
let mut result = StrBuf::new();
|
||||
fn parse_str(st: &mut PState, term: char) -> String {
|
||||
let mut result = String::new();
|
||||
while peek(st) != term {
|
||||
unsafe {
|
||||
result.push_bytes([next_byte(st)])
|
||||
|
@ -31,7 +31,7 @@ macro_rules! mywrite( ($($arg:tt)*) => ({ write!($($arg)*); }) )
|
||||
pub struct ctxt<'a> {
|
||||
pub diag: &'a SpanHandler,
|
||||
// Def -> str Callback:
|
||||
pub ds: fn(DefId) -> StrBuf,
|
||||
pub ds: fn(DefId) -> String,
|
||||
// The type context.
|
||||
pub tcx: &'a ty::ctxt,
|
||||
pub abbrevs: &'a abbrev_map
|
||||
@ -43,7 +43,7 @@ pub struct ctxt<'a> {
|
||||
pub struct ty_abbrev {
|
||||
pos: uint,
|
||||
len: uint,
|
||||
s: StrBuf
|
||||
s: String
|
||||
}
|
||||
|
||||
pub type abbrev_map = RefCell<HashMap<ty::t, ty_abbrev>>;
|
||||
|
@ -38,7 +38,7 @@ use std::io::Seek;
|
||||
use std::io::MemWriter;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
|
||||
use serialize::ebml::reader;
|
||||
use serialize::ebml;
|
||||
@ -1152,8 +1152,8 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
|
||||
Ok(ty)
|
||||
}).unwrap();
|
||||
|
||||
fn type_string(doc: ebml::Doc) -> StrBuf {
|
||||
let mut str = StrBuf::new();
|
||||
fn type_string(doc: ebml::Doc) -> String {
|
||||
let mut str = String::new();
|
||||
for i in range(doc.start, doc.end) {
|
||||
str.push_char(doc.data[i] as char);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ use util::ppaux::{note_and_explain_region, Repr, UserString};
|
||||
use std::cell::{Cell};
|
||||
use std::ops::{BitOr, BitAnd};
|
||||
use std::rc::Rc;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use syntax::ast;
|
||||
use syntax::ast_map;
|
||||
use syntax::ast_util;
|
||||
@ -91,7 +91,7 @@ pub fn check_crate(tcx: &ty::ctxt,
|
||||
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 total = bccx.stats.guaranteed_paths.get() as f64;
|
||||
format_strbuf!("{} ({:.0f}%)", stat , stat_f * 100.0 / total)
|
||||
@ -296,7 +296,7 @@ impl BitAnd<RestrictionSet,RestrictionSet> 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)
|
||||
}
|
||||
}
|
||||
@ -574,7 +574,7 @@ impl<'a> BorrowckCtxt<'a> {
|
||||
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 {
|
||||
err_mutbl => {
|
||||
let descr = match opt_loan_path(&err.cmt) {
|
||||
@ -734,7 +734,7 @@ impl<'a> BorrowckCtxt<'a> {
|
||||
|
||||
pub fn append_loan_path_to_str(&self,
|
||||
loan_path: &LoanPath,
|
||||
out: &mut StrBuf) {
|
||||
out: &mut String) {
|
||||
match *loan_path {
|
||||
LpVar(id) => {
|
||||
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,
|
||||
loan_path: &LoanPath,
|
||||
out: &mut StrBuf) {
|
||||
out: &mut String) {
|
||||
match *loan_path {
|
||||
LpExtend(ref lp_base, _, LpDeref(_)) => {
|
||||
// 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 {
|
||||
let mut result = StrBuf::new();
|
||||
pub fn loan_path_to_str(&self, loan_path: &LoanPath) -> String {
|
||||
let mut result = String::new();
|
||||
self.append_loan_path_to_str(loan_path, &mut 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)
|
||||
}
|
||||
}
|
||||
@ -819,7 +819,7 @@ impl DataFlowOperator for LoanDataFlowOperator {
|
||||
}
|
||||
|
||||
impl Repr for Loan {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> StrBuf {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
(format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
|
||||
self.index,
|
||||
self.loan_path.repr(tcx),
|
||||
@ -831,7 +831,7 @@ impl Repr for Loan {
|
||||
}
|
||||
|
||||
impl Repr for Restriction {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> StrBuf {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
(format!("Restriction({}, {:x})",
|
||||
self.loan_path.repr(tcx),
|
||||
self.set.bits as uint)).to_strbuf()
|
||||
@ -839,7 +839,7 @@ impl Repr for Restriction {
|
||||
}
|
||||
|
||||
impl Repr for LoanPath {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> StrBuf {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match self {
|
||||
&LpVar(id) => {
|
||||
(format!("$({})", tcx.map.node_to_str(id))).to_strbuf()
|
||||
|
@ -25,10 +25,10 @@ pub type Edge<'a> = &'a cfg::CFGEdge;
|
||||
pub struct LabelledCFG<'a>{
|
||||
pub ast_map: &'a ast_map::Map,
|
||||
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,
|
||||
// improving presentation of (long) pretty-printed expressions.
|
||||
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> {
|
||||
let mut label = StrBuf::new();
|
||||
let mut label = String::new();
|
||||
let mut put_one = false;
|
||||
for (i, &node_id) in e.data.exiting_scopes.iter().enumerate() {
|
||||
if put_one {
|
||||
|
@ -33,7 +33,7 @@ use syntax::visit;
|
||||
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 tcontents = ty::type_contents(cx, node_ty);
|
||||
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> {
|
||||
fn report_error(&self, span: Span, result: Option<StrBuf>) -> bool {
|
||||
fn report_error(&self, span: Span, result: Option<String>) -> bool {
|
||||
match result {
|
||||
None => { false }
|
||||
Some(msg) => {
|
||||
|
@ -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)
|
||||
-> Result<const_val, StrBuf> {
|
||||
fn fromb(b: bool) -> Result<const_val, StrBuf> { Ok(const_int(b as i64)) }
|
||||
-> Result<const_val, String> {
|
||||
fn fromb(b: bool) -> Result<const_val, String> { Ok(const_int(b as i64)) }
|
||||
match e.node {
|
||||
ExprUnary(UnNeg, inner) => {
|
||||
match eval_const_expr_partial(tcx, inner) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
use std::io;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use std::uint;
|
||||
use syntax::ast;
|
||||
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)
|
||||
}
|
||||
|
||||
fn bits_to_str(words: &[uint]) -> StrBuf {
|
||||
let mut result = StrBuf::new();
|
||||
fn bits_to_str(words: &[uint]) -> String {
|
||||
let mut result = String::new();
|
||||
let mut sep = '[';
|
||||
|
||||
// Note: this is a little endian printout of bytes.
|
||||
@ -892,7 +892,7 @@ fn set_bit(words: &mut [uint], bit: uint) -> bool {
|
||||
oldv != newv
|
||||
}
|
||||
|
||||
fn bit_str(bit: uint) -> StrBuf {
|
||||
fn bit_str(bit: uint) -> String {
|
||||
let byte = bit >> 8;
|
||||
let lobits = 1 << (bit & 0xFF);
|
||||
format_strbuf!("[{}:{}-{:02x}]", bit, byte, lobits)
|
||||
|
@ -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).
|
||||
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) {
|
||||
tcx.sess.span_err(sp,
|
||||
format!("variable `{}` has dynamically sized type \
|
||||
|
@ -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) {
|
||||
&Some(id) => Ok(id),
|
||||
&None => {
|
||||
|
@ -150,7 +150,7 @@ enum LiveNodeKind {
|
||||
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();
|
||||
match lnk {
|
||||
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()) {
|
||||
&Local(LocalInfo { ident: nm, .. }) | &Arg(_, nm) => {
|
||||
token::get_ident(nm).get().to_str().to_strbuf()
|
||||
@ -750,7 +750,7 @@ impl<'a> Liveness<'a> {
|
||||
}
|
||||
|
||||
#[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 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);
|
||||
if name.len() == 0 || name.as_slice()[0] == ('_' as u8) {
|
||||
None
|
||||
|
@ -1093,7 +1093,7 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmt_to_str(&self, cmt: &cmt_) -> StrBuf {
|
||||
pub fn cmt_to_str(&self, cmt: &cmt_) -> String {
|
||||
match cmt.cat {
|
||||
cat_static_item => {
|
||||
"static item".to_strbuf()
|
||||
@ -1249,7 +1249,7 @@ impl cmt_ {
|
||||
}
|
||||
|
||||
impl Repr for cmt_ {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> StrBuf {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
format_strbuf!("\\{{} id:{} m:{:?} ty:{}\\}",
|
||||
self.cat.repr(tcx),
|
||||
self.id,
|
||||
@ -1259,7 +1259,7 @@ impl Repr for cmt_ {
|
||||
}
|
||||
|
||||
impl Repr for categorization {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> StrBuf {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
cat_static_item |
|
||||
cat_rvalue(..) |
|
||||
@ -1300,7 +1300,7 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
|
||||
}
|
||||
|
||||
impl Repr for InteriorKind {
|
||||
fn repr(&self, _tcx: &ty::ctxt) -> StrBuf {
|
||||
fn repr(&self, _tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
InteriorField(NamedField(fld)) => {
|
||||
token::get_name(fld).get().to_str().to_strbuf()
|
||||
|
@ -45,7 +45,7 @@ pub type PublicItems = NodeSet;
|
||||
/// Result of a checking operation - None => no errors were found. Some => an
|
||||
/// error and contains the span and message for reporting that error and
|
||||
/// 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)
|
||||
@ -356,7 +356,7 @@ enum FieldName {
|
||||
|
||||
impl<'a> PrivacyVisitor<'a> {
|
||||
// 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()
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ use collections::{HashMap, HashSet};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::mem::replace;
|
||||
use std::rc::{Rc, Weak};
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use std::uint;
|
||||
|
||||
// Definition mapping
|
||||
@ -57,7 +57,7 @@ pub type TraitMap = NodeMap<Vec<DefId> >;
|
||||
pub type ExportMap2 = RefCell<NodeMap<Vec<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.
|
||||
}
|
||||
|
||||
@ -221,8 +221,8 @@ enum FallbackSuggestion {
|
||||
Field,
|
||||
Method,
|
||||
TraitMethod,
|
||||
StaticMethod(StrBuf),
|
||||
StaticTraitMethod(StrBuf),
|
||||
StaticMethod(String),
|
||||
StaticTraitMethod(String),
|
||||
}
|
||||
|
||||
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 result = StrBuf::new();
|
||||
let mut result = String::new();
|
||||
for ident in idents.iter() {
|
||||
if first {
|
||||
first = false
|
||||
@ -2084,7 +2084,7 @@ impl<'a> Resolver<'a> {
|
||||
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
|
||||
.iter()
|
||||
.map(|seg| seg.identifier)
|
||||
@ -2094,7 +2094,7 @@ impl<'a> Resolver<'a> {
|
||||
|
||||
fn import_directive_subclass_to_str(&mut self,
|
||||
subclass: ImportDirectiveSubclass)
|
||||
-> StrBuf {
|
||||
-> String {
|
||||
match subclass {
|
||||
SingleImport(_, source) => {
|
||||
token::get_ident(source).get().to_strbuf()
|
||||
@ -2106,7 +2106,7 @@ impl<'a> Resolver<'a> {
|
||||
fn import_path_to_str(&mut self,
|
||||
idents: &[Ident],
|
||||
subclass: ImportDirectiveSubclass)
|
||||
-> StrBuf {
|
||||
-> String {
|
||||
if idents.is_empty() {
|
||||
self.import_directive_subclass_to_str(subclass)
|
||||
} else {
|
||||
@ -5019,7 +5019,7 @@ impl<'a> Resolver<'a> {
|
||||
}
|
||||
|
||||
fn find_best_match_for_name(&mut self, name: &str, max_distance: uint)
|
||||
-> Option<StrBuf> {
|
||||
-> Option<String> {
|
||||
let this = &mut *self;
|
||||
|
||||
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.
|
||||
fn module_to_str(&mut self, module: &Module) -> StrBuf {
|
||||
fn module_to_str(&mut self, module: &Module) -> String {
|
||||
let mut idents = Vec::new();
|
||||
|
||||
fn collect_mod(idents: &mut Vec<ast::Ident>, module: &Module) {
|
||||
|
@ -400,7 +400,7 @@ struct 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() {
|
||||
// for many programs, this just take too long to serialize
|
||||
self.pats.repr(tcx)
|
||||
|
@ -23,7 +23,7 @@ use middle::trans::type_of;
|
||||
use middle::trans::type_::Type;
|
||||
|
||||
use std::c_str::ToCStr;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use syntax::ast;
|
||||
|
||||
// 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);
|
||||
|
||||
let mut constraints =
|
||||
StrBuf::from_str(constraints.iter()
|
||||
String::from_str(constraints.iter()
|
||||
.map(|s| s.get().to_strbuf())
|
||||
.collect::<Vec<StrBuf>>()
|
||||
.collect::<Vec<String>>()
|
||||
.connect(",")
|
||||
.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 = "mips")]
|
||||
fn getClobbers() -> StrBuf {
|
||||
fn getClobbers() -> String {
|
||||
"".to_strbuf()
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn getClobbers() -> StrBuf {
|
||||
fn getClobbers() -> String {
|
||||
"~{dirflag},~{fpsr},~{flags}".to_strbuf()
|
||||
}
|
||||
|
@ -125,13 +125,13 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
|
||||
|
||||
pub struct StatRecorder<'a> {
|
||||
ccx: &'a CrateContext,
|
||||
name: Option<StrBuf>,
|
||||
name: Option<String>,
|
||||
start: u64,
|
||||
istart: uint,
|
||||
}
|
||||
|
||||
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() {
|
||||
time::precise_time_ns()
|
||||
} 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
|
||||
// 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) {
|
||||
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) {
|
||||
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,
|
||||
sp: Span,
|
||||
sym: StrBuf,
|
||||
sym: String,
|
||||
node_id: ast::NodeId,
|
||||
node_type: ty::t)
|
||||
-> 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
|
||||
pub fn register_fn_llvmty(ccx: &CrateContext,
|
||||
sp: Span,
|
||||
sym: StrBuf,
|
||||
sym: String,
|
||||
node_id: ast::NodeId,
|
||||
cc: lib::llvm::CallConv,
|
||||
llfty: Type) -> ValueRef {
|
||||
@ -1872,7 +1872,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
|
||||
}
|
||||
|
||||
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") {
|
||||
// Use provided name
|
||||
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 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())
|
||||
}).collect();
|
||||
|
||||
|
@ -122,7 +122,7 @@ pub fn Invoke(cx: &Block,
|
||||
terminate(cx, "Invoke");
|
||||
debug!("Invoke({} with arguments ({}))",
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ use middle::trans::machine::llalign_of_pref;
|
||||
use middle::trans::type_::Type;
|
||||
use collections::HashMap;
|
||||
use libc::{c_uint, c_ulonglong, c_char};
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use syntax::codemap::Span;
|
||||
|
||||
pub struct Builder<'a> {
|
||||
@ -69,7 +69,7 @@ impl<'a> Builder<'a> {
|
||||
// Pass 2: concat strings for each elt, skipping
|
||||
// forwards over any cycles by advancing to rightmost
|
||||
// occurrence of each element in path.
|
||||
let mut s = StrBuf::from_str(".");
|
||||
let mut s = String::from_str(".");
|
||||
i = 0u;
|
||||
while i < len {
|
||||
i = *mm.get(&v[i]);
|
||||
@ -806,7 +806,7 @@ impl<'a> Builder<'a> {
|
||||
self.ccx.tn.val_to_str(llfn),
|
||||
args.iter()
|
||||
.map(|&v| self.ccx.tn.val_to_str(v))
|
||||
.collect::<Vec<StrBuf>>()
|
||||
.collect::<Vec<String>>()
|
||||
.connect(", "));
|
||||
|
||||
unsafe {
|
||||
|
@ -756,7 +756,7 @@ impl<'a> CleanupScope<'a> {
|
||||
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
|
||||
* handles this cleanup scope
|
||||
|
@ -104,7 +104,7 @@ pub struct 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))
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
// will only be set in the case of default methods.
|
||||
@ -194,12 +194,12 @@ impl param_substs {
|
||||
}
|
||||
}
|
||||
|
||||
fn param_substs_to_str(this: ¶m_substs, tcx: &ty::ctxt) -> StrBuf {
|
||||
fn param_substs_to_str(this: ¶m_substs, tcx: &ty::ctxt) -> String {
|
||||
format_strbuf!("param_substs({})", this.substs.repr(tcx))
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -442,15 +442,15 @@ impl<'a> Block<'a> {
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
pub fn expr_to_str(&self, e: &ast::Expr) -> StrBuf {
|
||||
pub fn expr_to_str(&self, e: &ast::Expr) -> String {
|
||||
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)
|
||||
}
|
||||
|
||||
pub fn llty_str(&self, ty: Type) -> StrBuf {
|
||||
pub fn llty_str(&self, ty: Type) -> String {
|
||||
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())
|
||||
}
|
||||
|
||||
pub fn to_str(&self) -> StrBuf {
|
||||
pub fn to_str(&self) -> String {
|
||||
let blk: *Block = self;
|
||||
format_strbuf!("[block {}]", blk)
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ pub struct Stats {
|
||||
pub n_inlines: Cell<uint>,
|
||||
pub n_closures: 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)
|
||||
pub fn_stats: RefCell<Vec<(StrBuf, uint, uint)> >,
|
||||
pub fn_stats: RefCell<Vec<(String, uint, uint)> >,
|
||||
}
|
||||
|
||||
pub struct CrateContext {
|
||||
@ -60,7 +60,7 @@ pub struct CrateContext {
|
||||
pub item_vals: RefCell<NodeMap<ValueRef>>,
|
||||
pub exp_map2: resolve::ExportMap2,
|
||||
pub reachable: NodeSet,
|
||||
pub item_symbols: RefCell<NodeMap<StrBuf>>,
|
||||
pub item_symbols: RefCell<NodeMap<String>>,
|
||||
pub link_meta: LinkMeta,
|
||||
pub drop_glues: RefCell<HashMap<ty::t, ValueRef>>,
|
||||
pub tydescs: RefCell<HashMap<ty::t, Rc<tydesc_info>>>,
|
||||
@ -109,8 +109,8 @@ pub struct CrateContext {
|
||||
pub llsizingtypes: RefCell<HashMap<ty::t, Type>>,
|
||||
pub adt_reprs: RefCell<HashMap<ty::t, Rc<adt::Repr>>>,
|
||||
pub symbol_hasher: RefCell<Sha256>,
|
||||
pub type_hashcodes: RefCell<HashMap<ty::t, StrBuf>>,
|
||||
pub all_llvm_symbols: RefCell<HashSet<StrBuf>>,
|
||||
pub type_hashcodes: RefCell<HashMap<ty::t, String>>,
|
||||
pub all_llvm_symbols: RefCell<HashSet<String>>,
|
||||
pub tcx: ty::ctxt,
|
||||
pub stats: Stats,
|
||||
pub int_type: Type,
|
||||
|
@ -624,7 +624,7 @@ impl<K:KindOps> Datum<K> {
|
||||
}
|
||||
|
||||
#[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({}, {}, {:?})",
|
||||
ccx.tn.val_to_str(self.val),
|
||||
ty_to_str(ccx.tcx(), self.ty),
|
||||
|
@ -149,7 +149,7 @@ use collections::HashMap;
|
||||
use collections::HashSet;
|
||||
use libc::{c_uint, c_ulonglong, c_longlong};
|
||||
use std::ptr;
|
||||
use std::strbuf::StrBuf;
|
||||
use std::string::String;
|
||||
use std::sync::atomics;
|
||||
use syntax::codemap::{Span, Pos};
|
||||
use syntax::{abi, ast, codemap, ast_util, ast_map};
|
||||
@ -178,7 +178,7 @@ pub struct CrateDebugContext {
|
||||
llcontext: ContextRef,
|
||||
builder: DIBuilderRef,
|
||||
current_debug_location: Cell<DebugLocation>,
|
||||
created_files: RefCell<HashMap<StrBuf, DIFile>>,
|
||||
created_files: RefCell<HashMap<String, DIFile>>,
|
||||
created_types: RefCell<HashMap<uint, DIType>>,
|
||||
created_enum_disr_types: RefCell<HashMap<ast::DefId, DIType>>,
|
||||
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.
|
||||
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,
|
||||
generics,
|
||||
param_substs,
|
||||
@ -824,7 +824,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
|
||||
generics: &ast::Generics,
|
||||
param_substs: Option<¶m_substs>,
|
||||
file_metadata: DIFile,
|
||||
name_to_append_suffix_to: &mut StrBuf)
|
||||
name_to_append_suffix_to: &mut String)
|
||||
-> DIArray {
|
||||
let self_type = match param_substs {
|
||||
Some(param_substs) => param_substs.substs.self_ty,
|
||||
@ -1454,7 +1454,7 @@ impl GeneralMemberDescriptionFactory {
|
||||
}
|
||||
|
||||
struct EnumVariantMemberDescriptionFactory {
|
||||
args: Vec<(StrBuf, ty::t)> ,
|
||||
args: Vec<(String, ty::t)> ,
|
||||
discriminant_type_metadata: Option<DIType>,
|
||||
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.
|
||||
let args: Vec<(StrBuf, ty::t)> = arg_names.iter()
|
||||
let args: Vec<(String, ty::t)> = arg_names.iter()
|
||||
.zip(struct_def.fields.iter())
|
||||
.map(|(s, &t)| (s.to_strbuf(), t))
|
||||
.collect();
|
||||
@ -1732,7 +1732,7 @@ enum MemberOffset {
|
||||
}
|
||||
|
||||
struct MemberDescription {
|
||||
name: StrBuf,
|
||||
name: String,
|
||||
llvm_type: Type,
|
||||
type_metadata: DIType,
|
||||
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
|
||||
// `prepare_enum_metadata()`.
|
||||
fn generate_unique_type_id(prefix: &'static str) -> StrBuf {
|
||||
fn generate_unique_type_id(prefix: &'static str) -> String {
|
||||
unsafe {
|
||||
static mut unique_id_counter: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
|
||||
format_strbuf!("{}{}",
|
||||
@ -2841,7 +2841,7 @@ fn populate_scope_map(cx: &CrateContext,
|
||||
ast::ExprInlineAsm(ast::InlineAsm { inputs: ref inputs,
|
||||
outputs: ref outputs,
|
||||
.. }) => {
|
||||
// inputs, outputs: ~[(StrBuf, @expr)]
|
||||
// inputs, outputs: ~[(String, @expr)]
|
||||
for &(_, exp) in inputs.iter() {
|
||||
walk_expr(cx, exp, scope_stack, scope_map);
|
||||
}
|
||||
@ -2866,8 +2866,8 @@ struct NamespaceTreeNode {
|
||||
}
|
||||
|
||||
impl NamespaceTreeNode {
|
||||
fn mangled_name_of_contained_item(&self, item_name: &str) -> StrBuf {
|
||||
fn fill_nested(node: &NamespaceTreeNode, output: &mut StrBuf) {
|
||||
fn mangled_name_of_contained_item(&self, item_name: &str) -> String {
|
||||
fn fill_nested(node: &NamespaceTreeNode, output: &mut String) {
|
||||
match node.parent {
|
||||
Some(ref parent) => fill_nested(&*parent.upgrade().unwrap(), output),
|
||||
None => {}
|
||||
@ -2877,7 +2877,7 @@ impl NamespaceTreeNode {
|
||||
output.push_str(string.get());
|
||||
}
|
||||
|
||||
let mut name = StrBuf::from_str("_ZN");
|
||||
let mut name = String::from_str("_ZN");
|
||||
fill_nested(self, &mut name);
|
||||
name.push_str(format!("{}", item_name.len()).as_slice());
|
||||
name.push_str(item_name);
|
||||
|
@ -86,7 +86,7 @@ pub enum Dest {
|
||||
}
|
||||
|
||||
impl Dest {
|
||||
pub fn to_str(&self, ccx: &CrateContext) -> StrBuf {
|
||||
pub fn to_str(&self, ccx: &CrateContext) -> String {
|
||||
match *self {
|
||||
SaveIn(v) => format_strbuf!("SaveIn({})", ccx.tn.val_to_str(v)),
|
||||
Ignore => "Ignore".to_strbuf()
|
||||
|
@ -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,
|
||||
sp: Span,
|
||||
sym: StrBuf,
|
||||
sym: String,
|
||||
node_id: ast::NodeId)
|
||||
-> ValueRef {
|
||||
let _icx = push_ctxt("foreign::register_foreign_fn");
|
||||
|
@ -13,24 +13,24 @@ use middle::trans::type_::Type;
|
||||
use lib::llvm::ValueRef;
|
||||
|
||||
pub trait LlvmRepr {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> StrBuf;
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String;
|
||||
}
|
||||
|
||||
impl<'a, T:LlvmRepr> LlvmRepr for &'a [T] {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> StrBuf {
|
||||
let reprs: Vec<StrBuf> = self.iter().map(|t| t.llrepr(ccx)).collect();
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String {
|
||||
let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
|
||||
format_strbuf!("[{}]", reprs.connect(","))
|
||||
}
|
||||
}
|
||||
|
||||
impl LlvmRepr for Type {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> StrBuf {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String {
|
||||
ccx.tn.type_to_str(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl LlvmRepr for ValueRef {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> StrBuf {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String {
|
||||
ccx.tn.val_to_str(*self)
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ pub struct 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={}, \
|
||||
llunit_size={}, llunit_alloc_size={}\\}",
|
||||
ty_to_str(ccx.tcx(), self.unit_ty),
|
||||
|
@ -302,7 +302,7 @@ pub fn llvm_type_name(cx: &CrateContext,
|
||||
what: named_ty,
|
||||
did: ast::DefId,
|
||||
tps: &[ty::t])
|
||||
-> StrBuf {
|
||||
-> String {
|
||||
let name = match what {
|
||||
a_struct => { "struct" }
|
||||
an_enum => { "enum" }
|
||||
|
@ -278,7 +278,7 @@ pub struct ctxt {
|
||||
pub freevars: RefCell<freevars::freevar_map>,
|
||||
pub tcache: type_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 tc_cache: RefCell<HashMap<uint, TypeContents>>,
|
||||
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()
|
||||
}
|
||||
|
||||
pub fn substs_to_str(cx: &ctxt, substs: &substs) -> StrBuf {
|
||||
pub fn substs_to_str(cx: &ctxt, substs: &substs) -> String {
|
||||
substs.repr(cx)
|
||||
}
|
||||
|
||||
@ -3201,7 +3201,7 @@ pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
|
||||
token::get_name(name),
|
||||
fields.iter()
|
||||
.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> {
|
||||
@ -3224,7 +3224,7 @@ pub fn param_tys_in_type(ty: t) -> Vec<param_ty> {
|
||||
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 {
|
||||
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) |
|
||||
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,
|
||||
@ -3265,7 +3265,7 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> StrBuf {
|
||||
* to present additional details, particularly when
|
||||
* it comes to lifetime-related errors. */
|
||||
|
||||
fn tstore_to_closure(s: &TraitStore) -> StrBuf {
|
||||
fn tstore_to_closure(s: &TraitStore) -> String {
|
||||
match s {
|
||||
&UniqTraitStore => "proc".to_strbuf(),
|
||||
&RegionTraitStore(..) => "closure".to_strbuf()
|
||||
@ -3708,7 +3708,7 @@ pub fn substd_enum_variants(cx: &ctxt,
|
||||
}).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()
|
||||
}
|
||||
|
||||
@ -4276,14 +4276,14 @@ pub fn each_bound_trait_and_supertraits(tcx: &ctxt,
|
||||
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.intrinsic_defs.borrow().find_copy(&tydesc_lang_item)
|
||||
.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.intrinsic_defs.borrow().find_copy(&opaque_lang_item)
|
||||
.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,
|
||||
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) {
|
||||
Ok(id) => id,
|
||||
Err(s) => { return Err(s); }
|
||||
|
@ -1495,11 +1495,11 @@ impl<'a> LookupContext<'a> {
|
||||
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)
|
||||
}
|
||||
|
||||
fn did_to_str(&self, did: DefId) -> StrBuf {
|
||||
fn did_to_str(&self, did: DefId) -> String {
|
||||
ty::item_path_str(self.tcx(), did)
|
||||
}
|
||||
|
||||
@ -1509,7 +1509,7 @@ impl<'a> LookupContext<'a> {
|
||||
}
|
||||
|
||||
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={}, \
|
||||
origin={:?})",
|
||||
self.rcvr_match_condition.repr(tcx),
|
||||
@ -1520,7 +1520,7 @@ impl Repr for Candidate {
|
||||
}
|
||||
|
||||
impl Repr for RcvrMatchCondition {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> StrBuf {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
RcvrMatchesIfObject(d) => {
|
||||
format_strbuf!("RcvrMatchesIfObject({})", d.repr(tcx))
|
||||
|
@ -468,7 +468,7 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
|
||||
let ret_ty = fn_sig.output;
|
||||
|
||||
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));
|
||||
|
||||
// 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> {
|
||||
pub fn tag(&self) -> StrBuf {
|
||||
pub fn tag(&self) -> String {
|
||||
format_strbuf!("{}", self as *FnCtxt)
|
||||
}
|
||||
|
||||
@ -1176,7 +1176,7 @@ impl<'a> FnCtxt<'a> {
|
||||
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())
|
||||
}
|
||||
|
||||
@ -1283,7 +1283,7 @@ impl<'a> FnCtxt<'a> {
|
||||
|
||||
pub fn type_error_message(&self,
|
||||
sp: Span,
|
||||
mk_msg: |StrBuf| -> StrBuf,
|
||||
mk_msg: |String| -> String,
|
||||
actual_ty: ty::t,
|
||||
err: Option<&ty::type_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={:?}",
|
||||
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.
|
||||
// We do this in a pretty awful way: first we typecheck any arguments
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user