diff --git a/doc/rust.md b/doc/rust.md index 1a7ea1543256..21d15c8b114f 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -449,7 +449,7 @@ Two examples of paths with type arguments: # import std::map; # fn f() { # fn id(t: T) -> T { t } -type t = map::hashmap; // Type arguments used in a type expression +type t = map::hashmap; // Type arguments used in a type expression let x = id::(10); // Type arguments used in a call expression # } ~~~~ @@ -563,7 +563,7 @@ a referencing crate file, or by the filename of the source file itself. A source file that contains a `main` function can be compiled to an executable. If a `main` function is present, it must have no [type parameters](#type-parameters) -and no [constraints](#constraints). Its return type must be [`nil`](#primitive-types) and it must either have no arguments, or a single argument of type `[str]`. +and no [constraints](#constraints). Its return type must be [`nil`](#primitive-types) and it must either have no arguments, or a single argument of type `[~str]`. # Items and attributes @@ -745,8 +745,8 @@ fn main() { log(info, some(1.0)); // Equivalent to 'log(core::info, - // core::str::hash(core::str::slice("foo", 0u, 1u)));' - log(info, hash(slice("foo", 0u, 1u))); + // core::str::hash(core::str::slice(~"foo", 0u, 1u)));' + log(info, hash(slice(~"foo", 0u, 1u))); } ~~~~ @@ -861,7 +861,7 @@ A special kind of function can be declared with a `!` character where the output slot type would normally be. For example: ~~~~ -fn my_err(s: str) -> ! { +fn my_err(s: ~str) -> ! { log(info, s); fail; } @@ -881,14 +881,14 @@ were declared without the `!` annotation, the following code would not typecheck: ~~~~ -# fn my_err(s: str) -> ! { fail } +# fn my_err(s: ~str) -> ! { fail } fn f(i: int) -> int { if i == 42 { ret 42; } else { - my_err("Bad number!"); + my_err(~"Bad number!"); } } ~~~~ @@ -1497,7 +1497,7 @@ string, boolean value, or the nil value. ~~~~~~~~ {.literals} (); // nil type -"hello"; // string type +~"hello"; // string type '5'; // character type 5; // integer type ~~~~~~~~ @@ -1510,7 +1510,7 @@ values. ~~~~~~~~ {.tuple} (0f, 4.5f); -("a", 4u, true); +(~"a", 4u, true); ~~~~~~~~ ### Record expressions @@ -1529,8 +1529,8 @@ written before its name. ~~~~ {x: 10f, y: 20f}; -{name: "Joe", age: 35u, score: 100_000}; -{ident: "X", mut count: 0u}; +{name: ~"Joe", age: 35u, score: 100_000}; +{ident: ~"X", mut count: 0u}; ~~~~ The order of the fields in a record expression is significant, and @@ -1594,7 +1594,7 @@ When no mutability is specified, the vector is immutable. ~~~~ ~[1, 2, 3, 4]; -~["a", "b", "c", "d"]; +~[~"a", ~"b", ~"c", ~"d"]; ~[mut 0u8, 0u8, 0u8, 0u8]; ~~~~ @@ -1620,7 +1620,7 @@ task in a _failing state_. (~[1, 2, 3, 4])[0]; (~[mut 'x', 'y'])[1] = 'z'; -(~["a", "b"])[10]; // fails +(~[~"a", ~"b"])[10]; // fails # } ~~~~ @@ -1965,7 +1965,7 @@ An example: # let println = io::println; while i < 10 { - println("hello\n"); + println(~"hello\n"); i = i + 1; } ~~~~ @@ -2103,9 +2103,9 @@ enum list { nil, cons(X, @list) } let x: list = cons(10, @cons(11, @nil)); alt x { - cons(_, @nil) { fail "singleton list"; } + cons(_, @nil) { fail ~"singleton list"; } cons(*) { ret; } - nil { fail "empty list"; } + nil { fail ~"empty list"; } } ~~~~ @@ -2152,19 +2152,19 @@ When matching fields of a record, the fields being matched are specified first, then a placeholder (`_`) represents the remaining fields. ~~~~ -# type options = {choose: bool, size: str}; -# type player = {player: str, stats: (), options: options}; +# type options = {choose: bool, size: ~str}; +# type player = {player: ~str, stats: (), options: options}; # fn load_stats() { } # fn choose_player(r: player) { } # fn next_player() { } fn main() { let r = { - player: "ralph", + player: ~"ralph", stats: load_stats(), options: { choose: true, - size: "small" + size: ~"small" } }; @@ -2172,8 +2172,8 @@ fn main() { {options: {choose: true, _}, _} { choose_player(r) } - {player: p, options: {size: "small", _}, _} { - log(info, p + " is small"); + {player: p, options: {size: ~"small", _}, _} { + log(info, p + ~" is small"); } _ { next_player(); @@ -2189,9 +2189,9 @@ range of values may be specified with `to`. For example: # let x = 2; let message = alt x { - 0 | 1 { "not many" } - 2 to 9 { "a few" } - _ { "lots" } + 0 | 1 { ~"not many" } + 2 to 9 { ~"a few" } + _ { ~"lots" } }; ~~~~ @@ -2250,9 +2250,9 @@ the `note` to the internal logging diagnostic buffer. An example of a `note` expression: ~~~~{.xfail-test} -fn read_file_lines(path: str) -> ~[str] { +fn read_file_lines(path: ~str) -> ~[~str] { note path; - let r: [str]; + let r: [~str]; let f: file = open_read(path); lines(f) |s| { r += ~[s]; @@ -2323,13 +2323,13 @@ The following examples all produce the same output, logged at the `error` logging level: ~~~~ -# let filename = "bulbasaur"; +# let filename = ~"bulbasaur"; // Full version, logging a value. -log(core::error, "file not found: " + filename); +log(core::error, ~"file not found: " + filename); // Log-level abbreviated, since core::* is imported by default. -log(error, "file not found: " + filename); +log(error, ~"file not found: " + filename); // Formatting the message using a format-string and #fmt log(error, #fmt("file not found: %s", filename)); @@ -2627,12 +2627,12 @@ type `float` may not be equal to the largest *supported* floating-point type. ### Textual types -The types `char` and `str` hold textual data. +The types `char` and `~str` hold textual data. A value of type `char` is a Unicode character, represented as a 32-bit unsigned word holding a UCS-4 codepoint. -A value of type `str` is a Unicode string, represented as a vector of 8-bit +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. @@ -2670,10 +2670,10 @@ order specified by the tuple type. An example of a tuple type and its use: ~~~~ -type pair = (int,str); -let p: pair = (10,"hello"); +type pair = (int,~str); +let p: pair = (10,~"hello"); let (a, b) = p; -assert b != "world"; +assert b != ~"world"; ~~~~ ### Vector types @@ -2837,7 +2837,7 @@ For example, this code: ~~~~~~~~ # let mut s; -s = "hello, world"; +s = ~"hello, world"; io::println(s); ~~~~~~~~ @@ -2862,8 +2862,8 @@ Whereas this code: ~~~~~~~~ -# fn x() -> str { "" } -# fn y() -> str { "" } +# fn x() -> ~str { ~"" } +# fn y() -> ~str { ~"" } io::println(x() + y()); ~~~~~~~~ @@ -3364,7 +3364,7 @@ An example of a send: ~~~~ let po = comm::port(); let ch = comm::chan(po); -comm::send(ch, "hello, world"); +comm::send(ch, ~"hello, world"); ~~~~ @@ -3380,7 +3380,7 @@ An example of a *receive*: ~~~~~~~~ # let po = comm::port(); # let ch = comm::chan(po); -# comm::send(ch, ""); +# comm::send(ch, ~""); let s = comm::recv(po); ~~~~~~~~ diff --git a/doc/tutorial.md b/doc/tutorial.md index 403b44e21a9d..749dcf043de8 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -84,8 +84,8 @@ fn main() { do listen |result_from_game| { let times = 10; - let player1 = "graydon"; - let player2 = "patrick"; + let player1 = ~"graydon"; + let player2 = ~"patrick"; for repeat(times) { // Start another task to play the game @@ -102,7 +102,7 @@ fn main() { } } - fn play_game(player1: str, player2: str) -> str { + fn play_game(player1: ~str, player2: ~str) -> ~str { // Our rock/paper/scissors types enum gesture { @@ -117,7 +117,7 @@ fn main() { alt (pick(), pick()) { (rock, scissors) | (paper, rock) | (scissors, paper) { copy player1 } (scissors, rock) | (rock, paper) | (paper, scissors) { copy player2 } - _ { "tie" } + _ { ~"tie" } } } } @@ -206,8 +206,8 @@ Rust program files are, by convention, given the extension `.rs`. Say we have a file `hello.rs` containing this program: ~~~~ -fn main(args: ~[str]) { - io::println("hello world from '" + args[0] + "'!"); +fn main(args: ~[~str]) { + io::println(~"hello world from '" + args[0] + ~"'!"); } ~~~~ @@ -220,7 +220,7 @@ If you modify the program to make it invalid (for example, by changing ~~~~ {.notrust} hello.rs:2:4: 2:16 error: unresolved name: io::print_it -hello.rs:2 io::print_it("hello world from '" + args[0] + "'!"); +hello.rs:2 io::print_it(~"hello world from '" + args[0] + ~"'!"); ^~~~~~~~~~~~ ~~~~ @@ -367,7 +367,7 @@ defined with `const`: use std; const repeat: uint = 5u; fn main() { - let hi = "Hi!"; + let hi = ~"Hi!"; let mut count = 0u; while count < repeat { io::println(hi); @@ -437,7 +437,7 @@ The basic types are written like this: `char` : A character is a 32-bit Unicode code point. -`str` +`~str` : String type. A string contains a UTF-8 encoded sequence of characters. These can be combined in composite types, which will be described in @@ -560,13 +560,13 @@ character escapes, using the backslash character: form the character code. String literals allow the same escape sequences. They are written -between double quotes (`"hello"`). Rust strings may contain newlines. +between double quotes (`~"hello"`). Rust strings may contain newlines. When a newline is preceded by a backslash, it, and all white space following it, will not appear in the resulting string literal. So -this is equivalent to `"abc"`: +this is equivalent to `~"abc"`: ~~~~ -let s = "a\ +let s = ~"a\ b\ c"; ~~~~ @@ -649,7 +649,7 @@ one is `#fmt`, a printf-style text formatting macro that is expanded at compile time. ~~~~ -io::println(#fmt("%s is %d", "the answer", 42)); +io::println(#fmt("%s is %d", ~"the answer", 42)); ~~~~ `#fmt` supports most of the directives that [printf][pf] supports, but @@ -676,11 +676,11 @@ compulsory, an optional `else` clause can be appended, and multiple ~~~~ if false { - io::println("that's odd"); + io::println(~"that's odd"); } else if true { - io::println("right"); + io::println(~"right"); } else { - io::println("neither true nor false"); + io::println(~"neither true nor false"); } ~~~~ @@ -713,10 +713,10 @@ the value. ~~~~ # let my_number = 1; alt my_number { - 0 { io::println("zero"); } - 1 | 2 { io::println("one or two"); } - 3 to 10 { io::println("three to ten"); } - _ { io::println("something else"); } + 0 { io::println(~"zero"); } + 1 | 2 { io::println(~"one or two"); } + 3 to 10 { io::println(~"three to ten"); } + _ { io::println(~"something else"); } } ~~~~ @@ -822,7 +822,7 @@ failure; failure is nonrecoverable. It is, however, possible for running. `fail` takes an optional argument specifying the reason for the -failure. It must have type `str`. +failure. It must have type `~str`. In addition to the `fail` statement, the following circumstances cause task failure: @@ -860,7 +860,7 @@ runtime will do its best to output a textual representation of the value. ~~~~ -log(warn, "hi"); +log(warn, ~"hi"); log(error, (1, ~[2.5, -1.8])); ~~~~ @@ -886,7 +886,7 @@ are available. These take a string and any number of format arguments, and will log the formatted string: ~~~~ -# fn get_error_string() -> str { "boo" } +# fn get_error_string() -> ~str { ~"boo" } #warn("only %d seconds remaining", 10); #error("fatal: %s", get_error_string()); ~~~~ @@ -905,8 +905,8 @@ with the `fn` keyword, the type of arguments are specified following colons and the return type follows the arrow. ~~~~ -fn int_to_str(i: int) -> str { - ret "tube sock"; +fn int_to_str(i: int) -> ~str { + ret ~"tube sock"; } ~~~~ @@ -917,20 +917,20 @@ expression. ~~~~ # const copernicus: int = 0; -fn int_to_str(i: int) -> str { +fn int_to_str(i: int) -> ~str { if i == copernicus { - ret "tube sock"; + ret ~"tube sock"; } else { - ret "violin"; + ret ~"violin"; } } ~~~~ ~~~~ # const copernicus: int = 0; -fn int_to_str(i: int) -> str { - if i == copernicus { "tube sock" } - else { "violin" } +fn int_to_str(i: int) -> ~str { + if i == copernicus { ~"tube sock" } + else { ~"violin" } } ~~~~ @@ -1348,7 +1348,7 @@ the pointer is guaranteed not to outlive the value it points to. ~~~~ # fn work_with_foo_by_pointer(f: &~str) { } -let foo = "foo"; +let foo = ~"foo"; work_with_foo_by_pointer(&foo); ~~~~ @@ -1359,7 +1359,7 @@ would outlive `foo` itself. ~~~~ {.ignore} let foo_ptr; { - let foo = "foo"; + let foo = ~"foo"; foo_ptr = &foo; } ~~~~ @@ -1469,7 +1469,7 @@ my_crayons += your_crayons; ## Strings -The `str` type in Rust is represented exactly the same way as a unique +The `~str` type in Rust is represented exactly the same way as a unique vector of immutable bytes (`~[u8]`). This sequence of bytes is interpreted as an UTF-8 encoded sequence of characters. This has the advantage that UTF-8 encoded I/O (which should really be the default @@ -1479,7 +1479,7 @@ disadvantage that you only get constant-time access by byte, not by character. ~~~~ -let huh = "what?"; +let huh = ~"what?"; let que: u8 = huh[4]; // indexing a string returns a `u8` assert que == '?' as u8; ~~~~ @@ -1510,7 +1510,7 @@ brief look at a few common ones. # fn unwrap_crayon(c: crayon) -> int { 0 } # fn eat_crayon_wax(i: int) { } # fn store_crayon_in_nasal_cavity(i: uint, c: crayon) { } -# fn crayon_to_str(c: crayon) -> str { "" } +# fn crayon_to_str(c: crayon) -> ~str { ~"" } let crayons = ~[almond, antique_brass, apricot]; @@ -1571,7 +1571,7 @@ them. In the rare case where the compiler needs assistance though, the arguments and return types may be annotated. ~~~~ -# type mygoodness = fn(str) -> str; type what_the = int; +# type mygoodness = fn(~str) -> ~str; type what_the = int; let bloop = |well, oh: mygoodness| -> what_the { fail oh(well) }; ~~~~ @@ -1611,17 +1611,17 @@ returns it from a function, and then calls it: ~~~~ use std; -fn mk_appender(suffix: str) -> fn@(str) -> str { - ret fn@(s: str) -> str { s + suffix }; +fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str { + ret fn@(s: ~str) -> ~str { s + suffix }; } fn main() { - let shout = mk_appender("!"); - io::println(shout("hey ho, let's go")); + let shout = mk_appender(~"!"); + io::println(shout(~"hey ho, let's go")); } ~~~~ -This example uses the long closure syntax, `fn@(s: str) ...`, +This example uses the long closure syntax, `fn@(s: ~str) ...`, making the fact that we are declaring a box closure explicit. In practice boxed closures are usually defined with the short closure syntax introduced earlier, in which case the compiler will infer @@ -1629,7 +1629,7 @@ the type of closure. Thus our boxed closure example could also be written: ~~~~ -fn mk_appender(suffix: str) -> fn@(str) -> str { +fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str { ret |s| s + suffix; } ~~~~ @@ -1654,11 +1654,11 @@ that callers have the flexibility to pass whatever they want. ~~~~ fn call_twice(f: fn()) { f(); f(); } -call_twice(|| { "I am an inferred stack closure"; } ); -call_twice(fn&() { "I am also a stack closure"; } ); -call_twice(fn@() { "I am a boxed closure"; }); -call_twice(fn~() { "I am a unique closure"; }); -fn bare_function() { "I am a plain function"; } +call_twice(|| { ~"I am an inferred stack closure"; } ); +call_twice(fn&() { ~"I am also a stack closure"; } ); +call_twice(fn@() { ~"I am a boxed closure"; }); +call_twice(fn~() { ~"I am a unique closure"; }); +fn bare_function() { ~"I am a plain function"; } call_twice(bare_function); ~~~~ @@ -1762,7 +1762,7 @@ And using this function to iterate over a vector: # import println = io::println; each(~[2, 4, 8, 5, 16], |n| { if n % 2 != 0 { - println("found odd number!"); + println(~"found odd number!"); false } else { true } }); @@ -1779,7 +1779,7 @@ to the next iteration, write `again`. # import println = io::println; for each(~[2, 4, 8, 5, 16]) |n| { if n % 2 != 0 { - println("found odd number!"); + println(~"found odd number!"); break; } } @@ -1832,7 +1832,7 @@ class example { } fn a() { - io::println("a"); + io::println(~"a"); } drop { @@ -1953,8 +1953,8 @@ being owned by the data structure, so if that can be done without a copy, that's a win. ~~~~ -type person = {name: str, address: str}; -fn make_person(+name: str, +address: str) -> person { +type person = {name: ~str, address: ~str}; +fn make_person(+name: ~str, +address: ~str) -> person { ret {name: name, address: address}; } ~~~~ @@ -2007,7 +2007,7 @@ enum option { some(T), none } ~~~~ You can then declare a function to take a `circular_buf` or return -an `option`, or even an `option` if the function itself is +an `option<~str>`, or even an `option` if the function itself is generic. The `option` type given above exists in the core library and is the @@ -2051,8 +2051,8 @@ take any type of value and output it. More interesting is that Rust also defines an ordering for values of all datatypes, and allows you to meaningfully apply comparison operators (`<`, `>`, `<=`, `>=`, `==`, `!=`) to them. For structural -types, the comparison happens left to right, so `"abc" < "bac"` (but -note that `"bac" < "ác"`, because the ordering acts on UTF-8 sequences +types, the comparison happens left to right, so `~"abc" < ~"bac"` (but +note that `~"bac" < ~"ác"`, because the ordering acts on UTF-8 sequences without any sophistication). ## Kinds @@ -2135,8 +2135,8 @@ explicitly import it, you must refer to it by its long name, ~~~~ mod farm { - fn chicken() -> str { "cluck cluck" } - fn cow() -> str { "mooo" } + fn chicken() -> ~str { ~"cluck cluck" } + fn cow() -> ~str { ~"mooo" } } fn main() { io::println(farm::chicken()); @@ -2249,14 +2249,14 @@ these two files: ~~~~ // mylib.rs #[link(name = "mylib", vers = "1.0")]; -fn world() -> str { "world" } +fn world() -> ~str { ~"world" } ~~~~ ~~~~ {.ignore} // main.rs use std; use mylib; -fn main() { io::println("hello " + mylib::world()); } +fn main() { io::println(~"hello " + mylib::world()); } ~~~~ Now compile and run like this (adjust to your platform if necessary): @@ -2279,7 +2279,7 @@ identifiers at the top of a file, module, or block. use std; import io::println; fn main() { - println("that was easy"); + println(~"that was easy"); } ~~~~ @@ -2345,7 +2345,7 @@ Identifiers can shadow each other. In this program, `x` is of type `int`: ~~~~ -type t = str; +type t = ~str; fn main() { type t = int; let x: t; @@ -2408,7 +2408,7 @@ can be converted to a string, with a single method of the same name: ~~~~ iface to_str { - fn to_str() -> str; + fn to_str() -> ~str; } ~~~~ @@ -2416,20 +2416,20 @@ iface to_str { To actually implement an interface for a given type, the `impl` form is used. This defines implementations of `to_str` for the `int` and -`str` types. +`~str` types. ~~~~ -# iface to_str { fn to_str() -> str; } +# iface to_str { fn to_str() -> ~str; } impl of to_str for int { - fn to_str() -> str { int::to_str(self, 10u) } + fn to_str() -> ~str { int::to_str(self, 10u) } } -impl of to_str for str { - fn to_str() -> str { self } +impl of to_str for ~str { + fn to_str() -> ~str { self } } ~~~~ -Given these, we may call `1.to_str()` to get `"1"`, or -`"foo".to_str()` to get `"foo"` again. This is basically a form of +Given these, we may call `1.to_str()` to get `~"1"`, or +`(~"foo").to_str()` to get `~"foo"` again. This is basically a form of static overloading—when the Rust compiler sees the `to_str` method call, it looks for an implementation that matches the type with a method that matches the name, and simply calls that. @@ -2444,9 +2444,9 @@ without problems). Or you can give them an explicit name if you prefer, using this syntax: ~~~~ -# iface to_str { fn to_str() -> str; } +# iface to_str { fn to_str() -> ~str; } impl nil_to_str of to_str for () { - fn to_str() -> str { "()" } + fn to_str() -> ~str { ~"()" } } ~~~~ @@ -2460,12 +2460,12 @@ known at compile time, it is possible to specify 'bounds' for type parameters. ~~~~ -# iface to_str { fn to_str() -> str; } -fn comma_sep(elts: ~[T]) -> str { - let mut result = "", first = true; +# iface to_str { fn to_str() -> ~str; } +fn comma_sep(elts: ~[T]) -> ~str { + let mut result = ~"", first = true; for elts.each |elt| { if first { first = false; } - else { result += ", "; } + else { result += ~", "; } result += elt.to_str(); } ret result; @@ -2576,14 +2576,14 @@ to leave off the `of` clause. ~~~~ # type currency = (); -# fn mk_currency(x: int, s: str) {} +# fn mk_currency(x: int, s: ~str) {} impl int_util for int { fn times(b: fn(int)) { let mut i = 0; while i < self { b(i); i += 1; } } fn dollars() -> currency { - mk_currency(self, "USD") + mk_currency(self, ~"USD") } } ~~~~ @@ -2615,20 +2615,20 @@ extern mod crypto { fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8; } -fn as_hex(data: ~[u8]) -> str { - let mut acc = ""; +fn as_hex(data: ~[u8]) -> ~str { + let mut acc = ~""; for data.each |byte| { acc += #fmt("%02x", byte as uint); } ret acc; } -fn sha1(data: str) -> str unsafe { +fn sha1(data: ~str) -> ~str unsafe { let bytes = str::bytes(data); let hash = crypto::SHA1(vec::unsafe::to_ptr(bytes), vec::len(bytes), ptr::null()); ret as_hex(vec::unsafe::from_buf(hash, 20u)); } -fn main(args: ~[str]) { +fn main(args: ~[~str]) { io::println(sha1(args[1])); } ~~~~ @@ -2719,8 +2719,8 @@ The `sha1` function is the most obscure part of the program. ~~~~ # mod crypto { fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8 { out } } -# fn as_hex(data: ~[u8]) -> str { "hi" } -fn sha1(data: str) -> str { +# fn as_hex(data: ~[u8]) -> ~str { ~"hi" } +fn sha1(data: ~str) -> ~str { unsafe { let bytes = str::bytes(data); let hash = crypto::SHA1(vec::unsafe::to_ptr(bytes), @@ -2746,7 +2746,7 @@ Unsafe blocks isolate unsafety. Unsafe functions, on the other hand, advertise it to the world. An unsafe function is written like this: ~~~~ -unsafe fn kaboom() { "I'm harmless!"; } +unsafe fn kaboom() { ~"I'm harmless!"; } ~~~~ This function can only be called from an unsafe block or another @@ -2762,8 +2762,8 @@ Let's look at our `sha1` function again. ~~~~ # mod crypto { fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8 { out } } -# fn as_hex(data: ~[u8]) -> str { "hi" } -# fn x(data: str) -> str { +# fn as_hex(data: ~[u8]) -> ~str { ~"hi" } +# fn x(data: ~str) -> ~str { # unsafe { let bytes = str::bytes(data); let hash = crypto::SHA1(vec::unsafe::to_ptr(bytes), @@ -2816,7 +2816,7 @@ fn unix_time_in_microseconds() -> u64 unsafe { ret (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64); } -# fn main() { assert #fmt("%?", unix_time_in_microseconds()) != ""; } +# fn main() { assert #fmt("%?", unix_time_in_microseconds()) != ~""; } ~~~~ The `#[nolink]` attribute indicates that there's no foreign library to @@ -2855,7 +2855,7 @@ import io::println; let some_value = 22; do spawn { - println("This executes in the child task."); + println(~"This executes in the child task."); println(#fmt("%d", some_value)); } ~~~~ @@ -2957,7 +2957,7 @@ Here is the function which implements the child task: ~~~~ # import comm::{port, chan, methods}; fn stringifier(from_parent: port, - to_parent: chan) { + to_parent: chan<~str>) { let mut value: uint; loop { value = from_parent.recv(); @@ -2981,10 +2981,10 @@ Here is the code for the parent task: # import task::{spawn_listener}; # import comm::{chan, port, methods}; # fn stringifier(from_parent: comm::port, -# to_parent: comm::chan) { -# comm::send(to_parent, "22"); -# comm::send(to_parent, "23"); -# comm::send(to_parent, "0"); +# to_parent: comm::chan<~str>) { +# comm::send(to_parent, ~"22"); +# comm::send(to_parent, ~"23"); +# comm::send(to_parent, ~"0"); # } # fn main() { @@ -2995,13 +2995,13 @@ let to_child = do spawn_listener |from_parent| { }; to_child.send(22u); -assert from_child.recv() == "22"; +assert from_child.recv() == ~"22"; to_child.send(23u); -assert from_child.recv() == "23"; +assert from_child.recv() == ~"23"; to_child.send(0u); -assert from_child.recv() == "0"; +assert from_child.recv() == ~"0"; # } ~~~~ diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index e69945c97b97..6b9b6c9c39de 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -15,106 +15,106 @@ import getopts::{optflag, optopt, opt_present}; type package = { - name: str, - uuid: str, - url: str, - method: str, - description: str, - ref: option, - tags: ~[str], - versions: ~[(str, str)] + name: ~str, + uuid: ~str, + url: ~str, + method: ~str, + description: ~str, + ref: option<~str>, + tags: ~[~str], + versions: ~[(~str, ~str)] }; type local_package = { - name: str, - metaname: str, - version: str, - files: ~[str] + name: ~str, + metaname: ~str, + version: ~str, + files: ~[~str] }; type source = @{ - name: str, - mut url: str, - mut method: str, - mut key: option, - mut keyfp: option, + name: ~str, + mut url: ~str, + mut method: ~str, + mut key: option<~str>, + mut keyfp: option<~str>, mut packages: ~[mut package] }; type cargo = { pgp: bool, - root: str, - installdir: str, - bindir: str, - libdir: str, - workdir: str, - sourcedir: str, - sources: map::hashmap, - mut current_install: str, - dep_cache: map::hashmap, + root: ~str, + installdir: ~str, + bindir: ~str, + libdir: ~str, + workdir: ~str, + sourcedir: ~str, + sources: map::hashmap<~str, source>, + mut current_install: ~str, + dep_cache: map::hashmap<~str, bool>, opts: options }; type crate = { - name: str, - vers: str, - uuid: str, - desc: option, - sigs: option, - crate_type: option, - deps: ~[str] + name: ~str, + vers: ~str, + uuid: ~str, + desc: option<~str>, + sigs: option<~str>, + crate_type: option<~str>, + deps: ~[~str] }; type options = { test: bool, mode: mode, - free: ~[str], + free: ~[~str], help: bool, }; enum mode { system_mode, user_mode, local_mode } fn opts() -> ~[getopts::opt] { - ~[optflag("g"), optflag("G"), optflag("test"), - optflag("h"), optflag("help")] + ~[optflag(~"g"), optflag(~"G"), optflag(~"test"), + optflag(~"h"), optflag(~"help")] } -fn info(msg: str) { +fn info(msg: ~str) { let out = io::stdout(); if term::color_supported() { term::fg(out, term::color_green); - out.write_str("info: "); + out.write_str(~"info: "); term::reset(out); out.write_line(msg); - } else { out.write_line("info: " + msg); } + } else { out.write_line(~"info: " + msg); } } -fn warn(msg: str) { +fn warn(msg: ~str) { let out = io::stdout(); if term::color_supported() { term::fg(out, term::color_yellow); - out.write_str("warning: "); + out.write_str(~"warning: "); term::reset(out); out.write_line(msg); - }else { out.write_line("warning: " + msg); } + }else { out.write_line(~"warning: " + msg); } } -fn error(msg: str) { +fn error(msg: ~str) { let out = io::stdout(); if term::color_supported() { term::fg(out, term::color_red); - out.write_str("error: "); + out.write_str(~"error: "); term::reset(out); out.write_line(msg); } - else { out.write_line("error: " + msg); } + else { out.write_line(~"error: " + msg); } } -fn is_uuid(id: str) -> bool { - let parts = str::split_str(id, "-"); +fn is_uuid(id: ~str) -> bool { + let parts = str::split_str(id, ~"-"); if vec::len(parts) == 5u { let mut correct = 0u; for vec::eachi(parts) |i, part| { @@ -156,69 +156,69 @@ fn is_hex_digit(ch: char) -> bool { #[test] fn test_is_uuid() { - assert is_uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaafAF09"); - assert !is_uuid("aaaaaaaa-aaaa-aaaa-aaaaa-aaaaaaaaaaaa"); - assert !is_uuid(""); - assert !is_uuid("aaaaaaaa-aaa -aaaa-aaaa-aaaaaaaaaaaa"); - assert !is_uuid("aaaaaaaa-aaa!-aaaa-aaaa-aaaaaaaaaaaa"); - assert !is_uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa-a"); - assert !is_uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaป"); + assert is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaafAF09"); + assert !is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaaa-aaaaaaaaaaaa"); + assert !is_uuid(~""); + assert !is_uuid(~"aaaaaaaa-aaa -aaaa-aaaa-aaaaaaaaaaaa"); + assert !is_uuid(~"aaaaaaaa-aaa!-aaaa-aaaa-aaaaaaaaaaaa"); + assert !is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa-a"); + assert !is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaป"); } // FIXME (#2661): implement url/URL parsing so we don't have to resort // to weak checks -fn has_archive_extension(p: str) -> bool { - str::ends_with(p, ".tar") || - str::ends_with(p, ".tar.gz") || - str::ends_with(p, ".tar.bz2") || - str::ends_with(p, ".tar.Z") || - str::ends_with(p, ".tar.lz") || - str::ends_with(p, ".tar.xz") || - str::ends_with(p, ".tgz") || - str::ends_with(p, ".tbz") || - str::ends_with(p, ".tbz2") || - str::ends_with(p, ".tb2") || - str::ends_with(p, ".taz") || - str::ends_with(p, ".tlz") || - str::ends_with(p, ".txz") +fn has_archive_extension(p: ~str) -> bool { + str::ends_with(p, ~".tar") || + str::ends_with(p, ~".tar.gz") || + str::ends_with(p, ~".tar.bz2") || + str::ends_with(p, ~".tar.Z") || + str::ends_with(p, ~".tar.lz") || + str::ends_with(p, ~".tar.xz") || + str::ends_with(p, ~".tgz") || + str::ends_with(p, ~".tbz") || + str::ends_with(p, ~".tbz2") || + str::ends_with(p, ~".tb2") || + str::ends_with(p, ~".taz") || + str::ends_with(p, ~".tlz") || + str::ends_with(p, ~".txz") } -fn is_archive_path(u: str) -> bool { +fn is_archive_path(u: ~str) -> bool { has_archive_extension(u) && os::path_exists(u) } -fn is_archive_url(u: str) -> bool { +fn is_archive_url(u: ~str) -> bool { // FIXME (#2661): this requires the protocol bit - if we had proper // url parsing, we wouldn't need it - alt str::find_str(u, "://") { + alt str::find_str(u, ~"://") { option::some(i) { has_archive_extension(u) } _ { false } } } -fn is_git_url(url: str) -> bool { - if str::ends_with(url, "/") { str::ends_with(url, ".git/") } +fn is_git_url(url: ~str) -> bool { + if str::ends_with(url, ~"/") { str::ends_with(url, ~".git/") } else { - str::starts_with(url, "git://") || str::ends_with(url, ".git") + str::starts_with(url, ~"git://") || str::ends_with(url, ~".git") } } -fn assume_source_method(url: str) -> str { +fn assume_source_method(url: ~str) -> ~str { if is_git_url(url) { - ret "git"; + ret ~"git"; } - if str::starts_with(url, "file://") || os::path_exists(url) { - ret "file"; + if str::starts_with(url, ~"file://") || os::path_exists(url) { + ret ~"file"; } - "curl" + ~"curl" } -fn load_link(mis: ~[@ast::meta_item]) -> (option, - option, - option) { +fn load_link(mis: ~[@ast::meta_item]) -> (option<~str>, + option<~str>, + option<~str>) { let mut name = none; let mut vers = none; let mut uuid = none; @@ -226,19 +226,19 @@ fn load_link(mis: ~[@ast::meta_item]) -> (option, alt a.node { ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) { alt *v { - "name" { name = some(*s); } - "vers" { vers = some(*s); } - "uuid" { uuid = some(*s); } + ~"name" { name = some(*s); } + ~"vers" { vers = some(*s); } + ~"uuid" { uuid = some(*s); } _ { } } } - _ { fail "load_link: meta items must be name-values"; } + _ { fail ~"load_link: meta items must be name-values"; } } } (name, vers, uuid) } -fn load_crate(filename: str) -> option { +fn load_crate(filename: ~str) -> option { let sess = parse::new_parse_sess(none); let c = parse::parse_crate_from_crate_file(filename, ~[], sess); @@ -253,14 +253,14 @@ fn load_crate(filename: str) -> option { alt a.node.value.node { ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) { alt *v { - "desc" { desc = some(*v); } - "sigs" { sigs = some(*v); } - "crate_type" { crate_type = some(*v); } + ~"desc" { desc = some(*v); } + ~"sigs" { sigs = some(*v); } + ~"crate_type" { crate_type = some(*v); } _ { } } } ast::meta_list(v, mis) { - if *v == "link" { + if *v == ~"link" { let (n, v, u) = load_link(mis); name = n; vers = v; @@ -268,28 +268,29 @@ fn load_crate(filename: str) -> option { } } _ { - fail "crate attributes may not contain " + - "meta_words"; + fail ~"crate attributes may not contain " + + ~"meta_words"; } } } type env = @{ - mut deps: ~[str] + mut deps: ~[~str] }; fn goto_view_item(e: env, i: @ast::view_item) { alt i.node { ast::view_item_use(ident, metas, id) { - let name_items = attr::find_meta_items_by_name(metas, "name"); + let name_items = + attr::find_meta_items_by_name(metas, ~"name"); let m = if name_items.is_empty() { - metas + ~[attr::mk_name_value_item_str(@"name", *ident)] + metas + ~[attr::mk_name_value_item_str(@~"name", *ident)] } else { metas }; let mut attr_name = ident; - let mut attr_vers = ""; - let mut attr_from = ""; + let mut attr_vers = ~""; + let mut attr_from = ~""; for m.each |item| { alt attr::get_meta_item_value_str(item) { @@ -297,8 +298,8 @@ fn goto_view_item(e: env, i: @ast::view_item) { let name = attr::get_meta_item_name(item); alt *name { - "vers" { attr_vers = *value; } - "from" { attr_from = *value; } + ~"vers" { attr_vers = *value; } + ~"from" { attr_from = *value; } _ {} } } @@ -310,12 +311,12 @@ fn goto_view_item(e: env, i: @ast::view_item) { attr_from } else { if !str::is_empty(attr_vers) { - *attr_name + "@" + attr_vers + *attr_name + ~"@" + attr_vers } else { *attr_name } }; alt *attr_name { - "std" | "core" { } + ~"std" | ~"core" { } _ { vec::push(e.deps, query); } } } @@ -353,26 +354,26 @@ fn goto_item(_e: env, _i: @ast::item) { } } -fn print(s: str) { +fn print(s: ~str) { io::stdout().write_line(s); } -fn rest(s: str, start: uint) -> str { +fn rest(s: ~str, start: uint) -> ~str { if (start >= str::len(s)) { - "" + ~"" } else { str::slice(s, start, str::len(s)) } } -fn need_dir(s: str) { +fn need_dir(s: ~str) { if os::path_is_dir(s) { ret; } if !os::make_dir(s, 493_i32 /* oct: 755 */) { fail #fmt["can't make_dir %s", s]; } } -fn valid_pkg_name(s: str) -> bool { +fn valid_pkg_name(s: ~str) -> bool { fn is_valid_digit(c: char) -> bool { ('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || @@ -384,38 +385,38 @@ fn is_valid_digit(c: char) -> bool { s.all(is_valid_digit) } -fn parse_source(name: str, j: json::json) -> source { +fn parse_source(name: ~str, j: json::json) -> source { if !valid_pkg_name(name) { fail #fmt("'%s' is an invalid source name", name); } alt j { json::dict(j) { - let mut url = alt j.find("url") { + let mut url = alt j.find(~"url") { some(json::string(u)) { *u } - _ { fail "needed 'url' field in source"; } + _ { fail ~"needed 'url' field in source"; } }; - let method = alt j.find("method") { + let method = alt j.find(~"method") { some(json::string(u)) { *u } _ { assume_source_method(url) } }; - let key = alt j.find("key") { + let key = alt j.find(~"key") { some(json::string(u)) { some(*u) } _ { none } }; - let keyfp = alt j.find("keyfp") { + let keyfp = alt j.find(~"keyfp") { some(json::string(u)) { some(*u) } _ { none } }; - if method == "file" { + if method == ~"file" { url = os::make_absolute(url); } ret @{ @@ -426,11 +427,11 @@ fn parse_source(name: str, j: json::json) -> source { mut keyfp: keyfp, mut packages: ~[mut] }; } - _ { fail "needed dict value in source"; } + _ { fail ~"needed dict value in source"; } }; } -fn try_parse_sources(filename: str, sources: map::hashmap) { +fn try_parse_sources(filename: ~str, sources: map::hashmap<~str, source>) { if !os::path_exists(filename) { ret; } let c = io::read_whole_file_str(filename); alt json::from_str(result::get(c)) { @@ -440,66 +441,69 @@ fn try_parse_sources(filename: str, sources: map::hashmap) { #debug("source: %s", k); } } - ok(_) { fail "malformed sources.json"; } + ok(_) { fail ~"malformed sources.json"; } err(e) { fail #fmt("%s:%s", filename, e.to_str()); } } } -fn load_one_source_package(src: source, p: map::hashmap) { - let name = alt p.find("name") { +fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { + let name = alt p.find(~"name") { some(json::string(n)) { if !valid_pkg_name(*n) { - warn("malformed source json: " + src.name + ", '" + *n + "'"+ - " is an invalid name (alphanumeric, underscores and" + - " dashes only)"); + warn(~"malformed source json: " + + src.name + ~", '" + *n + ~"'"+ + ~" is an invalid name (alphanumeric, underscores and" + + ~" dashes only)"); ret; } *n } _ { - warn("malformed source json: " + src.name + " (missing name)"); + warn(~"malformed source json: " + src.name + ~" (missing name)"); ret; } }; - let uuid = alt p.find("uuid") { + let uuid = alt p.find(~"uuid") { some(json::string(n)) { if !is_uuid(*n) { - warn("malformed source json: " + src.name + ", '" + *n + "'"+ - " is an invalid uuid"); + warn(~"malformed source json: " + + src.name + ~", '" + *n + ~"'"+ + ~" is an invalid uuid"); ret; } *n } _ { - warn("malformed source json: " + src.name + " (missing uuid)"); + warn(~"malformed source json: " + src.name + ~" (missing uuid)"); ret; } }; - let url = alt p.find("url") { + let url = alt p.find(~"url") { some(json::string(n)) { *n } _ { - warn("malformed source json: " + src.name + " (missing url)"); + warn(~"malformed source json: " + src.name + ~" (missing url)"); ret; } }; - let method = alt p.find("method") { + let method = alt p.find(~"method") { some(json::string(n)) { *n } _ { - warn("malformed source json: " + src.name + " (missing method)"); + warn(~"malformed source json: " + + src.name + ~" (missing method)"); ret; } }; - let ref = alt p.find("ref") { + let ref = alt p.find(~"ref") { some(json::string(n)) { some(*n) } _ { none } }; let mut tags = ~[]; - alt p.find("tags") { + alt p.find(~"tags") { some(json::list(js)) { for (*js).each |j| { alt j { @@ -511,11 +515,11 @@ fn load_one_source_package(src: source, p: map::hashmap) { _ { } } - let description = alt p.find("description") { + let description = alt p.find(~"description") { some(json::string(n)) { *n } _ { - warn("malformed source json: " + src.name - + " (missing description)"); + warn(~"malformed source json: " + src.name + + ~" (missing description)"); ret; } }; @@ -534,19 +538,19 @@ fn load_one_source_package(src: source, p: map::hashmap) { alt src.packages.position(|pkg| pkg.uuid == uuid ) { some(idx) { src.packages[idx] = newpkg; - log(debug, " updated package: " + src.name + "/" + name); + log(debug, ~" updated package: " + src.name + ~"/" + name); } none { vec::grow(src.packages, 1u, newpkg); } } - log(debug, " loaded package: " + src.name + "/" + name); + log(debug, ~" loaded package: " + src.name + ~"/" + name); } fn load_source_info(c: cargo, src: source) { let dir = path::connect(c.sourcedir, src.name); - let srcfile = path::connect(dir, "source.json"); + let srcfile = path::connect(dir, ~"source.json"); if !os::path_exists(srcfile) { ret; } let srcstr = io::read_whole_file_str(srcfile); alt json::from_str(result::get(srcstr)) { @@ -557,8 +561,8 @@ fn load_source_info(c: cargo, src: source) { src.keyfp = o.keyfp; } ok(_) { - warn("malformed source.json: " + src.name + - "(source info is not a dict)"); + warn(~"malformed source.json: " + src.name + + ~"(source info is not a dict)"); } err(e) { warn(#fmt("%s:%s", src.name, e.to_str())); @@ -566,9 +570,9 @@ fn load_source_info(c: cargo, src: source) { }; } fn load_source_packages(c: cargo, src: source) { - log(debug, "loading source: " + src.name); + log(debug, ~"loading source: " + src.name); let dir = path::connect(c.sourcedir, src.name); - let pkgfile = path::connect(dir, "packages.json"); + let pkgfile = path::connect(dir, ~"packages.json"); if !os::path_exists(pkgfile) { ret; } let pkgstr = io::read_whole_file_str(pkgfile); alt json::from_str(result::get(pkgstr)) { @@ -579,15 +583,15 @@ fn load_source_packages(c: cargo, src: source) { load_one_source_package(src, p); } _ { - warn("malformed source json: " + src.name + - " (non-dict pkg)"); + warn(~"malformed source json: " + src.name + + ~" (non-dict pkg)"); } } } } ok(_) { - warn("malformed packages.json: " + src.name + - "(packages is not a list)"); + warn(~"malformed packages.json: " + src.name + + ~"(packages is not a list)"); } err(e) { warn(#fmt("%s:%s", src.name, e.to_str())); @@ -595,7 +599,7 @@ fn load_source_packages(c: cargo, src: source) { }; } -fn build_cargo_options(argv: ~[str]) -> options { +fn build_cargo_options(argv: ~[~str]) -> options { let match = alt getopts::getopts(argv, opts()) { result::ok(m) { m } result::err(f) { @@ -603,19 +607,19 @@ fn build_cargo_options(argv: ~[str]) -> options { } }; - let test = opt_present(match, "test"); - let G = opt_present(match, "G"); - let g = opt_present(match, "g"); - let help = opt_present(match, "h") || opt_present(match, "help"); + let test = opt_present(match, ~"test"); + let G = opt_present(match, ~"G"); + let g = opt_present(match, ~"g"); + let help = opt_present(match, ~"h") || opt_present(match, ~"help"); let len = vec::len(match.free); - let is_install = len > 1u && match.free[1] == "install"; - let is_uninstall = len > 1u && match.free[1] == "uninstall"; + let is_install = len > 1u && match.free[1] == ~"install"; + let is_uninstall = len > 1u && match.free[1] == ~"uninstall"; - if G && g { fail "-G and -g both provided"; } + if G && g { fail ~"-G and -g both provided"; } if !is_install && !is_uninstall && (g || G) { - fail "-g and -G are only valid for `install` and `uninstall|rm`"; + fail ~"-g and -G are only valid for `install` and `uninstall|rm`"; } let mode = @@ -641,8 +645,8 @@ fn configure(opts: options) -> cargo { let p = result::get(get_cargo_dir()); let sources = map::str_hash(); - try_parse_sources(path::connect(home, "sources.json"), sources); - try_parse_sources(path::connect(home, "local-sources.json"), sources); + try_parse_sources(path::connect(home, ~"sources.json"), sources); + try_parse_sources(path::connect(home, ~"local-sources.json"), sources); let dep_cache = map::str_hash(); @@ -650,12 +654,12 @@ fn configure(opts: options) -> cargo { pgp: pgp::supported(), root: home, installdir: p, - bindir: path::connect(p, "bin"), - libdir: path::connect(p, "lib"), - workdir: path::connect(p, "work"), - sourcedir: path::connect(home, "sources"), + bindir: path::connect(p, ~"bin"), + libdir: path::connect(p, ~"lib"), + workdir: path::connect(p, ~"work"), + sourcedir: path::connect(home, ~"sources"), sources: sources, - mut current_install: "", + mut current_install: ~"", dep_cache: dep_cache, opts: opts }; @@ -676,9 +680,9 @@ fn configure(opts: options) -> cargo { if c.pgp { pgp::init(c.root); } else { - warn("command `gpg` was not found"); - warn("you have to install gpg from source " + - " or package manager to get it to work correctly"); + warn(~"command `gpg` was not found"); + warn(~"you have to install gpg from source " + + ~" or package manager to get it to work correctly"); } c @@ -696,7 +700,7 @@ fn for_each_package(c: cargo, b: fn(source, package)) { } // Runs all programs in directory -fn run_programs(buildpath: str) { +fn run_programs(buildpath: ~str) { let newv = os::list_dir_path(buildpath); for newv.each |ct| { run::run_program(ct, ~[]); @@ -705,13 +709,13 @@ fn run_programs(buildpath: str) { // Runs rustc in with the given flags // and returns -fn run_in_buildpath(what: str, path: str, subdir: str, cf: str, - extra_flags: ~[str]) -> option { +fn run_in_buildpath(what: ~str, path: ~str, subdir: ~str, cf: ~str, + extra_flags: ~[~str]) -> option<~str> { let buildpath = path::connect(path, subdir); need_dir(buildpath); #debug("%s: %s -> %s", what, cf, buildpath); let p = run::program_output(rustc_sysroot(), - ~["--out-dir", buildpath, cf] + extra_flags); + ~[~"--out-dir", buildpath, cf] + extra_flags); if p.status != 0 { error(#fmt["rustc failed: %d\n%s\n%s", p.status, p.err, p.out]); ret none; @@ -719,27 +723,27 @@ fn run_in_buildpath(what: str, path: str, subdir: str, cf: str, some(buildpath) } -fn test_one_crate(_c: cargo, path: str, cf: str) { - let buildpath = alt run_in_buildpath("testing", path, "/test", cf, - ~[ "--test"]) { +fn test_one_crate(_c: cargo, path: ~str, cf: ~str) { + let buildpath = alt run_in_buildpath(~"testing", path, ~"/test", cf, + ~[ ~"--test"]) { none { ret; } some(bp) { bp } }; run_programs(buildpath); } -fn install_one_crate(c: cargo, path: str, cf: str) { - let buildpath = alt run_in_buildpath("installing", path, - "/build", cf, ~[]) { +fn install_one_crate(c: cargo, path: ~str, cf: ~str) { + let buildpath = alt run_in_buildpath(~"installing", path, + ~"/build", cf, ~[]) { none { ret; } some(bp) { bp } }; let newv = os::list_dir_path(buildpath); let exec_suffix = os::exe_suffix(); for newv.each |ct| { - if (exec_suffix != "" && str::ends_with(ct, exec_suffix)) || - (exec_suffix == "" && !str::starts_with(path::basename(ct), - "lib")) { + if (exec_suffix != ~"" && str::ends_with(ct, exec_suffix)) || + (exec_suffix == ~"" && !str::starts_with(path::basename(ct), + ~"lib")) { #debug(" bin: %s", ct); install_to_dir(ct, c.bindir); if c.opts.mode == system_mode { @@ -755,32 +759,32 @@ fn install_one_crate(c: cargo, path: str, cf: str) { } -fn rustc_sysroot() -> str { +fn rustc_sysroot() -> ~str { alt os::self_exe_path() { some(path) { - let path = ~[path, "..", "bin", "rustc"]; + let path = ~[path, ~"..", ~"bin", ~"rustc"]; check vec::is_not_empty(path); let rustc = path::normalize(path::connect_many(path)); #debug(" rustc: %s", rustc); rustc } - none { "rustc" } + none { ~"rustc" } } } -fn install_source(c: cargo, path: str) { +fn install_source(c: cargo, path: ~str) { #debug("source: %s", path); os::change_dir(path); let mut cratefiles = ~[]; - for os::walk_dir(".") |p| { - if str::ends_with(p, ".rc") { + for os::walk_dir(~".") |p| { + if str::ends_with(p, ~".rc") { vec::push(cratefiles, p); } } if vec::is_empty(cratefiles) { - fail "this doesn't look like a rust package (no .rc files)"; + fail ~"this doesn't look like a rust package (no .rc files)"; } for cratefiles.each |cf| { @@ -793,7 +797,7 @@ fn install_source(c: cargo, path: str) { // condition") let wd_base = c.workdir + path::path_sep(); - let wd = alt tempfile::mkdtemp(wd_base, "") { + let wd = alt tempfile::mkdtemp(wd_base, ~"") { some(wd) { wd } none { fail #fmt("needed temp dir: %s", wd_base); } }; @@ -812,49 +816,49 @@ fn install_source(c: cargo, path: str) { } } -fn install_git(c: cargo, wd: str, url: str, ref: option) { - run::program_output("git", ~["clone", url, wd]); +fn install_git(c: cargo, wd: ~str, url: ~str, ref: option<~str>) { + run::program_output(~"git", ~[~"clone", url, wd]); if option::is_some(ref) { let r = option::get(ref); os::change_dir(wd); - run::run_program("git", ~["checkout", r]); + run::run_program(~"git", ~[~"checkout", r]); } install_source(c, wd); } -fn install_curl(c: cargo, wd: str, url: str) { - let tarpath = path::connect(wd, "pkg.tar"); - let p = run::program_output("curl", ~["-f", "-s", "-o", +fn install_curl(c: cargo, wd: ~str, url: ~str) { + let tarpath = path::connect(wd, ~"pkg.tar"); + let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", tarpath, url]); if p.status != 0 { fail #fmt["fetch of %s failed: %s", url, p.err]; } - run::run_program("tar", ~["-x", "--strip-components=1", - "-C", wd, "-f", tarpath]); + run::run_program(~"tar", ~[~"-x", ~"--strip-components=1", + ~"-C", wd, ~"-f", tarpath]); install_source(c, wd); } -fn install_file(c: cargo, wd: str, path: str) { - run::program_output("tar", ~["-x", "--strip-components=1", - "-C", wd, "-f", path]); +fn install_file(c: cargo, wd: ~str, path: ~str) { + run::program_output(~"tar", ~[~"-x", ~"--strip-components=1", + ~"-C", wd, ~"-f", path]); install_source(c, wd); } -fn install_package(c: cargo, src: str, wd: str, pkg: package) { +fn install_package(c: cargo, src: ~str, wd: ~str, pkg: package) { let url = copy pkg.url; let method = alt pkg.method { - "git" { "git" } - "file" { "file" } - _ { "curl" } + ~"git" { ~"git" } + ~"file" { ~"file" } + _ { ~"curl" } }; info(#fmt["installing %s/%s via %s...", src, pkg.name, method]); alt method { - "git" { install_git(c, wd, url, copy pkg.ref); } - "file" { install_file(c, wd, url); } - "curl" { install_curl(c, wd, copy url); } + ~"git" { install_git(c, wd, url, copy pkg.ref); } + ~"file" { install_file(c, wd, url); } + ~"curl" { install_curl(c, wd, copy url); } _ {} } } @@ -862,14 +866,14 @@ fn install_package(c: cargo, src: str, wd: str, pkg: package) { fn cargo_suggestion(c: cargo, fallback: fn()) { if c.sources.size() == 0u { - error("no sources defined - you may wish to run " + - "`cargo init`"); + error(~"no sources defined - you may wish to run " + + ~"`cargo init`"); ret; } fallback(); } -fn install_uuid(c: cargo, wd: str, uuid: str) { +fn install_uuid(c: cargo, wd: ~str, uuid: ~str) { let mut ps = ~[]; for_each_package(c, |s, p| { if p.uuid == uuid { @@ -882,18 +886,18 @@ fn install_uuid(c: cargo, wd: str, uuid: str) { ret; } else if vec::len(ps) == 0u { cargo_suggestion(c, || { - error("can't find package: " + uuid); + error(~"can't find package: " + uuid); }); ret; } - error("found multiple packages:"); + error(~"found multiple packages:"); for ps.each |elt| { let (sname,p) = copy elt; - info(" " + sname + "/" + p.uuid + " (" + p.name + ")"); + info(~" " + sname + ~"/" + p.uuid + ~" (" + p.name + ~")"); } } -fn install_named(c: cargo, wd: str, name: str) { +fn install_named(c: cargo, wd: ~str, name: ~str) { let mut ps = ~[]; for_each_package(c, |s, p| { if p.name == name { @@ -906,18 +910,18 @@ fn install_named(c: cargo, wd: str, name: str) { ret; } else if vec::len(ps) == 0u { cargo_suggestion(c, || { - error("can't find package: " + name); + error(~"can't find package: " + name); }); ret; } - error("found multiple packages:"); + error(~"found multiple packages:"); for ps.each |elt| { let (sname,p) = copy elt; - info(" " + sname + "/" + p.uuid + " (" + p.name + ")"); + info(~" " + sname + ~"/" + p.uuid + ~" (" + p.name + ~")"); } } -fn install_uuid_specific(c: cargo, wd: str, src: str, uuid: str) { +fn install_uuid_specific(c: cargo, wd: ~str, src: ~str, uuid: ~str) { alt c.sources.find(src) { some(s) { let packages = copy s.packages; @@ -930,10 +934,10 @@ fn install_uuid_specific(c: cargo, wd: str, src: str, uuid: str) { } _ { } } - error("can't find package: " + src + "/" + uuid); + error(~"can't find package: " + src + ~"/" + uuid); } -fn install_named_specific(c: cargo, wd: str, src: str, name: str) { +fn install_named_specific(c: cargo, wd: ~str, src: ~str, name: ~str) { alt c.sources.find(src) { some(s) { let packages = copy s.packages; @@ -946,7 +950,7 @@ fn install_named_specific(c: cargo, wd: str, src: str, name: str) { } _ { } } - error("can't find package: " + src + "/" + name); + error(~"can't find package: " + src + ~"/" + name); } fn cmd_uninstall(c: cargo) { @@ -965,13 +969,13 @@ fn cmd_uninstall(c: cargo) { // name only) if is_uuid(target) { for os::list_dir(lib).each |file| { - alt str::find_str(file, "-" + target + "-") { + alt str::find_str(file, ~"-" + target + ~"-") { some(idx) { let full = path::normalize(path::connect(lib, file)); if os::remove_file(full) { - info("uninstalled: '" + full + "'"); + info(~"uninstalled: '" + full + ~"'"); } else { - error("could not uninstall: '" + full + "'"); + error(~"could not uninstall: '" + full + ~"'"); } ret; } @@ -979,17 +983,17 @@ fn cmd_uninstall(c: cargo) { } } - error("can't find package with uuid: " + target); + error(~"can't find package with uuid: " + target); } else { for os::list_dir(lib).each |file| { - alt str::find_str(file, "lib" + target + "-") { + alt str::find_str(file, ~"lib" + target + ~"-") { some(idx) { let full = path::normalize(path::connect(lib, file)); if os::remove_file(full) { - info("uninstalled: '" + full + "'"); + info(~"uninstalled: '" + full + ~"'"); } else { - error("could not uninstall: '" + full + "'"); + error(~"could not uninstall: '" + full + ~"'"); } ret; } @@ -1001,9 +1005,9 @@ fn cmd_uninstall(c: cargo) { some(idx) { let full = path::normalize(path::connect(bin, file)); if os::remove_file(full) { - info("uninstalled: '" + full + "'"); + info(~"uninstalled: '" + full + ~"'"); } else { - error("could not uninstall: '" + full + "'"); + error(~"could not uninstall: '" + full + ~"'"); } ret; } @@ -1011,11 +1015,11 @@ fn cmd_uninstall(c: cargo) { } } - error("can't find package with name: " + target); + error(~"can't find package with name: " + target); } } -fn install_query(c: cargo, wd: str, target: str) { +fn install_query(c: cargo, wd: ~str, target: ~str) { alt c.dep_cache.find(target) { some(inst) { if inst { @@ -1071,20 +1075,20 @@ fn install_query(c: cargo, wd: str, target: str) { c.dep_cache.remove(k); } - c.current_install = ""; + c.current_install = ~""; } } fn cmd_install(c: cargo) unsafe { let wd_base = c.workdir + path::path_sep(); - let wd = alt tempfile::mkdtemp(wd_base, "") { + let wd = alt tempfile::mkdtemp(wd_base, ~"") { some(wd) { wd } none { fail #fmt("needed temp dir: %s", wd_base); } }; if vec::len(c.opts.free) == 2u { let cwd = os::getcwd(); - let status = run::run_program("cp", ~["-R", cwd, wd]); + let status = run::run_program(~"cp", ~[~"-R", cwd, wd]); if status != 0 { fail #fmt("could not copy directory: %s", cwd); @@ -1110,34 +1114,34 @@ fn sync(c: cargo) { } } -fn sync_one_file(c: cargo, dir: str, src: source) -> bool { +fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool { let name = src.name; - let srcfile = path::connect(dir, "source.json.new"); - let destsrcfile = path::connect(dir, "source.json"); - let pkgfile = path::connect(dir, "packages.json.new"); - let destpkgfile = path::connect(dir, "packages.json"); - let keyfile = path::connect(dir, "key.gpg"); - let srcsigfile = path::connect(dir, "source.json.sig"); - let sigfile = path::connect(dir, "packages.json.sig"); + let srcfile = path::connect(dir, ~"source.json.new"); + let destsrcfile = path::connect(dir, ~"source.json"); + let pkgfile = path::connect(dir, ~"packages.json.new"); + let destpkgfile = path::connect(dir, ~"packages.json"); + let keyfile = path::connect(dir, ~"key.gpg"); + let srcsigfile = path::connect(dir, ~"source.json.sig"); + let sigfile = path::connect(dir, ~"packages.json.sig"); let url = src.url; let mut has_src_file = false; - if !os::copy_file(path::connect(url, "packages.json"), pkgfile) { + if !os::copy_file(path::connect(url, ~"packages.json"), pkgfile) { error(#fmt["fetch for source %s (url %s) failed", name, url]); ret false; } - if os::copy_file(path::connect(url, "source.json"), srcfile) { + if os::copy_file(path::connect(url, ~"source.json"), srcfile) { has_src_file = false; } - os::copy_file(path::connect(url, "source.json.sig"), srcsigfile); - os::copy_file(path::connect(url, "packages.json.sig"), sigfile); + os::copy_file(path::connect(url, ~"source.json.sig"), srcsigfile); + os::copy_file(path::connect(url, ~"packages.json.sig"), sigfile); alt copy src.key { some(u) { - let p = run::program_output("curl", ~["-f", "-s", "-o", keyfile, - u]); + let p = run::program_output(~"curl", + ~[~"-f", ~"-s", ~"-o", keyfile, u]); if p.status != 0 { error(#fmt["fetch for source %s (key %s) failed", name, u]); ret false; @@ -1186,23 +1190,23 @@ fn sync_one_file(c: cargo, dir: str, src: source) -> bool { ret true; } -fn sync_one_git(c: cargo, dir: str, src: source) -> bool { +fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { let name = src.name; - let srcfile = path::connect(dir, "source.json"); - let pkgfile = path::connect(dir, "packages.json"); - let keyfile = path::connect(dir, "key.gpg"); - let srcsigfile = path::connect(dir, "source.json.sig"); - let sigfile = path::connect(dir, "packages.json.sig"); + let srcfile = path::connect(dir, ~"source.json"); + let pkgfile = path::connect(dir, ~"packages.json"); + let keyfile = path::connect(dir, ~"key.gpg"); + let srcsigfile = path::connect(dir, ~"source.json.sig"); + let sigfile = path::connect(dir, ~"packages.json.sig"); let url = src.url; - fn rollback(name: str, dir: str, insecure: bool) { - fn msg(name: str, insecure: bool) { + fn rollback(name: ~str, dir: ~str, insecure: bool) { + fn msg(name: ~str, insecure: bool) { error(#fmt["could not rollback source: %s", name]); if insecure { - warn("a past security check failed on source " + - name + " and rolling back the source failed -" - + " this source may be compromised"); + warn(~"a past security check failed on source " + + name + ~" and rolling back the source failed -" + + ~" this source may be compromised"); } } @@ -1210,8 +1214,8 @@ fn msg(name: str, insecure: bool) { msg(name, insecure); } else { - let p = run::program_output("git", ~["reset", "--hard", - "HEAD@{1}"]); + let p = run::program_output(~"git", ~[~"reset", ~"--hard", + ~"HEAD@{1}"]); if p.status != 0 { msg(name, insecure); @@ -1219,8 +1223,8 @@ fn msg(name: str, insecure: bool) { } } - if !os::path_exists(path::connect(dir, ".git")) { - let p = run::program_output("git", ~["clone", url, dir]); + if !os::path_exists(path::connect(dir, ~".git")) { + let p = run::program_output(~"git", ~[~"clone", url, dir]); if p.status != 0 { error(#fmt["fetch for source %s (url %s) failed", name, url]); @@ -1233,7 +1237,7 @@ fn msg(name: str, insecure: bool) { ret false; } - let p = run::program_output("git", ~["pull"]); + let p = run::program_output(~"git", ~[~"pull"]); if p.status != 0 { error(#fmt["fetch for source %s (url %s) failed", name, url]); @@ -1245,8 +1249,8 @@ fn msg(name: str, insecure: bool) { alt copy src.key { some(u) { - let p = run::program_output("curl", ~["-f", "-s", "-o", keyfile, - u]); + let p = run::program_output(~"curl", + ~[~"-f", ~"-s", ~"-o", keyfile, u]); if p.status != 0 { error(#fmt["fetch for source %s (key %s) failed", name, u]); rollback(name, dir, false); @@ -1288,33 +1292,35 @@ fn msg(name: str, insecure: bool) { ret true; } -fn sync_one_curl(c: cargo, dir: str, src: source) -> bool { +fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { let name = src.name; - let srcfile = path::connect(dir, "source.json.new"); - let destsrcfile = path::connect(dir, "source.json"); - let pkgfile = path::connect(dir, "packages.json.new"); - let destpkgfile = path::connect(dir, "packages.json"); - let keyfile = path::connect(dir, "key.gpg"); - let srcsigfile = path::connect(dir, "source.json.sig"); - let sigfile = path::connect(dir, "packages.json.sig"); + let srcfile = path::connect(dir, ~"source.json.new"); + let destsrcfile = path::connect(dir, ~"source.json"); + let pkgfile = path::connect(dir, ~"packages.json.new"); + let destpkgfile = path::connect(dir, ~"packages.json"); + let keyfile = path::connect(dir, ~"key.gpg"); + let srcsigfile = path::connect(dir, ~"source.json.sig"); + let sigfile = path::connect(dir, ~"packages.json.sig"); let mut url = src.url; - let smart = !str::ends_with(src.url, "packages.json"); + let smart = !str::ends_with(src.url, ~"packages.json"); let mut has_src_file = false; if smart { - url += "/packages.json"; + url += ~"/packages.json"; } - let p = run::program_output("curl", ~["-f", "-s", "-o", pkgfile, url]); + let p = run::program_output(~"curl", + ~[~"-f", ~"-s", ~"-o", pkgfile, url]); if p.status != 0 { error(#fmt["fetch for source %s (url %s) failed", name, url]); ret false; } if smart { - url = src.url + "/source.json"; + url = src.url + ~"/source.json"; let p = - run::program_output("curl", ~["-f", "-s", "-o", srcfile, url]); + run::program_output(~"curl", + ~[~"-f", ~"-s", ~"-o", srcfile, url]); if p.status == 0 { has_src_file = true; @@ -1323,8 +1329,8 @@ fn sync_one_curl(c: cargo, dir: str, src: source) -> bool { alt copy src.key { some(u) { - let p = run::program_output("curl", ~["-f", "-s", "-o", keyfile, - u]); + let p = run::program_output(~"curl", + ~[~"-f", ~"-s", ~"-o", keyfile, u]); if p.status != 0 { error(#fmt["fetch for source %s (key %s) failed", name, u]); ret false; @@ -1336,13 +1342,13 @@ fn sync_one_curl(c: cargo, dir: str, src: source) -> bool { alt (src.key, src.keyfp) { (some(_), some(f)) { if smart { - url = src.url + "/packages.json.sig"; + url = src.url + ~"/packages.json.sig"; } else { - url = src.url + ".sig"; + url = src.url + ~".sig"; } - let mut p = run::program_output("curl", ~["-f", "-s", "-o", + let mut p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", sigfile, url]); if p.status != 0 { error(#fmt["fetch for source %s (sig %s) failed", name, url]); @@ -1358,10 +1364,11 @@ fn sync_one_curl(c: cargo, dir: str, src: source) -> bool { } if smart && has_src_file { - url = src.url + "/source.json.sig"; + url = src.url + ~"/source.json.sig"; - p = run::program_output("curl", - ~["-f", "-s", "-o", srcsigfile, url]); + p = run::program_output(~"curl", + ~[~"-f", ~"-s", ~"-o", + srcsigfile, url]); if p.status != 0 { error(#fmt["fetch for source %s (sig %s) failed", name, url]); @@ -1371,8 +1378,8 @@ fn sync_one_curl(c: cargo, dir: str, src: source) -> bool { let e = pgp::verify(c.root, srcfile, srcsigfile, f); if !e { - error("signature verification failed for " + - "source " + name); + error(~"signature verification failed for " + + ~"source " + name); ret false; } } @@ -1406,8 +1413,8 @@ fn sync_one(c: cargo, src: source) { need_dir(dir); let result = alt src.method { - "git" { sync_one_git(c, dir, src) } - "file" { sync_one_file(c, dir, src) } + ~"git" { sync_one_git(c, dir, src) } + ~"file" { sync_one_file(c, dir, src) } _ { sync_one_curl(c, dir, src) } }; @@ -1418,22 +1425,22 @@ fn sync_one(c: cargo, src: source) { } fn cmd_init(c: cargo) { - let srcurl = "http://www.rust-lang.org/cargo/sources.json"; - let sigurl = "http://www.rust-lang.org/cargo/sources.json.sig"; + let srcurl = ~"http://www.rust-lang.org/cargo/sources.json"; + let sigurl = ~"http://www.rust-lang.org/cargo/sources.json.sig"; - let srcfile = path::connect(c.root, "sources.json.new"); - let sigfile = path::connect(c.root, "sources.json.sig"); - let destsrcfile = path::connect(c.root, "sources.json"); + let srcfile = path::connect(c.root, ~"sources.json.new"); + let sigfile = path::connect(c.root, ~"sources.json.sig"); + let destsrcfile = path::connect(c.root, ~"sources.json"); let p = - run::program_output("curl", ~["-f", "-s", "-o", srcfile, srcurl]); + run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", srcfile, srcurl]); if p.status != 0 { error(#fmt["fetch of sources.json failed: %s", p.out]); ret; } let p = - run::program_output("curl", ~["-f", "-s", "-o", sigfile, sigurl]); + run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", sigfile, sigurl]); if p.status != 0 { error(#fmt["fetch of sources.json.sig failed: %s", p.out]); ret; @@ -1453,31 +1460,31 @@ fn cmd_init(c: cargo) { } fn print_pkg(s: source, p: package) { - let mut m = s.name + "/" + p.name + " (" + p.uuid + ")"; + let mut m = s.name + ~"/" + p.name + ~" (" + p.uuid + ~")"; if vec::len(p.tags) > 0u { - m = m + " [" + str::connect(p.tags, ", ") + "]"; + m = m + ~" [" + str::connect(p.tags, ~", ") + ~"]"; } info(m); - if p.description != "" { - print(" >> " + p.description + "\n") + if p.description != ~"" { + print(~" >> " + p.description + ~"\n") } } fn print_source(s: source) { - info(s.name + " (" + s.url + ")"); + info(s.name + ~" (" + s.url + ~")"); let pks = sort::merge_sort(|a, b| a < b, copy s.packages); let l = vec::len(pks); print(io::with_str_writer(|writer| { - let mut list = " >> "; + let mut list = ~" >> "; do vec::iteri(pks) |i, pk| { if str::len(list) > 78u { writer.write_line(list); - list = " >> "; + list = ~" >> "; } - list += pk.name + (if l - 1u == i { "" } else { ", " }); + list += pk.name + (if l - 1u == i { ~"" } else { ~", " }); } writer.write_line(list); @@ -1521,7 +1528,7 @@ fn cmd_search(c: cargo) { let name = c.opts.free[2]; let tags = vec::slice(c.opts.free, 3u, vec::len(c.opts.free)); for_each_package(c, |s, p| { - if (str::contains(p.name, name) || name == "*") && + if (str::contains(p.name, name) || name == ~"*") && vec::all(tags, |t| vec::contains(p.tags, t) ) { print_pkg(s, p); n += 1; @@ -1530,10 +1537,10 @@ fn cmd_search(c: cargo) { info(#fmt["found %d packages", n]); } -fn install_to_dir(srcfile: str, destdir: str) { +fn install_to_dir(srcfile: ~str, destdir: ~str) { let newfile = path::connect(destdir, path::basename(srcfile)); - let status = run::run_program("cp", ~["-r", srcfile, newfile]); + let status = run::run_program(~"cp", ~[~"-r", srcfile, newfile]); if status == 0 { info(#fmt["installed: '%s'", newfile]); } else { @@ -1544,11 +1551,11 @@ fn install_to_dir(srcfile: str, destdir: str) { fn dump_cache(c: cargo) { need_dir(c.root); - let out = path::connect(c.root, "cache.json"); + let out = path::connect(c.root, ~"cache.json"); let _root = json::dict(map::str_hash()); if os::path_exists(out) { - copy_warn(out, path::connect(c.root, "cache.json.old")); + copy_warn(out, path::connect(c.root, ~"cache.json.old")); } } fn dump_sources(c: cargo) { @@ -1558,10 +1565,10 @@ fn dump_sources(c: cargo) { need_dir(c.root); - let out = path::connect(c.root, "sources.json"); + let out = path::connect(c.root, ~"sources.json"); if os::path_exists(out) { - copy_warn(out, path::connect(c.root, "sources.json.old")); + copy_warn(out, path::connect(c.root, ~"sources.json.old")); } alt io::buffered_file_writer(out) { @@ -1573,18 +1580,18 @@ fn dump_sources(c: cargo) { let chash = map::str_hash(); let child = json::dict(chash); - chash.insert("url", json::string(@v.url)); - chash.insert("method", json::string(@v.method)); + chash.insert(~"url", json::string(@v.url)); + chash.insert(~"method", json::string(@v.method)); alt copy v.key { some(key) { - chash.insert("key", json::string(@key)); + chash.insert(~"key", json::string(@key)); } _ {} } alt copy v.keyfp { some(keyfp) { - chash.insert("keyfp", json::string(@keyfp)); + chash.insert(~"keyfp", json::string(@keyfp)); } _ {} } @@ -1600,7 +1607,7 @@ fn dump_sources(c: cargo) { } } -fn copy_warn(srcfile: str, destfile: str) { +fn copy_warn(srcfile: ~str, destfile: ~str) { if !os::copy_file(srcfile, destfile) { warn(#fmt["copying %s to %s failed", srcfile, destfile]); } @@ -1618,14 +1625,14 @@ fn cmd_sources(c: cargo) { let action = c.opts.free[2u]; alt action { - "clear" { + ~"clear" { for c.sources.each_key |k| { c.sources.remove(k); } - info("cleared sources"); + info(~"cleared sources"); } - "add" { + ~"add" { if vec::len(c.opts.free) < 5u { cmd_usage(); ret; @@ -1656,7 +1663,7 @@ fn cmd_sources(c: cargo) { } } } - "remove" { + ~"remove" { if vec::len(c.opts.free) < 4u { cmd_usage(); ret; @@ -1679,7 +1686,7 @@ fn cmd_sources(c: cargo) { } } } - "set-url" { + ~"set-url" { if vec::len(c.opts.free) < 5u { cmd_usage(); ret; @@ -1710,7 +1717,7 @@ fn cmd_sources(c: cargo) { } } } - "set-method" { + ~"set-method" { if vec::len(c.opts.free) < 5u { cmd_usage(); ret; @@ -1729,9 +1736,9 @@ fn cmd_sources(c: cargo) { let old = copy source.method; source.method = alt method { - "git" { "git" } - "file" { "file" } - _ { "curl" } + ~"git" { ~"git" } + ~"file" { ~"file" } + _ { ~"curl" } }; c.sources.insert(name, source); @@ -1744,7 +1751,7 @@ fn cmd_sources(c: cargo) { } } } - "rename" { + ~"rename" { if vec::len(c.opts.free) < 5u { cmd_usage(); ret; @@ -1778,7 +1785,7 @@ fn cmd_sources(c: cargo) { } fn cmd_usage() { - print("Usage: cargo [options] [args..] + print(~"Usage: cargo [options] [args..] e.g. cargo install Where is one of: @@ -1793,14 +1800,14 @@ fn cmd_usage() { } fn cmd_usage_init() { - print("cargo init + print(~"cargo init Re-initialize cargo in ~/.cargo. Clears all sources and then adds the default sources from ."); } fn cmd_usage_install() { - print("cargo install + print(~"cargo install cargo install [source/][@version] cargo install [source/][@version] cargo install [ref] @@ -1819,7 +1826,7 @@ fn cmd_usage_install() { } fn cmd_usage_uninstall() { - print("cargo uninstall [source/][@version] + print(~"cargo uninstall [source/][@version] cargo uninstall [source/][@version] cargo uninstall [@version] cargo uninstall [@version] @@ -1836,7 +1843,7 @@ fn cmd_usage_uninstall() { } fn cmd_usage_list() { - print("cargo list [sources..] + print(~"cargo list [sources..] If no arguments are provided, list all sources and their packages. If source names are provided, list those sources and their packages. @@ -1844,13 +1851,13 @@ fn cmd_usage_list() { } fn cmd_usage_search() { - print("cargo search [tags..] + print(~"cargo search [tags..] Search packages."); } fn cmd_usage_sources() { - print("cargo sources + print(~"cargo sources cargo sources add cargo sources remove cargo sources rename @@ -1868,7 +1875,7 @@ fn cmd_usage_sources() { set-method Change the method for a source."); } -fn main(argv: ~[str]) { +fn main(argv: ~[~str]) { let o = build_cargo_options(argv); if vec::len(o.free) < 2u { @@ -1877,26 +1884,26 @@ fn main(argv: ~[str]) { } if o.help { alt o.free[1] { - "init" { cmd_usage_init(); } - "install" { cmd_usage_install(); } - "uninstall" { cmd_usage_uninstall(); } - "list" { cmd_usage_list(); } - "search" { cmd_usage_search(); } - "sources" { cmd_usage_sources(); } + ~"init" { cmd_usage_init(); } + ~"install" { cmd_usage_install(); } + ~"uninstall" { cmd_usage_uninstall(); } + ~"list" { cmd_usage_list(); } + ~"search" { cmd_usage_search(); } + ~"sources" { cmd_usage_sources(); } _ { cmd_usage(); } } ret; } - if o.free[1] == "usage" { + if o.free[1] == ~"usage" { cmd_usage(); ret; } let mut c = configure(o); let home = c.root; - let first_time = os::path_exists(path::connect(home, "sources.json")); + let first_time = os::path_exists(path::connect(home, ~"sources.json")); - if !first_time && o.free[1] != "init" { + if !first_time && o.free[1] != ~"init" { cmd_init(c); // FIXME (#2662): shouldn't need to reconfigure @@ -1904,12 +1911,12 @@ fn main(argv: ~[str]) { } alt o.free[1] { - "init" { cmd_init(c); } - "install" { cmd_install(c); } - "uninstall" { cmd_uninstall(c); } - "list" { cmd_list(c); } - "search" { cmd_search(c); } - "sources" { cmd_sources(c); } + ~"init" { cmd_init(c); } + ~"install" { cmd_install(c); } + ~"uninstall" { cmd_uninstall(c); } + ~"list" { cmd_list(c); } + ~"search" { cmd_search(c); } + ~"sources" { cmd_sources(c); } _ { cmd_usage(); } } diff --git a/src/cargo/pgp.rs b/src/cargo/pgp.rs index 9078e943cf2f..6977cdf02564 100644 --- a/src/cargo/pgp.rs +++ b/src/cargo/pgp.rs @@ -1,9 +1,9 @@ -fn gpg(args: ~[str]) -> { status: int, out: str, err: str } { - ret run::program_output("gpg", args); +fn gpg(args: ~[~str]) -> { status: int, out: ~str, err: ~str } { + ret run::program_output(~"gpg", args); } -fn signing_key() -> str { - " +fn signing_key() -> ~str { + ~" -----BEGIN PGP PUBLIC KEY BLOCK----- Version: SKS 1.1.0 @@ -54,42 +54,42 @@ fn signing_key() -> str { " } -fn signing_key_fp() -> str { - "FE79 EDB0 3DEF B0D8 27D2 6C41 0B2D 6A28 3033 6376" +fn signing_key_fp() -> ~str { + ~"FE79 EDB0 3DEF B0D8 27D2 6C41 0B2D 6A28 3033 6376" } fn supported() -> bool { - let r = gpg(~["--version"]); + let r = gpg(~[~"--version"]); r.status == 0 } -fn init(root: str) { - let p = path::connect(root, "gpg"); +fn init(root: ~str) { + let p = path::connect(root, ~"gpg"); if !os::path_is_dir(p) { os::make_dir(p, 0x1c0i32); - let p = run::start_program("gpg", ~["--homedir", p, "--import"]); + let p = run::start_program(~"gpg", ~[~"--homedir", p, ~"--import"]); p.input().write_str(signing_key()); let s = p.finish(); if s != 0 { - fail "pgp init failed"; + fail ~"pgp init failed"; } } } -fn add(root: str, key: str) { - let path = path::connect(root, "gpg"); +fn add(root: ~str, key: ~str) { + let path = path::connect(root, ~"gpg"); let p = - run::program_output("gpg", ~["--homedir", path, "--import", key]); + run::program_output(~"gpg", ~[~"--homedir", path, ~"--import", key]); if p.status != 0 { - fail "pgp add failed: " + p.out; + fail ~"pgp add failed: " + p.out; } } -fn verify(root: str, data: str, sig: str, keyfp: str) -> bool { - let path = path::connect(root, "gpg"); - let p = gpg(~["--homedir", path, "--with-fingerprint", "--verify", sig, +fn verify(root: ~str, data: ~str, sig: ~str, keyfp: ~str) -> bool { + let path = path::connect(root, ~"gpg"); + let p = gpg(~[~"--homedir", path, ~"--with-fingerprint", ~"--verify", sig, data]); - let res = "Primary key fingerprint: " + keyfp; + let res = ~"Primary key fingerprint: " + keyfp; for str::split_char(p.err, '\n').each |line| { if line == res { ret true; } } diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 0f68a756ec86..a7bcc8d67cc3 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -4,25 +4,25 @@ enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, } type config = { // The library paths required for running the compiler - compile_lib_path: str, + compile_lib_path: ~str, // The library paths required for running compiled programs - run_lib_path: str, + run_lib_path: ~str, // The rustc executable - rustc_path: str, + rustc_path: ~str, // The directory containing the tests to run - src_base: str, + src_base: ~str, // The directory where programs should be built - build_base: str, + build_base: ~str, // Directory for auxiliary libraries - aux_base: str, + aux_base: ~str, // The name of the stage being built (stage1, etc) - stage_id: str, + stage_id: ~str, // The test mode, compile-fail, run-fail, run-pass mode: mode, @@ -31,17 +31,17 @@ enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, } run_ignored: bool, // Only run tests that match this filter - filter: option, + filter: option<~str>, // Write out a parseable log of tests that were run - logfile: option, + logfile: option<~str>, // A command line to prefix program execution with, // for running under valgrind - runtool: option, + runtool: option<~str>, // Flags to pass to the compiler - rustcflags: option, + rustcflags: option<~str>, // Explain what's going on verbose: bool}; diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 359ca0c5bccf..30adf8ba5bbe 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -21,23 +21,23 @@ import common::mode; import util::logv; -fn main(args: ~[str]) { +fn main(args: ~[~str]) { let config = parse_config(args); log_config(config); run_tests(config); } -fn parse_config(args: ~[str]) -> config { +fn parse_config(args: ~[~str]) -> config { let opts = - ~[getopts::reqopt("compile-lib-path"), - getopts::reqopt("run-lib-path"), - getopts::reqopt("rustc-path"), getopts::reqopt("src-base"), - getopts::reqopt("build-base"), getopts::reqopt("aux-base"), - getopts::reqopt("stage-id"), - getopts::reqopt("mode"), getopts::optflag("ignored"), - getopts::optopt("runtool"), getopts::optopt("rustcflags"), - getopts::optflag("verbose"), - getopts::optopt("logfile")]; + ~[getopts::reqopt(~"compile-lib-path"), + getopts::reqopt(~"run-lib-path"), + getopts::reqopt(~"rustc-path"), getopts::reqopt(~"src-base"), + getopts::reqopt(~"build-base"), getopts::reqopt(~"aux-base"), + getopts::reqopt(~"stage-id"), + getopts::reqopt(~"mode"), getopts::optflag(~"ignored"), + getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"), + getopts::optflag(~"verbose"), + getopts::optopt(~"logfile")]; check (vec::is_not_empty(args)); let args_ = vec::tail(args); @@ -47,23 +47,23 @@ fn parse_config(args: ~[str]) -> config { err(f) { fail getopts::fail_str(f) } }; - ret {compile_lib_path: getopts::opt_str(match, "compile-lib-path"), - run_lib_path: getopts::opt_str(match, "run-lib-path"), - rustc_path: getopts::opt_str(match, "rustc-path"), - src_base: getopts::opt_str(match, "src-base"), - build_base: getopts::opt_str(match, "build-base"), - aux_base: getopts::opt_str(match, "aux-base"), - stage_id: getopts::opt_str(match, "stage-id"), - mode: str_mode(getopts::opt_str(match, "mode")), - run_ignored: getopts::opt_present(match, "ignored"), + ret {compile_lib_path: getopts::opt_str(match, ~"compile-lib-path"), + run_lib_path: getopts::opt_str(match, ~"run-lib-path"), + rustc_path: getopts::opt_str(match, ~"rustc-path"), + src_base: getopts::opt_str(match, ~"src-base"), + build_base: getopts::opt_str(match, ~"build-base"), + aux_base: getopts::opt_str(match, ~"aux-base"), + stage_id: getopts::opt_str(match, ~"stage-id"), + mode: str_mode(getopts::opt_str(match, ~"mode")), + run_ignored: getopts::opt_present(match, ~"ignored"), filter: if vec::len(match.free) > 0u { option::some(match.free[0]) } else { option::none }, - logfile: getopts::opt_maybe_str(match, "logfile"), - runtool: getopts::opt_maybe_str(match, "runtool"), - rustcflags: getopts::opt_maybe_str(match, "rustcflags"), - verbose: getopts::opt_present(match, "verbose")}; + logfile: getopts::opt_maybe_str(match, ~"logfile"), + runtool: getopts::opt_maybe_str(match, ~"runtool"), + rustcflags: getopts::opt_maybe_str(match, ~"rustcflags"), + verbose: getopts::opt_present(match, ~"verbose")}; } fn log_config(config: config) { @@ -84,30 +84,30 @@ fn log_config(config: config) { logv(c, #fmt["\n"]); } -fn opt_str(maybestr: option) -> str { - alt maybestr { option::some(s) { s } option::none { "(none)" } } +fn opt_str(maybestr: option<~str>) -> ~str { + alt maybestr { option::some(s) { s } option::none { ~"(none)" } } } -fn str_opt(maybestr: str) -> option { - if maybestr != "(none)" { option::some(maybestr) } else { option::none } +fn str_opt(maybestr: ~str) -> option<~str> { + if maybestr != ~"(none)" { option::some(maybestr) } else { option::none } } -fn str_mode(s: str) -> mode { +fn str_mode(s: ~str) -> mode { alt s { - "compile-fail" { mode_compile_fail } - "run-fail" { mode_run_fail } - "run-pass" { mode_run_pass } - "pretty" { mode_pretty } - _ { fail "invalid mode" } + ~"compile-fail" { mode_compile_fail } + ~"run-fail" { mode_run_fail } + ~"run-pass" { mode_run_pass } + ~"pretty" { mode_pretty } + _ { fail ~"invalid mode" } } } -fn mode_str(mode: mode) -> str { +fn mode_str(mode: mode) -> ~str { alt mode { - mode_compile_fail { "compile-fail" } - mode_run_fail { "run-fail" } - mode_run_pass { "run-pass" } - mode_pretty { "pretty" } + mode_compile_fail { ~"compile-fail" } + mode_run_fail { ~"run-fail" } + mode_run_pass { ~"run-pass" } + mode_pretty { ~"pretty" } } } @@ -115,7 +115,7 @@ fn run_tests(config: config) { let opts = test_opts(config); let tests = make_tests(config); let res = test::run_tests_console(opts, tests); - if !res { fail "Some tests failed"; } + if !res { fail ~"Some tests failed"; } } fn test_opts(config: config) -> test::test_opts { @@ -146,11 +146,11 @@ fn make_tests(config: config) -> ~[test::test_desc] { ret tests; } -fn is_test(config: config, testfile: str) -> bool { +fn is_test(config: config, testfile: ~str) -> bool { // Pretty-printer does not work with .rc files yet let valid_extensions = - alt config.mode { mode_pretty { ~[".rs"] } _ { ~[".rc", ".rs"] } }; - let invalid_prefixes = ~[".", "#", "~"]; + alt config.mode { mode_pretty { ~[~".rs"] } _ { ~[~".rc", ~".rs"] } }; + let invalid_prefixes = ~[~".", ~"#", ~"~"]; let name = path::basename(testfile); let mut valid = false; @@ -166,7 +166,7 @@ fn is_test(config: config, testfile: str) -> bool { ret valid; } -fn make_test(config: config, testfile: str) -> +fn make_test(config: config, testfile: ~str) -> test::test_desc { { name: make_test_name(config, testfile), @@ -176,11 +176,11 @@ fn make_test(config: config, testfile: str) -> } } -fn make_test_name(config: config, testfile: str) -> str { +fn make_test_name(config: config, testfile: ~str) -> ~str { #fmt["[%s] %s", mode_str(config.mode), testfile] } -fn make_test_closure(config: config, testfile: str) -> test::test_fn { +fn make_test_closure(config: config, testfile: ~str) -> test::test_fn { fn~() { runtest::run(config, copy testfile) } } diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index 3ccedc609217..64e36cb1f5e8 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -5,10 +5,10 @@ export load_errors; export expected_error; -type expected_error = { line: uint, kind: str, msg: str }; +type expected_error = { line: uint, kind: ~str, msg: ~str }; // Load any test directives embedded in the file -fn load_errors(testfile: str) -> ~[expected_error] { +fn load_errors(testfile: ~str) -> ~[expected_error] { let mut error_patterns = ~[]; let rdr = result::get(io::file_reader(testfile)); let mut line_num = 1u; @@ -20,8 +20,8 @@ fn load_errors(testfile: str) -> ~[expected_error] { ret error_patterns; } -fn parse_expected(line_num: uint, line: str) -> ~[expected_error] unsafe { - let error_tag = "//~"; +fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe { + let error_tag = ~"//~"; let mut idx; alt str::find_str(line, error_tag) { option::none { ret ~[]; } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 53f3876d9f69..0d90f1435b9c 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -10,20 +10,20 @@ type test_props = { // Lines that should be expected, in order, on standard out - error_patterns: ~[str], + error_patterns: ~[~str], // Extra flags to pass to the compiler - compile_flags: option, + compile_flags: option<~str>, // If present, the name of a file that this test should match when // pretty-printed - pp_exact: option, + pp_exact: option<~str>, // Modules from aux directory that should be compiled - aux_builds: ~[str], + aux_builds: ~[~str], // Environment settings to use during execution - exec_env: ~[(str,str)] + exec_env: ~[(~str,~str)] }; // Load any test directives embedded in the file -fn load_props(testfile: str) -> test_props { +fn load_props(testfile: ~str) -> test_props { let mut error_patterns = ~[]; let mut aux_builds = ~[]; let mut exec_env = ~[]; @@ -60,22 +60,22 @@ fn load_props(testfile: str) -> test_props { }; } -fn is_test_ignored(config: config, testfile: str) -> bool { +fn is_test_ignored(config: config, testfile: ~str) -> bool { let mut found = false; for iter_header(testfile) |ln| { - if parse_name_directive(ln, "xfail-test") { ret true; } + if parse_name_directive(ln, ~"xfail-test") { ret true; } if parse_name_directive(ln, xfail_target()) { ret true; } if config.mode == common::mode_pretty && - parse_name_directive(ln, "xfail-pretty") { ret true; } + parse_name_directive(ln, ~"xfail-pretty") { ret true; } }; ret found; - fn xfail_target() -> str { - "xfail-" + os::sysname() + fn xfail_target() -> ~str { + ~"xfail-" + os::sysname() } } -fn iter_header(testfile: str, it: fn(str) -> bool) -> bool { +fn iter_header(testfile: ~str, it: fn(~str) -> bool) -> bool { let rdr = result::get(io::file_reader(testfile)); while !rdr.eof() { let ln = rdr.read_line(); @@ -83,43 +83,43 @@ fn iter_header(testfile: str, it: fn(str) -> bool) -> bool { // Assume that any directives will be found before the first // module or function. This doesn't seem to be an optimization // with a warm page cache. Maybe with a cold one. - if str::starts_with(ln, "fn") - || str::starts_with(ln, "mod") { + if str::starts_with(ln, ~"fn") + || str::starts_with(ln, ~"mod") { ret false; } else { if !(it(ln)) { ret false; } } } ret true; } -fn parse_error_pattern(line: str) -> option { - parse_name_value_directive(line, "error-pattern") +fn parse_error_pattern(line: ~str) -> option<~str> { + parse_name_value_directive(line, ~"error-pattern") } -fn parse_aux_build(line: str) -> option { - parse_name_value_directive(line, "aux-build") +fn parse_aux_build(line: ~str) -> option<~str> { + parse_name_value_directive(line, ~"aux-build") } -fn parse_compile_flags(line: str) -> option { - parse_name_value_directive(line, "compile-flags") +fn parse_compile_flags(line: ~str) -> option<~str> { + parse_name_value_directive(line, ~"compile-flags") } -fn parse_exec_env(line: str) -> option<(str, str)> { - do parse_name_value_directive(line, "exec-env").map |nv| { +fn parse_exec_env(line: ~str) -> option<(~str, ~str)> { + do parse_name_value_directive(line, ~"exec-env").map |nv| { // nv is either FOO or FOO=BAR let strs = str::splitn_char(nv, '=', 1u); alt strs.len() { - 1u { (strs[0], "") } + 1u { (strs[0], ~"") } 2u { (strs[0], strs[1]) } n { fail #fmt["Expected 1 or 2 strings, not %u", n]; } } } } -fn parse_pp_exact(line: str, testfile: str) -> option { - alt parse_name_value_directive(line, "pp-exact") { +fn parse_pp_exact(line: ~str, testfile: ~str) -> option<~str> { + alt parse_name_value_directive(line, ~"pp-exact") { option::some(s) { option::some(s) } option::none { - if parse_name_directive(line, "pp-exact") { + if parse_name_directive(line, ~"pp-exact") { option::some(path::basename(testfile)) } else { option::none @@ -128,13 +128,13 @@ fn parse_pp_exact(line: str, testfile: str) -> option { } } -fn parse_name_directive(line: str, directive: str) -> bool { +fn parse_name_directive(line: ~str, directive: ~str) -> bool { str::contains(line, directive) } -fn parse_name_value_directive(line: str, - directive: str) -> option unsafe { - let keycolon = directive + ":"; +fn parse_name_value_directive(line: ~str, + directive: ~str) -> option<~str> unsafe { + let keycolon = directive + ~":"; alt str::find_str(line, keycolon) { option::some(colon) { let value = str::slice(line, colon + str::len(keycolon), diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index c46196fd7f64..d69d02c32eb5 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -27,17 +27,17 @@ fn target_env(lib_path: str, prog: str) -> ~[(str,str)] { #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] -fn target_env(_lib_path: str, _prog: str) -> ~[(str,str)] { +fn target_env(_lib_path: ~str, _prog: ~str) -> ~[(~str,~str)] { ~[] } // FIXME (#2659): This code is duplicated in core::run::program_output -fn run(lib_path: str, - prog: str, - args: ~[str], - env: ~[(str, str)], - input: option) -> {status: int, out: str, err: str} { +fn run(lib_path: ~str, + prog: ~str, + args: ~[~str], + env: ~[(~str, ~str)], + input: option<~str>) -> {status: int, out: ~str, err: ~str} { let pipe_in = os::pipe(); let pipe_out = os::pipe(); @@ -69,8 +69,8 @@ fn run(lib_path: str, comm::send(ch, (1, output)); } let status = run::waitpid(pid); - let mut errs = ""; - let mut outs = ""; + let mut errs = ~""; + let mut outs = ~""; let mut count = 2; while count > 0 { let stream = comm::recv(p); @@ -87,7 +87,7 @@ fn run(lib_path: str, ret {status: status, out: outs, err: errs}; } -fn writeclose(fd: c_int, s: option) { +fn writeclose(fd: c_int, s: option<~str>) { if option::is_some(s) { let writer = io::fd_writer(fd, false); writer.write_str(option::get(s)); @@ -96,11 +96,11 @@ fn writeclose(fd: c_int, s: option) { os::close(fd); } -fn readclose(fd: c_int) -> str { +fn readclose(fd: c_int) -> ~str { // Copied from run::program_output let file = os::fdopen(fd); let reader = io::FILE_reader(file, false); - let mut buf = ""; + let mut buf = ~""; while !reader.eof() { let bytes = reader.read_bytes(4096u); buf += str::from_bytes(bytes); diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 9c131f185643..cd8bcb79a9a9 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -11,10 +11,10 @@ export run; -fn run(config: config, testfile: str) { +fn run(config: config, testfile: ~str) { if config.verbose { // We're going to be dumping a lot of info. Start on a new line. - io::stdout().write_str("\n\n"); + io::stdout().write_str(~"\n\n"); } #debug("running %s", testfile); let props = load_props(testfile); @@ -26,11 +26,11 @@ fn run(config: config, testfile: str) { } } -fn run_cfail_test(config: config, props: test_props, testfile: str) { +fn run_cfail_test(config: config, props: test_props, testfile: ~str) { let procres = compile_test(config, props, testfile); if procres.status == 0 { - fatal_procres("compile-fail test compiled successfully!", procres); + fatal_procres(~"compile-fail test compiled successfully!", procres); } check_correct_failure_status(procres); @@ -38,7 +38,7 @@ fn run_cfail_test(config: config, props: test_props, testfile: str) { let expected_errors = errors::load_errors(testfile); if vec::is_not_empty(expected_errors) { if vec::is_not_empty(props.error_patterns) { - fatal("both error pattern and expected errors specified"); + fatal(~"both error pattern and expected errors specified"); } check_expected_errors(expected_errors, testfile, procres); } else { @@ -46,17 +46,17 @@ fn run_cfail_test(config: config, props: test_props, testfile: str) { } } -fn run_rfail_test(config: config, props: test_props, testfile: str) { +fn run_rfail_test(config: config, props: test_props, testfile: ~str) { let mut procres = compile_test(config, props, testfile); - if procres.status != 0 { fatal_procres("compilation failed!", procres); } + if procres.status != 0 { fatal_procres(~"compilation failed!", procres); } procres = exec_compiled_test(config, props, testfile); // The value our Makefile configures valgrind to return on failure const valgrind_err: int = 100; if procres.status == valgrind_err { - fatal_procres("run-fail test isn't valgrind-clean!", procres); + fatal_procres(~"run-fail test isn't valgrind-clean!", procres); } check_correct_failure_status(procres); @@ -74,20 +74,20 @@ fn check_correct_failure_status(procres: procres) { } } -fn run_rpass_test(config: config, props: test_props, testfile: str) { +fn run_rpass_test(config: config, props: test_props, testfile: ~str) { let mut procres = compile_test(config, props, testfile); - if procres.status != 0 { fatal_procres("compilation failed!", procres); } + if procres.status != 0 { fatal_procres(~"compilation failed!", procres); } procres = exec_compiled_test(config, props, testfile); - if procres.status != 0 { fatal_procres("test run failed!", procres); } + if procres.status != 0 { fatal_procres(~"test run failed!", procres); } } -fn run_pretty_test(config: config, props: test_props, testfile: str) { +fn run_pretty_test(config: config, props: test_props, testfile: ~str) { if option::is_some(props.pp_exact) { - logv(config, "testing for exact pretty-printing"); - } else { logv(config, "testing for converging pretty-printing"); } + logv(config, ~"testing for exact pretty-printing"); + } else { logv(config, ~"testing for converging pretty-printing"); } let rounds = alt props.pp_exact { option::some(_) { 1 } option::none { 2 } }; @@ -120,10 +120,10 @@ fn run_pretty_test(config: config, props: test_props, testfile: str) { if option::is_some(props.pp_exact) { // Now we have to care about line endings - let cr = "\r"; + let cr = ~"\r"; check (str::is_not_empty(cr)); - actual = str::replace(actual, cr, ""); - expected = str::replace(expected, cr, ""); + actual = str::replace(actual, cr, ~""); + expected = str::replace(expected, cr, ~""); } compare_source(expected, actual); @@ -132,25 +132,25 @@ fn run_pretty_test(config: config, props: test_props, testfile: str) { let procres = typecheck_source(config, props, testfile, actual); if procres.status != 0 { - fatal_procres("pretty-printed source does not typecheck", procres); + fatal_procres(~"pretty-printed source does not typecheck", procres); } ret; - fn print_source(config: config, testfile: str, src: str) -> procres { + fn print_source(config: config, testfile: ~str, src: ~str) -> procres { compose_and_run(config, testfile, make_pp_args(config, testfile), ~[], config.compile_lib_path, option::some(src)) } - fn make_pp_args(config: config, _testfile: str) -> procargs { + fn make_pp_args(config: config, _testfile: ~str) -> procargs { let prog = config.rustc_path; - let args = ~["-", "--pretty", "normal"]; + let args = ~[~"-", ~"--pretty", ~"normal"]; ret {prog: prog, args: args}; } - fn compare_source(expected: str, actual: str) { + fn compare_source(expected: ~str, actual: ~str) { if expected != actual { - error("pretty-printed source does not match expected source"); + error(~"pretty-printed source does not match expected source"); let msg = #fmt["\n\ expected:\n\ @@ -169,31 +169,32 @@ fn compare_source(expected: str, actual: str) { } fn typecheck_source(config: config, props: test_props, - testfile: str, src: str) -> procres { + testfile: ~str, src: ~str) -> procres { compose_and_run_compiler( config, props, testfile, make_typecheck_args(config, testfile), option::some(src)) } - fn make_typecheck_args(config: config, testfile: str) -> procargs { + fn make_typecheck_args(config: config, testfile: ~str) -> procargs { let prog = config.rustc_path; - let mut args = ~["-", "--no-trans", "--lib", "-L", config.build_base, - "-L", aux_output_dir_name(config, testfile)]; + let mut args = ~[~"-", + ~"--no-trans", ~"--lib", ~"-L", config.build_base, + ~"-L", aux_output_dir_name(config, testfile)]; args += split_maybe_args(config.rustcflags); ret {prog: prog, args: args}; } } fn check_error_patterns(props: test_props, - testfile: str, + testfile: ~str, procres: procres) { if vec::is_empty(props.error_patterns) { - fatal("no error pattern specified in " + testfile); + fatal(~"no error pattern specified in " + testfile); } if procres.status == 0 { - fatal("process did not return an error status"); + fatal(~"process did not return an error status"); } let mut next_err_idx = 0u; @@ -223,12 +224,12 @@ fn check_error_patterns(props: test_props, for missing_patterns.each |pattern| { error(#fmt["error pattern '%s' not found!", pattern]); } - fatal_procres("multiple error patterns not found", procres); + fatal_procres(~"multiple error patterns not found", procres); } } fn check_expected_errors(expected_errors: ~[errors::expected_error], - testfile: str, + testfile: ~str, procres: procres) { // true if we found the error in question @@ -236,7 +237,7 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error], vec::len(expected_errors), false)); if procres.status == 0 { - fatal("process did not return an error status"); + fatal(~"process did not return an error status"); } let prefixes = vec::map(expected_errors, |ee| { @@ -266,12 +267,12 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error], } // ignore this msg which gets printed at the end - if str::contains(line, "aborting due to") { + if str::contains(line, ~"aborting due to") { was_expected = true; } - if !was_expected && (str::contains(line, "error") || - str::contains(line, "warning")) { + if !was_expected && (str::contains(line, ~"error") || + str::contains(line, ~"warning")) { fatal_procres(#fmt["unexpected error pattern '%s'!", line], procres); } @@ -286,13 +287,13 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error], } } -type procargs = {prog: str, args: ~[str]}; +type procargs = {prog: ~str, args: ~[~str]}; -type procres = {status: int, stdout: str, stderr: str, cmdline: str}; +type procres = {status: int, stdout: ~str, stderr: ~str, cmdline: ~str}; fn compile_test(config: config, props: test_props, - testfile: str) -> procres { - let link_args = ~["-L", aux_output_dir_name(config, testfile)]; + testfile: ~str) -> procres { + let link_args = ~[~"-L", aux_output_dir_name(config, testfile)]; compose_and_run_compiler( config, props, testfile, make_compile_args(config, props, link_args, @@ -301,7 +302,7 @@ fn compile_test(config: config, props: test_props, } fn exec_compiled_test(config: config, props: test_props, - testfile: str) -> procres { + testfile: ~str) -> procres { compose_and_run(config, testfile, make_run_args(config, props, testfile), props.exec_env, @@ -311,20 +312,20 @@ fn exec_compiled_test(config: config, props: test_props, fn compose_and_run_compiler( config: config, props: test_props, - testfile: str, + testfile: ~str, args: procargs, - input: option) -> procres { + input: option<~str>) -> procres { if props.aux_builds.is_not_empty() { ensure_dir(aux_output_dir_name(config, testfile)); } - let extra_link_args = ~["-L", aux_output_dir_name(config, testfile)]; + let extra_link_args = ~[~"-L", aux_output_dir_name(config, testfile)]; do vec::iter(props.aux_builds) |rel_ab| { let abs_ab = path::connect(config.aux_base, rel_ab); let aux_args = - make_compile_args(config, props, ~["--lib"] + extra_link_args, + make_compile_args(config, props, ~[~"--lib"] + extra_link_args, |a,b| make_lib_name(a, b, testfile), abs_ab); let auxres = compose_and_run(config, abs_ab, aux_args, ~[], config.compile_lib_path, option::none); @@ -346,38 +347,38 @@ fn ensure_dir(path: path) { } } -fn compose_and_run(config: config, testfile: str, +fn compose_and_run(config: config, testfile: ~str, procargs: procargs, - procenv: ~[(str, str)], - lib_path: str, - input: option) -> procres { + procenv: ~[(~str, ~str)], + lib_path: ~str, + input: option<~str>) -> procres { ret program_output(config, testfile, lib_path, procargs.prog, procargs.args, procenv, input); } -fn make_compile_args(config: config, props: test_props, extras: ~[str], - xform: fn(config, str) -> str, testfile: str) -> +fn make_compile_args(config: config, props: test_props, extras: ~[~str], + xform: fn(config, ~str) -> ~str, testfile: ~str) -> procargs { let prog = config.rustc_path; - let mut args = ~[testfile, "-o", xform(config, testfile), - "-L", config.build_base] + extras; + let mut args = ~[testfile, ~"-o", xform(config, testfile), + ~"-L", config.build_base] + extras; args += split_maybe_args(config.rustcflags); args += split_maybe_args(props.compile_flags); ret {prog: prog, args: args}; } -fn make_lib_name(config: config, auxfile: str, testfile: str) -> str { +fn make_lib_name(config: config, auxfile: ~str, testfile: ~str) -> ~str { // what we return here is not particularly important, as it // happens; rustc ignores everything except for the directory. let auxname = output_testname(auxfile); path::connect(aux_output_dir_name(config, testfile), auxname) } -fn make_exe_name(config: config, testfile: str) -> str { +fn make_exe_name(config: config, testfile: ~str) -> ~str { output_base_name(config, testfile) + os::exe_suffix() } -fn make_run_args(config: config, _props: test_props, testfile: str) -> +fn make_run_args(config: config, _props: test_props, testfile: ~str) -> procargs { let toolargs = { // If we've got another tool to run under (valgrind), @@ -394,9 +395,9 @@ fn make_run_args(config: config, _props: test_props, testfile: str) -> ret {prog: args[0], args: vec::slice(args, 1u, vec::len(args))}; } -fn split_maybe_args(argstr: option) -> ~[str] { - fn rm_whitespace(v: ~[str]) -> ~[str] { - fn flt(&&s: str) -> option { +fn split_maybe_args(argstr: option<~str>) -> ~[~str] { + fn rm_whitespace(v: ~[~str]) -> ~[~str] { + fn flt(&&s: ~str) -> option<~str> { if !str::is_whitespace(s) { option::some(s) } else { option::none } } vec::filter_map(v, flt) @@ -408,9 +409,9 @@ fn flt(&&s: str) -> option { } } -fn program_output(config: config, testfile: str, lib_path: str, prog: str, - args: ~[str], env: ~[(str, str)], - input: option) -> procres { +fn program_output(config: config, testfile: ~str, lib_path: ~str, prog: ~str, + args: ~[~str], env: ~[(~str, ~str)], + input: option<~str>) -> procres { let cmdline = { let cmdline = make_cmdline(lib_path, prog, args); @@ -429,8 +430,8 @@ fn program_output(config: config, testfile: str, lib_path: str, prog: str, #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] -fn make_cmdline(_libpath: str, prog: str, args: ~[str]) -> str { - #fmt["%s %s", prog, str::connect(args, " ")] +fn make_cmdline(_libpath: ~str, prog: ~str, args: ~[~str]) -> ~str { + #fmt["%s %s", prog, str::connect(args, ~" ")] } #[cfg(target_os = "win32")] @@ -441,47 +442,48 @@ fn make_cmdline(libpath: str, prog: str, args: ~[str]) -> str { // Build the LD_LIBRARY_PATH variable as it would be seen on the command line // for diagnostic purposes -fn lib_path_cmd_prefix(path: str) -> str { +fn lib_path_cmd_prefix(path: ~str) -> ~str { #fmt["%s=\"%s\"", util::lib_path_env_var(), util::make_new_path(path)] } -fn dump_output(config: config, testfile: str, out: str, err: str) { - dump_output_file(config, testfile, out, "out"); - dump_output_file(config, testfile, err, "err"); +fn dump_output(config: config, testfile: ~str, out: ~str, err: ~str) { + dump_output_file(config, testfile, out, ~"out"); + dump_output_file(config, testfile, err, ~"err"); maybe_dump_to_stdout(config, out, err); } -fn dump_output_file(config: config, testfile: str, out: str, extension: str) { +fn dump_output_file(config: config, testfile: ~str, + out: ~str, extension: ~str) { let outfile = make_out_name(config, testfile, extension); let writer = result::get( io::file_writer(outfile, ~[io::create, io::truncate])); writer.write_str(out); } -fn make_out_name(config: config, testfile: str, extension: str) -> str { - output_base_name(config, testfile) + "." + extension +fn make_out_name(config: config, testfile: ~str, extension: ~str) -> ~str { + output_base_name(config, testfile) + ~"." + extension } -fn aux_output_dir_name(config: config, testfile: str) -> str { - output_base_name(config, testfile) + ".libaux" +fn aux_output_dir_name(config: config, testfile: ~str) -> ~str { + output_base_name(config, testfile) + ~".libaux" } -fn output_testname(testfile: str) -> str { +fn output_testname(testfile: ~str) -> ~str { let parts = str::split_char(path::basename(testfile), '.'); - str::connect(vec::slice(parts, 0u, vec::len(parts) - 1u), ".") + str::connect(vec::slice(parts, 0u, vec::len(parts) - 1u), ~".") } -fn output_base_name(config: config, testfile: str) -> str { +fn output_base_name(config: config, testfile: ~str) -> ~str { let base = config.build_base; let filename = output_testname(testfile); #fmt["%s%s.%s", base, filename, config.stage_id] } -fn maybe_dump_to_stdout(config: config, out: str, err: str) { +fn maybe_dump_to_stdout(config: config, out: ~str, err: ~str) { if config.verbose { - let sep1 = #fmt["------%s------------------------------", "stdout"]; - let sep2 = #fmt["------%s------------------------------", "stderr"]; - let sep3 = "------------------------------------------"; + let sep1 = #fmt["------%s------------------------------", ~"stdout"]; + let sep2 = #fmt["------%s------------------------------", ~"stderr"]; + let sep3 = ~"------------------------------------------"; io::stdout().write_line(sep1); io::stdout().write_line(out); io::stdout().write_line(sep2); @@ -490,11 +492,11 @@ fn maybe_dump_to_stdout(config: config, out: str, err: str) { } } -fn error(err: str) { io::stdout().write_line(#fmt["\nerror: %s", err]); } +fn error(err: ~str) { io::stdout().write_line(#fmt["\nerror: %s", err]); } -fn fatal(err: str) -> ! { error(err); fail; } +fn fatal(err: ~str) -> ! { error(err); fail; } -fn fatal_procres(err: str, procres: procres) -> ! { +fn fatal_procres(err: ~str, procres: procres) -> ! { let msg = #fmt["\n\ error: %s\n\ diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index b29b0d968c4f..7a38ffcc212d 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -3,7 +3,7 @@ import common::config; -fn make_new_path(path: str) -> str { +fn make_new_path(path: ~str) -> ~str { // Windows just uses PATH as the library search path, so we have to // maintain the current value while adding our own @@ -17,7 +17,7 @@ fn make_new_path(path: str) -> str { #[cfg(target_os = "linux")] #[cfg(target_os = "freebsd")] -fn lib_path_env_var() -> str { "LD_LIBRARY_PATH" } +fn lib_path_env_var() -> ~str { ~"LD_LIBRARY_PATH" } #[cfg(target_os = "macos")] fn lib_path_env_var() -> str { "DYLD_LIBRARY_PATH" } @@ -28,12 +28,12 @@ fn lib_path_env_var() -> str { "PATH" } #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] -fn path_div() -> str { ":" } +fn path_div() -> ~str { ~":" } #[cfg(target_os = "win32")] fn path_div() -> str { ";" } -fn logv(config: config, s: str) { +fn logv(config: config, s: ~str) { log(debug, s); if config.verbose { io::println(s); } } diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 00a9ceeabd7c..047d6433915a 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -8,23 +8,23 @@ enum test_mode { tm_converge, tm_run, } type context = { mode: test_mode }; // + rng -fn write_file(filename: str, content: str) { +fn write_file(filename: ~str, content: ~str) { result::get( io::file_writer(filename, ~[io::create, io::truncate])) .write_str(content); } -fn contains(haystack: str, needle: str) -> bool { +fn contains(haystack: ~str, needle: ~str) -> bool { str::contains(haystack, needle) } -fn find_rust_files(&files: ~[str], path: str) { - if str::ends_with(path, ".rs") && !contains(path, "utf8") { +fn find_rust_files(&files: ~[~str], path: ~str) { + if str::ends_with(path, ~".rs") && !contains(path, ~"utf8") { // ignoring "utf8" tests because something is broken files += ~[path]; } else if os::path_is_dir(path) - && !contains(path, "compile-fail") - && !contains(path, "build") { + && !contains(path, ~"compile-fail") + && !contains(path, ~"build") { for os::list_dir_path(path).each |p| { find_rust_files(files, p); } @@ -45,7 +45,7 @@ fn dsl(l: ast::lit_) -> ast::lit { dse(ast::expr_again), dse(ast::expr_fail(option::none)), dse(ast::expr_fail(option::some( - @dse(ast::expr_lit(@dsl(ast::lit_str(@"boo"))))))), + @dse(ast::expr_lit(@dsl(ast::lit_str(@~"boo"))))))), dse(ast::expr_ret(option::none)), dse(ast::expr_lit(@dsl(ast::lit_nil))), dse(ast::expr_lit(@dsl(ast::lit_bool(false)))), @@ -228,31 +228,31 @@ fn under(n: uint, it: fn(uint)) { fn devnull() -> io::writer { io::mem_buffer_writer(io::mem_buffer()) } -fn as_str(f: fn@(io::writer)) -> str { +fn as_str(f: fn@(io::writer)) -> ~str { let buf = io::mem_buffer(); f(io::mem_buffer_writer(buf)); io::mem_buffer_str(buf) } fn check_variants_of_ast(crate: ast::crate, codemap: codemap::codemap, - filename: str, cx: context) { + filename: ~str, cx: context) { let stolen = steal(crate, cx.mode); let extra_exprs = vec::filter(common_exprs(), |a| safe_to_use_expr(a, cx.mode) ); - check_variants_T(crate, codemap, filename, "expr", + check_variants_T(crate, codemap, filename, ~"expr", extra_exprs + stolen.exprs, pprust::expr_to_str, replace_expr_in_crate, cx); - check_variants_T(crate, codemap, filename, "ty", stolen.tys, + check_variants_T(crate, codemap, filename, ~"ty", stolen.tys, pprust::ty_to_str, replace_ty_in_crate, cx); } fn check_variants_T( crate: ast::crate, codemap: codemap::codemap, - filename: str, - thing_label: str, + filename: ~str, + thing_label: ~str, things: ~[T], - stringifier: fn@(@T) -> str, + stringifier: fn@(@T) -> ~str, replacer: fn@(ast::crate, uint, T, test_mode) -> ast::crate, cx: context ) { @@ -263,9 +263,9 @@ fn check_variants_T( if L < 100u { do under(uint::min(L, 20u)) |i| { - log(error, "Replacing... #" + uint::str(i)); + log(error, ~"Replacing... #" + uint::str(i)); do under(uint::min(L, 30u)) |j| { - log(error, "With... " + stringifier(@things[j])); + log(error, ~"With... " + stringifier(@things[j])); let crate2 = @replacer(crate, i, things[j], cx.mode); // It would be best to test the *crate* for stability, but // testing the string for stability is easier and ok for now. @@ -276,7 +276,7 @@ fn check_variants_T( diagnostic::mk_span_handler(handler, codemap), crate2, filename, - io::str_reader(""), a, + io::str_reader(~""), a, pprust::no_ann(), false)); alt cx.mode { @@ -297,21 +297,26 @@ fn check_variants_T( } } -fn last_part(filename: str) -> str { +fn last_part(filename: ~str) -> ~str { let ix = option::get(str::rfind_char(filename, '/')); str::slice(filename, ix + 1u, str::len(filename) - 3u) } -enum happiness { passed, cleanly_rejected(str), known_bug(str), failed(str), } +enum happiness { + passed, + cleanly_rejected(~str), + known_bug(~str), + failed(~str), +} // We'd find more bugs if we could take an AST here, but // - that would find many "false positives" or unimportant bugs // - that would be tricky, requiring use of tasks or serialization // or randomness. // This seems to find plenty of bugs as it is :) -fn check_whole_compiler(code: str, suggested_filename_prefix: str, +fn check_whole_compiler(code: ~str, suggested_filename_prefix: ~str, allow_running: bool) { - let filename = suggested_filename_prefix + ".rs"; + let filename = suggested_filename_prefix + ~".rs"; write_file(filename, code); let compile_result = check_compiling(filename); @@ -324,102 +329,102 @@ fn check_whole_compiler(code: str, suggested_filename_prefix: str, alt run_result { passed | cleanly_rejected(_) | known_bug(_) { removeIfExists(suggested_filename_prefix); - removeIfExists(suggested_filename_prefix + ".rs"); - removeDirIfExists(suggested_filename_prefix + ".dSYM"); + removeIfExists(suggested_filename_prefix + ~".rs"); + removeDirIfExists(suggested_filename_prefix + ~".dSYM"); } failed(s) { - log(error, "check_whole_compiler failure: " + s); - log(error, "Saved as: " + filename); + log(error, ~"check_whole_compiler failure: " + s); + log(error, ~"Saved as: " + filename); } } } -fn removeIfExists(filename: str) { +fn removeIfExists(filename: ~str) { // So sketchy! - assert !contains(filename, " "); - run::program_output("bash", ~["-c", "rm " + filename]); + assert !contains(filename, ~" "); + run::program_output(~"bash", ~[~"-c", ~"rm " + filename]); } -fn removeDirIfExists(filename: str) { +fn removeDirIfExists(filename: ~str) { // So sketchy! - assert !contains(filename, " "); - run::program_output("bash", ~["-c", "rm -r " + filename]); + assert !contains(filename, ~" "); + run::program_output(~"bash", ~[~"-c", ~"rm -r " + filename]); } -fn check_running(exe_filename: str) -> happiness { +fn check_running(exe_filename: ~str) -> happiness { let p = run::program_output( - "/Users/jruderman/scripts/timed_run_rust_program.py", + ~"/Users/jruderman/scripts/timed_run_rust_program.py", ~[exe_filename]); - let comb = p.out + "\n" + p.err; + let comb = p.out + ~"\n" + p.err; if str::len(comb) > 1u { - log(error, "comb comb comb: " + comb); + log(error, ~"comb comb comb: " + comb); } - if contains(comb, "Assertion failed:") { - failed("C++ assertion failure") - } else if contains(comb, "leaked memory in rust main loop") { + if contains(comb, ~"Assertion failed:") { + failed(~"C++ assertion failure") + } else if contains(comb, ~"leaked memory in rust main loop") { // might also use exit code 134 //failed("Leaked") - known_bug("https://github.com/mozilla/rust/issues/910") - } else if contains(comb, "src/rt/") { - failed("Mentioned src/rt/") - } else if contains(comb, "malloc") { - failed("Mentioned malloc") + known_bug(~"https://github.com/mozilla/rust/issues/910") + } else if contains(comb, ~"src/rt/") { + failed(~"Mentioned src/rt/") + } else if contains(comb, ~"malloc") { + failed(~"Mentioned malloc") } else { alt p.status { 0 { passed } - 100 { cleanly_rejected("running: explicit fail") } - 101 | 247 { cleanly_rejected("running: timed out") } + 100 { cleanly_rejected(~"running: explicit fail") } + 101 | 247 { cleanly_rejected(~"running: timed out") } 245 | 246 | 138 | 252 { - known_bug("https://github.com/mozilla/rust/issues/1466") + known_bug(~"https://github.com/mozilla/rust/issues/1466") } 136 | 248 { known_bug( - "SIGFPE - https://github.com/mozilla/rust/issues/944") + ~"SIGFPE - https://github.com/mozilla/rust/issues/944") } rc { - failed("Rust program ran but exited with status " + + failed(~"Rust program ran but exited with status " + int::str(rc)) } } } } -fn check_compiling(filename: str) -> happiness { +fn check_compiling(filename: ~str) -> happiness { let p = run::program_output( - "/Users/jruderman/code/rust/build/x86_64-apple-darwin/\ + ~"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\ stage1/bin/rustc", ~[filename]); //#error("Status: %d", p.status); if p.status == 0 { passed - } else if p.err != "" { - if contains(p.err, "error:") { - cleanly_rejected("rejected with span_error") + } else if p.err != ~"" { + if contains(p.err, ~"error:") { + cleanly_rejected(~"rejected with span_error") } else { - log(error, "Stderr: " + p.err); - failed("Unfamiliar error message") + log(error, ~"Stderr: " + p.err); + failed(~"Unfamiliar error message") } - } else if contains(p.out, "Assertion") && contains(p.out, "failed") { - log(error, "Stdout: " + p.out); - failed("Looks like an llvm assertion failure") - } else if contains(p.out, "internal compiler error unimplemented") { - known_bug("Something unimplemented") - } else if contains(p.out, "internal compiler error") { - log(error, "Stdout: " + p.out); - failed("internal compiler error") + } else if contains(p.out, ~"Assertion") && contains(p.out, ~"failed") { + log(error, ~"Stdout: " + p.out); + failed(~"Looks like an llvm assertion failure") + } else if contains(p.out, ~"internal compiler error unimplemented") { + known_bug(~"Something unimplemented") + } else if contains(p.out, ~"internal compiler error") { + log(error, ~"Stdout: " + p.out); + failed(~"internal compiler error") } else { log(error, p.status); - log(error, "!Stdout: " + p.out); - failed("What happened?") + log(error, ~"!Stdout: " + p.out); + failed(~"What happened?") } } -fn parse_and_print(code: @str/~) -> str { - let filename = "tmp.rs"; +fn parse_and_print(code: @~str) -> ~str { + let filename = ~"tmp.rs"; let sess = parse::new_parse_sess(option::none); write_file(filename, *code); let crate = parse::parse_crate_from_source_str( @@ -450,49 +455,49 @@ fn visit_ty(flag: @mut bool, t: @ast::ty) { ret *has_rp; } -fn content_is_dangerous_to_run(code: str) -> bool { +fn content_is_dangerous_to_run(code: ~str) -> bool { let dangerous_patterns = - ~["xfail-test", - "import", // espeically fs, run - "extern", - "unsafe", - "log"]; // python --> rust pipe deadlock? + ~[~"xfail-test", + ~"import", // espeically fs, run + ~"extern", + ~"unsafe", + ~"log"]; // python --> rust pipe deadlock? for dangerous_patterns.each |p| { if contains(code, p) { ret true; } } ret false; } -fn content_is_dangerous_to_compile(code: str) -> bool { +fn content_is_dangerous_to_compile(code: ~str) -> bool { let dangerous_patterns = - ~["xfail-test"]; + ~[~"xfail-test"]; for dangerous_patterns.each |p| { if contains(code, p) { ret true; } } ret false; } -fn content_might_not_converge(code: str) -> bool { +fn content_might_not_converge(code: ~str) -> bool { let confusing_patterns = - ~["xfail-test", - "xfail-pretty", - "self", // crazy rules enforced by parser not typechecker? - "spawn", // precedence issues? - "bind", // precedence issues? - " be ", // don't want to replace its child with a non-call: + ~[~"xfail-test", + ~"xfail-pretty", + ~"self", // crazy rules enforced by parser not typechecker? + ~"spawn", // precedence issues? + ~"bind", // precedence issues? + ~" be ", // don't want to replace its child with a non-call: // "Non-call expression in tail call" - "\n\n\n\n\n" // https://github.com/mozilla/rust/issues/850 + ~"\n\n\n\n\n" // https://github.com/mozilla/rust/issues/850 ]; for confusing_patterns.each |p| { if contains(code, p) { ret true; } } ret false; } -fn file_might_not_converge(filename: str) -> bool { +fn file_might_not_converge(filename: ~str) -> bool { let confusing_files = ~[ - "expr-alt.rs", // pretty-printing "(a = b) = c" + ~"expr-alt.rs", // pretty-printing "(a = b) = c" // vs "a = b = c" and wrapping - "block-arg-in-ternary.rs", // wrapping - "move-3-unique.rs", // 0 becomes (0), but both seem reasonable. wtf? - "move-3.rs" // 0 becomes (0), but both seem reasonable. wtf? + ~"block-arg-in-ternary.rs", // wrapping + ~"move-3-unique.rs", // 0 becomes (0), but both seem reasonable. wtf? + ~"move-3.rs" // 0 becomes (0), but both seem reasonable. wtf? ]; @@ -501,7 +506,7 @@ fn file_might_not_converge(filename: str) -> bool { ret false; } -fn check_roundtrip_convergence(code: @str/~, maxIters: uint) { +fn check_roundtrip_convergence(code: @~str, maxIters: uint) { let mut i = 0u; let mut newv = code; @@ -519,16 +524,16 @@ fn check_roundtrip_convergence(code: @str/~, maxIters: uint) { #error("Converged after %u iterations", i); } else { #error("Did not converge after %u iterations!", i); - write_file("round-trip-a.rs", *oldv); - write_file("round-trip-b.rs", *newv); - run::run_program("diff", - ~["-w", "-u", "round-trip-a.rs", - "round-trip-b.rs"]); - fail "Mismatch"; + write_file(~"round-trip-a.rs", *oldv); + write_file(~"round-trip-b.rs", *newv); + run::run_program(~"diff", + ~[~"-w", ~"-u", ~"round-trip-a.rs", + ~"round-trip-b.rs"]); + fail ~"Mismatch"; } } -fn check_convergence(files: ~[str]) { +fn check_convergence(files: ~[~str]) { #error("pp convergence tests: %u files", vec::len(files)); for files.each |file| { if !file_might_not_converge(file) { @@ -543,7 +548,7 @@ fn check_convergence(files: ~[str]) { } } -fn check_variants(files: ~[str], cx: context) { +fn check_variants(files: ~[~str], cx: context) { for files.each |file| { if cx.mode == tm_converge && file_might_not_converge(file) { #error("Skipping convergence test based on\ @@ -552,7 +557,7 @@ fn check_variants(files: ~[str], cx: context) { } let s = @result::get(io::read_whole_file_str(file)); - if contains(*s, "#") { + if contains(*s, ~"#") { again; // Macros are confusing } if cx.mode == tm_converge && content_might_not_converge(*s) { @@ -562,7 +567,7 @@ fn check_variants(files: ~[str], cx: context) { again; } - log(error, "check_variants: " + file); + log(error, ~"check_variants: " + file); let sess = parse::new_parse_sess(option::none); let crate = parse::parse_crate_from_source_str( @@ -582,7 +587,7 @@ fn check_variants(files: ~[str], cx: context) { } } -fn main(args: ~[str]) { +fn main(args: ~[~str]) { if vec::len(args) != 2u { #error("usage: %s ", args[0]); ret; diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 1f0d9174c735..83e7ebec8601 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -38,16 +38,16 @@ pure fn is_false(v: bool) -> bool { !v } /// Parse logic value from `s` -pure fn from_str(s: str) -> option { +pure fn from_str(s: ~str) -> option { alt check s { - "true" { some(true) } - "false" { some(false) } + ~"true" { some(true) } + ~"false" { some(false) } _ { none } } } /// Convert `v` into a string -pure fn to_str(v: bool) -> str { if v { "true" } else { "false" } } +pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } } /** * Iterates over all truth values by passing them to `blk` in an unspecified @@ -70,8 +70,8 @@ fn test_bool_from_str() { #[test] fn test_bool_to_str() { - assert to_str(false) == "false"; - assert to_str(true) == "true"; + assert to_str(false) == ~"false"; + assert to_str(true) == ~"true"; } #[test] diff --git a/src/libcore/char.rs b/src/libcore/char.rs index d68800a96fc7..af65c3f4b968 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -132,15 +132,15 @@ * - chars in [0x100,0xffff] get 4-digit escapes: `\\uNNNN` * - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN` */ -fn escape_unicode(c: char) -> str { +fn escape_unicode(c: char) -> ~str { let s = u32::to_str(c as u32, 16u); let (c, pad) = (if c <= '\xff' { ('x', 2u) } else if c <= '\uffff' { ('u', 4u) } else { ('U', 8u) }); assert str::len(s) <= pad; - let mut out = "\\"; + let mut out = ~"\\"; str::push_str(out, str::from_char(c)); - for uint::range(str::len(s), pad) |_i| { str::push_str(out, "0"); } + for uint::range(str::len(s), pad) |_i| { str::push_str(out, ~"0"); } str::push_str(out, s); ret out; } @@ -157,14 +157,14 @@ fn escape_unicode(c: char) -> str { * - Any other chars in the range [0x20,0x7e] are not escaped. * - Any other chars are given hex unicode escapes; see `escape_unicode`. */ -fn escape_default(c: char) -> str { +fn escape_default(c: char) -> ~str { alt c { - '\t' { "\\t" } - '\r' { "\\r" } - '\n' { "\\n" } - '\\' { "\\\\" } - '\'' { "\\'" } - '"' { "\\\"" } + '\t' { ~"\\t" } + '\r' { ~"\\r" } + '\n' { ~"\\n" } + '\\' { ~"\\\\" } + '\'' { ~"\\'" } + '"' { ~"\\\"" } '\x20' to '\x7e' { str::from_char(c) } _ { escape_unicode(c) } } @@ -232,8 +232,8 @@ fn test_to_digit() { #[test] fn test_is_ascii() { - assert str::all("banana", char::is_ascii); - assert ! str::all("ประเทศไทย中华Việt Nam", char::is_ascii); + assert str::all(~"banana", char::is_ascii); + assert ! str::all(~"ประเทศไทย中华Việt Nam", char::is_ascii); } #[test] @@ -248,28 +248,28 @@ fn test_is_digit() { #[test] fn test_escape_default() { - assert escape_default('\n') == "\\n"; - assert escape_default('\r') == "\\r"; - assert escape_default('\'') == "\\'"; - assert escape_default('"') == "\\\""; - assert escape_default(' ') == " "; - assert escape_default('a') == "a"; - assert escape_default('~') == "~"; - assert escape_default('\x00') == "\\x00"; - assert escape_default('\x1f') == "\\x1f"; - assert escape_default('\x7f') == "\\x7f"; - assert escape_default('\xff') == "\\xff"; - assert escape_default('\u011b') == "\\u011b"; - assert escape_default('\U0001d4b6') == "\\U0001d4b6"; + assert escape_default('\n') == ~"\\n"; + assert escape_default('\r') == ~"\\r"; + assert escape_default('\'') == ~"\\'"; + assert escape_default('"') == ~"\\\""; + assert escape_default(' ') == ~" "; + assert escape_default('a') == ~"a"; + assert escape_default('~') == ~"~"; + assert escape_default('\x00') == ~"\\x00"; + assert escape_default('\x1f') == ~"\\x1f"; + assert escape_default('\x7f') == ~"\\x7f"; + assert escape_default('\xff') == ~"\\xff"; + assert escape_default('\u011b') == ~"\\u011b"; + assert escape_default('\U0001d4b6') == ~"\\U0001d4b6"; } #[test] fn test_escape_unicode() { - assert escape_unicode('\x00') == "\\x00"; - assert escape_unicode('\n') == "\\x0a"; - assert escape_unicode(' ') == "\\x20"; - assert escape_unicode('a') == "\\x61"; - assert escape_unicode('\u011b') == "\\u011b"; - assert escape_unicode('\U0001d4b6') == "\\U0001d4b6"; + assert escape_unicode('\x00') == ~"\\x00"; + assert escape_unicode('\n') == ~"\\x0a"; + assert escape_unicode(' ') == ~"\\x20"; + assert escape_unicode('a') == ~"\\x61"; + assert escape_unicode('\u011b') == ~"\\u011b"; + assert escape_unicode('\U0001d4b6') == ~"\\U0001d4b6"; } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 9a50f4758f07..7c85e5c5d5a7 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -142,9 +142,9 @@ fn as_raw_port(ch: comm::chan, f: fn(*rust_port) -> U) -> U { let p = portref(rustrt::rust_port_take(*ch)); if ptr::is_null(p.p) { - fail "unable to locate port for channel" + fail ~"unable to locate port for channel" } else if rustrt::get_task_id() != rustrt::rust_port_task(p.p) { - fail "unable to access unowned port" + fail ~"unable to access unowned port" } f(p.p) @@ -245,7 +245,7 @@ fn select2(p_a: port, p_b: port) } else if resport == (**p_b).po { either::right(recv(p_b)) } else { - fail "unexpected result from rust_port_select"; + fail ~"unexpected result from rust_port_select"; } } @@ -348,13 +348,13 @@ fn test_select2_available() { let ch_a = chan(po_a); let ch_b = chan(po_b); - send(ch_a, "a"); + send(ch_a, ~"a"); - assert select2(po_a, po_b) == either::left("a"); + assert select2(po_a, po_b) == either::left(~"a"); - send(ch_b, "b"); + send(ch_b, ~"b"); - assert select2(po_a, po_b) == either::right("b"); + assert select2(po_a, po_b) == either::right(~"b"); } #[test] @@ -367,17 +367,17 @@ fn test_select2_rendezvous() { for iter::repeat(10u) { do task::spawn { for iter::repeat(10u) { task::yield() } - send(ch_a, "a"); + send(ch_a, ~"a"); }; - assert select2(po_a, po_b) == either::left("a"); + assert select2(po_a, po_b) == either::left(~"a"); do task::spawn { for iter::repeat(10u) { task::yield() } - send(ch_b, "b"); + send(ch_b, ~"b"); }; - assert select2(po_a, po_b) == either::right("b"); + assert select2(po_a, po_b) == either::right(~"b"); } } @@ -394,12 +394,12 @@ fn test_select2_stress() { for iter::repeat(times) { do task::spawn { for iter::repeat(msgs) { - send(ch_a, "a") + send(ch_a, ~"a") } }; do task::spawn { for iter::repeat(msgs) { - send(ch_b, "b") + send(ch_b, ~"b") } }; } @@ -408,8 +408,8 @@ fn test_select2_stress() { let mut bs = 0; for iter::repeat(msgs * times * 2u) { alt check select2(po_a, po_b) { - either::left("a") { as += 1 } - either::right("b") { bs += 1 } + either::left(~"a") { as += 1 } + either::right(~"b") { bs += 1 } } } @@ -421,8 +421,8 @@ fn test_select2_stress() { fn test_recv_chan() { let po = port(); let ch = chan(po); - send(ch, "flower"); - assert recv_chan(ch) == "flower"; + send(ch, ~"flower"); + assert recv_chan(ch) == ~"flower"; } #[test] @@ -430,7 +430,7 @@ fn test_recv_chan() { #[ignore(cfg(windows))] fn test_recv_chan_dead() { let ch = chan(port()); - send(ch, "flower"); + send(ch, ~"flower"); recv_chan(ch); } @@ -439,7 +439,7 @@ fn test_recv_chan_dead() { fn test_recv_chan_wrong_task() { let po = port(); let ch = chan(po); - send(ch, "flower"); + send(ch, ~"flower"); assert result::is_err(task::try(|| recv_chan(ch) )) @@ -464,9 +464,9 @@ fn test_chan_peek() { fn test_listen() { do listen |parent| { do task::spawn { - parent.send("oatmeal-salad"); + parent.send(~"oatmeal-salad"); } - assert parent.recv() == "oatmeal-salad"; + assert parent.recv() == ~"oatmeal-salad"; } } diff --git a/src/libcore/core.rs b/src/libcore/core.rs index 7e0ab17df17f..4cadf018df82 100644 --- a/src/libcore/core.rs +++ b/src/libcore/core.rs @@ -69,6 +69,6 @@ mod std { * any code paths following the appearance of this function as unreachable. */ fn unreachable() -> ! { - fail "Internal error: entered unreachable code"; + fail ~"Internal error: entered unreachable code"; } diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 06548e632b97..4fdad63eec58 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -32,10 +32,10 @@ impl private_methods for dlist_node { alt neighbour.prev { some(me) { if !box::ptr_eq(*self, *me) { - fail "Asymmetric next-link in dlist node." + fail ~"Asymmetric next-link in dlist node." } } - none { fail "One-way next-link in dlist node." } + none { fail ~"One-way next-link in dlist node." } } } none { } @@ -45,10 +45,10 @@ impl private_methods for dlist_node { alt neighbour.next { some(me) { if !box::ptr_eq(*me, *self) { - fail "Asymmetric prev-link in dlist node." + fail ~"Asymmetric prev-link in dlist node." } } - none { fail "One-way prev-link in dlist node." } + none { fail ~"One-way prev-link in dlist node." } } } none { } @@ -66,7 +66,7 @@ impl extensions for dlist_node { pure fn next_node() -> dlist_node { alt self.next_link() { some(nobe) { nobe } - none { fail "This dlist node has no next neighbour." } + none { fail ~"This dlist node has no next neighbour." } } } /// Get the previous node in the list, if there is one. @@ -78,7 +78,7 @@ impl extensions for dlist_node { pure fn prev_node() -> dlist_node { alt self.prev_link() { some(nobe) { nobe } - none { fail "This dlist node has no previous neighbour." } + none { fail ~"This dlist node has no previous neighbour." } } } @@ -87,7 +87,7 @@ fn remove() { if option::is_some(self.root) { option::get(self.root).remove(self); } else { - fail "Removing an orphaned dlist node - what do I remove from?" + fail ~"Removing an orphaned dlist node - what do I remove from?" } } } @@ -124,12 +124,12 @@ impl private_methods for dlist { pure fn assert_mine(nobe: dlist_node) { alt nobe.root { some(me) { assert box::ptr_eq(*self, *me); } - none { fail "This node isn't on this dlist." } + none { fail ~"This node isn't on this dlist." } } } fn make_mine(nobe: dlist_node) { if option::is_some(nobe.root) { - fail "Cannot insert node that's already on a dlist!" + fail ~"Cannot insert node that's already on a dlist!" } nobe.root = some(self); } @@ -287,14 +287,18 @@ fn pop_tail_n() -> option> { pure fn head_n() -> dlist_node { alt self.hd { some(nobe) { nobe } - none { fail "Attempted to get the head of an empty dlist." } + none { + fail ~"Attempted to get the head of an empty dlist." + } } } /// Get the node at the list's tail, failing if empty. O(1). pure fn tail_n() -> dlist_node { alt self.tl { some(nobe) { nobe } - none { fail "Attempted to get the tail of an empty dlist." } + none { + fail ~"Attempted to get the tail of an empty dlist." + } } } diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 1784acc1414c..2a5df0ea1563 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -80,7 +80,7 @@ fn check_not_borrowed() { unsafe { let data: *() = unsafe::reinterpret_cast(self.data); if data.is_null() { - fail "Recursive use of dvec"; + fail ~"Recursive use of dvec"; } } } @@ -91,7 +91,7 @@ fn borrow(f: fn(-~[mut A]) -> B) -> B { let mut data = unsafe::reinterpret_cast(null::<()>()); data <-> self.data; let data_ptr: *() = unsafe::reinterpret_cast(data); - if data_ptr.is_null() { fail "Recursive use of dvec"; } + if data_ptr.is_null() { fail ~"Recursive use of dvec"; } ret f(data); } } @@ -149,11 +149,11 @@ fn unshift(-t: A) { let mut data = unsafe::reinterpret_cast(null::<()>()); data <-> self.data; let data_ptr: *() = unsafe::reinterpret_cast(data); - if data_ptr.is_null() { fail "Recursive use of dvec"; } - log(error, "a"); + if data_ptr.is_null() { fail ~"Recursive use of dvec"; } + log(error, ~"a"); self.data <- ~[mut t]; vec::push_all_move(self.data, data); - log(error, "b"); + log(error, ~"b"); } } @@ -276,7 +276,7 @@ fn last() -> A { let length = self.len(); if length == 0u { - fail "attempt to retrieve the last element of an empty vector"; + fail ~"attempt to retrieve the last element of an empty vector"; } ret self.data[length - 1u]; diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 9d37ac14fbff..09910ce5cff0 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -78,31 +78,31 @@ enum count { // A fragment of the output sequence - enum piece { piece_string(str), piece_conv(conv), } - type error_fn = fn@(str) -> ! ; + enum piece { piece_string(~str), piece_conv(conv), } + type error_fn = fn@(~str) -> ! ; - fn parse_fmt_string(s: str, error: error_fn) -> ~[piece] { + fn parse_fmt_string(s: ~str, error: error_fn) -> ~[piece] { let mut pieces: ~[piece] = ~[]; let lim = str::len(s); - let mut buf = ""; - fn flush_buf(buf: str, &pieces: ~[piece]) -> str { + let mut buf = ~""; + fn flush_buf(buf: ~str, &pieces: ~[piece]) -> ~str { if str::len(buf) > 0u { let piece = piece_string(buf); vec::push(pieces, piece); } - ret ""; + ret ~""; } let mut i = 0u; while i < lim { let size = str::utf8_char_width(s[i]); let curr = str::slice(s, i, i+size); - if str::eq(curr, "%") { + if str::eq(curr, ~"%") { i += 1u; if i >= lim { - error("unterminated conversion at end of string"); + error(~"unterminated conversion at end of string"); } let curr2 = str::slice(s, i, i+1u); - if str::eq(curr2, "%") { + if str::eq(curr2, ~"%") { buf += curr2; i += 1u; } else { @@ -116,7 +116,7 @@ fn flush_buf(buf: str, &pieces: ~[piece]) -> str { flush_buf(buf, pieces); ret pieces; } - fn peek_num(s: str, i: uint, lim: uint) -> + fn peek_num(s: ~str, i: uint, lim: uint) -> option<{num: uint, next: uint}> { if i >= lim { ret none; } let c = s[i]; @@ -131,7 +131,7 @@ fn peek_num(s: str, i: uint, lim: uint) -> } }; } - fn parse_conversion(s: str, i: uint, lim: uint, error: error_fn) -> + fn parse_conversion(s: ~str, i: uint, lim: uint, error: error_fn) -> {piece: piece, next: uint} { let parm = parse_parameter(s, i, lim); let flags = parse_flags(s, parm.next, lim); @@ -146,7 +146,7 @@ fn parse_conversion(s: str, i: uint, lim: uint, error: error_fn) -> ty: ty.ty}), next: ty.next}; } - fn parse_parameter(s: str, i: uint, lim: uint) -> + fn parse_parameter(s: ~str, i: uint, lim: uint) -> {param: option, next: uint} { if i >= lim { ret {param: none, next: i}; } let num = peek_num(s, i, lim); @@ -161,12 +161,12 @@ fn parse_parameter(s: str, i: uint, lim: uint) -> } }; } - fn parse_flags(s: str, i: uint, lim: uint) -> + fn parse_flags(s: ~str, i: uint, lim: uint) -> {flags: ~[flag], next: uint} { let noflags: ~[flag] = ~[]; if i >= lim { ret {flags: noflags, next: i}; } - fn more_(f: flag, s: str, i: uint, lim: uint) -> + fn more_(f: flag, s: ~str, i: uint, lim: uint) -> {flags: ~[flag], next: uint} { let next = parse_flags(s, i + 1u, lim); let rest = next.flags; @@ -188,7 +188,8 @@ fn more_(f: flag, s: str, i: uint, lim: uint) -> more(flag_alternate) } else { {flags: noflags, next: i} }; } - fn parse_count(s: str, i: uint, lim: uint) -> {count: count, next: uint} { + fn parse_count(s: ~str, i: uint, lim: uint) + -> {count: count, next: uint} { ret if i >= lim { {count: count_implied, next: i} } else if s[i] == '*' as u8 { @@ -208,7 +209,7 @@ fn parse_count(s: str, i: uint, lim: uint) -> {count: count, next: uint} { } }; } - fn parse_precision(s: str, i: uint, lim: uint) -> + fn parse_precision(s: ~str, i: uint, lim: uint) -> {count: count, next: uint} { ret if i >= lim { {count: count_implied, next: i} @@ -224,36 +225,36 @@ fn parse_precision(s: str, i: uint, lim: uint) -> } } else { {count: count_implied, next: i} }; } - fn parse_type(s: str, i: uint, lim: uint, error: error_fn) -> + fn parse_type(s: ~str, i: uint, lim: uint, error: error_fn) -> {ty: ty, next: uint} { - if i >= lim { error("missing type in conversion"); } + if i >= lim { error(~"missing type in conversion"); } let tstr = str::slice(s, i, i+1u); // FIXME (#2249): Do we really want two signed types here? // How important is it to be printf compatible? let t = - if str::eq(tstr, "b") { + if str::eq(tstr, ~"b") { ty_bool - } else if str::eq(tstr, "s") { + } else if str::eq(tstr, ~"s") { ty_str - } else if str::eq(tstr, "c") { + } else if str::eq(tstr, ~"c") { ty_char - } else if str::eq(tstr, "d") || str::eq(tstr, "i") { + } else if str::eq(tstr, ~"d") || str::eq(tstr, ~"i") { ty_int(signed) - } else if str::eq(tstr, "u") { + } else if str::eq(tstr, ~"u") { ty_int(unsigned) - } else if str::eq(tstr, "x") { + } else if str::eq(tstr, ~"x") { ty_hex(case_lower) - } else if str::eq(tstr, "X") { + } else if str::eq(tstr, ~"X") { ty_hex(case_upper) - } else if str::eq(tstr, "t") { + } else if str::eq(tstr, ~"t") { ty_bits - } else if str::eq(tstr, "o") { + } else if str::eq(tstr, ~"o") { ty_octal - } else if str::eq(tstr, "f") { + } else if str::eq(tstr, ~"f") { ty_float - } else if str::eq(tstr, "?") { + } else if str::eq(tstr, ~"?") { ty_poly - } else { error("unknown type in conversion: " + tstr) }; + } else { error(~"unknown type in conversion: " + tstr) }; ret {ty: t, next: i + 1u}; } } @@ -276,10 +277,10 @@ enum ty { ty_default, ty_bits, ty_hex_upper, ty_hex_lower, ty_octal, } type conv = {flags: u32, width: count, precision: count, ty: ty}; - fn conv_int(cv: conv, i: int) -> str { + fn conv_int(cv: conv, i: int) -> ~str { let radix = 10u; let prec = get_int_precision(cv); - let mut s : str = int_to_str_prec(i, radix, prec); + let mut s : ~str = int_to_str_prec(i, radix, prec); if 0 <= i { if have_flag(cv.flags, flag_sign_always) { str::unshift_char(s, '+'); @@ -289,7 +290,7 @@ fn conv_int(cv: conv, i: int) -> str { } ret pad(cv, s, pad_signed); } - fn conv_uint(cv: conv, u: uint) -> str { + fn conv_uint(cv: conv, u: uint) -> ~str { let prec = get_int_precision(cv); let mut rs = alt cv.ty { @@ -301,17 +302,17 @@ fn conv_uint(cv: conv, u: uint) -> str { }; ret pad(cv, rs, pad_unsigned); } - fn conv_bool(cv: conv, b: bool) -> str { - let s = if b { "true" } else { "false" }; + fn conv_bool(cv: conv, b: bool) -> ~str { + let s = if b { ~"true" } else { ~"false" }; // run the boolean conversion through the string conversion logic, // giving it the same rules for precision, etc. ret conv_str(cv, s); } - fn conv_char(cv: conv, c: char) -> str { + fn conv_char(cv: conv, c: char) -> ~str { let mut s = str::from_char(c); ret pad(cv, s, pad_nozero); } - fn conv_str(cv: conv, s: str) -> str { + fn conv_str(cv: conv, s: ~str) -> ~str { // For strings, precision is the maximum characters // displayed let mut unpadded = alt cv.precision { @@ -324,7 +325,7 @@ fn conv_str(cv: conv, s: str) -> str { }; ret pad(cv, unpadded, pad_nozero); } - fn conv_float(cv: conv, f: float) -> str { + fn conv_float(cv: conv, f: float) -> ~str { let (to_str, digits) = alt cv.precision { count_is(c) { (float::to_str_exact, c as uint) } count_implied { (float::to_str, 6u) } @@ -332,32 +333,32 @@ fn conv_float(cv: conv, f: float) -> str { let mut s = to_str(f, digits); if 0.0 <= f { if have_flag(cv.flags, flag_sign_always) { - s = "+" + s; + s = ~"+" + s; } else if have_flag(cv.flags, flag_space_for_sign) { - s = " " + s; + s = ~" " + s; } } ret pad(cv, s, pad_float); } - fn conv_poly(cv: conv, v: T) -> str { + fn conv_poly(cv: conv, v: T) -> ~str { let s = sys::log_str(v); ret conv_str(cv, s); } // Convert an int to string with minimum number of digits. If precision is // 0 and num is 0 then the result is the empty string. - fn int_to_str_prec(num: int, radix: uint, prec: uint) -> str { + fn int_to_str_prec(num: int, radix: uint, prec: uint) -> ~str { ret if num < 0 { - "-" + uint_to_str_prec(-num as uint, radix, prec) + ~"-" + uint_to_str_prec(-num as uint, radix, prec) } else { uint_to_str_prec(num as uint, radix, prec) }; } // Convert a uint to string with a minimum number of digits. If precision // is 0 and num is 0 then the result is the empty string. Could move this // to uint: but it doesn't seem all that useful. - fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> str { + fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> ~str { ret if prec == 0u && num == 0u { - "" + ~"" } else { let s = uint::to_str(num, radix); let len = str::char_len(s); @@ -375,7 +376,7 @@ fn get_int_precision(cv: conv) -> uint { }; } enum pad_mode { pad_signed, pad_unsigned, pad_nozero, pad_float } - fn pad(cv: conv, &s: str, mode: pad_mode) -> str { + fn pad(cv: conv, &s: ~str, mode: pad_mode) -> ~str { let uwidth : uint = alt cv.width { count_implied { ret s; } count_is(width) { diff --git a/src/libcore/float.rs b/src/libcore/float.rs index 1ba6e75a1ec8..0139c60873b8 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -102,12 +102,12 @@ mod consts { * * digits - The number of significant digits * * exact - Whether to enforce the exact number of significant digits */ -fn to_str_common(num: float, digits: uint, exact: bool) -> str { - if is_NaN(num) { ret "NaN"; } - if num == infinity { ret "inf"; } - if num == neg_infinity { ret "-inf"; } +fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { + if is_NaN(num) { ret ~"NaN"; } + if num == infinity { ret ~"inf"; } + if num == neg_infinity { ret ~"-inf"; } - let mut (num, sign) = if num < 0.0 { (-num, "-") } else { (num, "") }; + let mut (num, sign) = if num < 0.0 { (-num, ~"-") } else { (num, ~"") }; // truncated integer let trunc = num as uint; @@ -145,7 +145,7 @@ fn to_str_common(num: float, digits: uint, exact: bool) -> str { } let mut acc; - let mut racc = ""; + let mut racc = ~""; let mut carry = if frac * 10.0 as uint >= 5u { 1u } else { 0u }; // turn digits into string @@ -165,15 +165,15 @@ fn to_str_common(num: float, digits: uint, exact: bool) -> str { // pad decimals with trailing zeroes while str::len(racc) < digits && exact { - racc += "0" + racc += ~"0" } // combine ints and decimals let mut ones = uint::str(trunc + carry); - if racc == "" { + if racc == ~"" { acc = sign + ones; } else { - acc = sign + ones + "." + racc; + acc = sign + ones + ~"." + racc; } ret acc; @@ -188,14 +188,14 @@ fn to_str_common(num: float, digits: uint, exact: bool) -> str { * * num - The float value * * digits - The number of significant digits */ -fn to_str_exact(num: float, digits: uint) -> str { +fn to_str_exact(num: float, digits: uint) -> ~str { to_str_common(num, digits, true) } #[test] fn test_to_str_exact_do_decimal() { let s = to_str_exact(5.0, 4u); - assert s == "5.0000"; + assert s == ~"5.0000"; } @@ -208,7 +208,7 @@ fn test_to_str_exact_do_decimal() { * * num - The float value * * digits - The number of significant digits */ -fn to_str(num: float, digits: uint) -> str { +fn to_str(num: float, digits: uint) -> ~str { to_str_common(num, digits, false) } @@ -238,12 +238,12 @@ fn to_str(num: float, digits: uint) -> str { * `none` if the string did not represent a valid number. Otherwise, * `some(n)` where `n` is the floating-point number represented by `[num]`. */ -fn from_str(num: str) -> option { - if num == "inf" { +fn from_str(num: ~str) -> option { + if num == ~"inf" { ret some(infinity as float); - } else if num == "-inf" { + } else if num == ~"-inf" { ret some(neg_infinity as float); - } else if num == "NaN" { + } else if num == ~"NaN" { ret some(NaN as float); } @@ -433,45 +433,45 @@ impl num of num::num for float { #[test] fn test_from_str() { - assert from_str("3") == some(3.); - assert from_str("3") == some(3.); - assert from_str("3.14") == some(3.14); - assert from_str("+3.14") == some(3.14); - assert from_str("-3.14") == some(-3.14); - assert from_str("2.5E10") == some(25000000000.); - assert from_str("2.5e10") == some(25000000000.); - assert from_str("25000000000.E-10") == some(2.5); - assert from_str(".") == some(0.); - assert from_str(".e1") == some(0.); - assert from_str(".e-1") == some(0.); - assert from_str("5.") == some(5.); - assert from_str(".5") == some(0.5); - assert from_str("0.5") == some(0.5); - assert from_str("0.5") == some(0.5); - assert from_str("0.5") == some(0.5); - assert from_str("-.5") == some(-0.5); - assert from_str("-.5") == some(-0.5); - assert from_str("-5") == some(-5.); - assert from_str("-0") == some(-0.); - assert from_str("0") == some(0.); - assert from_str("inf") == some(infinity); - assert from_str("-inf") == some(neg_infinity); + assert from_str(~"3") == some(3.); + assert from_str(~"3") == some(3.); + assert from_str(~"3.14") == some(3.14); + assert from_str(~"+3.14") == some(3.14); + assert from_str(~"-3.14") == some(-3.14); + assert from_str(~"2.5E10") == some(25000000000.); + assert from_str(~"2.5e10") == some(25000000000.); + assert from_str(~"25000000000.E-10") == some(2.5); + assert from_str(~".") == some(0.); + assert from_str(~".e1") == some(0.); + assert from_str(~".e-1") == some(0.); + assert from_str(~"5.") == some(5.); + assert from_str(~".5") == some(0.5); + assert from_str(~"0.5") == some(0.5); + assert from_str(~"0.5") == some(0.5); + assert from_str(~"0.5") == some(0.5); + assert from_str(~"-.5") == some(-0.5); + assert from_str(~"-.5") == some(-0.5); + assert from_str(~"-5") == some(-5.); + assert from_str(~"-0") == some(-0.); + assert from_str(~"0") == some(0.); + assert from_str(~"inf") == some(infinity); + assert from_str(~"-inf") == some(neg_infinity); // note: NaN != NaN, hence this slightly complex test - alt from_str("NaN") { + alt from_str(~"NaN") { some(f) { assert is_NaN(f); } none { fail; } } - assert from_str("") == none; - assert from_str("x") == none; - assert from_str(" ") == none; - assert from_str(" ") == none; - assert from_str("e") == none; - assert from_str("E") == none; - assert from_str("E1") == none; - assert from_str("1e1e1") == none; - assert from_str("1e1.1") == none; - assert from_str("1e1-1") == none; + assert from_str(~"") == none; + assert from_str(~"x") == none; + assert from_str(~" ") == none; + assert from_str(~" ") == none; + assert from_str(~"e") == none; + assert from_str(~"E") == none; + assert from_str(~"E1") == none; + assert from_str(~"1e1e1") == none; + assert from_str(~"1e1.1") == none; + assert from_str(~"1e1-1") == none; } #[test] @@ -520,8 +520,8 @@ fn test_nonnegative() { #[test] fn test_to_str_inf() { - assert to_str(infinity, 10u) == "inf"; - assert to_str(-infinity, 10u) == "-inf"; + assert to_str(infinity, 10u) == ~"inf"; + assert to_str(-infinity, 10u) == ~"-inf"; } #[test] diff --git a/src/libcore/future.rs b/src/libcore/future.rs index 05af670db178..f26643a6cab4 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -143,47 +143,47 @@ fn with(future: future, blk: fn(A) -> B) -> B { #[test] fn test_from_value() { - let f = from_value("snail"); - assert get(f) == "snail"; + let f = from_value(~"snail"); + assert get(f) == ~"snail"; } #[test] fn test_from_port() { let (po, ch) = future_pipe::init(); - future_pipe::server::completed(ch, "whale"); + future_pipe::server::completed(ch, ~"whale"); let f = from_port(po); - assert get(f) == "whale"; + assert get(f) == ~"whale"; } #[test] fn test_from_fn() { - let f = fn@() -> str { "brail" }; + let f = fn@() -> ~str { ~"brail" }; let f = from_fn(f); - assert get(f) == "brail"; + assert get(f) == ~"brail"; } #[test] fn test_iface_get() { - let f = from_value("fail"); - assert f.get() == "fail"; + let f = from_value(~"fail"); + assert f.get() == ~"fail"; } #[test] fn test_with() { - let f = from_value("nail"); - assert with(f, |v| v) == "nail"; + let f = from_value(~"nail"); + assert with(f, |v| v) == ~"nail"; } #[test] fn test_iface_with() { - let f = from_value("kale"); - assert f.with(|v| v) == "kale"; + let f = from_value(~"kale"); + assert f.with(|v| v) == ~"kale"; } #[test] fn test_spawn() { - let f = spawn(|| "bale"); - assert get(f) == "bale"; + let f = spawn(|| ~"bale"); + assert get(f) == ~"bale"; } #[test] @@ -191,5 +191,5 @@ fn test_spawn() { #[ignore(cfg(target_os = "win32"))] fn test_futurefail() { let f = spawn(|| fail); - let _x: str = get(f); + let _x: ~str = get(f); } diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index b712c68888b9..983d1b9968f3 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -89,10 +89,10 @@ fn parse_buf(buf: ~[u8], radix: uint) -> option { } /// Parse a string to an int -fn from_str(s: str) -> option { parse_buf(str::bytes(s), 10u) } +fn from_str(s: ~str) -> option { parse_buf(str::bytes(s), 10u) } /// Convert to a string in a given base -fn to_str(n: T, radix: uint) -> str { +fn to_str(n: T, radix: uint) -> ~str { do to_str_bytes(n, radix) |slice| { do vec::unpack_slice(slice) |p, len| { unsafe { str::unsafe::from_buf_len(p, len) } @@ -109,7 +109,7 @@ fn to_str_bytes(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { } /// Convert to a string -fn str(i: T) -> str { ret to_str(i, 10u); } +fn str(i: T) -> ~str { ret to_str(i, 10u); } impl ord of ord for T { fn lt(&&other: T) -> bool { @@ -159,20 +159,20 @@ fn times(it: fn() -> bool) { #[test] #[ignore] fn test_from_str() { - assert from_str("0") == some(0 as T); - assert from_str("3") == some(3 as T); - assert from_str("10") == some(10 as T); - assert from_str("123456789") == some(123456789 as T); - assert from_str("00100") == some(100 as T); + assert from_str(~"0") == some(0 as T); + assert from_str(~"3") == some(3 as T); + assert from_str(~"10") == some(10 as T); + assert from_str(~"123456789") == some(123456789 as T); + assert from_str(~"00100") == some(100 as T); - assert from_str("-1") == some(-1 as T); - assert from_str("-3") == some(-3 as T); - assert from_str("-10") == some(-10 as T); - assert from_str("-123456789") == some(-123456789 as T); - assert from_str("-00100") == some(-100 as T); + assert from_str(~"-1") == some(-1 as T); + assert from_str(~"-3") == some(-3 as T); + assert from_str(~"-10") == some(-10 as T); + assert from_str(~"-123456789") == some(-123456789 as T); + assert from_str(~"-00100") == some(-100 as T); - assert from_str(" ") == none; - assert from_str("x") == none; + assert from_str(~" ") == none; + assert from_str(~"x") == none; } // FIXME: Has alignment issues on windows and 32-bit linux (#2609) @@ -180,36 +180,36 @@ fn test_from_str() { #[ignore] fn test_parse_buf() { import str::bytes; - assert parse_buf(bytes("123"), 10u) == some(123 as T); - assert parse_buf(bytes("1001"), 2u) == some(9 as T); - assert parse_buf(bytes("123"), 8u) == some(83 as T); - assert parse_buf(bytes("123"), 16u) == some(291 as T); - assert parse_buf(bytes("ffff"), 16u) == some(65535 as T); - assert parse_buf(bytes("FFFF"), 16u) == some(65535 as T); - assert parse_buf(bytes("z"), 36u) == some(35 as T); - assert parse_buf(bytes("Z"), 36u) == some(35 as T); + assert parse_buf(bytes(~"123"), 10u) == some(123 as T); + assert parse_buf(bytes(~"1001"), 2u) == some(9 as T); + assert parse_buf(bytes(~"123"), 8u) == some(83 as T); + assert parse_buf(bytes(~"123"), 16u) == some(291 as T); + assert parse_buf(bytes(~"ffff"), 16u) == some(65535 as T); + assert parse_buf(bytes(~"FFFF"), 16u) == some(65535 as T); + assert parse_buf(bytes(~"z"), 36u) == some(35 as T); + assert parse_buf(bytes(~"Z"), 36u) == some(35 as T); - assert parse_buf(bytes("-123"), 10u) == some(-123 as T); - assert parse_buf(bytes("-1001"), 2u) == some(-9 as T); - assert parse_buf(bytes("-123"), 8u) == some(-83 as T); - assert parse_buf(bytes("-123"), 16u) == some(-291 as T); - assert parse_buf(bytes("-ffff"), 16u) == some(-65535 as T); - assert parse_buf(bytes("-FFFF"), 16u) == some(-65535 as T); - assert parse_buf(bytes("-z"), 36u) == some(-35 as T); - assert parse_buf(bytes("-Z"), 36u) == some(-35 as T); + assert parse_buf(bytes(~"-123"), 10u) == some(-123 as T); + assert parse_buf(bytes(~"-1001"), 2u) == some(-9 as T); + assert parse_buf(bytes(~"-123"), 8u) == some(-83 as T); + assert parse_buf(bytes(~"-123"), 16u) == some(-291 as T); + assert parse_buf(bytes(~"-ffff"), 16u) == some(-65535 as T); + assert parse_buf(bytes(~"-FFFF"), 16u) == some(-65535 as T); + assert parse_buf(bytes(~"-z"), 36u) == some(-35 as T); + assert parse_buf(bytes(~"-Z"), 36u) == some(-35 as T); - assert parse_buf(str::bytes("Z"), 35u) == none; - assert parse_buf(str::bytes("-9"), 2u) == none; + assert parse_buf(str::bytes(~"Z"), 35u) == none; + assert parse_buf(str::bytes(~"-9"), 2u) == none; } #[test] fn test_to_str() { import str::eq; - assert (eq(to_str(0 as T, 10u), "0")); - assert (eq(to_str(1 as T, 10u), "1")); - assert (eq(to_str(-1 as T, 10u), "-1")); - assert (eq(to_str(127 as T, 16u), "7f")); - assert (eq(to_str(100 as T, 10u), "100")); + assert (eq(to_str(0 as T, 10u), ~"0")); + assert (eq(to_str(1 as T, 10u), ~"1")); + assert (eq(to_str(-1 as T, 10u), ~"-1")); + assert (eq(to_str(127 as T, 16u), ~"7f")); + assert (eq(to_str(100 as T, 10u), ~"100")); } #[test] @@ -243,5 +243,5 @@ fn test_times() { #[should_fail] #[ignore(cfg(windows))] fn test_times_negative() { - for (-10).times { log(error, "nope!"); } + for (-10).times { log(error, ~"nope!"); } } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index f9666a1f22e3..cb4b94b8286f 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -109,7 +109,7 @@ fn read_char() -> char { ret c[0]; } - fn read_line() -> str { + fn read_line() -> ~str { let mut buf = ~[]; loop { let ch = self.read_byte(); @@ -119,7 +119,7 @@ fn read_line() -> str { str::from_bytes(buf) } - fn read_c_str() -> str { + fn read_c_str() -> ~str { let mut buf: ~[u8] = ~[]; loop { let ch = self.read_byte(); @@ -174,7 +174,7 @@ fn each_char(it: fn(char) -> bool) { } } - fn each_line(it: fn(str) -> bool) { + fn each_line(it: fn(~str) -> bool) { while !self.eof() { if !it(self.read_line()) { break; } } @@ -244,13 +244,13 @@ fn FILE_reader(f: *libc::FILE, cleanup: bool) -> reader { fn stdin() -> reader { rustrt::rust_get_stdin() as reader } -fn file_reader(path: str) -> result { +fn file_reader(path: ~str) -> result { let f = os::as_c_charp(path, |pathbuf| { - os::as_c_charp("r", |modebuf| + os::as_c_charp(~"r", |modebuf| libc::fopen(pathbuf, modebuf) ) }); - ret if f as uint == 0u { result::err("error opening " + path) } + ret if f as uint == 0u { result::err(~"error opening " + path) } else { result::ok(FILE_reader(f, true)) } @@ -303,11 +303,11 @@ fn with_bytes_reader_between(bytes: ~[u8], start: uint, end: uint, f(bytes_reader_between(bytes, start, end)) } -fn str_reader(s: str) -> reader { +fn str_reader(s: ~str) -> reader { bytes_reader(str::bytes(s)) } -fn with_str_reader(s: str, f: fn(reader) -> T) -> T { +fn with_str_reader(s: ~str, f: fn(reader) -> T) -> T { do str::as_bytes(s) |bytes| { with_bytes_reader_between(bytes, 0u, str::len(s), f) } @@ -402,8 +402,8 @@ fn fd_writer(fd: fd_t, cleanup: bool) -> writer { } -fn mk_file_writer(path: str, flags: ~[fileflag]) - -> result { +fn mk_file_writer(path: ~str, flags: ~[fileflag]) + -> result { #[cfg(windows)] fn wb() -> c_int { (O_WRONLY | O_BINARY) as c_int } @@ -514,10 +514,10 @@ fn write_char(ch: char) { self.write_str(str::from_char(ch)); } } - fn write_str(s: str/&) { str::byte_slice(s, |v| self.write(v)) } - fn write_line(s: str/&) { + fn write_str(s: &str) { str::byte_slice(s, |v| self.write(v)) } + fn write_line(s: &str) { self.write_str(s); - self.write_str("\n"/&); + self.write_str(&"\n"); } fn write_int(n: int) { int::to_str_bytes(n, 10u, |buf| self.write(buf)) @@ -577,19 +577,19 @@ fn write_le_i16(n: i16) { fn write_u8(n: u8) { self.write(&[n]) } } -fn file_writer(path: str, flags: ~[fileflag]) -> result { +fn file_writer(path: ~str, flags: ~[fileflag]) -> result { result::chain(mk_file_writer(path, flags), |w| result::ok(w)) } // FIXME: fileflags // #2004 -fn buffered_file_writer(path: str) -> result { +fn buffered_file_writer(path: ~str) -> result { let f = do os::as_c_charp(path) |pathbuf| { - do os::as_c_charp("w") |modebuf| { + do os::as_c_charp(~"w") |modebuf| { libc::fopen(pathbuf, modebuf) } }; - ret if f as uint == 0u { result::err("error opening " + path) } + ret if f as uint == 0u { result::err(~"error opening " + path) } else { result::ok(FILE_writer(f, true)) } } @@ -599,8 +599,8 @@ fn buffered_file_writer(path: str) -> result { fn stdout() -> writer { fd_writer(libc::STDOUT_FILENO as c_int, false) } fn stderr() -> writer { fd_writer(libc::STDERR_FILENO as c_int, false) } -fn print(s: str) { stdout().write_str(s); } -fn println(s: str) { stdout().write_line(s); } +fn print(s: ~str) { stdout().write_str(s); } +fn println(s: ~str) { stdout().write_line(s); } type mem_buffer = @{buf: dvec, mut pos: uint}; @@ -639,11 +639,11 @@ fn mem_buffer() -> mem_buffer { } fn mem_buffer_writer(b: mem_buffer) -> writer { b as writer } fn mem_buffer_buf(b: mem_buffer) -> ~[u8] { b.buf.get() } -fn mem_buffer_str(b: mem_buffer) -> str { +fn mem_buffer_str(b: mem_buffer) -> ~str { str::from_bytes(b.buf.get()) } -fn with_str_writer(f: fn(writer)) -> str { +fn with_str_writer(f: fn(writer)) -> ~str { let buf = mem_buffer(); let wr = mem_buffer_writer(buf); f(wr); @@ -671,7 +671,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) -> ret bpos as uint; } -fn read_whole_file_str(file: str) -> result { +fn read_whole_file_str(file: ~str) -> result<~str, ~str> { result::chain(read_whole_file(file), |bytes| { result::ok(str::from_bytes(bytes)) }) @@ -679,7 +679,7 @@ fn read_whole_file_str(file: str) -> result { // FIXME (#2004): implement this in a low-level way. Going through the // abstractions is pointless. -fn read_whole_file(file: str) -> result<~[u8], str> { +fn read_whole_file(file: ~str) -> result<~[u8], ~str> { result::chain(file_reader(file), |rdr| { result::ok(rdr.read_whole_stream()) }) @@ -765,9 +765,10 @@ mod tests { #[test] fn test_simple() { - let tmpfile: str = "tmp/lib-io-test-simple.tmp"; + let tmpfile: ~str = ~"tmp/lib-io-test-simple.tmp"; log(debug, tmpfile); - let frood: str = "A hoopy frood who really knows where his towel is."; + let frood: ~str = + ~"A hoopy frood who really knows where his towel is."; log(debug, frood); { let out: io::writer = @@ -776,28 +777,28 @@ fn test_simple() { out.write_str(frood); } let inp: io::reader = result::get(io::file_reader(tmpfile)); - let frood2: str = inp.read_c_str(); + let frood2: ~str = inp.read_c_str(); log(debug, frood2); assert (str::eq(frood, frood2)); } #[test] fn test_readchars_empty() { - let inp : io::reader = io::str_reader(""); + let inp : io::reader = io::str_reader(~""); let res : ~[char] = inp.read_chars(128u); assert(vec::len(res) == 0u); } #[test] fn test_readchars_wide() { - let wide_test = "生锈的汤匙切肉汤hello生锈的汤匙切肉汤"; + let wide_test = ~"生锈的汤匙切肉汤hello生锈的汤匙切肉汤"; let ivals : ~[int] = ~[ 29983, 38152, 30340, 27748, 21273, 20999, 32905, 27748, 104, 101, 108, 108, 111, 29983, 38152, 30340, 27748, 21273, 20999, 32905, 27748]; - fn check_read_ln(len : uint, s: str, ivals: ~[int]) { + fn check_read_ln(len : uint, s: ~str, ivals: ~[int]) { let inp : io::reader = io::str_reader(s); let res : ~[char] = inp.read_chars(len); if (len <= vec::len(ivals)) { @@ -817,23 +818,23 @@ fn check_read_ln(len : uint, s: str, ivals: ~[int]) { #[test] fn test_readchar() { - let inp : io::reader = io::str_reader("生"); + let inp : io::reader = io::str_reader(~"生"); let res : char = inp.read_char(); assert(res as int == 29983); } #[test] fn test_readchar_empty() { - let inp : io::reader = io::str_reader(""); + let inp : io::reader = io::str_reader(~""); let res : char = inp.read_char(); assert(res as int == -1); } #[test] fn file_reader_not_exist() { - alt io::file_reader("not a file") { + alt io::file_reader(~"not a file") { result::err(e) { - assert e == "error opening not a file"; + assert e == ~"error opening not a file"; } result::ok(_) { fail; } } @@ -841,9 +842,9 @@ fn file_reader_not_exist() { #[test] fn file_writer_bad_name() { - alt io::file_writer("?/?", ~[]) { + alt io::file_writer(~"?/?", ~[]) { result::err(e) { - assert str::starts_with(e, "error opening ?/?"); + assert str::starts_with(e, ~"error opening ?/?"); } result::ok(_) { fail; } } @@ -851,9 +852,9 @@ fn file_writer_bad_name() { #[test] fn buffered_file_writer_bad_name() { - alt io::buffered_file_writer("?/?") { + alt io::buffered_file_writer(~"?/?") { result::err(e) { - assert e == "error opening ?/?"; + assert e == ~"error opening ?/?"; } result::ok(_) { fail; } } diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index b1a822a5bad1..e00e51b49411 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -16,7 +16,7 @@ fn EACH(self: IMPL_T, f: fn(A) -> bool) { // Check dlist invariant. if !option::is_some(nobe.root) || !box::ptr_eq(*option::get(nobe.root), *self) { - fail "Iteration encountered a dlist node not on this dlist." + fail ~"Iteration encountered a dlist node not on this dlist." } if !f(nobe.data) { break; } // Check that the user didn't do a remove. @@ -24,7 +24,7 @@ fn EACH(self: IMPL_T, f: fn(A) -> bool) { // immediately put it back in a different position. I allow this. if !option::is_some(nobe.root) || !box::ptr_eq(*option::get(nobe.root), *self) { - fail "Removing a dlist node during iteration is forbidden!" + fail ~"Removing a dlist node during iteration is forbidden!" } link = nobe.next_link(); } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 31e47d19c8f6..e2a321cde23d 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -132,7 +132,7 @@ fn min>(self: IA) -> A { } } { some(val) { val } - none { fail "min called on empty iterator" } + none { fail ~"min called on empty iterator" } } } @@ -148,7 +148,7 @@ fn max>(self: IA) -> A { } } { some(val) { val } - none { fail "max called on empty iterator" } + none { fail ~"max called on empty iterator" } } } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index ac7dd013be9a..80b3915cb90d 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -23,10 +23,10 @@ enum option { * Fails if the value equals `none` */ - alt opt { some(x) { ret x; } none { fail "option none"; } } + alt opt { some(x) { ret x; } none { fail ~"option none"; } } } -pure fn expect(opt: option, reason: str) -> T { +pure fn expect(opt: option, reason: ~str) -> T { #[doc = " Gets the value out of an option, printing a specified message on failure @@ -93,7 +93,7 @@ enum option { unsafe { let addr = alt opt { some(x) { ptr::addr_of(x) } - none { fail "option none" } + none { fail ~"option none" } }; let liberated_value = unsafe::reinterpret_cast(*addr); unsafe::forget(opt); @@ -138,7 +138,7 @@ fn get_default(def: T) -> T { get_default(self, def) } * * Fails if the value equals `none` */ - pure fn expect(reason: str) -> T { expect(self, reason) } + pure fn expect(reason: ~str) -> T { expect(self, reason) } } #[test] @@ -153,7 +153,7 @@ fn test_unwrap_ptr() { #[test] fn test_unwrap_str() { - let x = "test"; + let x = ~"test"; let addr_x = str::as_buf(x, |buf| ptr::addr_of(buf)); let opt = some(x); let y = unwrap(opt); diff --git a/src/libcore/os.rs b/src/libcore/os.rs index c1b7574c9cc3..24988870c0d3 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -40,18 +40,18 @@ export as_c_charp, fill_charp_buf; extern mod rustrt { - fn rust_env_pairs() -> ~[str]; - fn rust_getcwd() -> str; + fn rust_env_pairs() -> ~[~str]; + fn rust_getcwd() -> ~str; fn rust_path_is_dir(path: *libc::c_char) -> c_int; fn rust_path_exists(path: *libc::c_char) -> c_int; - fn rust_list_files(path: str) -> ~[str]; + fn rust_list_files(path: ~str) -> ~[~str]; fn rust_process_wait(handle: c_int) -> c_int; - fn last_os_error() -> str; + fn last_os_error() -> ~str; fn rust_set_exit_status(code: libc::intptr_t); } -fn env() -> ~[(str,str)] { +fn env() -> ~[(~str,~str)] { let mut pairs = ~[]; for vec::each(rustrt::rust_env_pairs()) |p| { let vs = str::splitn_char(p, '=', 1u); @@ -63,12 +63,12 @@ fn env() -> ~[(str,str)] { const tmpbuf_sz : uint = 1000u; -fn as_c_charp(s: str, f: fn(*c_char) -> T) -> T { +fn as_c_charp(s: ~str, f: fn(*c_char) -> T) -> T { str::as_c_str(s, |b| f(b as *c_char)) } fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool) - -> option { + -> option<~str> { let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char)); do vec::as_mut_buf(buf) |b| { if f(b, tmpbuf_sz as size_t) unsafe { @@ -121,11 +121,11 @@ fn as_utf16_p(s: str, f: fn(*u16) -> T) -> T { } } -fn getenv(n: str) -> option { +fn getenv(n: ~str) -> option<~str> { global_env::getenv(n) } -fn setenv(n: str, v: str) { +fn setenv(n: ~str, v: ~str) { global_env::setenv(n, v) } @@ -140,18 +140,18 @@ mod global_env { } enum msg { - msg_getenv(str, comm::chan>), - msg_setenv(str, str, comm::chan<()>) + msg_getenv(~str, comm::chan>), + msg_setenv(~str, ~str, comm::chan<()>) } - fn getenv(n: str) -> option { + fn getenv(n: ~str) -> option<~str> { let env_ch = get_global_env_chan(); let po = comm::port(); comm::send(env_ch, msg_getenv(n, comm::chan(po))); comm::recv(po) } - fn setenv(n: str, v: str) { + fn setenv(n: ~str, v: ~str) { let env_ch = get_global_env_chan(); let po = comm::port(); comm::send(env_ch, msg_setenv(n, v, comm::chan(po))); @@ -199,14 +199,14 @@ fn global_env_task(msg_po: comm::port) { mod impl { #[cfg(unix)] - fn getenv(n: str) -> option { + fn getenv(n: ~str) -> option<~str> { unsafe { let s = str::as_c_str(n, libc::getenv); ret if unsafe::reinterpret_cast(s) == 0 { - option::none:: + option::none::<~str> } else { let s = unsafe::reinterpret_cast(s); - option::some::(str::unsafe::from_buf(s)) + option::some::<~str>(str::unsafe::from_buf(s)) }; } } @@ -225,7 +225,7 @@ fn getenv(n: str) -> option { #[cfg(unix)] - fn setenv(n: str, v: str) { + fn setenv(n: ~str, v: ~str) { // FIXME: remove this when export globs work properly. #1238 import libc::funcs::posix01::unistd::setenv; @@ -253,7 +253,7 @@ fn setenv(n: str, v: str) { } fn fdopen(fd: c_int) -> *FILE { - ret do as_c_charp("r") |modebuf| { + ret do as_c_charp(~"r") |modebuf| { libc::fdopen(fd, modebuf) }; } @@ -348,11 +348,11 @@ fn pipe() -> {in: c_int, out: c_int} { } -fn dll_filename(base: str) -> str { +fn dll_filename(base: ~str) -> ~str { ret pre() + base + dll_suffix(); #[cfg(unix)] - fn pre() -> str { "lib" } + fn pre() -> ~str { ~"lib" } #[cfg(windows)] fn pre() -> str { "" } @@ -381,7 +381,7 @@ fn load_self() -> option { fn load_self() -> option { import libc::funcs::posix01::unistd::readlink; do fill_charp_buf() |buf, sz| { - do as_c_charp("/proc/self/exe") |proc_self_buf| { + do as_c_charp(~"/proc/self/exe") |proc_self_buf| { readlink(proc_self_buf, buf, sz) != (-1 as ssize_t) } } @@ -428,7 +428,7 @@ fn load_self() -> option { * Otherwise, homedir returns option::none. */ fn homedir() -> option { - ret alt getenv("HOME") { + ret alt getenv(~"HOME") { some(p) { if !str::is_empty(p) { some(p) @@ -548,10 +548,10 @@ fn mkdir(p: path, mode: c_int) -> bool { } /// Lists the contents of a directory -fn list_dir(p: path) -> ~[str] { +fn list_dir(p: path) -> ~[~str] { #[cfg(unix)] - fn star(p: str) -> str { p } + fn star(p: ~str) -> ~str { p } #[cfg(windows)] fn star(p: str) -> str { @@ -565,7 +565,7 @@ fn star(p: str) -> str { } do rustrt::rust_list_files(star(p)).filter |filename| { - !str::eq(filename, ".") && !str::eq(filename, "..") + !str::eq(filename, ~".") && !str::eq(filename, ~"..") } } @@ -574,7 +574,7 @@ fn star(p: str) -> str { * * This version prepends each entry with the directory. */ -fn list_dir_path(p: path) -> ~[str] { +fn list_dir_path(p: path) -> ~[~str] { let mut p = p; let pl = str::len(p); if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep @@ -649,7 +649,7 @@ fn do_copy_file(from: path, to: path) -> bool { #[cfg(unix)] fn do_copy_file(from: path, to: path) -> bool { let istream = do as_c_charp(from) |fromp| { - do as_c_charp("rb") |modebuf| { + do as_c_charp(~"rb") |modebuf| { libc::fopen(fromp, modebuf) } }; @@ -657,7 +657,7 @@ fn do_copy_file(from: path, to: path) -> bool { ret false; } let ostream = do as_c_charp(to) |top| { - do as_c_charp("w+b") |modebuf| { + do as_c_charp(~"w+b") |modebuf| { libc::fopen(top, modebuf) } }; @@ -717,7 +717,7 @@ fn unlink(p: path) -> bool { } /// Get a string representing the platform-dependent last error -fn last_os_error() -> str { +fn last_os_error() -> ~str { rustrt::last_os_error() } @@ -734,7 +734,7 @@ fn set_exit_status(code: int) { } #[cfg(unix)] -fn family() -> str { "unix" } +fn family() -> ~str { ~"unix" } #[cfg(windows)] fn family() -> str { "windows" } @@ -755,9 +755,9 @@ fn dll_suffix() -> str { ".so" } #[cfg(target_os = "linux")] mod consts { - fn sysname() -> str { "linux" } - fn exe_suffix() -> str { "" } - fn dll_suffix() -> str { ".so" } + fn sysname() -> ~str { ~"linux" } + fn exe_suffix() -> ~str { ~"" } + fn dll_suffix() -> ~str { ~".so" } } #[cfg(target_os = "win32")] @@ -771,7 +771,7 @@ fn dll_suffix() -> str { ".dll" } fn arch() -> str { "x86" } #[cfg(target_arch = "x86_64")] -fn arch() -> str { "x86_64" } +fn arch() -> ~str { ~"x86_64" } #[cfg(target_arch = "arm")] fn arch() -> str { "arm" } @@ -784,10 +784,10 @@ fn last_os_error() { log(debug, last_os_error()); } - fn make_rand_name() -> str { + fn make_rand_name() -> ~str { import rand; let rng: rand::rng = rand::rng(); - let n = "TEST" + rng.gen_str(10u); + let n = ~"TEST" + rng.gen_str(10u); assert option::is_none(getenv(n)); n } @@ -795,8 +795,8 @@ fn make_rand_name() -> str { #[test] fn test_setenv() { let n = make_rand_name(); - setenv(n, "VALUE"); - assert getenv(n) == option::some("VALUE"); + setenv(n, ~"VALUE"); + assert getenv(n) == option::some(~"VALUE"); } #[test] @@ -804,11 +804,11 @@ fn test_setenv() { #[ignore] fn test_setenv_overwrite() { let n = make_rand_name(); - setenv(n, "1"); - setenv(n, "2"); - assert getenv(n) == option::some("2"); - setenv(n, ""); - assert getenv(n) == option::some(""); + setenv(n, ~"1"); + setenv(n, ~"2"); + assert getenv(n) == option::some(~"2"); + setenv(n, ~""); + assert getenv(n) == option::some(~""); } // Windows GetEnvironmentVariable requires some extra work to make sure @@ -817,9 +817,9 @@ fn test_setenv_overwrite() { #[ignore(cfg(windows))] #[ignore] fn test_getenv_big() { - let mut s = ""; + let mut s = ~""; let mut i = 0; - while i < 100 { s += "aaaaaaaaaa"; i += 1; } + while i < 100 { s += ~"aaaaaaaaaa"; i += 1; } let n = make_rand_name(); setenv(n, s); log(debug, s); @@ -834,7 +834,7 @@ fn test_self_exe_path() { log(debug, path); // Hard to test this function - if os::sysname() != "win32" { + if os::sysname() != ~"win32" { assert str::starts_with(path, path::path_sep()); } else { assert path[1] == ':' as u8; @@ -862,35 +862,35 @@ fn test_env_setenv() { let n = make_rand_name(); let mut e = env(); - setenv(n, "VALUE"); - assert !vec::contains(e, (n, "VALUE")); + setenv(n, ~"VALUE"); + assert !vec::contains(e, (n, ~"VALUE")); e = env(); - assert vec::contains(e, (n, "VALUE")); + assert vec::contains(e, (n, ~"VALUE")); } #[test] fn test() { - assert (!path::path_is_absolute("test-path")); + assert (!path::path_is_absolute(~"test-path")); - log(debug, "Current working directory: " + getcwd()); + log(debug, ~"Current working directory: " + getcwd()); - log(debug, make_absolute("test-path")); - log(debug, make_absolute("/usr/bin")); + log(debug, make_absolute(~"test-path")); + log(debug, make_absolute(~"/usr/bin")); } #[test] #[cfg(unix)] fn homedir() { - let oldhome = getenv("HOME"); + let oldhome = getenv(~"HOME"); - setenv("HOME", "/home/MountainView"); - assert os::homedir() == some("/home/MountainView"); + setenv(~"HOME", ~"/home/MountainView"); + assert os::homedir() == some(~"/home/MountainView"); - setenv("HOME", ""); + setenv(~"HOME", ~""); assert os::homedir() == none; - option::iter(oldhome, |s| setenv("HOME", s)); + option::iter(oldhome, |s| setenv(~"HOME", s)); } #[test] @@ -927,11 +927,11 @@ fn homedir() { // Issue #712 #[test] - fn test_list_dir_no_invalid_memory_access() { os::list_dir("."); } + fn test_list_dir_no_invalid_memory_access() { os::list_dir(~"."); } #[test] fn list_dir() { - let dirs = os::list_dir("."); + let dirs = os::list_dir(~"."); // Just assuming that we've got some contents in the current directory assert (vec::len(dirs) > 0u); @@ -940,21 +940,21 @@ fn list_dir() { #[test] fn path_is_dir() { - assert (os::path_is_dir(".")); - assert (!os::path_is_dir("test/stdtest/fs.rs")); + assert (os::path_is_dir(~".")); + assert (!os::path_is_dir(~"test/stdtest/fs.rs")); } #[test] fn path_exists() { - assert (os::path_exists(".")); - assert (!os::path_exists("test/nonexistent-bogus-path")); + assert (os::path_exists(~".")); + assert (!os::path_exists(~"test/nonexistent-bogus-path")); } #[test] fn copy_file_does_not_exist() { - assert !os::copy_file("test/nonexistent-bogus-path", - "test/other-bogus-path"); - assert !os::path_exists("test/other-bogus-path"); + assert !os::copy_file(~"test/nonexistent-bogus-path", + ~"test/other-bogus-path"); + assert !os::path_exists(~"test/other-bogus-path"); } #[test] @@ -962,17 +962,17 @@ fn copy_file_ok() { let tempdir = getcwd(); // would like to use $TMPDIR, // doesn't seem to work on Linux assert (str::len(tempdir) > 0u); - let in = tempdir + path::path_sep() + "in.txt"; - let out = tempdir + path::path_sep() + "out.txt"; + let in = tempdir + path::path_sep() + ~"in.txt"; + let out = tempdir + path::path_sep() + ~"out.txt"; /* Write the temp input file */ let ostream = do as_c_charp(in) |fromp| { - do as_c_charp("w+b") |modebuf| { + do as_c_charp(~"w+b") |modebuf| { libc::fopen(fromp, modebuf) } }; assert (ostream as uint != 0u); - let s = "hello"; + let s = ~"hello"; let mut buf = vec::to_mut(str::bytes(s) + ~[0 as u8]); do vec::as_mut_buf(buf) |b| { assert (libc::fwrite(b as *c_void, 1u as size_t, @@ -984,7 +984,7 @@ fn copy_file_ok() { fail (#fmt("%s doesn't exist", in)); } assert(rs); - let rslt = run::run_program("diff", ~[in, out]); + let rslt = run::run_program(~"diff", ~[in, out]); assert (rslt == 0); assert (remove_file(in)); assert (remove_file(out)); diff --git a/src/libcore/path.rs b/src/libcore/path.rs index 67f420025572..35fc7510757e 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -14,7 +14,7 @@ // FIXME: This type should probably be constrained (#2624) /// A path or fragment of a filesystem path -type path = str; +type path = ~str; #[cfg(unix)] mod consts { @@ -58,9 +58,9 @@ fn path_is_absolute(p: str) -> bool { } /// Get the default path separator for the host platform -fn path_sep() -> str { ret str::from_char(consts::path_sep); } +fn path_sep() -> ~str { ret str::from_char(consts::path_sep); } -fn split_dirname_basename (pp: path) -> {dirname: str, basename: str} { +fn split_dirname_basename (pp: path) -> {dirname: ~str, basename: ~str} { alt str::rfind(pp, |ch| ch == consts::path_sep || ch == consts::alt_path_sep ) { @@ -68,7 +68,7 @@ fn split_dirname_basename (pp: path) -> {dirname: str, basename: str} { {dirname: str::slice(pp, 0u, i), basename: str::slice(pp, i + 1u, str::len(pp))} } - none { {dirname: ".", basename: pp} } + none { {dirname: ~".", basename: pp} } } } @@ -159,16 +159,16 @@ fn split(p: path) -> ~[path] { * ignored. If the path includes directory components then they are included * in the filename part of the result pair. */ -fn splitext(p: path) -> (str, str) { - if str::is_empty(p) { ("", "") } +fn splitext(p: path) -> (~str, ~str) { + if str::is_empty(p) { (~"", ~"") } else { let parts = str::split_char(p, '.'); if vec::len(parts) > 1u { - let base = str::connect(vec::init(parts), "."); + let base = str::connect(vec::init(parts), ~"."); // We just checked that parts is non-empty, so this is safe - let ext = "." + vec::last(parts); + let ext = ~"." + vec::last(parts); - fn is_dotfile(base: str) -> bool { + fn is_dotfile(base: ~str) -> bool { str::is_empty(base) || str::ends_with( base, str::from_char(consts::path_sep)) @@ -176,11 +176,11 @@ fn is_dotfile(base: str) -> bool { base, str::from_char(consts::alt_path_sep)) } - fn ext_contains_sep(ext: str) -> bool { + fn ext_contains_sep(ext: ~str) -> bool { vec::len(split(ext)) > 1u } - fn no_basename(ext: str) -> bool { + fn no_basename(ext: ~str) -> bool { str::ends_with( ext, str::from_char(consts::path_sep)) || str::ends_with( @@ -190,12 +190,12 @@ fn no_basename(ext: str) -> bool { if is_dotfile(base) || ext_contains_sep(ext) || no_basename(ext) { - (p, "") + (p, ~"") } else { (base, ext) } } else { - (p, "") + (p, ~"") } } } @@ -220,13 +220,13 @@ fn normalize(p: path) -> path { let s = if check vec::is_not_empty(s) { connect_many(s) } else { - "" + ~"" }; let s = reabsolute(p, s); let s = reterminate(p, s); let s = if str::len(s) == 0u { - "." + ~"." } else { s }; @@ -235,7 +235,7 @@ fn normalize(p: path) -> path { fn strip_dots(s: ~[path]) -> ~[path] { vec::filter_map(s, |elem| - if elem == "." { + if elem == ~"." { option::none } else { option::some(elem) @@ -252,7 +252,7 @@ fn rollup_doubledots(s: ~[path]) -> ~[path] { let mut skip = 0; while i != 0u { i -= 1u; - if s[i] == ".." { + if s[i] == ~".." { skip += 1; } else { if skip == 0 { @@ -264,7 +264,7 @@ fn rollup_doubledots(s: ~[path]) -> ~[path] { } let mut t = vec::reversed(t); while skip > 0 { - vec::push(t, ".."); + vec::push(t, ~".."); skip -= 1; } ret t; @@ -304,122 +304,122 @@ mod tests { #[test] fn test_connect() { let slash = path_sep(); - log(error, connect("a", "b")); - assert (connect("a", "b") == "a" + slash + "b"); - assert (connect("a" + slash, "b") == "a" + slash + "b"); + log(error, connect(~"a", ~"b")); + assert (connect(~"a", ~"b") == ~"a" + slash + ~"b"); + assert (connect(~"a" + slash, ~"b") == ~"a" + slash + ~"b"); } - fn ps() -> str { + fn ps() -> ~str { path_sep() } - fn aps() -> str { - "/" + fn aps() -> ~str { + ~"/" } #[test] fn split1() { - let actual = split("a" + ps() + "b"); - let expected = ~["a", "b"]; + let actual = split(~"a" + ps() + ~"b"); + let expected = ~[~"a", ~"b"]; assert actual == expected; } #[test] fn split2() { - let actual = split("a" + aps() + "b"); - let expected = ~["a", "b"]; + let actual = split(~"a" + aps() + ~"b"); + let expected = ~[~"a", ~"b"]; assert actual == expected; } #[test] fn split3() { - let actual = split(ps() + "a" + ps() + "b"); - let expected = ~["a", "b"]; + let actual = split(ps() + ~"a" + ps() + ~"b"); + let expected = ~[~"a", ~"b"]; assert actual == expected; } #[test] fn split4() { - let actual = split("a" + ps() + "b" + aps() + "c"); - let expected = ~["a", "b", "c"]; + let actual = split(~"a" + ps() + ~"b" + aps() + ~"c"); + let expected = ~[~"a", ~"b", ~"c"]; assert actual == expected; } #[test] fn normalize1() { - let actual = normalize("a/b/.."); - let expected = "a"; + let actual = normalize(~"a/b/.."); + let expected = ~"a"; assert actual == expected; } #[test] fn normalize2() { - let actual = normalize("/a/b/.."); - let expected = "/a"; + let actual = normalize(~"/a/b/.."); + let expected = ~"/a"; assert actual == expected; } #[test] fn normalize3() { - let actual = normalize("a/../b"); - let expected = "b"; + let actual = normalize(~"a/../b"); + let expected = ~"b"; assert actual == expected; } #[test] fn normalize4() { - let actual = normalize("/a/../b"); - let expected = "/b"; + let actual = normalize(~"/a/../b"); + let expected = ~"/b"; assert actual == expected; } #[test] fn normalize5() { - let actual = normalize("a/."); - let expected = "a"; + let actual = normalize(~"a/."); + let expected = ~"a"; assert actual == expected; } #[test] fn normalize6() { - let actual = normalize("a/./b/"); - let expected = "a/b/"; + let actual = normalize(~"a/./b/"); + let expected = ~"a/b/"; assert actual == expected; } #[test] fn normalize7() { - let actual = normalize("a/.."); - let expected = "."; + let actual = normalize(~"a/.."); + let expected = ~"."; assert actual == expected; } #[test] fn normalize8() { - let actual = normalize("../../.."); - let expected = "../../.."; + let actual = normalize(~"../../.."); + let expected = ~"../../.."; assert actual == expected; } #[test] fn normalize9() { - let actual = normalize("a/b/../../.."); - let expected = ".."; + let actual = normalize(~"a/b/../../.."); + let expected = ~".."; assert actual == expected; } #[test] fn normalize10() { - let actual = normalize("/a/b/c/../d/./../../e/"); - let expected = "/a/e/"; + let actual = normalize(~"/a/b/c/../d/./../../e/"); + let expected = ~"/a/e/"; log(error, actual); assert actual == expected; } #[test] fn normalize11() { - let actual = normalize("/a/.."); - let expected = "/"; + let actual = normalize(~"/a/.."); + let expected = ~"/"; assert actual == expected; } @@ -440,58 +440,58 @@ fn path_is_absolute_win32() { #[test] fn splitext_empty() { - let (base, ext) = splitext(""); - assert base == ""; - assert ext == ""; + let (base, ext) = splitext(~""); + assert base == ~""; + assert ext == ~""; } #[test] fn splitext_ext() { - let (base, ext) = splitext("grum.exe"); - assert base == "grum"; - assert ext == ".exe"; + let (base, ext) = splitext(~"grum.exe"); + assert base == ~"grum"; + assert ext == ~".exe"; } #[test] fn splitext_noext() { - let (base, ext) = splitext("grum"); - assert base == "grum"; - assert ext == ""; + let (base, ext) = splitext(~"grum"); + assert base == ~"grum"; + assert ext == ~""; } #[test] fn splitext_dotfile() { - let (base, ext) = splitext(".grum"); - assert base == ".grum"; - assert ext == ""; + let (base, ext) = splitext(~".grum"); + assert base == ~".grum"; + assert ext == ~""; } #[test] fn splitext_path_ext() { - let (base, ext) = splitext("oh/grum.exe"); - assert base == "oh/grum"; - assert ext == ".exe"; + let (base, ext) = splitext(~"oh/grum.exe"); + assert base == ~"oh/grum"; + assert ext == ~".exe"; } #[test] fn splitext_path_noext() { - let (base, ext) = splitext("oh/grum"); - assert base == "oh/grum"; - assert ext == ""; + let (base, ext) = splitext(~"oh/grum"); + assert base == ~"oh/grum"; + assert ext == ~""; } #[test] fn splitext_dot_in_path() { - let (base, ext) = splitext("oh.my/grum"); - assert base == "oh.my/grum"; - assert ext == ""; + let (base, ext) = splitext(~"oh.my/grum"); + assert base == ~"oh.my/grum"; + assert ext == ~""; } #[test] fn splitext_nobasename() { - let (base, ext) = splitext("oh.my/"); - assert base == "oh.my/"; - assert ext == ""; + let (base, ext) = splitext(~"oh.my/"); + assert base == ~"oh.my/"; + assert ext == ~""; } } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 7362614a769c..d16f0f3a3307 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -84,7 +84,7 @@ fn wait_event(this: *rust_task) -> *libc::c_void { let res = rustrt::task_wait_event(this, &mut killed); if killed && !task::failing() { - fail "killed" + fail ~"killed" } res } @@ -118,7 +118,7 @@ fn send(-p: send_packet, -payload: T) { // The receiver will eventually clean this up. unsafe { forget(p); } } - full { fail "duplicate send" } + full { fail ~"duplicate send" } blocked { #debug("waking up task for %?", p_); alt p.header.blocked_task { @@ -126,7 +126,7 @@ fn send(-p: send_packet, -payload: T) { rustrt::task_signal_event( task, ptr::addr_of(p.header) as *libc::c_void); } - none { fail "blocked packet has no task" } + none { fail ~"blocked packet has no task" } } // The receiver will eventually clean this up. @@ -162,7 +162,7 @@ fn try_recv(-p: recv_packet) -> option { } blocked { if first { - fail "blocking on already blocked packet" + fail ~"blocking on already blocked packet" } } full { @@ -184,7 +184,7 @@ fn try_recv(-p: recv_packet) -> option { pure fn peek(p: recv_packet) -> bool { alt unsafe {(*p.header()).state} { empty { false } - blocked { fail "peeking on blocked packet" } + blocked { fail ~"peeking on blocked packet" } full | terminated { true } } } @@ -207,7 +207,7 @@ fn sender_terminate(p: *packet) { } full { // This is impossible - fail "you dun goofed" + fail ~"you dun goofed" } terminated { // I have to clean up, use drop_glue @@ -224,7 +224,7 @@ fn receiver_terminate(p: *packet) { } blocked { // this shouldn't happen. - fail "terminating a blocked packet" + fail ~"terminating a blocked packet" } terminated | full { // I have to clean up, use drop_glue @@ -267,7 +267,7 @@ fn wait_many(pkts: &[*packet_header]) -> uint { (*p).state = old; break; } - blocked { fail "blocking on blocked packet" } + blocked { fail ~"blocking on blocked packet" } empty { } } } @@ -313,7 +313,7 @@ fn select2( alt i { 0 { left((try_recv(a), b)) } 1 { right((a, try_recv(b))) } - _ { fail "select2 return an invalid packet" } + _ { fail ~"select2 return an invalid packet" } } } } @@ -397,7 +397,7 @@ fn unwrap() -> *packet { header } } - none { fail "packet already consumed" } + none { fail ~"packet already consumed" } } } } @@ -508,7 +508,7 @@ fn try_recv() -> option { some(endp) { pipes::peek(endp) } - none { fail "peeking empty stream" } + none { fail ~"peeking empty stream" } }; self.endp <-> endp; peek @@ -558,7 +558,7 @@ impl private_methods/& for pipes::port { some(endp) { endp.header() } - none { fail "peeking empty stream" } + none { fail ~"peeking empty stream" } } } } diff --git a/src/libcore/priv.rs b/src/libcore/priv.rs index adda674de322..4d6ac7bac35d 100644 --- a/src/libcore/priv.rs +++ b/src/libcore/priv.rs @@ -32,11 +32,11 @@ enum msg { abort } - log(debug,"ENTERING chan_from_global_ptr, before is_prob_zero check"); + log(debug,~"ENTERING chan_from_global_ptr, before is_prob_zero check"); let is_probably_zero = *global == 0u; - log(debug,"after is_prob_zero check"); + log(debug,~"after is_prob_zero check"); if is_probably_zero { - log(debug,"is probably zero..."); + log(debug,~"is probably zero..."); // There's no global channel. We must make it let setup_po = comm::port(); @@ -54,14 +54,14 @@ enum msg { } }; - log(debug,"before setup recv.."); + log(debug,~"before setup recv.."); // This is the proposed global channel let ch = comm::recv(setup_po); // 0 is our sentinal value. It is not a valid channel assert unsafe::reinterpret_cast(ch) != 0u; // Install the channel - log(debug,"BEFORE COMPARE AND SWAP"); + log(debug,~"BEFORE COMPARE AND SWAP"); let swapped = compare_and_swap( global, 0u, unsafe::reinterpret_cast(ch)); log(debug,#fmt("AFTER .. swapped? %?", swapped)); @@ -76,7 +76,7 @@ enum msg { unsafe::reinterpret_cast(*global) } } else { - log(debug, "global != 0"); + log(debug, ~"global != 0"); unsafe::reinterpret_cast(*global) } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 97795103f52d..178a68a1c654 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -174,7 +174,7 @@ fn test_position() { import str::as_c_str; import libc::c_char; - let s = "hello"; + let s = ~"hello"; unsafe { assert 2u == as_c_str(s, |p| position(p, |c| c == 'l' as c_char)); assert 4u == as_c_str(s, |p| position(p, |c| c == 'o' as c_char)); @@ -184,9 +184,9 @@ fn test_position() { #[test] fn test_buf_len() { - let s0 = "hello"; - let s1 = "there"; - let s2 = "thing"; + let s0 = ~"hello"; + let s1 = ~"there"; + let s2 = ~"thing"; do str::as_c_str(s0) |p0| { do str::as_c_str(s1) |p1| { do str::as_c_str(s2) |p2| { diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index ce4a29f376ae..8d392e1be90f 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -121,7 +121,7 @@ fn gen_char() -> char { /** * Return a char randomly chosen from chars, failing if chars is empty */ - fn gen_char_from(chars: str) -> char { + fn gen_char_from(chars: ~str) -> char { assert !chars.is_empty(); self.choose(str::chars(chars)) } @@ -143,11 +143,11 @@ fn gen_weighted_bool(n: uint) -> bool { /** * Return a random string of the specified length composed of A-Z,a-z,0-9 */ - fn gen_str(len: uint) -> str { - let charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\ + fn gen_str(len: uint) -> ~str { + let charset = ~"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789"; - let mut s = ""; + let mut s = ~""; let mut i = 0u; while (i < len) { s = s + str::from_char(self.gen_char_from(charset)); diff --git a/src/libcore/result.rs b/src/libcore/result.rs index f7f6f9ca03bc..c0c68459fb63 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -37,7 +37,7 @@ enum result { alt res { err(u) { u } ok(_) { - fail "get_error called on ok result"; + fail ~"get_error called on ok result"; } } } @@ -333,7 +333,7 @@ fn unwrap(-res: result) -> T { unsafe { let addr = alt res { ok(x) { ptr::addr_of(x) } - err(_) { fail "error result" } + err(_) { fail ~"error result" } }; let liberated_value = unsafe::reinterpret_cast(*addr); unsafe::forget(res); @@ -343,13 +343,13 @@ fn unwrap(-res: result) -> T { #[cfg(test)] mod tests { - fn op1() -> result::result { result::ok(666) } + fn op1() -> result::result { result::ok(666) } - fn op2(&&i: int) -> result::result { + fn op2(&&i: int) -> result::result { result::ok(i as uint + 1u) } - fn op3() -> result::result { result::err("sadface") } + fn op3() -> result::result { result::err(~"sadface") } #[test] fn chain_success() { @@ -358,39 +358,39 @@ fn chain_success() { #[test] fn chain_failure() { - assert get_err(chain(op3(), op2)) == "sadface"; + assert get_err(chain(op3(), op2)) == ~"sadface"; } #[test] fn test_impl_iter() { let mut valid = false; - ok::("a").iter(|_x| valid = true); + ok::<~str, ~str>(~"a").iter(|_x| valid = true); assert valid; - err::("b").iter(|_x| valid = false); + err::<~str, ~str>(~"b").iter(|_x| valid = false); assert valid; } #[test] fn test_impl_iter_err() { let mut valid = true; - ok::("a").iter_err(|_x| valid = false); + ok::<~str, ~str>(~"a").iter_err(|_x| valid = false); assert valid; valid = false; - err::("b").iter_err(|_x| valid = true); + err::<~str, ~str>(~"b").iter_err(|_x| valid = true); assert valid; } #[test] fn test_impl_map() { - assert ok::("a").map(|_x| "b") == ok("b"); - assert err::("a").map(|_x| "b") == err("a"); + assert ok::<~str, ~str>(~"a").map(|_x| ~"b") == ok(~"b"); + assert err::<~str, ~str>(~"a").map(|_x| ~"b") == err(~"a"); } #[test] fn test_impl_map_err() { - assert ok::("a").map_err(|_x| "b") == ok("a"); - assert err::("a").map_err(|_x| "b") == err("b"); + assert ok::<~str, ~str>(~"a").map_err(|_x| ~"b") == ok(~"a"); + assert err::<~str, ~str>(~"a").map_err(|_x| ~"b") == err(~"b"); } } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 55a58430fc04..c8e55bea2a5a 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -62,9 +62,9 @@ fn rust_run_program(argv: **libc::c_char, envp: *c_void, * * The process id of the spawned process */ -fn spawn_process(prog: str, args: ~[str], - env: option<~[(str,str)]>, - dir: option, +fn spawn_process(prog: ~str, args: ~[~str], + env: option<~[(~str,~str)]>, + dir: option<~str>, in_fd: c_int, out_fd: c_int, err_fd: c_int) -> pid_t { do with_argv(prog, args) |argv| { @@ -77,7 +77,7 @@ fn spawn_process(prog: str, args: ~[str], } } -fn with_argv(prog: str, args: ~[str], +fn with_argv(prog: ~str, args: ~[~str], cb: fn(**libc::c_char) -> T) -> T { let mut argptrs = str::as_c_str(prog, |b| ~[b]); let mut tmps = ~[]; @@ -91,7 +91,7 @@ fn with_argv(prog: str, args: ~[str], } #[cfg(unix)] -fn with_envp(env: option<~[(str,str)]>, +fn with_envp(env: option<~[(~str,~str)]>, cb: fn(*c_void) -> T) -> T { // On posixy systems we can pass a char** for envp, which is // a null-terminated array of "k=v\n" strings. @@ -144,7 +144,7 @@ fn with_envp(env: option<~[(str,str)]>, } } -fn with_dirp(d: option, +fn with_dirp(d: option<~str>, cb: fn(*libc::c_char) -> T) -> T { alt d { some(dir) { str::as_c_str(dir, cb) } @@ -164,7 +164,7 @@ fn with_dirp(d: option, * * The process id */ -fn run_program(prog: str, args: ~[str]) -> int { +fn run_program(prog: ~str, args: ~[~str]) -> int { let pid = spawn_process(prog, args, none, none, 0i32, 0i32, 0i32); if pid == -1 as pid_t { fail; } @@ -187,7 +187,7 @@ fn run_program(prog: str, args: ~[str]) -> int { * * A class with a field */ -fn start_program(prog: str, args: ~[str]) -> program { +fn start_program(prog: ~str, args: ~[~str]) -> program { let pipe_input = os::pipe(); let pipe_output = os::pipe(); let pipe_err = os::pipe(); @@ -248,8 +248,8 @@ fn finish() -> int { finish_repr(self.r) } ret prog_res(repr) as program; } -fn read_all(rd: io::reader) -> str { - let mut buf = ""; +fn read_all(rd: io::reader) -> ~str { + let mut buf = ~""; while !rd.eof() { let bytes = rd.read_bytes(4096u); buf += str::from_bytes(bytes); @@ -271,8 +271,8 @@ fn read_all(rd: io::reader) -> str { * A record, {status: int, out: str, err: str} containing the exit code, * the contents of stdout and the contents of stderr. */ -fn program_output(prog: str, args: ~[str]) -> - {status: int, out: str, err: str} { +fn program_output(prog: ~str, args: ~[~str]) -> + {status: int, out: ~str, err: ~str} { let pipe_in = os::pipe(); let pipe_out = os::pipe(); @@ -307,8 +307,8 @@ fn program_output(prog: str, args: ~[str]) -> comm::send(ch, (1, output)); }; let status = run::waitpid(pid); - let mut errs = ""; - let mut outs = ""; + let mut errs = ~""; + let mut outs = ~""; let mut count = 2; while count > 0 { let stream = comm::recv(p); @@ -325,7 +325,7 @@ fn program_output(prog: str, args: ~[str]) -> ret {status: status, out: outs, err: errs}; } -fn writeclose(fd: c_int, s: str) { +fn writeclose(fd: c_int, s: ~str) { import io::writer_util; #error("writeclose %d, %s", fd as int, s); @@ -335,10 +335,10 @@ fn writeclose(fd: c_int, s: str) { os::close(fd); } -fn readclose(fd: c_int) -> str { +fn readclose(fd: c_int) -> ~str { let file = os::fdopen(fd); let reader = io::FILE_reader(file, false); - let mut buf = ""; + let mut buf = ~""; while !reader.eof() { let bytes = reader.read_bytes(4096u); buf += str::from_bytes(bytes); @@ -397,9 +397,9 @@ mod tests { // Regression test for memory leaks #[ignore(cfg(windows))] // FIXME (#2626) fn test_leaks() { - run::run_program("echo", ~[]); - run::start_program("echo", ~[]); - run::program_output("echo", ~[]); + run::run_program(~"echo", ~[]); + run::start_program(~"echo", ~[]); + run::program_output(~"echo", ~[]); } #[test] @@ -410,14 +410,14 @@ fn test_pipes() { let pid = run::spawn_process( - "cat", ~[], none, none, + ~"cat", ~[], none, none, pipe_in.in, pipe_out.out, pipe_err.out); os::close(pipe_in.in); os::close(pipe_out.out); os::close(pipe_err.out); if pid == -1i32 { fail; } - let expected = "test"; + let expected = ~"test"; writeclose(pipe_in.out, expected); let actual = readclose(pipe_out.in); readclose(pipe_err.in); @@ -430,7 +430,7 @@ fn test_pipes() { #[test] fn waitpid() { - let pid = run::spawn_process("false", ~[], + let pid = run::spawn_process(~"false", ~[], none, none, 0i32, 0i32, 0i32); let status = run::waitpid(pid); diff --git a/src/libcore/str.rs b/src/libcore/str.rs index f05410bafe9d..cc5ae30268df 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -110,8 +110,8 @@ #[abi = "cdecl"] extern mod rustrt { - fn rust_str_push(&s: str, ch: u8); - fn str_reserve_shared(&ss: str, nn: libc::size_t); + fn rust_str_push(&s: ~str, ch: u8); + fn str_reserve_shared(&ss: ~str, nn: libc::size_t); } /* @@ -125,7 +125,7 @@ * * Fails if invalid UTF-8 */ -pure fn from_bytes(+vv: ~[u8]) -> str { +pure fn from_bytes(+vv: ~[u8]) -> ~str { assert is_utf8(vv); ret unsafe { unsafe::from_bytes(vv) }; } @@ -137,14 +137,14 @@ * * Fails if invalid UTF-8 */ -pure fn from_byte(b: u8) -> str { +pure fn from_byte(b: u8) -> ~str { assert b < 128u8; let mut v = ~[b, 0u8]; unsafe { ::unsafe::transmute(v) } } /// Appends a character at the end of a string -fn push_char(&s: str, ch: char) { +fn push_char(&s: ~str, ch: char) { unsafe { let code = ch as uint; let nb = if code < max_one_b { 1u } @@ -220,15 +220,15 @@ fn push_char(&s: str, ch: char) { } /// Convert a char to a string -pure fn from_char(ch: char) -> str { - let mut buf = ""; +pure fn from_char(ch: char) -> ~str { + let mut buf = ~""; unchecked { push_char(buf, ch); } ret buf; } /// Convert a vector of chars to a string -pure fn from_chars(chs: &[const char]) -> str { - let mut buf = ""; +pure fn from_chars(chs: &[const char]) -> ~str { + let mut buf = ~""; unchecked { reserve(buf, chs.len()); for vec::each(chs) |ch| { push_char(buf, ch); } @@ -238,7 +238,7 @@ fn push_char(&s: str, ch: char) { /// Appends a string slice to the back of a string, without overallocating #[inline(always)] -fn push_str_no_overallocate(&lhs: str, rhs: str/&) { +fn push_str_no_overallocate(&lhs: ~str, rhs: &str) { unsafe { let llen = lhs.len(); let rlen = rhs.len(); @@ -254,7 +254,7 @@ fn push_str_no_overallocate(&lhs: str, rhs: str/&) { } /// Appends a string slice to the back of a string #[inline(always)] -fn push_str(&lhs: str, rhs: str/&) { +fn push_str(&lhs: ~str, rhs: &str) { unsafe { let llen = lhs.len(); let rlen = rhs.len(); @@ -271,7 +271,7 @@ fn push_str(&lhs: str, rhs: str/&) { /// Concatenate two strings together #[inline(always)] -pure fn append(+lhs: str, rhs: str/&) -> str { +pure fn append(+lhs: ~str, rhs: &str) -> ~str { let mut v <- lhs; unchecked { push_str_no_overallocate(v, rhs); @@ -281,15 +281,15 @@ fn push_str(&lhs: str, rhs: str/&) { /// Concatenate a vector of strings -pure fn concat(v: &[const str]) -> str { - let mut s: str = ""; +pure fn concat(v: &[const ~str]) -> ~str { + let mut s: ~str = ~""; for vec::each(v) |ss| { unchecked { push_str(s, ss) }; } ret s; } /// Concatenate a vector of strings, placing a given separator between each -pure fn connect(v: &[const str], sep: str) -> str { - let mut s = "", first = true; +pure fn connect(v: &[const ~str], sep: ~str) -> ~str { + let mut s = ~"", first = true; for vec::each(v) |ss| { if first { first = false; } else { unchecked { push_str(s, sep); } } unchecked { push_str(s, ss) }; @@ -308,7 +308,7 @@ fn push_str(&lhs: str, rhs: str/&) { * * If the string does not contain any characters */ -fn pop_char(&s: str) -> char { +fn pop_char(&s: ~str) -> char { let end = len(s); assert end > 0u; let {ch, prev} = char_range_at_reverse(s, end); @@ -323,19 +323,19 @@ fn pop_char(&s: str) -> char { * * If the string does not contain any characters */ -fn shift_char(&s: str) -> char { +fn shift_char(&s: ~str) -> char { let {ch, next} = char_range_at(s, 0u); s = unsafe { unsafe::slice_bytes(s, next, len(s)) }; ret ch; } /// Prepend a char to a string -fn unshift_char(&s: str, ch: char) { s = from_char(ch) + s; } +fn unshift_char(&s: ~str, ch: char) { s = from_char(ch) + s; } /// Returns a string with leading whitespace removed -pure fn trim_left(+s: str) -> str { +pure fn trim_left(+s: ~str) -> ~str { alt find(s, |c| !char::is_whitespace(c)) { - none { "" } + none { ~"" } some(first) { if first == 0u { s } else unsafe { unsafe::slice_bytes(s, first, len(s)) } @@ -344,9 +344,9 @@ fn shift_char(&s: str) -> char { } /// Returns a string with trailing whitespace removed -pure fn trim_right(+s: str) -> str { +pure fn trim_right(+s: ~str) -> ~str { alt rfind(s, |c| !char::is_whitespace(c)) { - none { "" } + none { ~"" } some(last) { let {next, _} = char_range_at(s, last); if next == len(s) { s } @@ -356,7 +356,7 @@ fn shift_char(&s: str) -> char { } /// Returns a string with leading and trailing whitespace removed -pure fn trim(+s: str) -> str { trim_left(trim_right(s)) } +pure fn trim(+s: ~str) -> ~str { trim_left(trim_right(s)) } /* Section: Transforming strings @@ -367,7 +367,7 @@ fn shift_char(&s: str) -> char { * * The result vector is not null-terminated. */ -pure fn bytes(s: str) -> ~[u8] { +pure fn bytes(s: ~str) -> ~[u8] { unsafe { let mut s_copy = s; let mut v: ~[u8] = ::unsafe::transmute(s_copy); @@ -378,14 +378,14 @@ fn shift_char(&s: str) -> char { /// Work with the string as a byte slice, not including trailing null. #[inline(always)] -pure fn byte_slice(s: str/&, f: fn(v: &[u8]) -> T) -> T { +pure fn byte_slice(s: &str, f: fn(v: &[u8]) -> T) -> T { do unpack_slice(s) |p,n| { unsafe { vec::unsafe::form_slice(p, n-1u, f) } } } /// Convert a string to a vector of characters -pure fn chars(s: str/&) -> ~[char] { +pure fn chars(s: &str) -> ~[char] { let mut buf = ~[], i = 0u; let len = len(s); while i < len { @@ -402,7 +402,7 @@ fn shift_char(&s: str) -> char { * Returns a string containing `n` characters starting at byte offset * `begin`. */ -pure fn substr(s: str/&, begin: uint, n: uint) -> str { +pure fn substr(s: &str, begin: uint, n: uint) -> ~str { slice(s, begin, begin + count_bytes(s, begin, n)) } @@ -412,14 +412,14 @@ fn shift_char(&s: str) -> char { * Fails when `begin` and `end` do not point to valid characters or * beyond the last character of the string */ -pure fn slice(s: str/&, begin: uint, end: uint) -> str { +pure fn slice(s: &str, begin: uint, end: uint) -> ~str { assert is_char_boundary(s, begin); assert is_char_boundary(s, end); unsafe { unsafe::slice_bytes(s, begin, end) } } /// Splits a string into substrings at each occurrence of a given character -pure fn split_char(s: str/&, sep: char) -> ~[str] { +pure fn split_char(s: &str, sep: char) -> ~[~str] { split_char_inner(s, sep, len(s), true) } @@ -429,17 +429,17 @@ fn shift_char(&s: str) -> char { * * The byte must be a valid UTF-8/ASCII byte */ -pure fn splitn_char(s: str/&, sep: char, count: uint) -> ~[str] { +pure fn splitn_char(s: &str, sep: char, count: uint) -> ~[~str] { split_char_inner(s, sep, count, true) } /// Like `split_char`, but omits empty strings from the returned vector -pure fn split_char_nonempty(s: str/&, sep: char) -> ~[str] { +pure fn split_char_nonempty(s: &str, sep: char) -> ~[~str] { split_char_inner(s, sep, len(s), false) } -pure fn split_char_inner(s: str/&, sep: char, count: uint, allow_empty: bool) - -> ~[str] { +pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool) + -> ~[~str] { if sep < 128u as char { let b = sep as u8, l = len(s); let mut result = ~[], done = 0u; @@ -466,7 +466,7 @@ fn shift_char(&s: str) -> char { /// Splits a string into substrings using a character function -pure fn split(s: str/&, sepfn: fn(char) -> bool) -> ~[str] { +pure fn split(s: &str, sepfn: fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), true) } @@ -474,17 +474,17 @@ fn shift_char(&s: str) -> char { * Splits a string into substrings using a character function, cutting at * most `count` times. */ -pure fn splitn(s: str/&, sepfn: fn(char) -> bool, count: uint) -> ~[str] { +pure fn splitn(s: &str, sepfn: fn(char) -> bool, count: uint) -> ~[~str] { split_inner(s, sepfn, count, true) } /// Like `split`, but omits empty strings from the returned vector -pure fn split_nonempty(s: str/&, sepfn: fn(char) -> bool) -> ~[str] { +pure fn split_nonempty(s: &str, sepfn: fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), false) } -pure fn split_inner(s: str/&, sepfn: fn(cc: char) -> bool, count: uint, - allow_empty: bool) -> ~[str] { +pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint, + allow_empty: bool) -> ~[~str] { let l = len(s); let mut result = ~[], i = 0u, start = 0u, done = 0u; while i < l && done < count { @@ -505,7 +505,7 @@ fn shift_char(&s: str) -> char { } // See Issue #1932 for why this is a naive search -pure fn iter_matches(s: str/&a, sep: str/&b, f: fn(uint, uint)) { +pure fn iter_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { let sep_len = len(sep), l = len(s); assert sep_len > 0u; let mut i = 0u, match_start = 0u, match_i = 0u; @@ -532,7 +532,7 @@ fn shift_char(&s: str) -> char { } } -pure fn iter_between_matches(s: str/&a, sep: str/&b, f: fn(uint, uint)) { +pure fn iter_between_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { let mut last_end = 0u; do iter_matches(s, sep) |from, to| { f(last_end, from); @@ -550,7 +550,7 @@ fn shift_char(&s: str) -> char { * assert ["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", ".") * ~~~ */ -pure fn split_str(s: str/&a, sep: str/&b) -> ~[str] { +pure fn split_str(s: &a/str, sep: &b/str) -> ~[~str] { let mut result = ~[]; do iter_between_matches(s, sep) |from, to| { unsafe { vec::push(result, unsafe::slice_bytes(s, from, to)); } @@ -558,7 +558,7 @@ fn shift_char(&s: str) -> char { result } -pure fn split_str_nonempty(s: str/&a, sep: str/&b) -> ~[str] { +pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] { let mut result = ~[]; do iter_between_matches(s, sep) |from, to| { if to > from { @@ -571,13 +571,13 @@ fn shift_char(&s: str) -> char { /** * Splits a string into a vector of the substrings separated by LF ('\n') */ -pure fn lines(s: str/&) -> ~[str] { split_char(s, '\n') } +pure fn lines(s: &str) -> ~[~str] { split_char(s, '\n') } /** * Splits a string into a vector of the substrings separated by LF ('\n') * and/or CR LF ("\r\n") */ -pure fn lines_any(s: str/&) -> ~[str] { +pure fn lines_any(s: &str) -> ~[~str] { vec::map(lines(s), |s| { let l = len(s); let mut cp = s; @@ -589,19 +589,19 @@ fn shift_char(&s: str) -> char { } /// Splits a string into a vector of the substrings separated by whitespace -pure fn words(s: str/&) -> ~[str] { +pure fn words(s: &str) -> ~[~str] { split_nonempty(s, |c| char::is_whitespace(c)) } /// Convert a string to lowercase. ASCII only -pure fn to_lower(s: str/&) -> str { +pure fn to_lower(s: &str) -> ~str { map(s, |c| unchecked{(libc::tolower(c as libc::c_char)) as char} ) } /// Convert a string to uppercase. ASCII only -pure fn to_upper(s: str/&) -> str { +pure fn to_upper(s: &str) -> ~str { map(s, |c| unchecked{(libc::toupper(c as libc::c_char)) as char} ) @@ -620,8 +620,8 @@ fn shift_char(&s: str) -> char { * * The original string with all occurances of `from` replaced with `to` */ -pure fn replace(s: str, from: str, to: str) -> str { - let mut result = "", first = true; +pure fn replace(s: ~str, from: ~str, to: ~str) -> ~str { + let mut result = ~"", first = true; do iter_between_matches(s, from) |start, end| { if first { first = false; } else { unchecked {push_str(result, to); }} unsafe { push_str(result, unsafe::slice_bytes(s, start, end)); } @@ -634,7 +634,7 @@ fn shift_char(&s: str) -> char { */ /// Bytewise string equality -pure fn eq(&&a: str, &&b: str) -> bool { +pure fn eq(&&a: ~str, &&b: ~str) -> bool { // FIXME (#2627): This should just be "a == b" but that calls into the // shape code. let a_len = a.len(); @@ -652,10 +652,10 @@ fn shift_char(&s: str) -> char { } /// Bytewise less than or equal -pure fn le(&&a: str, &&b: str) -> bool { a <= b } +pure fn le(&&a: ~str, &&b: ~str) -> bool { a <= b } /// String hash function -pure fn hash(&&s: str) -> uint { +pure fn hash(&&s: ~str) -> uint { // djb hash. // FIXME: replace with murmur. (see #859 and #1616) let mut u: uint = 5381u; @@ -671,7 +671,7 @@ fn shift_char(&s: str) -> char { * Return true if a predicate matches all characters or if the string * contains no characters */ -pure fn all(s: str/&, it: fn(char) -> bool) -> bool { +pure fn all(s: &str, it: fn(char) -> bool) -> bool { all_between(s, 0u, len(s), it) } @@ -679,13 +679,13 @@ fn shift_char(&s: str) -> char { * Return true if a predicate matches any character (and false if it * matches none or there are no characters) */ -pure fn any(ss: str/&, pred: fn(char) -> bool) -> bool { +pure fn any(ss: &str, pred: fn(char) -> bool) -> bool { !all(ss, |cc| !pred(cc)) } /// Apply a function to each character -pure fn map(ss: str/&, ff: fn(char) -> char) -> str { - let mut result = ""; +pure fn map(ss: &str, ff: fn(char) -> char) -> ~str { + let mut result = ~""; unchecked { reserve(result, len(ss)); do chars_iter(ss) |cc| { @@ -696,7 +696,7 @@ fn shift_char(&s: str) -> char { } /// Iterate over the bytes in a string -pure fn bytes_iter(ss: str/&, it: fn(u8)) { +pure fn bytes_iter(ss: &str, it: fn(u8)) { let mut pos = 0u; let len = len(ss); @@ -708,13 +708,13 @@ fn shift_char(&s: str) -> char { /// Iterate over the bytes in a string #[inline(always)] -pure fn each(s: str/&, it: fn(u8) -> bool) { +pure fn each(s: &str, it: fn(u8) -> bool) { eachi(s, |_i, b| it(b) ) } /// Iterate over the bytes in a string, with indices #[inline(always)] -pure fn eachi(s: str/&, it: fn(uint, u8) -> bool) { +pure fn eachi(s: &str, it: fn(uint, u8) -> bool) { let mut i = 0u, l = len(s); while (i < l) { if !it(i, s[i]) { break; } @@ -724,13 +724,13 @@ fn shift_char(&s: str) -> char { /// Iterates over the chars in a string #[inline(always)] -pure fn each_char(s: str/&, it: fn(char) -> bool) { +pure fn each_char(s: &str, it: fn(char) -> bool) { each_chari(s, |_i, c| it(c)) } /// Iterates over the chars in a string, with indices #[inline(always)] -pure fn each_chari(s: str/&, it: fn(uint, char) -> bool) { +pure fn each_chari(s: &str, it: fn(uint, char) -> bool) { let mut pos = 0u, ch_pos = 0u; let len = len(s); while pos < len { @@ -742,7 +742,7 @@ fn shift_char(&s: str) -> char { } /// Iterate over the characters in a string -pure fn chars_iter(s: str/&, it: fn(char)) { +pure fn chars_iter(s: &str, it: fn(char)) { let mut pos = 0u; let len = len(s); while (pos < len) { @@ -753,7 +753,7 @@ fn shift_char(&s: str) -> char { } /// Apply a function to each substring after splitting by character -pure fn split_char_iter(ss: str/&, cc: char, ff: fn(&&str)) { +pure fn split_char_iter(ss: &str, cc: char, ff: fn(&&~str)) { vec::iter(split_char(ss, cc), ff) } @@ -761,20 +761,20 @@ fn shift_char(&s: str) -> char { * Apply a function to each substring after splitting by character, up to * `count` times */ -pure fn splitn_char_iter(ss: str/&, sep: char, count: uint, - ff: fn(&&str)) { +pure fn splitn_char_iter(ss: &str, sep: char, count: uint, + ff: fn(&&~str)) { vec::iter(splitn_char(ss, sep, count), ff) } /// Apply a function to each word -pure fn words_iter(ss: str/&, ff: fn(&&str)) { +pure fn words_iter(ss: &str, ff: fn(&&~str)) { vec::iter(words(ss), ff) } /** * Apply a function to each line (by '\n') */ -pure fn lines_iter(ss: str/&, ff: fn(&&str)) { +pure fn lines_iter(ss: &str, ff: fn(&&~str)) { vec::iter(lines(ss), ff) } @@ -795,7 +795,7 @@ fn shift_char(&s: str) -> char { * An `option` containing the byte index of the first matching character * or `none` if there is no match */ -pure fn find_char(s: str/&, c: char) -> option { +pure fn find_char(s: &str, c: char) -> option { find_char_between(s, c, 0u, len(s)) } @@ -819,7 +819,7 @@ fn shift_char(&s: str) -> char { * `start` must be less than or equal to `len(s)`. `start` must be the * index of a character boundary, as defined by `is_char_boundary`. */ -pure fn find_char_from(s: str/&, c: char, start: uint) -> option { +pure fn find_char_from(s: &str, c: char, start: uint) -> option { find_char_between(s, c, start, len(s)) } @@ -844,7 +844,7 @@ fn shift_char(&s: str) -> char { * or equal to `len(s)`. `start` must be the index of a character boundary, * as defined by `is_char_boundary`. */ -pure fn find_char_between(s: str/&, c: char, start: uint, end: uint) +pure fn find_char_between(s: &str, c: char, start: uint, end: uint) -> option { if c < 128u as char { assert start <= end; @@ -874,7 +874,7 @@ fn shift_char(&s: str) -> char { * An `option` containing the byte index of the last matching character * or `none` if there is no match */ -pure fn rfind_char(s: str/&, c: char) -> option { +pure fn rfind_char(s: &str, c: char) -> option { rfind_char_between(s, c, len(s), 0u) } @@ -898,7 +898,7 @@ fn shift_char(&s: str) -> char { * `start` must be less than or equal to `len(s)`. `start` must be * the index of a character boundary, as defined by `is_char_boundary`. */ -pure fn rfind_char_from(s: str/&, c: char, start: uint) -> option { +pure fn rfind_char_from(s: &str, c: char, start: uint) -> option { rfind_char_between(s, c, start, 0u) } @@ -923,7 +923,7 @@ fn shift_char(&s: str) -> char { * or equal to `len(s)`. `start` must be the index of a character boundary, * as defined by `is_char_boundary`. */ -pure fn rfind_char_between(s: str/&, c: char, start: uint, end: uint) +pure fn rfind_char_between(s: &str, c: char, start: uint, end: uint) -> option { if c < 128u as char { assert start >= end; @@ -954,7 +954,7 @@ fn shift_char(&s: str) -> char { * An `option` containing the byte index of the first matching character * or `none` if there is no match */ -pure fn find(s: str/&, f: fn(char) -> bool) -> option { +pure fn find(s: &str, f: fn(char) -> bool) -> option { find_between(s, 0u, len(s), f) } @@ -978,7 +978,7 @@ fn shift_char(&s: str) -> char { * `start` must be less than or equal to `len(s)`. `start` must be the * index of a character boundary, as defined by `is_char_boundary`. */ -pure fn find_from(s: str/&, start: uint, f: fn(char) +pure fn find_from(s: &str, start: uint, f: fn(char) -> bool) -> option { find_between(s, start, len(s), f) } @@ -1005,7 +1005,7 @@ fn shift_char(&s: str) -> char { * or equal to `len(s)`. `start` must be the index of a character * boundary, as defined by `is_char_boundary`. */ -pure fn find_between(s: str/&, start: uint, end: uint, f: fn(char) -> bool) +pure fn find_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) -> option { assert start <= end; assert end <= len(s); @@ -1033,7 +1033,7 @@ fn shift_char(&s: str) -> char { * An option containing the byte index of the last matching character * or `none` if there is no match */ -pure fn rfind(s: str/&, f: fn(char) -> bool) -> option { +pure fn rfind(s: &str, f: fn(char) -> bool) -> option { rfind_between(s, len(s), 0u, f) } @@ -1057,7 +1057,7 @@ fn shift_char(&s: str) -> char { * `start` must be less than or equal to `len(s)', `start` must be the * index of a character boundary, as defined by `is_char_boundary` */ -pure fn rfind_from(s: str/&, start: uint, f: fn(char) -> bool) +pure fn rfind_from(s: &str, start: uint, f: fn(char) -> bool) -> option { rfind_between(s, start, 0u, f) } @@ -1084,7 +1084,7 @@ fn shift_char(&s: str) -> char { * than or equal to `len(s)`. `start` must be the index of a character * boundary, as defined by `is_char_boundary` */ -pure fn rfind_between(s: str/&, start: uint, end: uint, f: fn(char) -> bool) +pure fn rfind_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) -> option { assert start >= end; assert start <= len(s); @@ -1099,7 +1099,7 @@ fn shift_char(&s: str) -> char { } // Utility used by various searching functions -pure fn match_at(haystack: str/&a, needle: str/&b, at: uint) -> bool { +pure fn match_at(haystack: &a/str, needle: &b/str, at: uint) -> bool { let mut i = at; for each(needle) |c| { if haystack[i] != c { ret false; } i += 1u; } ret true; @@ -1118,7 +1118,7 @@ fn shift_char(&s: str) -> char { * An `option` containing the byte index of the first matching substring * or `none` if there is no match */ -pure fn find_str(haystack: str/&a, needle: str/&b) -> option { +pure fn find_str(haystack: &a/str, needle: &b/str) -> option { find_str_between(haystack, needle, 0u, len(haystack)) } @@ -1141,7 +1141,7 @@ fn shift_char(&s: str) -> char { * * `start` must be less than or equal to `len(s)` */ -pure fn find_str_from(haystack: str/&a, needle: str/&b, start: uint) +pure fn find_str_from(haystack: &a/str, needle: &b/str, start: uint) -> option { find_str_between(haystack, needle, start, len(haystack)) } @@ -1166,7 +1166,7 @@ fn shift_char(&s: str) -> char { * `start` must be less than or equal to `end` and `end` must be less than * or equal to `len(s)`. */ -pure fn find_str_between(haystack: str/&a, needle: str/&b, start: uint, +pure fn find_str_between(haystack: &a/str, needle: &b/str, start: uint, end:uint) -> option { // See Issue #1932 for why this is a naive search @@ -1192,7 +1192,7 @@ fn shift_char(&s: str) -> char { * * haystack - The string to look in * * needle - The string to look for */ -pure fn contains(haystack: str/&a, needle: str/&b) -> bool { +pure fn contains(haystack: &a/str, needle: &b/str) -> bool { option::is_some(find_str(haystack, needle)) } @@ -1204,7 +1204,7 @@ fn shift_char(&s: str) -> char { * * haystack - The string to look in * * needle - The char to look for */ -pure fn contains_char(haystack: str/&, needle: char) -> bool { +pure fn contains_char(haystack: &str, needle: char) -> bool { option::is_some(find_char(haystack, needle)) } @@ -1216,7 +1216,7 @@ fn shift_char(&s: str) -> char { * * haystack - The string to look in * * needle - The string to look for */ -pure fn starts_with(haystack: str/&a, needle: str/&b) -> bool { +pure fn starts_with(haystack: &a/str, needle: &b/str) -> bool { let haystack_len = len(haystack), needle_len = len(needle); if needle_len == 0u { true } else if needle_len > haystack_len { false } @@ -1231,7 +1231,7 @@ fn shift_char(&s: str) -> char { * * haystack - The string to look in * * needle - The string to look for */ -pure fn ends_with(haystack: str/&a, needle: str/&b) -> bool { +pure fn ends_with(haystack: &a/str, needle: &b/str) -> bool { let haystack_len = len(haystack), needle_len = len(needle); if needle_len == 0u { true } else if needle_len > haystack_len { false } @@ -1243,24 +1243,24 @@ fn shift_char(&s: str) -> char { */ /// Determines if a string contains only ASCII characters -pure fn is_ascii(s: str/&) -> bool { +pure fn is_ascii(s: &str) -> bool { let mut i: uint = len(s); while i > 0u { i -= 1u; if !u8::is_ascii(s[i]) { ret false; } } ret true; } /// Returns true if the string has length 0 -pure fn is_empty(s: str/&) -> bool { len(s) == 0u } +pure fn is_empty(s: &str) -> bool { len(s) == 0u } /// Returns true if the string has length greater than 0 -pure fn is_not_empty(s: str/&) -> bool { !is_empty(s) } +pure fn is_not_empty(s: &str) -> bool { !is_empty(s) } /** * Returns true if the string contains only whitespace * * Whitespace characters are determined by `char::is_whitespace` */ -pure fn is_whitespace(s: str/&) -> bool { +pure fn is_whitespace(s: &str) -> bool { ret all(s, char::is_whitespace); } @@ -1269,17 +1269,17 @@ fn shift_char(&s: str) -> char { * * Alphanumeric characters are determined by `char::is_alphanumeric` */ -fn is_alphanumeric(s: str/&) -> bool { +fn is_alphanumeric(s: &str) -> bool { ret all(s, char::is_alphanumeric); } /// Returns the string length/size in bytes not counting the null terminator -pure fn len(s: str/&) -> uint { +pure fn len(s: &str) -> uint { do unpack_slice(s) |_p, n| { n - 1u } } /// Returns the number of characters that a string holds -pure fn char_len(s: str/&) -> uint { count_chars(s, 0u, len(s)) } +pure fn char_len(s: &str) -> uint { count_chars(s, 0u, len(s)) } /* Section: Misc @@ -1325,7 +1325,7 @@ fn is_alphanumeric(s: str/&) -> bool { } /// Converts to a vector of `u16` encoded as UTF-16 -pure fn to_utf16(s: str/&) -> ~[u16] { +pure fn to_utf16(s: &str) -> ~[u16] { let mut u = ~[]; do chars_iter(s) |cch| { // Arithmetic with u32 literals is easier on the eyes than chars. @@ -1372,8 +1372,8 @@ fn is_alphanumeric(s: str/&) -> bool { } -pure fn from_utf16(v: &[const u16]) -> str { - let mut buf = ""; +pure fn from_utf16(v: &[const u16]) -> ~str { + let mut buf = ~""; unchecked { reserve(buf, vec::len(v)); utf16_chars(v, |ch| push_char(buf, ch)); @@ -1395,7 +1395,7 @@ fn is_alphanumeric(s: str/&) -> bool { * * The number of Unicode characters in `s` between the given indices. */ -pure fn count_chars(s: str/&, start: uint, end: uint) -> uint { +pure fn count_chars(s: &str, start: uint, end: uint) -> uint { assert is_char_boundary(s, start); assert is_char_boundary(s, end); let mut i = start, len = 0u; @@ -1408,7 +1408,7 @@ fn is_alphanumeric(s: str/&) -> bool { } /// Counts the number of bytes taken by the `n` in `s` starting from `start`. -pure fn count_bytes(s: str/&b, start: uint, n: uint) -> uint { +pure fn count_bytes(s: &b/str, start: uint, n: uint) -> uint { assert is_char_boundary(s, start); let mut end = start, cnt = n; let l = len(s); @@ -1438,7 +1438,7 @@ fn is_alphanumeric(s: str/&) -> bool { * Returns false if the index points into the middle of a multi-byte * character sequence. */ -pure fn is_char_boundary(s: str/&, index: uint) -> bool { +pure fn is_char_boundary(s: &str, index: uint) -> bool { if index == len(s) { ret true; } let b = s[index]; ret b < 128u8 || b >= 192u8; @@ -1493,7 +1493,7 @@ fn is_alphanumeric(s: str/&) -> bool { * If `i` is greater than or equal to the length of the string. * If `i` is not the index of the beginning of a valid UTF-8 character. */ -pure fn char_range_at(s: str/&, i: uint) -> {ch: char, next: uint} { +pure fn char_range_at(s: &str, i: uint) -> {ch: char, next: uint} { let b0 = s[i]; let w = utf8_char_width(b0); assert (w != 0u); @@ -1516,14 +1516,14 @@ fn is_alphanumeric(s: str/&) -> bool { } /// Pluck a character out of a string -pure fn char_at(s: str/&, i: uint) -> char { ret char_range_at(s, i).ch; } +pure fn char_at(s: &str, i: uint) -> char { ret char_range_at(s, i).ch; } /** * Given a byte position and a str, return the previous char and its position * * This function can be used to iterate over a unicode string in reverse. */ -pure fn char_range_at_reverse(ss: str/&, start: uint) +pure fn char_range_at_reverse(ss: &str, start: uint) -> {ch: char, prev: uint} { let mut prev = start; @@ -1562,7 +1562,7 @@ fn is_alphanumeric(s: str/&) -> bool { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pure fn all_between(s: str/&, start: uint, end: uint, +pure fn all_between(s: &str, start: uint, end: uint, it: fn(char) -> bool) -> bool { assert is_char_boundary(s, start); let mut i = start; @@ -1595,7 +1595,7 @@ fn is_alphanumeric(s: str/&) -> bool { * * `true` if `it` returns `true` for any character */ -pure fn any_between(s: str/&, start: uint, end: uint, +pure fn any_between(s: &str, start: uint, end: uint, it: fn(char) -> bool) -> bool { !all_between(s, start, end, |c| !it(c)) } @@ -1627,7 +1627,7 @@ fn is_alphanumeric(s: str/&) -> bool { * let i = str::as_bytes("Hello World") { |bytes| vec::len(bytes) }; * ~~~ */ -pure fn as_bytes(s: str, f: fn(~[u8]) -> T) -> T { +pure fn as_bytes(s: ~str, f: fn(~[u8]) -> T) -> T { unsafe { let v: *~[u8] = ::unsafe::reinterpret_cast(ptr::addr_of(s)); f(*v) @@ -1640,7 +1640,7 @@ fn is_alphanumeric(s: str/&) -> bool { * Allows for unsafe manipulation of strings, which is useful for foreign * interop. */ -pure fn as_buf(s: str, f: fn(*u8) -> T) -> T { +pure fn as_buf(s: ~str, f: fn(*u8) -> T) -> T { as_bytes(s, |v| unsafe { vec::as_buf(v, f) }) } @@ -1656,7 +1656,7 @@ fn is_alphanumeric(s: str/&) -> bool { * let s = str::as_buf("PATH", { |path_buf| libc::getenv(path_buf) }); * ~~~ */ -pure fn as_c_str(s: str, f: fn(*libc::c_char) -> T) -> T { +pure fn as_c_str(s: ~str, f: fn(*libc::c_char) -> T) -> T { as_buf(s, |buf| f(buf as *libc::c_char)) } @@ -1670,7 +1670,7 @@ fn is_alphanumeric(s: str/&) -> bool { * to full strings, or suffixes of them. */ #[inline(always)] -pure fn unpack_slice(s: str/&, f: fn(*u8, uint) -> T) -> T { +pure fn unpack_slice(s: &str, f: fn(*u8, uint) -> T) -> T { unsafe { let v : *(*u8,uint) = ::unsafe::reinterpret_cast(ptr::addr_of(s)); let (buf,len) = *v; @@ -1694,7 +1694,7 @@ fn is_alphanumeric(s: str/&) -> bool { * * s - A string * * n - The number of bytes to reserve space for */ -fn reserve(&s: str, n: uint) { +fn reserve(&s: ~str, n: uint) { if capacity(s) < n { rustrt::str_reserve_shared(s, n as size_t); } @@ -1720,7 +1720,7 @@ fn reserve(&s: str, n: uint) { * * s - A string * * n - The number of bytes to reserve space for */ -fn reserve_at_least(&s: str, n: uint) { +fn reserve_at_least(&s: ~str, n: uint) { reserve(s, uint::next_power_of_two(n + 1u) - 1u) } @@ -1728,7 +1728,7 @@ fn reserve_at_least(&s: str, n: uint) { * Returns the number of single-byte characters the string can hold without * reallocating */ -pure fn capacity(&&s: str) -> uint { +pure fn capacity(&&s: ~str) -> uint { do as_bytes(s) |buf| { let vcap = vec::capacity(buf); assert vcap > 0u; @@ -1737,8 +1737,8 @@ fn reserve_at_least(&s: str, n: uint) { } /// Escape each char in `s` with char::escape_default. -pure fn escape_default(s: str/&) -> str { - let mut out: str = ""; +pure fn escape_default(s: &str) -> ~str { + let mut out: ~str = ~""; unchecked { reserve_at_least(out, str::len(s)); chars_iter(s, |c| push_str(out, char::escape_default(c))); @@ -1747,8 +1747,8 @@ fn reserve_at_least(&s: str, n: uint) { } /// Escape each char in `s` with char::escape_unicode. -pure fn escape_unicode(s: str/&) -> str { - let mut out: str = ""; +pure fn escape_unicode(s: &str) -> ~str { + let mut out: ~str = ~""; unchecked { reserve_at_least(out, str::len(s)); chars_iter(s, |c| push_str(out, char::escape_unicode(c))); @@ -1771,7 +1771,7 @@ mod unsafe { set_len; /// Create a Rust string from a null-terminated *u8 buffer - unsafe fn from_buf(buf: *u8) -> str { + unsafe fn from_buf(buf: *u8) -> ~str { let mut curr = buf, i = 0u; while *curr != 0u8 { i += 1u; @@ -1781,7 +1781,7 @@ unsafe fn from_buf(buf: *u8) -> str { } /// Create a Rust string from a *u8 buffer of the given length - unsafe fn from_buf_len(buf: *u8, len: uint) -> str { + unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str { let mut v: ~[u8] = ~[]; vec::reserve(v, len + 1u); vec::as_buf(v, |b| ptr::memcpy(b, buf, len)); @@ -1793,12 +1793,12 @@ unsafe fn from_buf_len(buf: *u8, len: uint) -> str { } /// Create a Rust string from a null-terminated C string - unsafe fn from_c_str(c_str: *libc::c_char) -> str { + unsafe fn from_c_str(c_str: *libc::c_char) -> ~str { from_buf(::unsafe::reinterpret_cast(c_str)) } /// Create a Rust string from a `*c_char` buffer of the given length - unsafe fn from_c_str_len(c_str: *libc::c_char, len: uint) -> str { + unsafe fn from_c_str_len(c_str: *libc::c_char, len: uint) -> ~str { from_buf_len(::unsafe::reinterpret_cast(c_str), len) } @@ -1807,7 +1807,7 @@ unsafe fn from_c_str_len(c_str: *libc::c_char, len: uint) -> str { * * Does not verify that the vector contains valid UTF-8. */ - unsafe fn from_bytes(+v: ~[const u8]) -> str { + unsafe fn from_bytes(+v: ~[const u8]) -> ~str { unsafe { let mut vcopy = ::unsafe::transmute(v); vec::push(vcopy, 0u8); @@ -1820,7 +1820,7 @@ unsafe fn from_bytes(+v: ~[const u8]) -> str { * * Does not verify that the byte is valid UTF-8. */ - unsafe fn from_byte(u: u8) -> str { unsafe::from_bytes(~[u]) } + unsafe fn from_byte(u: u8) -> ~str { unsafe::from_bytes(~[u]) } /** * Takes a bytewise (not UTF-8) slice from a string. @@ -1832,7 +1832,7 @@ unsafe fn from_byte(u: u8) -> str { unsafe::from_bytes(~[u]) } * If begin is greater than end. * If end is greater than the length of the string. */ - unsafe fn slice_bytes(s: str/&, begin: uint, end: uint) -> str { + unsafe fn slice_bytes(s: &str, begin: uint, end: uint) -> ~str { do unpack_slice(s) |sbuf, n| { assert (begin <= end); assert (end <= n); @@ -1852,17 +1852,17 @@ unsafe fn slice_bytes(s: str/&, begin: uint, end: uint) -> str { } /// Appends a byte to a string. (Not UTF-8 safe). - unsafe fn push_byte(&s: str, b: u8) { + unsafe fn push_byte(&s: ~str, b: u8) { rustrt::rust_str_push(s, b); } /// Appends a vector of bytes to a string. (Not UTF-8 safe). - unsafe fn push_bytes(&s: str, bytes: ~[u8]) { + unsafe fn push_bytes(&s: ~str, bytes: ~[u8]) { for vec::each(bytes) |byte| { rustrt::rust_str_push(s, byte); } } /// Removes the last byte from a string and returns it. (Not UTF-8 safe). - unsafe fn pop_byte(&s: str) -> u8 { + unsafe fn pop_byte(&s: ~str) -> u8 { let len = len(s); assert (len > 0u); let b = s[len - 1u]; @@ -1871,7 +1871,7 @@ unsafe fn pop_byte(&s: str) -> u8 { } /// Removes the first byte from a string and returns it. (Not UTF-8 safe). - unsafe fn shift_byte(&s: str) -> u8 { + unsafe fn shift_byte(&s: ~str) -> u8 { let len = len(s); assert (len > 0u); let b = s[0]; @@ -1880,7 +1880,7 @@ unsafe fn shift_byte(&s: str) -> u8 { } /// Sets the length of the string and adds the null terminator - unsafe fn set_len(&v: str, new_len: uint) { + unsafe fn set_len(&v: ~str, new_len: uint) { let repr: *vec::unsafe::vec_repr = ::unsafe::reinterpret_cast(v); (*repr).fill = new_len + 1u; let null = ptr::mut_offset(ptr::mut_addr_of((*repr).data), new_len); @@ -1893,7 +1893,7 @@ fn test_from_buf_len() { let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; let b = vec::unsafe::to_ptr(a); let c = from_buf_len(b, 3u); - assert (c == "AAA"); + assert (c == ~"AAA"); } } @@ -1903,24 +1903,24 @@ trait unique_str { fn trim() -> self; fn trim_left() -> self; fn trim_right() -> self; - pure fn +(rhs: str/&) -> self; + pure fn +(rhs: &str) -> self; } /// Extension methods for strings -impl extensions of unique_str for str { +impl extensions of unique_str for ~str { /// Returns a string with leading and trailing whitespace removed #[inline] - fn trim() -> str { trim(self) } + fn trim() -> ~str { trim(self) } /// Returns a string with leading whitespace removed #[inline] - fn trim_left() -> str { trim_left(self) } + fn trim_left() -> ~str { trim_left(self) } /// Returns a string with trailing whitespace removed #[inline] - fn trim_right() -> str { trim_right(self) } + fn trim_right() -> ~str { trim_right(self) } /// Concatenate two strings: operator version #[inline(always)] - pure fn +(rhs: str/&) -> str { + pure fn +(rhs: &str) -> ~str { append(self, rhs) } } @@ -1928,32 +1928,32 @@ fn trim_right() -> str { trim_right(self) } trait str_slice { fn all(it: fn(char) -> bool) -> bool; fn any(it: fn(char) -> bool) -> bool; - fn contains(needle: str/&a) -> bool; + fn contains(needle: &a/str) -> bool; fn contains_char(needle: char) -> bool; fn each(it: fn(u8) -> bool); fn eachi(it: fn(uint, u8) -> bool); fn each_char(it: fn(char) -> bool); fn each_chari(it: fn(uint, char) -> bool); - fn ends_with(needle: str/&) -> bool; + fn ends_with(needle: &str) -> bool; fn is_empty() -> bool; fn is_not_empty() -> bool; fn is_whitespace() -> bool; fn is_alphanumeric() -> bool; pure fn len() -> uint; - fn slice(begin: uint, end: uint) -> str; - fn split(sepfn: fn(char) -> bool) -> ~[str]; - fn split_char(sep: char) -> ~[str]; - fn split_str(sep: str/&a) -> ~[str]; - fn starts_with(needle: str/&a) -> bool; - fn substr(begin: uint, n: uint) -> str; - fn to_lower() -> str; - fn to_upper() -> str; - fn escape_default() -> str; - fn escape_unicode() -> str; + fn slice(begin: uint, end: uint) -> ~str; + fn split(sepfn: fn(char) -> bool) -> ~[~str]; + fn split_char(sep: char) -> ~[~str]; + fn split_str(sep: &a/str) -> ~[~str]; + fn starts_with(needle: &a/str) -> bool; + fn substr(begin: uint, n: uint) -> ~str; + fn to_lower() -> ~str; + fn to_upper() -> ~str; + fn escape_default() -> ~str; + fn escape_unicode() -> ~str; } /// Extension methods for strings -impl extensions/& of str_slice for str/& { +impl extensions/& of str_slice for &str { /** * Return true if a predicate matches all characters or if the string * contains no characters @@ -1968,7 +1968,7 @@ fn all(it: fn(char) -> bool) -> bool { all(self, it) } fn any(it: fn(char) -> bool) -> bool { any(self, it) } /// Returns true if one string contains another #[inline] - fn contains(needle: str/&a) -> bool { contains(self, needle) } + fn contains(needle: &a/str) -> bool { contains(self, needle) } /// Returns true if a string contains a char #[inline] fn contains_char(needle: char) -> bool { contains_char(self, needle) } @@ -1986,7 +1986,7 @@ fn each_char(it: fn(char) -> bool) { each_char(self, it) } fn each_chari(it: fn(uint, char) -> bool) { each_chari(self, it) } /// Returns true if one string ends with another #[inline] - fn ends_with(needle: str/&) -> bool { ends_with(self, needle) } + fn ends_with(needle: &str) -> bool { ends_with(self, needle) } /// Returns true if the string has length 0 #[inline] fn is_empty() -> bool { is_empty(self) } @@ -2018,24 +2018,24 @@ fn is_alphanumeric() -> bool { is_alphanumeric(self) } * beyond the last character of the string */ #[inline] - fn slice(begin: uint, end: uint) -> str { slice(self, begin, end) } + fn slice(begin: uint, end: uint) -> ~str { slice(self, begin, end) } /// Splits a string into substrings using a character function #[inline] - fn split(sepfn: fn(char) -> bool) -> ~[str] { split(self, sepfn) } + fn split(sepfn: fn(char) -> bool) -> ~[~str] { split(self, sepfn) } /** * Splits a string into substrings at each occurrence of a given character */ #[inline] - fn split_char(sep: char) -> ~[str] { split_char(self, sep) } + fn split_char(sep: char) -> ~[~str] { split_char(self, sep) } /** * Splits a string into a vector of the substrings separated by a given * string */ #[inline] - fn split_str(sep: str/&a) -> ~[str] { split_str(self, sep) } + fn split_str(sep: &a/str) -> ~[~str] { split_str(self, sep) } /// Returns true if one string starts with another #[inline] - fn starts_with(needle: str/&a) -> bool { starts_with(self, needle) } + fn starts_with(needle: &a/str) -> bool { starts_with(self, needle) } /** * Take a substring of another. * @@ -2043,19 +2043,19 @@ fn starts_with(needle: str/&a) -> bool { starts_with(self, needle) } * `begin`. */ #[inline] - fn substr(begin: uint, n: uint) -> str { substr(self, begin, n) } + fn substr(begin: uint, n: uint) -> ~str { substr(self, begin, n) } /// Convert a string to lowercase #[inline] - fn to_lower() -> str { to_lower(self) } + fn to_lower() -> ~str { to_lower(self) } /// Convert a string to uppercase #[inline] - fn to_upper() -> str { to_upper(self) } + fn to_upper() -> ~str { to_upper(self) } /// Escape each char in `s` with char::escape_default. #[inline] - fn escape_default() -> str { escape_default(self) } + fn escape_default() -> ~str { escape_default(self) } /// Escape each char in `s` with char::escape_unicode. #[inline] - fn escape_unicode() -> str { escape_unicode(self) } + fn escape_unicode() -> ~str { escape_unicode(self) } } #[cfg(test)] @@ -2065,61 +2065,61 @@ mod tests { #[test] fn test_eq() { - assert (eq("", "")); - assert (eq("foo", "foo")); - assert (!eq("foo", "bar")); + assert (eq(~"", ~"")); + assert (eq(~"foo", ~"foo")); + assert (!eq(~"foo", ~"bar")); } #[test] fn test_le() { - assert (le("", "")); - assert (le("", "foo")); - assert (le("foo", "foo")); - assert (!eq("foo", "bar")); + assert (le(~"", ~"")); + assert (le(~"", ~"foo")); + assert (le(~"foo", ~"foo")); + assert (!eq(~"foo", ~"bar")); } #[test] fn test_len() { - assert (len("") == 0u); - assert (len("hello world") == 11u); - assert (len("\x63") == 1u); - assert (len("\xa2") == 2u); - assert (len("\u03c0") == 2u); - assert (len("\u2620") == 3u); - assert (len("\U0001d11e") == 4u); + assert (len(~"") == 0u); + assert (len(~"hello world") == 11u); + assert (len(~"\x63") == 1u); + assert (len(~"\xa2") == 2u); + assert (len(~"\u03c0") == 2u); + assert (len(~"\u2620") == 3u); + assert (len(~"\U0001d11e") == 4u); - assert (char_len("") == 0u); - assert (char_len("hello world") == 11u); - assert (char_len("\x63") == 1u); - assert (char_len("\xa2") == 1u); - assert (char_len("\u03c0") == 1u); - assert (char_len("\u2620") == 1u); - assert (char_len("\U0001d11e") == 1u); - assert (char_len("ประเทศไทย中华Việt Nam") == 19u); + assert (char_len(~"") == 0u); + assert (char_len(~"hello world") == 11u); + assert (char_len(~"\x63") == 1u); + assert (char_len(~"\xa2") == 1u); + assert (char_len(~"\u03c0") == 1u); + assert (char_len(~"\u2620") == 1u); + assert (char_len(~"\U0001d11e") == 1u); + assert (char_len(~"ประเทศไทย中华Việt Nam") == 19u); } #[test] fn test_rfind_char() { - assert rfind_char("hello", 'l') == some(3u); - assert rfind_char("hello", 'o') == some(4u); - assert rfind_char("hello", 'h') == some(0u); - assert rfind_char("hello", 'z') == none; - assert rfind_char("ประเทศไทย中华Việt Nam", '华') == some(30u); + assert rfind_char(~"hello", 'l') == some(3u); + assert rfind_char(~"hello", 'o') == some(4u); + assert rfind_char(~"hello", 'h') == some(0u); + assert rfind_char(~"hello", 'z') == none; + assert rfind_char(~"ประเทศไทย中华Việt Nam", '华') == some(30u); } #[test] fn test_pop_char() { - let mut data = "ประเทศไทย中华"; + let mut data = ~"ประเทศไทย中华"; let cc = pop_char(data); - assert "ประเทศไทย中" == data; + assert ~"ประเทศไทย中" == data; assert '华' == cc; } #[test] fn test_pop_char_2() { - let mut data2 = "华"; + let mut data2 = ~"华"; let cc2 = pop_char(data2); - assert "" == data2; + assert ~"" == data2; assert '华' == cc2; } @@ -2127,247 +2127,248 @@ fn test_pop_char_2() { #[should_fail] #[ignore(cfg(windows))] fn test_pop_char_fail() { - let mut data = ""; + let mut data = ~""; let _cc3 = pop_char(data); } #[test] fn test_split_char() { - fn t(s: str, c: char, u: ~[str]) { - log(debug, "split_byte: " + s); + fn t(s: ~str, c: char, u: ~[~str]) { + log(debug, ~"split_byte: " + s); let v = split_char(s, c); #debug("split_byte to: %?", v); assert vec::all2(v, u, |a,b| a == b); } - t("abc.hello.there", '.', ~["abc", "hello", "there"]); - t(".hello.there", '.', ~["", "hello", "there"]); - t("...hello.there.", '.', ~["", "", "", "hello", "there", ""]); + t(~"abc.hello.there", '.', ~[~"abc", ~"hello", ~"there"]); + t(~".hello.there", '.', ~[~"", ~"hello", ~"there"]); + t(~"...hello.there.", '.', ~[~"", ~"", ~"", ~"hello", ~"there", ~""]); - assert ~["", "", "", "hello", "there", ""] - == split_char("...hello.there.", '.'); + assert ~[~"", ~"", ~"", ~"hello", ~"there", ~""] + == split_char(~"...hello.there.", '.'); - assert ~[""] == split_char("", 'z'); - assert ~["",""] == split_char("z", 'z'); - assert ~["ok"] == split_char("ok", 'z'); + assert ~[~""] == split_char(~"", 'z'); + assert ~[~"",~""] == split_char(~"z", 'z'); + assert ~[~"ok"] == split_char(~"ok", 'z'); } #[test] fn test_split_char_2() { - let data = "ประเทศไทย中华Việt Nam"; - assert ~["ประเทศไทย中华", "iệt Nam"] + let data = ~"ประเทศไทย中华Việt Nam"; + assert ~[~"ประเทศไทย中华", ~"iệt Nam"] == split_char(data, 'V'); - assert ~["ประเ", "ศไ", "ย中华Việt Nam"] + assert ~[~"ประเ", ~"ศไ", ~"ย中华Việt Nam"] == split_char(data, 'ท'); } #[test] fn test_splitn_char() { - fn t(s: str, c: char, n: uint, u: ~[str]) { - log(debug, "splitn_byte: " + s); + fn t(s: ~str, c: char, n: uint, u: ~[~str]) { + log(debug, ~"splitn_byte: " + s); let v = splitn_char(s, c, n); #debug("split_byte to: %?", v); #debug("comparing vs. %?", u); assert vec::all2(v, u, |a,b| a == b); } - t("abc.hello.there", '.', 0u, ~["abc.hello.there"]); - t("abc.hello.there", '.', 1u, ~["abc", "hello.there"]); - t("abc.hello.there", '.', 2u, ~["abc", "hello", "there"]); - t("abc.hello.there", '.', 3u, ~["abc", "hello", "there"]); - t(".hello.there", '.', 0u, ~[".hello.there"]); - t(".hello.there", '.', 1u, ~["", "hello.there"]); - t("...hello.there.", '.', 3u, ~["", "", "", "hello.there."]); - t("...hello.there.", '.', 5u, ~["", "", "", "hello", "there", ""]); + t(~"abc.hello.there", '.', 0u, ~[~"abc.hello.there"]); + t(~"abc.hello.there", '.', 1u, ~[~"abc", ~"hello.there"]); + t(~"abc.hello.there", '.', 2u, ~[~"abc", ~"hello", ~"there"]); + t(~"abc.hello.there", '.', 3u, ~[~"abc", ~"hello", ~"there"]); + t(~".hello.there", '.', 0u, ~[~".hello.there"]); + t(~".hello.there", '.', 1u, ~[~"", ~"hello.there"]); + t(~"...hello.there.", '.', 3u, ~[~"", ~"", ~"", ~"hello.there."]); + t(~"...hello.there.", '.', 5u, + ~[~"", ~"", ~"", ~"hello", ~"there", ~""]); - assert ~[""] == splitn_char("", 'z', 5u); - assert ~["",""] == splitn_char("z", 'z', 5u); - assert ~["ok"] == splitn_char("ok", 'z', 5u); - assert ~["z"] == splitn_char("z", 'z', 0u); - assert ~["w.x.y"] == splitn_char("w.x.y", '.', 0u); - assert ~["w","x.y"] == splitn_char("w.x.y", '.', 1u); + assert ~[~""] == splitn_char(~"", 'z', 5u); + assert ~[~"",~""] == splitn_char(~"z", 'z', 5u); + assert ~[~"ok"] == splitn_char(~"ok", 'z', 5u); + assert ~[~"z"] == splitn_char(~"z", 'z', 0u); + assert ~[~"w.x.y"] == splitn_char(~"w.x.y", '.', 0u); + assert ~[~"w",~"x.y"] == splitn_char(~"w.x.y", '.', 1u); } #[test] fn test_splitn_char_2 () { - let data = "ประเทศไทย中华Việt Nam"; - assert ~["ประเทศไทย中", "Việt Nam"] + let data = ~"ประเทศไทย中华Việt Nam"; + assert ~[~"ประเทศไทย中", ~"Việt Nam"] == splitn_char(data, '华', 1u); - assert ~["", "", "XXX", "YYYzWWWz"] - == splitn_char("zzXXXzYYYzWWWz", 'z', 3u); - assert ~["",""] == splitn_char("z", 'z', 5u); - assert ~[""] == splitn_char("", 'z', 5u); - assert ~["ok"] == splitn_char("ok", 'z', 5u); + assert ~[~"", ~"", ~"XXX", ~"YYYzWWWz"] + == splitn_char(~"zzXXXzYYYzWWWz", 'z', 3u); + assert ~[~"",~""] == splitn_char(~"z", 'z', 5u); + assert ~[~""] == splitn_char(~"", 'z', 5u); + assert ~[~"ok"] == splitn_char(~"ok", 'z', 5u); } #[test] fn test_splitn_char_3() { - let data = "ประเทศไทย中华Việt Nam"; - assert ~["ประเทศไทย中华", "iệt Nam"] + let data = ~"ประเทศไทย中华Việt Nam"; + assert ~[~"ประเทศไทย中华", ~"iệt Nam"] == splitn_char(data, 'V', 1u); - assert ~["ประเ", "ศไทย中华Việt Nam"] + assert ~[~"ประเ", ~"ศไทย中华Việt Nam"] == splitn_char(data, 'ท', 1u); } #[test] fn test_split_str() { - fn t(s: str, sep: str/&a, i: int, k: str) { + fn t(s: ~str, sep: &a/str, i: int, k: ~str) { let v = split_str(s, sep); assert eq(v[i], k); } - t("--1233345--", "12345", 0, "--1233345--"); - t("abc::hello::there", "::", 0, "abc"); - t("abc::hello::there", "::", 1, "hello"); - t("abc::hello::there", "::", 2, "there"); - t("::hello::there", "::", 0, ""); - t("hello::there::", "::", 2, ""); - t("::hello::there::", "::", 3, ""); + t(~"--1233345--", ~"12345", 0, ~"--1233345--"); + t(~"abc::hello::there", ~"::", 0, ~"abc"); + t(~"abc::hello::there", ~"::", 1, ~"hello"); + t(~"abc::hello::there", ~"::", 2, ~"there"); + t(~"::hello::there", ~"::", 0, ~""); + t(~"hello::there::", ~"::", 2, ~""); + t(~"::hello::there::", ~"::", 3, ~""); - let data = "ประเทศไทย中华Việt Nam"; - assert ~["ประเทศไทย", "Việt Nam"] - == split_str (data, "中华"); + let data = ~"ประเทศไทย中华Việt Nam"; + assert ~[~"ประเทศไทย", ~"Việt Nam"] + == split_str (data, ~"中华"); - assert ~["", "XXX", "YYY", ""] - == split_str("zzXXXzzYYYzz", "zz"); + assert ~[~"", ~"XXX", ~"YYY", ~""] + == split_str(~"zzXXXzzYYYzz", ~"zz"); - assert ~["zz", "zYYYz"] - == split_str("zzXXXzYYYz", "XXX"); + assert ~[~"zz", ~"zYYYz"] + == split_str(~"zzXXXzYYYz", ~"XXX"); - assert ~["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", "."); - assert ~[""] == split_str("", "."); - assert ~["",""] == split_str("zz", "zz"); - assert ~["ok"] == split_str("ok", "z"); - assert ~["","z"] == split_str("zzz", "zz"); - assert ~["","","z"] == split_str("zzzzz", "zz"); + assert ~[~"", ~"XXX", ~"YYY", ~""] == split_str(~".XXX.YYY.", ~"."); + assert ~[~""] == split_str(~"", ~"."); + assert ~[~"",~""] == split_str(~"zz", ~"zz"); + assert ~[~"ok"] == split_str(~"ok", ~"z"); + assert ~[~"",~"z"] == split_str(~"zzz", ~"zz"); + assert ~[~"",~"",~"z"] == split_str(~"zzzzz", ~"zz"); } #[test] fn test_split() { - let data = "ประเทศไทย中华Việt Nam"; - assert ~["ประเทศไทย中", "Việt Nam"] + let data = ~"ประเทศไทย中华Việt Nam"; + assert ~[~"ประเทศไทย中", ~"Việt Nam"] == split (data, |cc| cc == '华'); - assert ~["", "", "XXX", "YYY", ""] - == split("zzXXXzYYYz", char::is_lowercase); + assert ~[~"", ~"", ~"XXX", ~"YYY", ~""] + == split(~"zzXXXzYYYz", char::is_lowercase); - assert ~["zz", "", "", "z", "", "", "z"] - == split("zzXXXzYYYz", char::is_uppercase); + assert ~[~"zz", ~"", ~"", ~"z", ~"", ~"", ~"z"] + == split(~"zzXXXzYYYz", char::is_uppercase); - assert ~["",""] == split("z", |cc| cc == 'z'); - assert ~[""] == split("", |cc| cc == 'z'); - assert ~["ok"] == split("ok", |cc| cc == 'z'); + assert ~[~"",~""] == split(~"z", |cc| cc == 'z'); + assert ~[~""] == split(~"", |cc| cc == 'z'); + assert ~[~"ok"] == split(~"ok", |cc| cc == 'z'); } #[test] fn test_lines() { - let lf = "\nMary had a little lamb\nLittle lamb\n"; - let crlf = "\r\nMary had a little lamb\r\nLittle lamb\r\n"; + let lf = ~"\nMary had a little lamb\nLittle lamb\n"; + let crlf = ~"\r\nMary had a little lamb\r\nLittle lamb\r\n"; - assert ~["", "Mary had a little lamb", "Little lamb", ""] + assert ~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] == lines(lf); - assert ~["", "Mary had a little lamb", "Little lamb", ""] + assert ~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] == lines_any(lf); - assert ~["\r", "Mary had a little lamb\r", "Little lamb\r", ""] + assert ~[~"\r", ~"Mary had a little lamb\r", ~"Little lamb\r", ~""] == lines(crlf); - assert ~["", "Mary had a little lamb", "Little lamb", ""] + assert ~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] == lines_any(crlf); - assert ~[""] == lines (""); - assert ~[""] == lines_any(""); - assert ~["",""] == lines ("\n"); - assert ~["",""] == lines_any("\n"); - assert ~["banana"] == lines ("banana"); - assert ~["banana"] == lines_any("banana"); + assert ~[~""] == lines (~""); + assert ~[~""] == lines_any(~""); + assert ~[~"",~""] == lines (~"\n"); + assert ~[~"",~""] == lines_any(~"\n"); + assert ~[~"banana"] == lines (~"banana"); + assert ~[~"banana"] == lines_any(~"banana"); } #[test] fn test_words () { - let data = "\nMary had a little lamb\nLittle lamb\n"; - assert ~["Mary","had","a","little","lamb","Little","lamb"] + let data = ~"\nMary had a little lamb\nLittle lamb\n"; + assert ~[~"Mary",~"had",~"a",~"little",~"lamb",~"Little",~"lamb"] == words(data); - assert ~["ok"] == words("ok"); - assert ~[] == words(""); + assert ~[~"ok"] == words(~"ok"); + assert ~[] == words(~""); } #[test] fn test_find_str() { // byte positions - assert find_str("banana", "apple pie") == none; - assert find_str("", "") == some(0u); + assert find_str(~"banana", ~"apple pie") == none; + assert find_str(~"", ~"") == some(0u); - let data = "ประเทศไทย中华Việt Nam"; - assert find_str(data, "") == some(0u); - assert find_str(data, "ประเ") == some( 0u); - assert find_str(data, "ะเ") == some( 6u); - assert find_str(data, "中华") == some(27u); - assert find_str(data, "ไท华") == none; + let data = ~"ประเทศไทย中华Việt Nam"; + assert find_str(data, ~"") == some(0u); + assert find_str(data, ~"ประเ") == some( 0u); + assert find_str(data, ~"ะเ") == some( 6u); + assert find_str(data, ~"中华") == some(27u); + assert find_str(data, ~"ไท华") == none; } #[test] fn test_find_str_between() { // byte positions - assert find_str_between("", "", 0u, 0u) == some(0u); + assert find_str_between(~"", ~"", 0u, 0u) == some(0u); - let data = "abcabc"; - assert find_str_between(data, "ab", 0u, 6u) == some(0u); - assert find_str_between(data, "ab", 2u, 6u) == some(3u); - assert find_str_between(data, "ab", 2u, 4u) == none; + let data = ~"abcabc"; + assert find_str_between(data, ~"ab", 0u, 6u) == some(0u); + assert find_str_between(data, ~"ab", 2u, 6u) == some(3u); + assert find_str_between(data, ~"ab", 2u, 4u) == none; - let mut data = "ประเทศไทย中华Việt Nam"; + let mut data = ~"ประเทศไทย中华Việt Nam"; data += data; - assert find_str_between(data, "", 0u, 43u) == some(0u); - assert find_str_between(data, "", 6u, 43u) == some(6u); + assert find_str_between(data, ~"", 0u, 43u) == some(0u); + assert find_str_between(data, ~"", 6u, 43u) == some(6u); - assert find_str_between(data, "ประ", 0u, 43u) == some( 0u); - assert find_str_between(data, "ทศไ", 0u, 43u) == some(12u); - assert find_str_between(data, "ย中", 0u, 43u) == some(24u); - assert find_str_between(data, "iệt", 0u, 43u) == some(34u); - assert find_str_between(data, "Nam", 0u, 43u) == some(40u); + assert find_str_between(data, ~"ประ", 0u, 43u) == some( 0u); + assert find_str_between(data, ~"ทศไ", 0u, 43u) == some(12u); + assert find_str_between(data, ~"ย中", 0u, 43u) == some(24u); + assert find_str_between(data, ~"iệt", 0u, 43u) == some(34u); + assert find_str_between(data, ~"Nam", 0u, 43u) == some(40u); - assert find_str_between(data, "ประ", 43u, 86u) == some(43u); - assert find_str_between(data, "ทศไ", 43u, 86u) == some(55u); - assert find_str_between(data, "ย中", 43u, 86u) == some(67u); - assert find_str_between(data, "iệt", 43u, 86u) == some(77u); - assert find_str_between(data, "Nam", 43u, 86u) == some(83u); + assert find_str_between(data, ~"ประ", 43u, 86u) == some(43u); + assert find_str_between(data, ~"ทศไ", 43u, 86u) == some(55u); + assert find_str_between(data, ~"ย中", 43u, 86u) == some(67u); + assert find_str_between(data, ~"iệt", 43u, 86u) == some(77u); + assert find_str_between(data, ~"Nam", 43u, 86u) == some(83u); } #[test] fn test_substr() { - fn t(a: str, b: str, start: int) { + fn t(a: ~str, b: ~str, start: int) { assert (eq(substr(a, start as uint, len(b)), b)); } - t("hello", "llo", 2); - t("hello", "el", 1); - assert "ะเทศไท" == substr("ประเทศไทย中华Việt Nam", 6u, 6u); + t(~"hello", ~"llo", 2); + t(~"hello", ~"el", 1); + assert ~"ะเทศไท" == substr(~"ประเทศไทย中华Việt Nam", 6u, 6u); } #[test] fn test_concat() { - fn t(v: ~[str], s: str) { assert (eq(concat(v), s)); } - t(~["you", "know", "I'm", "no", "good"], "youknowI'mnogood"); - let v: ~[str] = ~[]; - t(v, ""); - t(~["hi"], "hi"); + fn t(v: ~[~str], s: ~str) { assert (eq(concat(v), s)); } + t(~[~"you", ~"know", ~"I'm", ~"no", ~"good"], ~"youknowI'mnogood"); + let v: ~[~str] = ~[]; + t(v, ~""); + t(~[~"hi"], ~"hi"); } #[test] fn test_connect() { - fn t(v: ~[str], sep: str, s: str) { + fn t(v: ~[~str], sep: ~str, s: ~str) { assert (eq(connect(v, sep), s)); } - t(~["you", "know", "I'm", "no", "good"], - " ", "you know I'm no good"); - let v: ~[str] = ~[]; - t(v, " ", ""); - t(~["hi"], " ", "hi"); + t(~[~"you", ~"know", ~"I'm", ~"no", ~"good"], + ~" ", ~"you know I'm no good"); + let v: ~[~str] = ~[]; + t(v, ~" ", ~""); + t(~[~"hi"], ~" ", ~"hi"); } #[test] @@ -2375,36 +2376,36 @@ fn test_to_upper() { // libc::toupper, and hence str::to_upper // are culturally insensitive: they only work for ASCII // (see Issue #1347) - let unicode = ""; //"\u65e5\u672c"; // uncomment once non-ASCII works - let input = "abcDEF" + unicode + "xyz:.;"; - let expected = "ABCDEF" + unicode + "XYZ:.;"; + let unicode = ~""; //"\u65e5\u672c"; // uncomment once non-ASCII works + let input = ~"abcDEF" + unicode + ~"xyz:.;"; + let expected = ~"ABCDEF" + unicode + ~"XYZ:.;"; let actual = to_upper(input); assert (eq(expected, actual)); } #[test] fn test_to_lower() { - assert "" == map("", |c| libc::tolower(c as c_char) as char); - assert "ymca" == map("YMCA", + assert ~"" == map(~"", |c| libc::tolower(c as c_char) as char); + assert ~"ymca" == map(~"YMCA", |c| libc::tolower(c as c_char) as char); } #[test] fn test_unsafe_slice() { unsafe { - assert (eq("ab", unsafe::slice_bytes("abc", 0u, 2u))); - assert (eq("bc", unsafe::slice_bytes("abc", 1u, 3u))); - assert (eq("", unsafe::slice_bytes("abc", 1u, 1u))); - fn a_million_letter_a() -> str { + assert (eq(~"ab", unsafe::slice_bytes(~"abc", 0u, 2u))); + assert (eq(~"bc", unsafe::slice_bytes(~"abc", 1u, 3u))); + assert (eq(~"", unsafe::slice_bytes(~"abc", 1u, 1u))); + fn a_million_letter_a() -> ~str { let mut i = 0; - let mut rs = ""; - while i < 100000 { push_str(rs, "aaaaaaaaaa"); i += 1; } + let mut rs = ~""; + while i < 100000 { push_str(rs, ~"aaaaaaaaaa"); i += 1; } ret rs; } - fn half_a_million_letter_a() -> str { + fn half_a_million_letter_a() -> ~str { let mut i = 0; - let mut rs = ""; - while i < 100000 { push_str(rs, "aaaaa"); i += 1; } + let mut rs = ~""; + while i < 100000 { push_str(rs, ~"aaaaa"); i += 1; } ret rs; } assert eq(half_a_million_letter_a(), @@ -2415,107 +2416,107 @@ fn half_a_million_letter_a() -> str { #[test] fn test_starts_with() { - assert (starts_with("", "")); - assert (starts_with("abc", "")); - assert (starts_with("abc", "a")); - assert (!starts_with("a", "abc")); - assert (!starts_with("", "abc")); + assert (starts_with(~"", ~"")); + assert (starts_with(~"abc", ~"")); + assert (starts_with(~"abc", ~"a")); + assert (!starts_with(~"a", ~"abc")); + assert (!starts_with(~"", ~"abc")); } #[test] fn test_ends_with() { - assert (ends_with("", "")); - assert (ends_with("abc", "")); - assert (ends_with("abc", "c")); - assert (!ends_with("a", "abc")); - assert (!ends_with("", "abc")); + assert (ends_with(~"", ~"")); + assert (ends_with(~"abc", ~"")); + assert (ends_with(~"abc", ~"c")); + assert (!ends_with(~"a", ~"abc")); + assert (!ends_with(~"", ~"abc")); } #[test] fn test_is_empty() { - assert (is_empty("")); - assert (!is_empty("a")); + assert (is_empty(~"")); + assert (!is_empty(~"a")); } #[test] fn test_is_not_empty() { - assert (is_not_empty("a")); - assert (!is_not_empty("")); + assert (is_not_empty(~"a")); + assert (!is_not_empty(~"")); } #[test] fn test_replace() { - let a = "a"; - assert replace("", a, "b") == ""; - assert replace("a", a, "b") == "b"; - assert replace("ab", a, "b") == "bb"; - let test = "test"; - assert replace(" test test ", test, "toast") == " toast toast "; - assert replace(" test test ", test, "") == " "; + let a = ~"a"; + assert replace(~"", a, ~"b") == ~""; + assert replace(~"a", a, ~"b") == ~"b"; + assert replace(~"ab", a, ~"b") == ~"bb"; + let test = ~"test"; + assert replace(~" test test ", test, ~"toast") == ~" toast toast "; + assert replace(~" test test ", test, ~"") == ~" "; } #[test] fn test_replace_2a() { - let data = "ประเทศไทย中华"; - let repl = "دولة الكويت"; + let data = ~"ประเทศไทย中华"; + let repl = ~"دولة الكويت"; - let a = "ประเ"; - let A = "دولة الكويتทศไทย中华"; + let a = ~"ประเ"; + let A = ~"دولة الكويتทศไทย中华"; assert (replace(data, a, repl) == A); } #[test] fn test_replace_2b() { - let data = "ประเทศไทย中华"; - let repl = "دولة الكويت"; + let data = ~"ประเทศไทย中华"; + let repl = ~"دولة الكويت"; - let b = "ะเ"; - let B = "ปรدولة الكويتทศไทย中华"; + let b = ~"ะเ"; + let B = ~"ปรدولة الكويتทศไทย中华"; assert (replace(data, b, repl) == B); } #[test] fn test_replace_2c() { - let data = "ประเทศไทย中华"; - let repl = "دولة الكويت"; + let data = ~"ประเทศไทย中华"; + let repl = ~"دولة الكويت"; - let c = "中华"; - let C = "ประเทศไทยدولة الكويت"; + let c = ~"中华"; + let C = ~"ประเทศไทยدولة الكويت"; assert (replace(data, c, repl) == C); } #[test] fn test_replace_2d() { - let data = "ประเทศไทย中华"; - let repl = "دولة الكويت"; + let data = ~"ประเทศไทย中华"; + let repl = ~"دولة الكويت"; - let d = "ไท华"; + let d = ~"ไท华"; assert (replace(data, d, repl) == data); } #[test] fn test_slice() { - assert (eq("ab", slice("abc", 0u, 2u))); - assert (eq("bc", slice("abc", 1u, 3u))); - assert (eq("", slice("abc", 1u, 1u))); - assert (eq("\u65e5", slice("\u65e5\u672c", 0u, 3u))); + assert (eq(~"ab", slice(~"abc", 0u, 2u))); + assert (eq(~"bc", slice(~"abc", 1u, 3u))); + assert (eq(~"", slice(~"abc", 1u, 1u))); + assert (eq(~"\u65e5", slice(~"\u65e5\u672c", 0u, 3u))); - let data = "ประเทศไทย中华"; - assert "ป" == slice(data, 0u, 3u); - assert "ร" == slice(data, 3u, 6u); - assert "" == slice(data, 3u, 3u); - assert "华" == slice(data, 30u, 33u); + let data = ~"ประเทศไทย中华"; + assert ~"ป" == slice(data, 0u, 3u); + assert ~"ร" == slice(data, 3u, 6u); + assert ~"" == slice(data, 3u, 3u); + assert ~"华" == slice(data, 30u, 33u); - fn a_million_letter_X() -> str { + fn a_million_letter_X() -> ~str { let mut i = 0; - let mut rs = ""; - while i < 100000 { push_str(rs, "华华华华华华华华华华"); i += 1; } + let mut rs = ~""; + while i < 100000 { push_str(rs, ~"华华华华华华华华华华"); i += 1; } ret rs; } - fn half_a_million_letter_X() -> str { + fn half_a_million_letter_X() -> ~str { let mut i = 0; - let mut rs = ""; - while i < 100000 { push_str(rs, "华华华华华"); i += 1; } + let mut rs = ~""; + while i < 100000 { push_str(rs, ~"华华华华华"); i += 1; } ret rs; } assert eq(half_a_million_letter_X(), @@ -2524,18 +2525,18 @@ fn half_a_million_letter_X() -> str { #[test] fn test_slice_2() { - let ss = "中华Việt Nam"; + let ss = ~"中华Việt Nam"; - assert "华" == slice(ss, 3u, 6u); - assert "Việt Nam" == slice(ss, 6u, 16u); + assert ~"华" == slice(ss, 3u, 6u); + assert ~"Việt Nam" == slice(ss, 6u, 16u); - assert "ab" == slice("abc", 0u, 2u); - assert "bc" == slice("abc", 1u, 3u); - assert "" == slice("abc", 1u, 1u); + assert ~"ab" == slice(~"abc", 0u, 2u); + assert ~"bc" == slice(~"abc", 1u, 3u); + assert ~"" == slice(~"abc", 1u, 1u); - assert "中" == slice(ss, 0u, 3u); - assert "华V" == slice(ss, 3u, 7u); - assert "" == slice(ss, 3u, 3u); + assert ~"中" == slice(ss, 0u, 3u); + assert ~"华V" == slice(ss, 3u, 7u); + assert ~"" == slice(ss, 3u, 3u); /*0: 中 3: 华 6: V @@ -2552,68 +2553,68 @@ fn test_slice_2() { #[should_fail] #[ignore(cfg(windows))] fn test_slice_fail() { - slice("中华Việt Nam", 0u, 2u); + slice(~"中华Việt Nam", 0u, 2u); } #[test] fn test_trim_left() { - assert (trim_left("") == ""); - assert (trim_left("a") == "a"); - assert (trim_left(" ") == ""); - assert (trim_left(" blah") == "blah"); - assert (trim_left(" \u3000 wut") == "wut"); - assert (trim_left("hey ") == "hey "); + assert (trim_left(~"") == ~""); + assert (trim_left(~"a") == ~"a"); + assert (trim_left(~" ") == ~""); + assert (trim_left(~" blah") == ~"blah"); + assert (trim_left(~" \u3000 wut") == ~"wut"); + assert (trim_left(~"hey ") == ~"hey "); } #[test] fn test_trim_right() { - assert (trim_right("") == ""); - assert (trim_right("a") == "a"); - assert (trim_right(" ") == ""); - assert (trim_right("blah ") == "blah"); - assert (trim_right("wut \u3000 ") == "wut"); - assert (trim_right(" hey") == " hey"); + assert (trim_right(~"") == ~""); + assert (trim_right(~"a") == ~"a"); + assert (trim_right(~" ") == ~""); + assert (trim_right(~"blah ") == ~"blah"); + assert (trim_right(~"wut \u3000 ") == ~"wut"); + assert (trim_right(~" hey") == ~" hey"); } #[test] fn test_trim() { - assert (trim("") == ""); - assert (trim("a") == "a"); - assert (trim(" ") == ""); - assert (trim(" blah ") == "blah"); - assert (trim("\nwut \u3000 ") == "wut"); - assert (trim(" hey dude ") == "hey dude"); + assert (trim(~"") == ~""); + assert (trim(~"a") == ~"a"); + assert (trim(~" ") == ~""); + assert (trim(~" blah ") == ~"blah"); + assert (trim(~"\nwut \u3000 ") == ~"wut"); + assert (trim(~" hey dude ") == ~"hey dude"); } #[test] fn test_is_whitespace() { - assert (is_whitespace("")); - assert (is_whitespace(" ")); - assert (is_whitespace("\u2009")); // Thin space - assert (is_whitespace(" \n\t ")); - assert (!is_whitespace(" _ ")); + assert (is_whitespace(~"")); + assert (is_whitespace(~" ")); + assert (is_whitespace(~"\u2009")); // Thin space + assert (is_whitespace(~" \n\t ")); + assert (!is_whitespace(~" _ ")); } #[test] fn test_is_ascii() { - assert (is_ascii("")); - assert (is_ascii("a")); - assert (!is_ascii("\u2009")); + assert (is_ascii(~"")); + assert (is_ascii(~"a")); + assert (!is_ascii(~"\u2009")); } #[test] fn test_shift_byte() { - let mut s = "ABC"; + let mut s = ~"ABC"; let b = unsafe { unsafe::shift_byte(s) }; - assert (s == "BC"); + assert (s == ~"BC"); assert (b == 65u8); } #[test] fn test_pop_byte() { - let mut s = "ABC"; + let mut s = ~"ABC"; let b = unsafe { unsafe::pop_byte(s) }; - assert (s == "AB"); + assert (s == ~"AB"); assert (b == 67u8); } @@ -2621,12 +2622,12 @@ fn test_pop_byte() { fn test_unsafe_from_bytes() { let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8]; let b = unsafe { unsafe::from_bytes(a) }; - assert (b == "AAAAAAA"); + assert (b == ~"AAAAAAA"); } #[test] fn test_from_bytes() { - let ss = "ศไทย中华Việt Nam"; + let ss = ~"ศไทย中华Việt Nam"; let bb = ~[0xe0_u8, 0xb8_u8, 0xa8_u8, 0xe0_u8, 0xb9_u8, 0x84_u8, 0xe0_u8, 0xb8_u8, 0x97_u8, @@ -2665,7 +2666,7 @@ fn test_from_buf() { let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; let b = vec::unsafe::to_ptr(a); let c = unsafe::from_buf(b); - assert (c == "AAAAAAA"); + assert (c == ~"AAAAAAA"); } } @@ -2674,12 +2675,12 @@ fn test_from_buf() { #[should_fail] fn test_as_bytes_fail() { // Don't double free - as_bytes::<()>("", |_bytes| fail ); + as_bytes::<()>(~"", |_bytes| fail ); } #[test] fn test_as_buf() { - let a = "Abcdefg"; + let a = ~"Abcdefg"; let b = as_buf(a, |buf| { assert unsafe { *buf } == 65u8; 100 @@ -2689,7 +2690,7 @@ fn test_as_buf() { #[test] fn test_as_buf_small() { - let a = "A"; + let a = ~"A"; let b = as_buf(a, |buf| { assert unsafe { *buf } == 65u8; 100 @@ -2700,7 +2701,7 @@ fn test_as_buf_small() { #[test] fn test_as_buf2() { unsafe { - let s = "hello"; + let s = ~"hello"; let sb = as_buf(s, |b| b); let s_cstr = unsafe::from_buf(sb); assert (eq(s_cstr, s)); @@ -2709,10 +2710,10 @@ fn test_as_buf2() { #[test] fn vec_str_conversions() { - let s1: str = "All mimsy were the borogoves"; + let s1: ~str = ~"All mimsy were the borogoves"; let v: ~[u8] = bytes(s1); - let s2: str = from_bytes(v); + let s2: ~str = from_bytes(v); let mut i: uint = 0u; let n1: uint = len(s1); let n2: uint = vec::len::(v); @@ -2729,33 +2730,33 @@ fn vec_str_conversions() { #[test] fn test_contains() { - assert contains("abcde", "bcd"); - assert contains("abcde", "abcd"); - assert contains("abcde", "bcde"); - assert contains("abcde", ""); - assert contains("", ""); - assert !contains("abcde", "def"); - assert !contains("", "a"); + assert contains(~"abcde", ~"bcd"); + assert contains(~"abcde", ~"abcd"); + assert contains(~"abcde", ~"bcde"); + assert contains(~"abcde", ~""); + assert contains(~"", ~""); + assert !contains(~"abcde", ~"def"); + assert !contains(~"", ~"a"); - let data = "ประเทศไทย中华Việt Nam"; - assert contains(data, "ประเ"); - assert contains(data, "ะเ"); - assert contains(data, "中华"); - assert !contains(data, "ไท华"); + let data = ~"ประเทศไทย中华Việt Nam"; + assert contains(data, ~"ประเ"); + assert contains(data, ~"ะเ"); + assert contains(data, ~"中华"); + assert !contains(data, ~"ไท华"); } #[test] fn test_contains_char() { - assert contains_char("abc", 'b'); - assert contains_char("a", 'a'); - assert !contains_char("abc", 'd'); - assert !contains_char("", 'a'); + assert contains_char(~"abc", 'b'); + assert contains_char(~"a", 'a'); + assert !contains_char(~"abc", 'd'); + assert !contains_char(~"", 'a'); } #[test] fn test_chars_iter() { let mut i = 0; - do chars_iter("x\u03c0y") |ch| { + do chars_iter(~"x\u03c0y") |ch| { alt check i { 0 { assert ch == 'x'; } 1 { assert ch == '\u03c0'; } @@ -2764,14 +2765,14 @@ fn test_chars_iter() { i += 1; } - chars_iter("", |_ch| fail ); // should not fail + chars_iter(~"", |_ch| fail ); // should not fail } #[test] fn test_bytes_iter() { let mut i = 0; - do bytes_iter("xyz") |bb| { + do bytes_iter(~"xyz") |bb| { alt check i { 0 { assert bb == 'x' as u8; } 1 { assert bb == 'y' as u8; } @@ -2780,21 +2781,21 @@ fn test_bytes_iter() { i += 1; } - bytes_iter("", |bb| assert bb == 0u8); + bytes_iter(~"", |bb| assert bb == 0u8); } #[test] fn test_split_char_iter() { - let data = "\nMary had a little lamb\nLittle lamb\n"; + let data = ~"\nMary had a little lamb\nLittle lamb\n"; let mut ii = 0; do split_char_iter(data, ' ') |xx| { alt ii { - 0 { assert "\nMary" == xx; } - 1 { assert "had" == xx; } - 2 { assert "a" == xx; } - 3 { assert "little" == xx; } + 0 { assert ~"\nMary" == xx; } + 1 { assert ~"had" == xx; } + 2 { assert ~"a" == xx; } + 3 { assert ~"little" == xx; } _ { () } } ii += 1; @@ -2803,15 +2804,15 @@ fn test_split_char_iter() { #[test] fn test_splitn_char_iter() { - let data = "\nMary had a little lamb\nLittle lamb\n"; + let data = ~"\nMary had a little lamb\nLittle lamb\n"; let mut ii = 0; do splitn_char_iter(data, ' ', 2u) |xx| { alt ii { - 0 { assert "\nMary" == xx; } - 1 { assert "had" == xx; } - 2 { assert "a little lamb\nLittle lamb\n" == xx; } + 0 { assert ~"\nMary" == xx; } + 1 { assert ~"had" == xx; } + 2 { assert ~"a little lamb\nLittle lamb\n" == xx; } _ { () } } ii += 1; @@ -2820,36 +2821,36 @@ fn test_splitn_char_iter() { #[test] fn test_words_iter() { - let data = "\nMary had a little lamb\nLittle lamb\n"; + let data = ~"\nMary had a little lamb\nLittle lamb\n"; let mut ii = 0; do words_iter(data) |ww| { alt ii { - 0 { assert "Mary" == ww; } - 1 { assert "had" == ww; } - 2 { assert "a" == ww; } - 3 { assert "little" == ww; } + 0 { assert ~"Mary" == ww; } + 1 { assert ~"had" == ww; } + 2 { assert ~"a" == ww; } + 3 { assert ~"little" == ww; } _ { () } } ii += 1; } - words_iter("", |_x| fail); // should not fail + words_iter(~"", |_x| fail); // should not fail } #[test] fn test_lines_iter () { - let lf = "\nMary had a little lamb\nLittle lamb\n"; + let lf = ~"\nMary had a little lamb\nLittle lamb\n"; let mut ii = 0; do lines_iter(lf) |x| { alt ii { - 0 { assert "" == x; } - 1 { assert "Mary had a little lamb" == x; } - 2 { assert "Little lamb" == x; } - 3 { assert "" == x; } + 0 { assert ~"" == x; } + 1 { assert ~"Mary had a little lamb" == x; } + 2 { assert ~"Little lamb" == x; } + 3 { assert ~"" == x; } _ { () } } ii += 1; @@ -2858,31 +2859,32 @@ fn test_lines_iter () { #[test] fn test_map() { - assert "" == map("", |c| libc::toupper(c as c_char) as char); - assert "YMCA" == map("ymca", |c| libc::toupper(c as c_char) as char); + assert ~"" == map(~"", |c| libc::toupper(c as c_char) as char); + assert ~"YMCA" == map(~"ymca", + |c| libc::toupper(c as c_char) as char); } #[test] fn test_all() { - assert true == all("", char::is_uppercase); - assert false == all("ymca", char::is_uppercase); - assert true == all("YMCA", char::is_uppercase); - assert false == all("yMCA", char::is_uppercase); - assert false == all("YMCy", char::is_uppercase); + assert true == all(~"", char::is_uppercase); + assert false == all(~"ymca", char::is_uppercase); + assert true == all(~"YMCA", char::is_uppercase); + assert false == all(~"yMCA", char::is_uppercase); + assert false == all(~"YMCy", char::is_uppercase); } #[test] fn test_any() { - assert false == any("", char::is_uppercase); - assert false == any("ymca", char::is_uppercase); - assert true == any("YMCA", char::is_uppercase); - assert true == any("yMCA", char::is_uppercase); - assert true == any("Ymcy", char::is_uppercase); + assert false == any(~"", char::is_uppercase); + assert false == any(~"ymca", char::is_uppercase); + assert true == any(~"YMCA", char::is_uppercase); + assert true == any(~"yMCA", char::is_uppercase); + assert true == any(~"Ymcy", char::is_uppercase); } #[test] fn test_chars() { - let ss = "ศไทย中华Việt Nam"; + let ss = ~"ศไทย中华Việt Nam"; assert ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'] == chars(ss); } @@ -2890,13 +2892,13 @@ fn test_chars() { #[test] fn test_utf16() { let pairs = - ~[("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n", + ~[(~"𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n", ~[0xd800_u16, 0xdf45_u16, 0xd800_u16, 0xdf3f_u16, 0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf46_u16, 0xd800_u16, 0xdf39_u16, 0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf30_u16, 0x000a_u16]), - ("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n", + (~"𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n", ~[0xd801_u16, 0xdc12_u16, 0xd801_u16, 0xdc49_u16, 0xd801_u16, 0xdc2e_u16, 0xd801_u16, 0xdc40_u16, 0xd801_u16, 0xdc32_u16, 0xd801_u16, @@ -2904,7 +2906,7 @@ fn test_utf16() { 0xd801_u16, 0xdc32_u16, 0xd801_u16, 0xdc4d_u16, 0x000a_u16]), - ("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n", + (~"𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n", ~[0xd800_u16, 0xdf00_u16, 0xd800_u16, 0xdf16_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16, 0xdf04_u16, 0xd800_u16, 0xdf11_u16, 0xd800_u16, 0xdf09_u16, @@ -2913,7 +2915,7 @@ fn test_utf16() { 0xdf04_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16, 0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]), - ("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n", + (~"𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n", ~[0xd801_u16, 0xdc8b_u16, 0xd801_u16, 0xdc98_u16, 0xd801_u16, 0xdc88_u16, 0xd801_u16, 0xdc91_u16, 0xd801_u16, 0xdc9b_u16, 0xd801_u16, 0xdc92_u16, @@ -2937,7 +2939,7 @@ fn test_utf16() { #[test] fn test_each_char() { - let s = "abc"; + let s = ~"abc"; let mut found_b = false; for each_char(s) |ch| { if ch == 'b' { @@ -2950,7 +2952,7 @@ fn test_each_char() { #[test] fn test_unpack_slice() { - let a = "hello"; + let a = ~"hello"; do unpack_slice(a) |buf, len| { unsafe { assert a[0] == 'h' as u8; @@ -2964,29 +2966,29 @@ fn test_unpack_slice() { #[test] fn test_escape_unicode() { - assert escape_unicode("abc") == "\\x61\\x62\\x63"; - assert escape_unicode("a c") == "\\x61\\x20\\x63"; - assert escape_unicode("\r\n\t") == "\\x0d\\x0a\\x09"; - assert escape_unicode("'\"\\") == "\\x27\\x22\\x5c"; - assert escape_unicode("\x00\x01\xfe\xff") == "\\x00\\x01\\xfe\\xff"; - assert escape_unicode("\u0100\uffff") == "\\u0100\\uffff"; - assert escape_unicode("\U00010000\U0010ffff") == - "\\U00010000\\U0010ffff"; - assert escape_unicode("ab\ufb00") == "\\x61\\x62\\ufb00"; - assert escape_unicode("\U0001d4ea\r") == "\\U0001d4ea\\x0d"; + assert escape_unicode(~"abc") == ~"\\x61\\x62\\x63"; + assert escape_unicode(~"a c") == ~"\\x61\\x20\\x63"; + assert escape_unicode(~"\r\n\t") == ~"\\x0d\\x0a\\x09"; + assert escape_unicode(~"'\"\\") == ~"\\x27\\x22\\x5c"; + assert escape_unicode(~"\x00\x01\xfe\xff") == ~"\\x00\\x01\\xfe\\xff"; + assert escape_unicode(~"\u0100\uffff") == ~"\\u0100\\uffff"; + assert escape_unicode(~"\U00010000\U0010ffff") == + ~"\\U00010000\\U0010ffff"; + assert escape_unicode(~"ab\ufb00") == ~"\\x61\\x62\\ufb00"; + assert escape_unicode(~"\U0001d4ea\r") == ~"\\U0001d4ea\\x0d"; } #[test] fn test_escape_default() { - assert escape_default("abc") == "abc"; - assert escape_default("a c") == "a c"; - assert escape_default("\r\n\t") == "\\r\\n\\t"; - assert escape_default("'\"\\") == "\\'\\\"\\\\"; - assert escape_default("\u0100\uffff") == "\\u0100\\uffff"; - assert escape_default("\U00010000\U0010ffff") == - "\\U00010000\\U0010ffff"; - assert escape_default("ab\ufb00") == "ab\\ufb00"; - assert escape_default("\U0001d4ea\r") == "\\U0001d4ea\\r"; + assert escape_default(~"abc") == ~"abc"; + assert escape_default(~"a c") == ~"a c"; + assert escape_default(~"\r\n\t") == ~"\\r\\n\\t"; + assert escape_default(~"'\"\\") == ~"\\'\\\"\\\\"; + assert escape_default(~"\u0100\uffff") == ~"\\u0100\\uffff"; + assert escape_default(~"\U00010000\U0010ffff") == + ~"\\U00010000\\U0010ffff"; + assert escape_default(~"ab\ufb00") == ~"ab\\ufb00"; + assert escape_default(~"\U0001d4ea\r") == ~"\\U0001d4ea\\r"; } } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 7f3e49de5510..0e5a39e859e5 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -20,7 +20,7 @@ enum type_desc = { #[abi = "cdecl"] extern mod rustrt { fn unsupervise(); - pure fn shape_log_str(t: *sys::type_desc, data: *()) -> str; + pure fn shape_log_str(t: *sys::type_desc, data: *()) -> ~str; fn rust_create_cond_lock() -> rust_cond_lock; fn rust_destroy_cond_lock(lock: rust_cond_lock); @@ -77,7 +77,7 @@ enum type_desc = { } } -pure fn log_str(t: T) -> str { +pure fn log_str(t: T) -> ~str { unsafe { let data_ptr: *() = unsafe::reinterpret_cast(ptr::addr_of(t)); rustrt::shape_log_str(get_type_desc::(), data_ptr) diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 474f7f14969e..b9a642c16b51 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -520,7 +520,7 @@ fn yield() { let mut killed = false; rustrt::rust_task_yield(task_, killed); if killed && !failing() { - fail "killed"; + fail ~"killed"; } } @@ -782,20 +782,20 @@ fn make_child_wrapper(child_task: *rust_task, -child_tg: taskgroup_arc, fn new_task_in_new_sched(opts: sched_opts) -> *rust_task { if opts.foreign_stack_size != none { - fail "foreign_stack_size scheduler option unimplemented"; + fail ~"foreign_stack_size scheduler option unimplemented"; } let num_threads = alt opts.mode { single_threaded { 1u } thread_per_core { - fail "thread_per_core scheduling mode unimplemented" + fail ~"thread_per_core scheduling mode unimplemented" } thread_per_task { - fail "thread_per_task scheduling mode unimplemented" + fail ~"thread_per_task scheduling mode unimplemented" } manual_threads(threads) { if threads == 0u { - fail "can not create a scheduler with no threads"; + fail ~"can not create a scheduler with no threads"; } threads } @@ -1146,21 +1146,21 @@ fn test_spawn_listiner_bidi() { // Now the child has a port called 'po' to read from and // an environment-captured channel called 'ch'. let res = comm::recv(po); - assert res == "ping"; - comm::send(ch, "pong"); + assert res == ~"ping"; + comm::send(ch, ~"pong"); }; // Likewise, the parent has both a 'po' and 'ch' - comm::send(ch, "ping"); + comm::send(ch, ~"ping"); let res = comm::recv(po); - assert res == "pong"; + assert res == ~"pong"; } #[test] fn test_try_success() { alt do try { - "Success!" + ~"Success!" } { - result::ok("Success!") { } + result::ok(~"Success!") { } _ { fail; } } } @@ -1466,54 +1466,54 @@ fn test_unkillable_nested() { #[test] fn test_tls_multitask() unsafe { - fn my_key(+_x: @str/~) { } - local_data_set(my_key, @"parent data"); + fn my_key(+_x: @~str) { } + local_data_set(my_key, @~"parent data"); do task::spawn { assert local_data_get(my_key) == none; // TLS shouldn't carry over. - local_data_set(my_key, @"child data"); - assert *(local_data_get(my_key).get()) == "child data"; + local_data_set(my_key, @~"child data"); + assert *(local_data_get(my_key).get()) == ~"child data"; // should be cleaned up for us } // Must work multiple times - assert *(local_data_get(my_key).get()) == "parent data"; - assert *(local_data_get(my_key).get()) == "parent data"; - assert *(local_data_get(my_key).get()) == "parent data"; + assert *(local_data_get(my_key).get()) == ~"parent data"; + assert *(local_data_get(my_key).get()) == ~"parent data"; + assert *(local_data_get(my_key).get()) == ~"parent data"; } #[test] fn test_tls_overwrite() unsafe { - fn my_key(+_x: @str/~) { } - local_data_set(my_key, @"first data"); - local_data_set(my_key, @"next data"); // Shouldn't leak. - assert *(local_data_get(my_key).get()) == "next data"; + fn my_key(+_x: @~str) { } + local_data_set(my_key, @~"first data"); + local_data_set(my_key, @~"next data"); // Shouldn't leak. + assert *(local_data_get(my_key).get()) == ~"next data"; } #[test] fn test_tls_pop() unsafe { - fn my_key(+_x: @str/~) { } - local_data_set(my_key, @"weasel"); - assert *(local_data_pop(my_key).get()) == "weasel"; + fn my_key(+_x: @~str) { } + local_data_set(my_key, @~"weasel"); + assert *(local_data_pop(my_key).get()) == ~"weasel"; // Pop must remove the data from the map. assert local_data_pop(my_key) == none; } #[test] fn test_tls_modify() unsafe { - fn my_key(+_x: @str/~) { } + fn my_key(+_x: @~str) { } local_data_modify(my_key, |data| { alt data { - some(@val) { fail "unwelcome value: " + val } - none { some(@"first data") } + some(@val) { fail ~"unwelcome value: " + val } + none { some(@~"first data") } } }); local_data_modify(my_key, |data| { alt data { - some(@"first data") { some(@"next data") } - some(@val) { fail "wrong value: " + val } - none { fail "missing value" } + some(@~"first data") { some(@~"next data") } + some(@val) { fail ~"wrong value: " + val } + none { fail ~"missing value" } } }); - assert *(local_data_pop(my_key).get()) == "next data"; + assert *(local_data_pop(my_key).get()) == ~"next data"; } #[test] @@ -1523,19 +1523,19 @@ fn test_tls_crust_automorestack_memorial_bug() unsafe { // jump over to the rust stack, which causes next_c_sp to get recorded as // something within a rust stack segment. Then a subsequent upcall (esp. // for logging, think vsnprintf) would run on a stack smaller than 1 MB. - fn my_key(+_x: @str/~) { } + fn my_key(+_x: @~str) { } do task::spawn { - unsafe { local_data_set(my_key, @"hax"); } + unsafe { local_data_set(my_key, @~"hax"); } } } #[test] fn test_tls_multiple_types() unsafe { - fn str_key(+_x: @str/~) { } + fn str_key(+_x: @~str) { } fn box_key(+_x: @@()) { } fn int_key(+_x: @int) { } do task::spawn { - local_data_set(str_key, @"string data"); + local_data_set(str_key, @~"string data"); local_data_set(box_key, @@()); local_data_set(int_key, @42); } @@ -1543,11 +1543,11 @@ fn int_key(+_x: @int) { } #[test] fn test_tls_overwrite_multiple_types() unsafe { - fn str_key(+_x: @str/~) { } + fn str_key(+_x: @~str) { } fn box_key(+_x: @@()) { } fn int_key(+_x: @int) { } do task::spawn { - local_data_set(str_key, @"string data"); + local_data_set(str_key, @~"string data"); local_data_set(int_key, @42); // This could cause a segfault if overwriting-destruction is done with // the crazy polymorphic transmute rather than the provided finaliser. @@ -1559,13 +1559,13 @@ fn int_key(+_x: @int) { } #[should_fail] #[ignore(cfg(windows))] fn test_tls_cleanup_on_failure() unsafe { - fn str_key(+_x: @str/~) { } + fn str_key(+_x: @~str) { } fn box_key(+_x: @@()) { } fn int_key(+_x: @int) { } - local_data_set(str_key, @"parent data"); + local_data_set(str_key, @~"parent data"); local_data_set(box_key, @@()); do task::spawn { // spawn_linked - local_data_set(str_key, @"string data"); + local_data_set(str_key, @~"string data"); local_data_set(box_key, @@()); local_data_set(int_key, @42); fail; diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index 3c56a6fd4f1c..0daeff819751 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -10,10 +10,10 @@ impl of to_bytes for @~[u8] { fn to_bytes() -> ~[u8] { copy *self } } -impl of to_bytes for str { +impl of to_bytes for ~str { fn to_bytes() -> ~[u8] { str::bytes(self) } } -impl of to_bytes for @(str/~) { +impl of to_bytes for @(~str) { fn to_bytes() -> ~[u8] { str::bytes(*self) } } diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 572c028a30e6..138a408435a5 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -1,67 +1,67 @@ -iface to_str { fn to_str() -> str; } +iface to_str { fn to_str() -> ~str; } impl of to_str for int { - fn to_str() -> str { int::str(self) } + fn to_str() -> ~str { int::str(self) } } impl of to_str for i8 { - fn to_str() -> str { i8::str(self) } + fn to_str() -> ~str { i8::str(self) } } impl of to_str for i16 { - fn to_str() -> str { i16::str(self) } + fn to_str() -> ~str { i16::str(self) } } impl of to_str for i32 { - fn to_str() -> str { i32::str(self) } + fn to_str() -> ~str { i32::str(self) } } impl of to_str for i64 { - fn to_str() -> str { i64::str(self) } + fn to_str() -> ~str { i64::str(self) } } impl of to_str for uint { - fn to_str() -> str { uint::str(self) } + fn to_str() -> ~str { uint::str(self) } } impl of to_str for u8 { - fn to_str() -> str { u8::str(self) } + fn to_str() -> ~str { u8::str(self) } } impl of to_str for u16 { - fn to_str() -> str { u16::str(self) } + fn to_str() -> ~str { u16::str(self) } } impl of to_str for u32 { - fn to_str() -> str { u32::str(self) } + fn to_str() -> ~str { u32::str(self) } } impl of to_str for u64 { - fn to_str() -> str { u64::str(self) } + fn to_str() -> ~str { u64::str(self) } } impl of to_str for float { - fn to_str() -> str { float::to_str(self, 4u) } + fn to_str() -> ~str { float::to_str(self, 4u) } } impl of to_str for bool { - fn to_str() -> str { bool::to_str(self) } + fn to_str() -> ~str { bool::to_str(self) } } impl of to_str for () { - fn to_str() -> str { "()" } + fn to_str() -> ~str { ~"()" } } -impl of to_str for str { - fn to_str() -> str { self } +impl of to_str for ~str { + fn to_str() -> ~str { self } } impl of to_str for (A, B) { - fn to_str() -> str { + fn to_str() -> ~str { let (a, b) = self; - "(" + a.to_str() + ", " + b.to_str() + ")" + ~"(" + a.to_str() + ~", " + b.to_str() + ~")" } } impl of to_str for (A, B, C){ - fn to_str() -> str { + fn to_str() -> ~str { let (a, b, c) = self; - "(" + a.to_str() + ", " + b.to_str() + ", " + c.to_str() + ")" + ~"(" + a.to_str() + ~", " + b.to_str() + ~", " + c.to_str() + ~")" } } impl of to_str for ~[A] { - fn to_str() -> str { - let mut acc = "[", first = true; + fn to_str() -> ~str { + let mut acc = ~"[", first = true; for vec::each(self) |elt| { if first { first = false; } - else { str::push_str(acc, ", "); } + else { str::push_str(acc, ~", "); } str::push_str(acc, elt.to_str()); } str::push_char(acc, ']'); @@ -70,47 +70,47 @@ fn to_str() -> str { } impl of to_str for @A { - fn to_str() -> str { "@" + (*self).to_str() } + fn to_str() -> ~str { ~"@" + (*self).to_str() } } impl of to_str for ~A { - fn to_str() -> str { "~" + (*self).to_str() } + fn to_str() -> ~str { ~"~" + (*self).to_str() } } #[cfg(test)] mod tests { #[test] fn test_simple_types() { - assert 1.to_str() == "1"; - assert (-1).to_str() == "-1"; - assert 200u.to_str() == "200"; - assert 2u8.to_str() == "2"; - assert true.to_str() == "true"; - assert false.to_str() == "false"; - assert ().to_str() == "()"; - assert "hi".to_str() == "hi"; + assert 1.to_str() == ~"1"; + assert (-1).to_str() == ~"-1"; + assert 200u.to_str() == ~"200"; + assert 2u8.to_str() == ~"2"; + assert true.to_str() == ~"true"; + assert false.to_str() == ~"false"; + assert ().to_str() == ~"()"; + assert (~"hi").to_str() == ~"hi"; } #[test] fn test_tuple_types() { - assert (1, 2).to_str() == "(1, 2)"; - assert ("a", "b", false).to_str() == "(a, b, false)"; - assert ((), ((), 100)).to_str() == "((), ((), 100))"; + assert (1, 2).to_str() == ~"(1, 2)"; + assert (~"a", ~"b", false).to_str() == ~"(a, b, false)"; + assert ((), ((), 100)).to_str() == ~"((), ((), 100))"; } #[test] #[ignore] fn test_vectors() { let x: ~[int] = ~[]; - assert x.to_str() == "~[]"; - assert (~[1]).to_str() == "~[1]"; - assert (~[1, 2, 3]).to_str() == "~[1, 2, 3]"; + assert x.to_str() == ~"~[]"; + assert (~[1]).to_str() == ~"~[1]"; + assert (~[1, 2, 3]).to_str() == ~"~[1, 2, 3]"; assert (~[~[], ~[1], ~[1, 1]]).to_str() == - "~[~[], ~[1], ~[1, 1]]"; + ~"~[~[], ~[1], ~[1, 1]]"; } #[test] fn test_pointer_types() { - assert (@1).to_str() == "@1"; - assert (~(true, false)).to_str() == "~(true, false)"; + assert (@1).to_str() == ~"@1"; + assert (~(true, false)).to_str() == ~"~(true, false)"; } } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index d50ee4ac6872..fe6f15f5d690 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -22,7 +22,7 @@ #[test] fn test_tuple() { assert first((948, 4039.48)) == 948; - assert second((34.5, "foo")) == "foo"; + assert second((34.5, ~"foo")) == ~"foo"; assert swap(('a', 2)) == (2, 'a'); } diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 0433cd7ce30b..7c4244efd9bd 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -121,10 +121,10 @@ fn times(it: fn() -> bool) { } /// Parse a string to an int -fn from_str(s: str) -> option { parse_buf(str::bytes(s), 10u) } +fn from_str(s: ~str) -> option { parse_buf(str::bytes(s), 10u) } /// Parse a string as an unsigned integer. -fn from_str_radix(buf: str, radix: u64) -> option { +fn from_str_radix(buf: ~str, radix: u64) -> option { if str::len(buf) == 0u { ret none; } let mut i = str::len(buf) - 1u; let mut power = 1u64, n = 0u64; @@ -146,7 +146,7 @@ fn from_str_radix(buf: str, radix: u64) -> option { * * Fails if `radix` < 2 or `radix` > 16 */ -fn to_str(num: T, radix: uint) -> str { +fn to_str(num: T, radix: uint) -> ~str { do to_str_bytes(false, num, radix) |slice| { do vec::unpack_slice(slice) |p, len| { unsafe { str::unsafe::from_buf_len(p, len) } @@ -220,46 +220,46 @@ fn digit(n: T) -> u8 { } /// Convert to a string -fn str(i: T) -> str { ret to_str(i, 10u); } +fn str(i: T) -> ~str { ret to_str(i, 10u); } #[test] fn test_to_str() { - assert to_str(0 as T, 10u) == "0"; - assert to_str(1 as T, 10u) == "1"; - assert to_str(2 as T, 10u) == "2"; - assert to_str(11 as T, 10u) == "11"; - assert to_str(11 as T, 16u) == "b"; - assert to_str(255 as T, 16u) == "ff"; - assert to_str(0xff as T, 10u) == "255"; + assert to_str(0 as T, 10u) == ~"0"; + assert to_str(1 as T, 10u) == ~"1"; + assert to_str(2 as T, 10u) == ~"2"; + assert to_str(11 as T, 10u) == ~"11"; + assert to_str(11 as T, 16u) == ~"b"; + assert to_str(255 as T, 16u) == ~"ff"; + assert to_str(0xff as T, 10u) == ~"255"; } #[test] #[ignore] fn test_from_str() { - assert from_str("0") == some(0u as T); - assert from_str("3") == some(3u as T); - assert from_str("10") == some(10u as T); - assert from_str("123456789") == some(123456789u as T); - assert from_str("00100") == some(100u as T); + assert from_str(~"0") == some(0u as T); + assert from_str(~"3") == some(3u as T); + assert from_str(~"10") == some(10u as T); + assert from_str(~"123456789") == some(123456789u as T); + assert from_str(~"00100") == some(100u as T); - assert from_str("") == none; - assert from_str(" ") == none; - assert from_str("x") == none; + assert from_str(~"") == none; + assert from_str(~" ") == none; + assert from_str(~"x") == none; } #[test] #[ignore] fn test_parse_buf() { import str::bytes; - assert parse_buf(bytes("123"), 10u) == some(123u as T); - assert parse_buf(bytes("1001"), 2u) == some(9u as T); - assert parse_buf(bytes("123"), 8u) == some(83u as T); - assert parse_buf(bytes("123"), 16u) == some(291u as T); - assert parse_buf(bytes("ffff"), 16u) == some(65535u as T); - assert parse_buf(bytes("z"), 36u) == some(35u as T); + assert parse_buf(bytes(~"123"), 10u) == some(123u as T); + assert parse_buf(bytes(~"1001"), 2u) == some(9u as T); + assert parse_buf(bytes(~"123"), 8u) == some(83u as T); + assert parse_buf(bytes(~"123"), 16u) == some(291u as T); + assert parse_buf(bytes(~"ffff"), 16u) == some(65535u as T); + assert parse_buf(bytes(~"z"), 36u) == some(35u as T); - assert parse_buf(str::bytes("Z"), 10u) == none; - assert parse_buf(str::bytes("_"), 2u) == none; + assert parse_buf(str::bytes(~"Z"), 10u) == none; + assert parse_buf(str::bytes(~"_"), 2u) == none; } #[test] diff --git a/src/libcore/unsafe.rs b/src/libcore/unsafe.rs index 0a62e77c410e..343fca55813e 100644 --- a/src/libcore/unsafe.rs +++ b/src/libcore/unsafe.rs @@ -58,13 +58,13 @@ fn test_reinterpret_cast() { #[test] fn test_bump_box_refcount() { unsafe { - let box = @"box box box"; // refcount 1 + let box = @~"box box box"; // refcount 1 bump_box_refcount(box); // refcount 2 let ptr: *int = transmute(box); // refcount 2 - let _box1: @str/~ = reinterpret_cast(ptr); - let _box2: @str/~ = reinterpret_cast(ptr); - assert *_box1 == "box box box"; - assert *_box2 == "box box box"; + let _box1: @~str = reinterpret_cast(ptr); + let _box2: @~str = reinterpret_cast(ptr); + assert *_box1 == ~"box box box"; + assert *_box2 == ~"box box box"; // Will destroy _box1 and _box2. Without the bump, this would // use-after-free. With too many bumps, it would leak. } @@ -83,7 +83,7 @@ fn test_transmute() { #[test] fn test_transmute2() { unsafe { - assert transmute("L") == ~[76u8, 0u8]; + assert transmute(~"L") == ~[76u8, 0u8]; } } } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index c08a93cd63a4..475f15576102 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -239,7 +239,7 @@ fn from_mut(+v: ~[mut T]) -> ~[T] { /// Returns the last element of the slice `v`, failing if the slice is empty. pure fn last(v: &[const T]) -> T { - if len(v) == 0u { fail "last_unsafe: empty vector" } + if len(v) == 0u { fail ~"last_unsafe: empty vector" } v[len(v) - 1u] } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 3ca34c4b7569..e2c8ad31344d 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -1,17 +1,17 @@ import io::{reader, reader_util}; iface to_base64 { - fn to_base64() -> str; + fn to_base64() -> ~str; } impl of to_base64 for ~[u8] { - fn to_base64() -> str { + fn to_base64() -> ~str { let chars = str::chars( - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + ~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ); let len = self.len(); - let mut s = ""; + let mut s = ~""; str::reserve(s, ((len + 3u) / 4u) * 3u); let mut i = 0u; @@ -52,8 +52,8 @@ fn to_base64() -> str { } } -impl of to_base64 for str { - fn to_base64() -> str { +impl of to_base64 for ~str { + fn to_base64() -> ~str { str::bytes(self).to_base64() } } @@ -64,7 +64,7 @@ fn to_base64() -> str { impl of from_base64 for ~[u8] { fn from_base64() -> ~[u8] { - if self.len() % 4u != 0u { fail "invalid base64 length"; } + if self.len() % 4u != 0u { fail ~"invalid base64 length"; } let len = self.len(); let mut padding = 0u; @@ -107,11 +107,11 @@ fn from_base64() -> ~[u8] { ret copy r; } _ { - fail "invalid base64 padding"; + fail ~"invalid base64 padding"; } } } else { - fail "invalid base64 character"; + fail ~"invalid base64 character"; } i += 1u; @@ -126,7 +126,7 @@ fn from_base64() -> ~[u8] { } } -impl of from_base64 for str { +impl of from_base64 for ~str { fn from_base64() -> ~[u8] { str::bytes(self).from_base64() } @@ -136,23 +136,23 @@ fn from_base64() -> ~[u8] { mod tests { #[test] fn test_to_base64() { - assert "".to_base64() == ""; - assert "f".to_base64() == "Zg=="; - assert "fo".to_base64() == "Zm8="; - assert "foo".to_base64() == "Zm9v"; - assert "foob".to_base64() == "Zm9vYg=="; - assert "fooba".to_base64() == "Zm9vYmE="; - assert "foobar".to_base64() == "Zm9vYmFy"; + assert (~"").to_base64() == ~""; + assert (~"f").to_base64() == ~"Zg=="; + assert (~"fo").to_base64() == ~"Zm8="; + assert (~"foo").to_base64() == ~"Zm9v"; + assert (~"foob").to_base64() == ~"Zm9vYg=="; + assert (~"fooba").to_base64() == ~"Zm9vYmE="; + assert (~"foobar").to_base64() == ~"Zm9vYmFy"; } #[test] fn test_from_base64() { - assert "".from_base64() == str::bytes(""); - assert "Zg==".from_base64() == str::bytes("f"); - assert "Zm8=".from_base64() == str::bytes("fo"); - assert "Zm9v".from_base64() == str::bytes("foo"); - assert "Zm9vYg==".from_base64() == str::bytes("foob"); - assert "Zm9vYmE=".from_base64() == str::bytes("fooba"); - assert "Zm9vYmFy".from_base64() == str::bytes("foobar"); + assert (~"").from_base64() == str::bytes(~""); + assert (~"Zg==").from_base64() == str::bytes(~"f"); + assert (~"Zm8=").from_base64() == str::bytes(~"fo"); + assert (~"Zm9v").from_base64() == str::bytes(~"foo"); + assert (~"Zm9vYg==").from_base64() == str::bytes(~"foob"); + assert (~"Zm9vYmE=").from_base64() == str::bytes(~"fooba"); + assert (~"Zm9vYmFy").from_base64() == str::bytes(~"foobar"); } } diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index f6c7b573f65e..3816e415b963 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -213,9 +213,9 @@ fn each_storage(v: bitv, op: fn(&uint) -> bool) { * The resulting string has the same length as the bitvector, and each * character is either '0' or '1'. */ -fn to_str(v: bitv) -> str { - let mut rs = ""; - for each(v) |i| { if i { rs += "1"; } else { rs += "0"; } } +fn to_str(v: bitv) -> ~str { + let mut rs = ~""; + for each(v) |i| { if i { rs += ~"1"; } else { rs += ~"0"; } } ret rs; } @@ -243,10 +243,10 @@ mod tests { #[test] fn test_to_str() { let zerolen = bitv(0u, false); - assert to_str(zerolen) == ""; + assert to_str(zerolen) == ~""; let eightbits = bitv(8u, false); - assert to_str(eightbits) == "00000000"; + assert to_str(eightbits) == ~"00000000"; } #[test] diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 69a4920a4ae1..5f833a20e326 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -127,7 +127,7 @@ fn with_doc_data(d: doc, f: fn(x: &[u8]) -> T) -> T { ret f(vec::slice::(*d.data, d.start, d.end)); } -fn doc_as_str(d: doc) -> str { ret str::from_bytes(doc_data(d)); } +fn doc_as_str(d: doc) -> ~str { ret str::from_bytes(doc_data(d)); } fn doc_as_u8(d: doc) -> u8 { assert d.end == d.start + 1u; @@ -271,7 +271,7 @@ fn wr_tagged_i8(tag_id: uint, v: i8) { self.wr_tagged_bytes(tag_id, &[v as u8]); } - fn wr_tagged_str(tag_id: uint, v: str) { + fn wr_tagged_str(tag_id: uint, v: ~str) { // Lame: can't use str::as_bytes() here because the resulting // vector is NULL-terminated. Annoyingly, the underlying // writer interface doesn't permit us to write a slice of a @@ -286,7 +286,7 @@ fn wr_bytes(b: &[u8]) { self.writer.write(b); } - fn wr_str(s: str) { + fn wr_str(s: ~str) { #debug["Write str: %?", s]; self.writer.write(str::bytes(s)); } @@ -320,7 +320,7 @@ fn _emit_tagged_uint(t: ebml_serializer_tag, v: uint) { self.wr_tagged_u32(t as uint, v as u32); } - fn _emit_label(label: str) { + fn _emit_label(label: ~str) { // There are various strings that we have access to, such as // the name of a record field, which do not actually appear in // the serialized EBML (normally). This is just for @@ -345,17 +345,17 @@ fn _emit_label(label: str) { fn emit_bool(v: bool) { self.wr_tagged_u8(es_bool as uint, v as u8) } // FIXME (#2742): implement these - fn emit_f64(_v: f64) { fail "Unimplemented: serializing an f64"; } - fn emit_f32(_v: f32) { fail "Unimplemented: serializing an f32"; } - fn emit_float(_v: float) { fail "Unimplemented: serializing a float"; } + fn emit_f64(_v: f64) { fail ~"Unimplemented: serializing an f64"; } + fn emit_f32(_v: f32) { fail ~"Unimplemented: serializing an f32"; } + fn emit_float(_v: float) { fail ~"Unimplemented: serializing a float"; } - fn emit_str(v: str) { self.wr_tagged_str(es_str as uint, v) } + fn emit_str(v: ~str) { self.wr_tagged_str(es_str as uint, v) } - fn emit_enum(name: str, f: fn()) { + fn emit_enum(name: ~str, f: fn()) { self._emit_label(name); self.wr_tag(es_enum as uint, f) } - fn emit_enum_variant(_v_name: str, v_id: uint, _cnt: uint, f: fn()) { + fn emit_enum_variant(_v_name: ~str, v_id: uint, _cnt: uint, f: fn()) { self._emit_tagged_uint(es_enum_vid, v_id); self.wr_tag(es_enum_body as uint, f) } @@ -375,7 +375,7 @@ fn emit_vec_elt(_idx: uint, f: fn()) { fn emit_box(f: fn()) { f() } fn emit_uniq(f: fn()) { f() } fn emit_rec(f: fn()) { f() } - fn emit_rec_field(f_name: str, _f_idx: uint, f: fn()) { + fn emit_rec_field(f_name: ~str, _f_idx: uint, f: fn()) { self._emit_label(f_name); f() } @@ -391,7 +391,7 @@ fn ebml_deserializer(d: ebml::doc) -> ebml_deserializer { } impl deserializer of serialization::deserializer for ebml_deserializer { - fn _check_label(lbl: str) { + fn _check_label(lbl: ~str) { if self.pos < self.parent.end { let {tag: r_tag, doc: r_doc} = ebml::doc_at(self.parent.data, self.pos); @@ -408,7 +408,7 @@ fn _check_label(lbl: str) { fn next_doc(exp_tag: ebml_serializer_tag) -> ebml::doc { #debug[". next_doc(exp_tag=%?)", exp_tag]; if self.pos >= self.parent.end { - fail "no more documents in current node!"; + fail ~"no more documents in current node!"; } let {tag: r_tag, doc: r_doc} = ebml::doc_at(self.parent.data, self.pos); @@ -472,14 +472,14 @@ fn read_int() -> int { fn read_bool() -> bool { ebml::doc_as_u8(self.next_doc(es_bool)) as bool } - fn read_f64() -> f64 { fail "read_f64()"; } - fn read_f32() -> f32 { fail "read_f32()"; } - fn read_float() -> float { fail "read_float()"; } + fn read_f64() -> f64 { fail ~"read_f64()"; } + fn read_f32() -> f32 { fail ~"read_f32()"; } + fn read_float() -> float { fail ~"read_float()"; } - fn read_str() -> str { ebml::doc_as_str(self.next_doc(es_str)) } + fn read_str() -> ~str { ebml::doc_as_str(self.next_doc(es_str)) } // Compound types: - fn read_enum(name: str, f: fn() -> T) -> T { + fn read_enum(name: ~str, f: fn() -> T) -> T { #debug["read_enum(%s)", name]; self._check_label(name); self.push_doc(self.next_doc(es_enum), f) @@ -528,7 +528,7 @@ fn read_rec(f: fn() -> T) -> T { f() } - fn read_rec_field(f_name: str, f_idx: uint, f: fn() -> T) -> T { + fn read_rec_field(f_name: ~str, f_idx: uint, f: fn() -> T) -> T { #debug["read_rec_field(%s, idx=%u)", f_name, f_idx]; self._check_label(f_name); f() @@ -556,13 +556,13 @@ fn serialize_1(s: S, v: int) { } fn serialize_0(s: S, v: option) { - do s.emit_enum("core::option::t") { + do s.emit_enum(~"core::option::t") { alt v { none { - s.emit_enum_variant("core::option::none", 0u, 0u, || { } ); + s.emit_enum_variant(~"core::option::none", 0u, 0u, || { } ); } some(v0) { - do s.emit_enum_variant("core::option::some", 1u, 1u) { + do s.emit_enum_variant(~"core::option::some", 1u, 1u) { s.emit_enum_variant_arg(0u, || serialize_1(s, v0)); } } @@ -575,7 +575,7 @@ fn deserialize_1(s: S) -> int { } fn deserialize_0(s: S) -> option { - do s.read_enum("core::option::t") { + do s.read_enum(~"core::option::t") { do s.read_enum_variant |i| { alt check i { 0u { none } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index e6df8e1d8985..8ba2dc16b76c 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -84,7 +84,7 @@ export opt_default; export result; //NDM -enum name { long(str), short(char), } +enum name { long(~str), short(char), } enum hasarg { yes, no, maybe, } @@ -93,29 +93,29 @@ enum occur { req, optional, multi, } /// A description of a possible option type opt = {name: name, hasarg: hasarg, occur: occur}; -fn mkname(nm: str) -> name { +fn mkname(nm: ~str) -> name { ret if str::len(nm) == 1u { short(str::char_at(nm, 0u)) } else { long(nm) }; } /// Create an option that is required and takes an argument -fn reqopt(name: str) -> opt { +fn reqopt(name: ~str) -> opt { ret {name: mkname(name), hasarg: yes, occur: req}; } /// Create an option that is optional and takes an argument -fn optopt(name: str) -> opt { +fn optopt(name: ~str) -> opt { ret {name: mkname(name), hasarg: yes, occur: optional}; } /// Create an option that is optional and does not take an argument -fn optflag(name: str) -> opt { +fn optflag(name: ~str) -> opt { ret {name: mkname(name), hasarg: no, occur: optional}; } /// Create an option that is optional and takes an optional argument -fn optflagopt(name: str) -> opt { +fn optflagopt(name: ~str) -> opt { ret {name: mkname(name), hasarg: maybe, occur: optional}; } @@ -123,23 +123,23 @@ fn optflagopt(name: str) -> opt { * Create an option that is optional, takes an argument, and may occur * multiple times */ -fn optmulti(name: str) -> opt { +fn optmulti(name: ~str) -> opt { ret {name: mkname(name), hasarg: yes, occur: multi}; } -enum optval { val(str), given, } +enum optval { val(~str), given, } /** * The result of checking command line arguments. Contains a vector * of matches and a vector of free strings. */ -type match = {opts: ~[opt], vals: ~[~[optval]], free: ~[str]}; +type match = {opts: ~[opt], vals: ~[~[optval]], free: ~[~str]}; -fn is_arg(arg: str) -> bool { +fn is_arg(arg: ~str) -> bool { ret str::len(arg) > 1u && arg[0] == '-' as u8; } -fn name_str(nm: name) -> str { +fn name_str(nm: name) -> ~str { ret alt nm { short(ch) { str::from_char(ch) } long(s) { s } }; } @@ -152,24 +152,26 @@ fn find_opt(opts: ~[opt], nm: name) -> option { * expected format. Pass this value to to get an error message. */ enum fail_ { - argument_missing(str), - unrecognized_option(str), - option_missing(str), - option_duplicated(str), - unexpected_argument(str), + argument_missing(~str), + unrecognized_option(~str), + option_missing(~str), + option_duplicated(~str), + unexpected_argument(~str), } /// Convert a `fail_` enum into an error string -fn fail_str(f: fail_) -> str { +fn fail_str(f: fail_) -> ~str { ret alt f { - argument_missing(nm) { "Argument to option '" + nm + "' missing." } - unrecognized_option(nm) { "Unrecognized option: '" + nm + "'." } - option_missing(nm) { "Required option '" + nm + "' missing." } + argument_missing(nm) { + ~"Argument to option '" + nm + ~"' missing." + } + unrecognized_option(nm) { ~"Unrecognized option: '" + nm + ~"'." } + option_missing(nm) { ~"Required option '" + nm + ~"' missing." } option_duplicated(nm) { - "Option '" + nm + "' given more than once." + ~"Option '" + nm + ~"' given more than once." } unexpected_argument(nm) { - "Option " + nm + " does not take an argument." + ~"Option " + nm + ~" does not take an argument." } }; } @@ -187,11 +189,11 @@ fn fail_str(f: fail_) -> str { * `opt_str`, etc. to interrogate results. Returns `err(fail_)` on failure. * Use to get an error message. */ -fn getopts(args: ~[str], opts: ~[opt]) -> result unsafe { +fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { let n_opts = vec::len::(opts); fn f(_x: uint) -> ~[optval] { ret ~[]; } let vals = vec::to_mut(vec::from_fn(n_opts, f)); - let mut free: ~[str] = ~[]; + let mut free: ~[~str] = ~[]; let l = vec::len(args); let mut i = 0u; while i < l { @@ -199,13 +201,13 @@ fn getopts(args: ~[str], opts: ~[opt]) -> result unsafe { let curlen = str::len(cur); if !is_arg(cur) { vec::push(free, cur); - } else if str::eq(cur, "--") { + } else if str::eq(cur, ~"--") { let mut j = i + 1u; while j < l { vec::push(free, args[j]); j += 1u; } break; } else { let mut names; - let mut i_arg = option::none::; + let mut i_arg = option::none::<~str>; if cur[1] == '-' as u8 { let tail = str::slice(cur, 2u, curlen); let tail_eq = str::splitn_char(tail, '=', 1u); @@ -215,7 +217,7 @@ fn getopts(args: ~[str], opts: ~[opt]) -> result unsafe { names = ~[long(tail_eq[0])]; i_arg = - option::some::(tail_eq[1]); + option::some::<~str>(tail_eq[1]); } } else { let mut j = 1u; @@ -264,13 +266,13 @@ fn getopts(args: ~[str], opts: ~[opt]) -> result unsafe { }; alt opts[optid].hasarg { no { - if !option::is_none::(i_arg) { + if !option::is_none::<~str>(i_arg) { ret err(unexpected_argument(name_str(nm))); } vec::push(vals[optid], given); } maybe { - if !option::is_none::(i_arg) { + if !option::is_none::<~str>(i_arg) { vec::push(vals[optid], val(option::get(i_arg))); } else if name_pos < vec::len::(names) || i + 1u == l || is_arg(args[i + 1u]) { @@ -278,9 +280,9 @@ fn getopts(args: ~[str], opts: ~[opt]) -> result unsafe { } else { i += 1u; vec::push(vals[optid], val(args[i])); } } yes { - if !option::is_none::(i_arg) { + if !option::is_none::<~str>(i_arg) { vec::push(vals[optid], - val(option::get::(i_arg))); + val(option::get::<~str>(i_arg))); } else if i + 1u == l { ret err(argument_missing(name_str(nm))); } else { i += 1u; vec::push(vals[optid], val(args[i])); } @@ -309,22 +311,22 @@ fn getopts(args: ~[str], opts: ~[opt]) -> result unsafe { ret ok({opts: opts, vals: vec::from_mut(vals), free: free}); } -fn opt_vals(m: match, nm: str) -> ~[optval] { +fn opt_vals(m: match, nm: ~str) -> ~[optval] { ret alt find_opt(m.opts, mkname(nm)) { some(id) { m.vals[id] } none { #error("No option '%s' defined", nm); fail } }; } -fn opt_val(m: match, nm: str) -> optval { ret opt_vals(m, nm)[0]; } +fn opt_val(m: match, nm: ~str) -> optval { ret opt_vals(m, nm)[0]; } /// Returns true if an option was matched -fn opt_present(m: match, nm: str) -> bool { +fn opt_present(m: match, nm: ~str) -> bool { ret vec::len::(opt_vals(m, nm)) > 0u; } /// Returns true if any of several options were matched -fn opts_present(m: match, names: ~[str]) -> bool { +fn opts_present(m: match, names: ~[~str]) -> bool { for vec::each(names) |nm| { alt find_opt(m.opts, mkname(nm)) { some(_) { ret true; } @@ -341,7 +343,7 @@ fn opts_present(m: match, names: ~[str]) -> bool { * Fails if the option was not matched or if the match did not take an * argument */ -fn opt_str(m: match, nm: str) -> str { +fn opt_str(m: match, nm: ~str) -> ~str { ret alt opt_val(m, nm) { val(s) { s } _ { fail } }; } @@ -351,7 +353,7 @@ fn opt_str(m: match, nm: str) -> str { * Fails if the no option was provided from the given list, or if the no such * option took an argument */ -fn opts_str(m: match, names: ~[str]) -> str { +fn opts_str(m: match, names: ~[~str]) -> ~str { for vec::each(names) |nm| { alt opt_val(m, nm) { val(s) { ret s } @@ -368,8 +370,8 @@ fn opts_str(m: match, names: ~[str]) -> str { * * Used when an option accepts multiple values. */ -fn opt_strs(m: match, nm: str) -> ~[str] { - let mut acc: ~[str] = ~[]; +fn opt_strs(m: match, nm: ~str) -> ~[~str] { + let mut acc: ~[~str] = ~[]; for vec::each(opt_vals(m, nm)) |v| { alt v { val(s) { vec::push(acc, s); } _ { } } } @@ -377,10 +379,10 @@ fn opt_strs(m: match, nm: str) -> ~[str] { } /// Returns the string argument supplied to a matching option or none -fn opt_maybe_str(m: match, nm: str) -> option { +fn opt_maybe_str(m: match, nm: ~str) -> option<~str> { let vals = opt_vals(m, nm); - if vec::len::(vals) == 0u { ret none::; } - ret alt vals[0] { val(s) { some::(s) } _ { none:: } }; + if vec::len::(vals) == 0u { ret none::<~str>; } + ret alt vals[0] { val(s) { some::<~str>(s) } _ { none::<~str> } }; } @@ -391,10 +393,10 @@ fn opt_maybe_str(m: match, nm: str) -> option { * present but no argument was provided, and the argument if the option was * present and an argument was provided. */ -fn opt_default(m: match, nm: str, def: str) -> option { +fn opt_default(m: match, nm: ~str, def: ~str) -> option<~str> { let vals = opt_vals(m, nm); - if vec::len::(vals) == 0u { ret none::; } - ret alt vals[0] { val(s) { some::(s) } _ { some::(def) } } + if vec::len::(vals) == 0u { ret none::<~str>; } + ret alt vals[0] { val(s) { some::<~str>(s) } _ { some::<~str>(def) } } } #[cfg(test)] @@ -424,21 +426,21 @@ fn check_fail_type(f: fail_, ft: fail_type) { // Tests for reqopt #[test] fn test_reqopt_long() { - let args = ~["--test=20"]; - let opts = ~[reqopt("test")]; + let args = ~[~"--test=20"]; + let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); alt check rs { ok(m) { - assert (opt_present(m, "test")); - assert (opt_str(m, "test") == "20"); + assert (opt_present(m, ~"test")); + assert (opt_str(m, ~"test") == ~"20"); } } } #[test] fn test_reqopt_long_missing() { - let args = ~["blah"]; - let opts = ~[reqopt("test")]; + let args = ~[~"blah"]; + let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_missing_); } @@ -448,8 +450,8 @@ fn test_reqopt_long_missing() { #[test] fn test_reqopt_long_no_arg() { - let args = ~["--test"]; - let opts = ~[reqopt("test")]; + let args = ~[~"--test"]; + let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -459,8 +461,8 @@ fn test_reqopt_long_no_arg() { #[test] fn test_reqopt_long_multi() { - let args = ~["--test=20", "--test=30"]; - let opts = ~[reqopt("test")]; + let args = ~[~"--test=20", ~"--test=30"]; + let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -470,13 +472,13 @@ fn test_reqopt_long_multi() { #[test] fn test_reqopt_short() { - let args = ~["-t", "20"]; - let opts = ~[reqopt("t")]; + let args = ~[~"-t", ~"20"]; + let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); alt rs { ok(m) { - assert (opt_present(m, "t")); - assert (opt_str(m, "t") == "20"); + assert (opt_present(m, ~"t")); + assert (opt_str(m, ~"t") == ~"20"); } _ { fail; } } @@ -484,8 +486,8 @@ fn test_reqopt_short() { #[test] fn test_reqopt_short_missing() { - let args = ~["blah"]; - let opts = ~[reqopt("t")]; + let args = ~[~"blah"]; + let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_missing_); } @@ -495,8 +497,8 @@ fn test_reqopt_short_missing() { #[test] fn test_reqopt_short_no_arg() { - let args = ~["-t"]; - let opts = ~[reqopt("t")]; + let args = ~[~"-t"]; + let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -506,8 +508,8 @@ fn test_reqopt_short_no_arg() { #[test] fn test_reqopt_short_multi() { - let args = ~["-t", "20", "-t", "30"]; - let opts = ~[reqopt("t")]; + let args = ~[~"-t", ~"20", ~"-t", ~"30"]; + let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -519,13 +521,13 @@ fn test_reqopt_short_multi() { // Tests for optopt #[test] fn test_optopt_long() { - let args = ~["--test=20"]; - let opts = ~[optopt("test")]; + let args = ~[~"--test=20"]; + let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); alt rs { ok(m) { - assert (opt_present(m, "test")); - assert (opt_str(m, "test") == "20"); + assert (opt_present(m, ~"test")); + assert (opt_str(m, ~"test") == ~"20"); } _ { fail; } } @@ -533,19 +535,19 @@ fn test_optopt_long() { #[test] fn test_optopt_long_missing() { - let args = ~["blah"]; - let opts = ~[optopt("test")]; + let args = ~[~"blah"]; + let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); alt rs { - ok(m) { assert (!opt_present(m, "test")); } + ok(m) { assert (!opt_present(m, ~"test")); } _ { fail; } } } #[test] fn test_optopt_long_no_arg() { - let args = ~["--test"]; - let opts = ~[optopt("test")]; + let args = ~[~"--test"]; + let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -555,8 +557,8 @@ fn test_optopt_long_no_arg() { #[test] fn test_optopt_long_multi() { - let args = ~["--test=20", "--test=30"]; - let opts = ~[optopt("test")]; + let args = ~[~"--test=20", ~"--test=30"]; + let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -566,13 +568,13 @@ fn test_optopt_long_multi() { #[test] fn test_optopt_short() { - let args = ~["-t", "20"]; - let opts = ~[optopt("t")]; + let args = ~[~"-t", ~"20"]; + let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); alt rs { ok(m) { - assert (opt_present(m, "t")); - assert (opt_str(m, "t") == "20"); + assert (opt_present(m, ~"t")); + assert (opt_str(m, ~"t") == ~"20"); } _ { fail; } } @@ -580,19 +582,19 @@ fn test_optopt_short() { #[test] fn test_optopt_short_missing() { - let args = ~["blah"]; - let opts = ~[optopt("t")]; + let args = ~[~"blah"]; + let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); alt rs { - ok(m) { assert (!opt_present(m, "t")); } + ok(m) { assert (!opt_present(m, ~"t")); } _ { fail; } } } #[test] fn test_optopt_short_no_arg() { - let args = ~["-t"]; - let opts = ~[optopt("t")]; + let args = ~[~"-t"]; + let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -602,8 +604,8 @@ fn test_optopt_short_no_arg() { #[test] fn test_optopt_short_multi() { - let args = ~["-t", "20", "-t", "30"]; - let opts = ~[optopt("t")]; + let args = ~[~"-t", ~"20", ~"-t", ~"30"]; + let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -615,30 +617,30 @@ fn test_optopt_short_multi() { // Tests for optflag #[test] fn test_optflag_long() { - let args = ~["--test"]; - let opts = ~[optflag("test")]; + let args = ~[~"--test"]; + let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); alt rs { - ok(m) { assert (opt_present(m, "test")); } + ok(m) { assert (opt_present(m, ~"test")); } _ { fail; } } } #[test] fn test_optflag_long_missing() { - let args = ~["blah"]; - let opts = ~[optflag("test")]; + let args = ~[~"blah"]; + let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); alt rs { - ok(m) { assert (!opt_present(m, "test")); } + ok(m) { assert (!opt_present(m, ~"test")); } _ { fail; } } } #[test] fn test_optflag_long_arg() { - let args = ~["--test=20"]; - let opts = ~[optflag("test")]; + let args = ~[~"--test=20"]; + let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { @@ -651,8 +653,8 @@ fn test_optflag_long_arg() { #[test] fn test_optflag_long_multi() { - let args = ~["--test", "--test"]; - let opts = ~[optflag("test")]; + let args = ~[~"--test", ~"--test"]; + let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -662,36 +664,36 @@ fn test_optflag_long_multi() { #[test] fn test_optflag_short() { - let args = ~["-t"]; - let opts = ~[optflag("t")]; + let args = ~[~"-t"]; + let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); alt rs { - ok(m) { assert (opt_present(m, "t")); } + ok(m) { assert (opt_present(m, ~"t")); } _ { fail; } } } #[test] fn test_optflag_short_missing() { - let args = ~["blah"]; - let opts = ~[optflag("t")]; + let args = ~[~"blah"]; + let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); alt rs { - ok(m) { assert (!opt_present(m, "t")); } + ok(m) { assert (!opt_present(m, ~"t")); } _ { fail; } } } #[test] fn test_optflag_short_arg() { - let args = ~["-t", "20"]; - let opts = ~[optflag("t")]; + let args = ~[~"-t", ~"20"]; + let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); alt rs { ok(m) { // The next variable after the flag is just a free argument - assert (m.free[0] == "20"); + assert (m.free[0] == ~"20"); } _ { fail; } } @@ -699,8 +701,8 @@ fn test_optflag_short_arg() { #[test] fn test_optflag_short_multi() { - let args = ~["-t", "-t"]; - let opts = ~[optflag("t")]; + let args = ~[~"-t", ~"-t"]; + let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -712,13 +714,13 @@ fn test_optflag_short_multi() { // Tests for optmulti #[test] fn test_optmulti_long() { - let args = ~["--test=20"]; - let opts = ~[optmulti("test")]; + let args = ~[~"--test=20"]; + let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); alt rs { ok(m) { - assert (opt_present(m, "test")); - assert (opt_str(m, "test") == "20"); + assert (opt_present(m, ~"test")); + assert (opt_str(m, ~"test") == ~"20"); } _ { fail; } } @@ -726,19 +728,19 @@ fn test_optmulti_long() { #[test] fn test_optmulti_long_missing() { - let args = ~["blah"]; - let opts = ~[optmulti("test")]; + let args = ~[~"blah"]; + let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); alt rs { - ok(m) { assert (!opt_present(m, "test")); } + ok(m) { assert (!opt_present(m, ~"test")); } _ { fail; } } } #[test] fn test_optmulti_long_no_arg() { - let args = ~["--test"]; - let opts = ~[optmulti("test")]; + let args = ~[~"--test"]; + let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -748,15 +750,15 @@ fn test_optmulti_long_no_arg() { #[test] fn test_optmulti_long_multi() { - let args = ~["--test=20", "--test=30"]; - let opts = ~[optmulti("test")]; + let args = ~[~"--test=20", ~"--test=30"]; + let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); alt rs { ok(m) { - assert (opt_present(m, "test")); - assert (opt_str(m, "test") == "20"); - assert (opt_strs(m, "test")[0] == "20"); - assert (opt_strs(m, "test")[1] == "30"); + assert (opt_present(m, ~"test")); + assert (opt_str(m, ~"test") == ~"20"); + assert (opt_strs(m, ~"test")[0] == ~"20"); + assert (opt_strs(m, ~"test")[1] == ~"30"); } _ { fail; } } @@ -764,13 +766,13 @@ fn test_optmulti_long_multi() { #[test] fn test_optmulti_short() { - let args = ~["-t", "20"]; - let opts = ~[optmulti("t")]; + let args = ~[~"-t", ~"20"]; + let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); alt rs { ok(m) { - assert (opt_present(m, "t")); - assert (opt_str(m, "t") == "20"); + assert (opt_present(m, ~"t")); + assert (opt_str(m, ~"t") == ~"20"); } _ { fail; } } @@ -778,19 +780,19 @@ fn test_optmulti_short() { #[test] fn test_optmulti_short_missing() { - let args = ~["blah"]; - let opts = ~[optmulti("t")]; + let args = ~[~"blah"]; + let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); alt rs { - ok(m) { assert (!opt_present(m, "t")); } + ok(m) { assert (!opt_present(m, ~"t")); } _ { fail; } } } #[test] fn test_optmulti_short_no_arg() { - let args = ~["-t"]; - let opts = ~[optmulti("t")]; + let args = ~[~"-t"]; + let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -800,15 +802,15 @@ fn test_optmulti_short_no_arg() { #[test] fn test_optmulti_short_multi() { - let args = ~["-t", "20", "-t", "30"]; - let opts = ~[optmulti("t")]; + let args = ~[~"-t", ~"20", ~"-t", ~"30"]; + let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); alt rs { ok(m) { - assert (opt_present(m, "t")); - assert (opt_str(m, "t") == "20"); - assert (opt_strs(m, "t")[0] == "20"); - assert (opt_strs(m, "t")[1] == "30"); + assert (opt_present(m, ~"t")); + assert (opt_str(m, ~"t") == ~"20"); + assert (opt_strs(m, ~"t")[0] == ~"20"); + assert (opt_strs(m, ~"t")[1] == ~"30"); } _ { fail; } } @@ -816,8 +818,8 @@ fn test_optmulti_short_multi() { #[test] fn test_unrecognized_option_long() { - let args = ~["--untest"]; - let opts = ~[optmulti("t")]; + let args = ~[~"--untest"]; + let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, unrecognized_option_); } @@ -827,8 +829,8 @@ fn test_unrecognized_option_long() { #[test] fn test_unrecognized_option_short() { - let args = ~["-t"]; - let opts = ~[optmulti("test")]; + let args = ~[~"-t"]; + let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, unrecognized_option_); } @@ -839,27 +841,28 @@ fn test_unrecognized_option_short() { #[test] fn test_combined() { let args = - ~["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", - "-f", "-m", "40", "-m", "50", "-n", "-A B", "-n", "-60 70"]; + ~[~"prog", ~"free1", ~"-s", ~"20", ~"free2", + ~"--flag", ~"--long=30", ~"-f", ~"-m", ~"40", + ~"-m", ~"50", ~"-n", ~"-A B", ~"-n", ~"-60 70"]; let opts = - ~[optopt("s"), optflag("flag"), reqopt("long"), - optflag("f"), optmulti("m"), optmulti("n"), - optopt("notpresent")]; + ~[optopt(~"s"), optflag(~"flag"), reqopt(~"long"), + optflag(~"f"), optmulti(~"m"), optmulti(~"n"), + optopt(~"notpresent")]; let rs = getopts(args, opts); alt rs { ok(m) { - assert (m.free[0] == "prog"); - assert (m.free[1] == "free1"); - assert (opt_str(m, "s") == "20"); - assert (m.free[2] == "free2"); - assert (opt_present(m, "flag")); - assert (opt_str(m, "long") == "30"); - assert (opt_present(m, "f")); - assert (opt_strs(m, "m")[0] == "40"); - assert (opt_strs(m, "m")[1] == "50"); - assert (opt_strs(m, "n")[0] == "-A B"); - assert (opt_strs(m, "n")[1] == "-60 70"); - assert (!opt_present(m, "notpresent")); + assert (m.free[0] == ~"prog"); + assert (m.free[1] == ~"free1"); + assert (opt_str(m, ~"s") == ~"20"); + assert (m.free[2] == ~"free2"); + assert (opt_present(m, ~"flag")); + assert (opt_str(m, ~"long") == ~"30"); + assert (opt_present(m, ~"f")); + assert (opt_strs(m, ~"m")[0] == ~"40"); + assert (opt_strs(m, ~"m")[1] == ~"50"); + assert (opt_strs(m, ~"n")[0] == ~"-A B"); + assert (opt_strs(m, ~"n")[1] == ~"-60 70"); + assert (!opt_present(m, ~"notpresent")); } _ { fail; } } @@ -867,35 +870,35 @@ fn test_combined() { #[test] fn test_multi() { - let args = ~["-e", "foo", "--encrypt", "foo"]; - let opts = ~[optopt("e"), optopt("encrypt")]; + let args = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"]; + let opts = ~[optopt(~"e"), optopt(~"encrypt")]; let match = alt getopts(args, opts) { result::ok(m) { m } result::err(f) { fail; } }; - assert opts_present(match, ~["e"]); - assert opts_present(match, ~["encrypt"]); - assert opts_present(match, ~["encrypt", "e"]); - assert opts_present(match, ~["e", "encrypt"]); - assert !opts_present(match, ~["thing"]); + assert opts_present(match, ~[~"e"]); + assert opts_present(match, ~[~"encrypt"]); + assert opts_present(match, ~[~"encrypt", ~"e"]); + assert opts_present(match, ~[~"e", ~"encrypt"]); + assert !opts_present(match, ~[~"thing"]); assert !opts_present(match, ~[]); - assert opts_str(match, ~["e"]) == "foo"; - assert opts_str(match, ~["encrypt"]) == "foo"; - assert opts_str(match, ~["e", "encrypt"]) == "foo"; - assert opts_str(match, ~["encrypt", "e"]) == "foo"; + assert opts_str(match, ~[~"e"]) == ~"foo"; + assert opts_str(match, ~[~"encrypt"]) == ~"foo"; + assert opts_str(match, ~[~"e", ~"encrypt"]) == ~"foo"; + assert opts_str(match, ~[~"encrypt", ~"e"]) == ~"foo"; } #[test] fn test_nospace() { - let args = ~["-Lfoo"]; - let opts = ~[optmulti("L")]; + let args = ~[~"-Lfoo"]; + let opts = ~[optmulti(~"L")]; let match = alt getopts(args, opts) { result::ok(m) { m } result::err(f) { fail; } }; - assert opts_present(match, ~["L"]); - assert opts_str(match, ~["L"]) == "foo"; + assert opts_present(match, ~[~"L"]); + assert opts_str(match, ~[~"L"]) == ~"foo"; } } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 917cae32e2dd..f81942046265 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -29,17 +29,17 @@ /// Represents a json value enum json { num(float), - string(@str/~), + string(@~str), boolean(bool), list(@~[json]), - dict(map::hashmap), + dict(map::hashmap<~str, json>), null, } type error = { line: uint, col: uint, - msg: @str/~, + msg: @~str, }; /// Serializes a json value into a io::writer @@ -50,14 +50,14 @@ fn to_writer(wr: io::writer, j: json) { wr.write_str(escape_str(*s)); } boolean(b) { - wr.write_str(if b { "true" } else { "false" }); + wr.write_str(if b { ~"true" } else { ~"false" }); } list(v) { wr.write_char('['); let mut first = true; for (*v).each |item| { if !first { - wr.write_str(", "); + wr.write_str(~", "); } first = false; to_writer(wr, item); @@ -66,51 +66,51 @@ fn to_writer(wr: io::writer, j: json) { } dict(d) { if d.size() == 0u { - wr.write_str("{}"); + wr.write_str(~"{}"); ret; } - wr.write_str("{ "); + wr.write_str(~"{ "); let mut first = true; for d.each |key, value| { if !first { - wr.write_str(", "); + wr.write_str(~", "); } first = false; wr.write_str(escape_str(key)); - wr.write_str(": "); + wr.write_str(~": "); to_writer(wr, value); }; - wr.write_str(" }"); + wr.write_str(~" }"); } null { - wr.write_str("null"); + wr.write_str(~"null"); } } } -fn escape_str(s: str) -> str { - let mut escaped = "\""; +fn escape_str(s: ~str) -> ~str { + let mut escaped = ~"\""; do str::chars_iter(s) |c| { alt c { - '"' { escaped += "\\\""; } - '\\' { escaped += "\\\\"; } - '\x08' { escaped += "\\b"; } - '\x0c' { escaped += "\\f"; } - '\n' { escaped += "\\n"; } - '\r' { escaped += "\\r"; } - '\t' { escaped += "\\t"; } + '"' { escaped += ~"\\\""; } + '\\' { escaped += ~"\\\\"; } + '\x08' { escaped += ~"\\b"; } + '\x0c' { escaped += ~"\\f"; } + '\n' { escaped += ~"\\n"; } + '\r' { escaped += ~"\\r"; } + '\t' { escaped += ~"\\t"; } _ { escaped += str::from_char(c); } } }; - escaped += "\""; + escaped += ~"\""; escaped } /// Serializes a json value into a string -fn to_str(j: json) -> str { +fn to_str(j: json) -> ~str { io::with_str_writer(|wr| to_writer(wr, j)) } @@ -140,7 +140,7 @@ fn next_char() -> char { self.ch } - fn error(+msg: str) -> result { + fn error(+msg: ~str) -> result { err({ line: self.line, col: self.col, msg: @msg }) } @@ -153,7 +153,7 @@ fn parse() -> result { if self.eof() { ok(value) } else { - self.error("trailing characters") + self.error(~"trailing characters") } } e { e } @@ -163,12 +163,12 @@ fn parse() -> result { fn parse_value() -> result { self.parse_whitespace(); - if self.eof() { ret self.error("EOF while parsing value"); } + if self.eof() { ret self.error(~"EOF while parsing value"); } alt self.ch { - 'n' { self.parse_ident("ull", null) } - 't' { self.parse_ident("rue", boolean(true)) } - 'f' { self.parse_ident("alse", boolean(false)) } + 'n' { self.parse_ident(~"ull", null) } + 't' { self.parse_ident(~"rue", boolean(true)) } + 'f' { self.parse_ident(~"alse", boolean(false)) } '0' to '9' | '-' { self.parse_number() } '"' { alt self.parse_str() { @@ -178,7 +178,7 @@ fn parse_value() -> result { } '[' { self.parse_list() } '{' { self.parse_object() } - _ { self.error("invalid syntax") } + _ { self.error(~"invalid syntax") } } } @@ -186,12 +186,12 @@ fn parse_whitespace() { while char::is_whitespace(self.ch) { self.bump(); } } - fn parse_ident(ident: str, value: json) -> result { + fn parse_ident(ident: ~str, value: json) -> result { if str::all(ident, |c| c == self.next_char()) { self.bump(); ok(value) } else { - self.error("invalid syntax") + self.error(~"invalid syntax") } } @@ -234,7 +234,7 @@ fn parse_integer() -> result { // There can be only one leading '0'. alt self.ch { - '0' to '9' { ret self.error("invalid number"); } + '0' to '9' { ret self.error(~"invalid number"); } _ {} } } @@ -251,7 +251,7 @@ fn parse_integer() -> result { } } } - _ { ret self.error("invalid number"); } + _ { ret self.error(~"invalid number"); } } ok(res) @@ -263,7 +263,7 @@ fn parse_decimal(res: float) -> result { // Make sure a digit follows the decimal place. alt self.ch { '0' to '9' {} - _ { ret self.error("invalid number"); } + _ { ret self.error(~"invalid number"); } } let mut res = res; @@ -299,7 +299,7 @@ fn parse_exponent(res: float) -> result { // Make sure a digit follows the exponent place. alt self.ch { '0' to '9' {} - _ { ret self.error("invalid number"); } + _ { ret self.error(~"invalid number"); } } while !self.eof() { @@ -324,9 +324,9 @@ fn parse_exponent(res: float) -> result { ok(res) } - fn parse_str() -> result<@str/~, error> { + fn parse_str() -> result<@~str, error> { let mut escape = false; - let mut res = ""; + let mut res = ~""; while !self.eof() { self.bump(); @@ -351,19 +351,19 @@ fn parse_str() -> result<@str/~, error> { n = n * 10u + (self.ch as uint) - ('0' as uint); } - _ { ret self.error("invalid \\u escape"); } + _ { ret self.error(~"invalid \\u escape"); } } i += 1u; } // Error out if we didn't parse 4 digits. if i != 4u { - ret self.error("invalid \\u escape"); + ret self.error(~"invalid \\u escape"); } str::push_char(res, n as char); } - _ { ret self.error("invalid escape"); } + _ { ret self.error(~"invalid escape"); } } escape = false; } else if self.ch == '\\' { @@ -377,7 +377,7 @@ fn parse_str() -> result<@str/~, error> { } } - self.error("EOF while parsing string") + self.error(~"EOF while parsing string") } fn parse_list() -> result { @@ -399,13 +399,13 @@ fn parse_list() -> result { self.parse_whitespace(); if self.eof() { - ret self.error("EOF while parsing list"); + ret self.error(~"EOF while parsing list"); } alt self.ch { ',' { self.bump(); } ']' { self.bump(); ret ok(list(@values)); } - _ { ret self.error("expected `,` or `]`"); } + _ { ret self.error(~"expected `,` or `]`"); } } }; } @@ -425,7 +425,7 @@ fn parse_object() -> result { self.parse_whitespace(); if self.ch != '"' { - ret self.error("key must be a string"); + ret self.error(~"key must be a string"); } let key = alt self.parse_str() { @@ -437,7 +437,7 @@ fn parse_object() -> result { if self.ch != ':' { if self.eof() { break; } - ret self.error("expected `:`"); + ret self.error(~"expected `:`"); } self.bump(); @@ -452,12 +452,12 @@ fn parse_object() -> result { '}' { self.bump(); ret ok(dict(values)); } _ { if self.eof() { break; } - ret self.error("expected `,` or `}`"); + ret self.error(~"expected `,` or `}`"); } } } - ret self.error("EOF while parsing object"); + ret self.error(~"EOF while parsing object"); } } @@ -474,7 +474,7 @@ fn from_reader(rdr: io::reader) -> result { } /// Deserializes a json value from a string -fn from_str(s: str) -> result { +fn from_str(s: ~str) -> result { io::with_str_reader(s, from_reader) } @@ -575,11 +575,11 @@ impl of to_json for bool { fn to_json() -> json { boolean(self) } } -impl of to_json for str { +impl of to_json for ~str { fn to_json() -> json { string(@copy self) } } -impl of to_json for @str/~ { +impl of to_json for @~str { fn to_json() -> json { string(self) } } @@ -602,7 +602,7 @@ impl of to_json for ~[A] { fn to_json() -> json { list(@self.map(|elt| elt.to_json())) } } -impl of to_json for hashmap { +impl of to_json for hashmap<~str, A> { fn to_json() -> json { let d = map::str_hash(); for self.each() |key, value| { @@ -622,18 +622,18 @@ fn to_json() -> json { } impl of to_str::to_str for json { - fn to_str() -> str { to_str(self) } + fn to_str() -> ~str { to_str(self) } } impl of to_str::to_str for error { - fn to_str() -> str { + fn to_str() -> ~str { #fmt("%u:%u: %s", self.line, self.col, *self.msg) } } #[cfg(test)] mod tests { - fn mk_dict(items: ~[(str, json)]) -> json { + fn mk_dict(items: ~[(~str, json)]) -> json { let d = map::str_hash(); do vec::iter(items) |item| { @@ -646,229 +646,230 @@ fn mk_dict(items: ~[(str, json)]) -> json { #[test] fn test_write_null() { - assert to_str(null) == "null"; + assert to_str(null) == ~"null"; } #[test] fn test_write_num() { - assert to_str(num(3f)) == "3"; - assert to_str(num(3.1f)) == "3.1"; - assert to_str(num(-1.5f)) == "-1.5"; - assert to_str(num(0.5f)) == "0.5"; + assert to_str(num(3f)) == ~"3"; + assert to_str(num(3.1f)) == ~"3.1"; + assert to_str(num(-1.5f)) == ~"-1.5"; + assert to_str(num(0.5f)) == ~"0.5"; } #[test] fn test_write_str() { - assert to_str(string(@"")) == "\"\""; - assert to_str(string(@"foo")) == "\"foo\""; + assert to_str(string(@~"")) == ~"\"\""; + assert to_str(string(@~"foo")) == ~"\"foo\""; } #[test] fn test_write_bool() { - assert to_str(boolean(true)) == "true"; - assert to_str(boolean(false)) == "false"; + assert to_str(boolean(true)) == ~"true"; + assert to_str(boolean(false)) == ~"false"; } #[test] fn test_write_list() { - assert to_str(list(@~[])) == "[]"; - assert to_str(list(@~[boolean(true)])) == "[true]"; + assert to_str(list(@~[])) == ~"[]"; + assert to_str(list(@~[boolean(true)])) == ~"[true]"; assert to_str(list(@~[ boolean(false), null, - list(@~[string(@"foo\nbar"), num(3.5f)]) - ])) == "[false, null, [\"foo\\nbar\", 3.5]]"; + list(@~[string(@~"foo\nbar"), num(3.5f)]) + ])) == ~"[false, null, [\"foo\\nbar\", 3.5]]"; } #[test] fn test_write_dict() { - assert to_str(mk_dict(~[])) == "{}"; - assert to_str(mk_dict(~[("a", boolean(true))])) == "{ \"a\": true }"; + assert to_str(mk_dict(~[])) == ~"{}"; + assert to_str(mk_dict(~[(~"a", boolean(true))])) + == ~"{ \"a\": true }"; assert to_str(mk_dict(~[ - ("a", boolean(true)), - ("b", list(@~[ - mk_dict(~[("c", string(@"\x0c\r"))]), - mk_dict(~[("d", string(@""))]) + (~"a", boolean(true)), + (~"b", list(@~[ + mk_dict(~[(~"c", string(@~"\x0c\r"))]), + mk_dict(~[(~"d", string(@~""))]) ])) ])) == - "{ " + - "\"a\": true, " + - "\"b\": [" + - "{ \"c\": \"\\f\\r\" }, " + - "{ \"d\": \"\" }" + - "]" + - " }"; + ~"{ " + + ~"\"a\": true, " + + ~"\"b\": [" + + ~"{ \"c\": \"\\f\\r\" }, " + + ~"{ \"d\": \"\" }" + + ~"]" + + ~" }"; } #[test] fn test_trailing_characters() { - assert from_str("nulla") == - err({line: 1u, col: 5u, msg: @"trailing characters"}); - assert from_str("truea") == - err({line: 1u, col: 5u, msg: @"trailing characters"}); - assert from_str("falsea") == - err({line: 1u, col: 6u, msg: @"trailing characters"}); - assert from_str("1a") == - err({line: 1u, col: 2u, msg: @"trailing characters"}); - assert from_str("[]a") == - err({line: 1u, col: 3u, msg: @"trailing characters"}); - assert from_str("{}a") == - err({line: 1u, col: 3u, msg: @"trailing characters"}); + assert from_str(~"nulla") == + err({line: 1u, col: 5u, msg: @~"trailing characters"}); + assert from_str(~"truea") == + err({line: 1u, col: 5u, msg: @~"trailing characters"}); + assert from_str(~"falsea") == + err({line: 1u, col: 6u, msg: @~"trailing characters"}); + assert from_str(~"1a") == + err({line: 1u, col: 2u, msg: @~"trailing characters"}); + assert from_str(~"[]a") == + err({line: 1u, col: 3u, msg: @~"trailing characters"}); + assert from_str(~"{}a") == + err({line: 1u, col: 3u, msg: @~"trailing characters"}); } #[test] fn test_read_identifiers() { - assert from_str("n") == - err({line: 1u, col: 2u, msg: @"invalid syntax"}); - assert from_str("nul") == - err({line: 1u, col: 4u, msg: @"invalid syntax"}); + assert from_str(~"n") == + err({line: 1u, col: 2u, msg: @~"invalid syntax"}); + assert from_str(~"nul") == + err({line: 1u, col: 4u, msg: @~"invalid syntax"}); - assert from_str("t") == - err({line: 1u, col: 2u, msg: @"invalid syntax"}); - assert from_str("truz") == - err({line: 1u, col: 4u, msg: @"invalid syntax"}); + assert from_str(~"t") == + err({line: 1u, col: 2u, msg: @~"invalid syntax"}); + assert from_str(~"truz") == + err({line: 1u, col: 4u, msg: @~"invalid syntax"}); - assert from_str("f") == - err({line: 1u, col: 2u, msg: @"invalid syntax"}); - assert from_str("faz") == - err({line: 1u, col: 3u, msg: @"invalid syntax"}); + assert from_str(~"f") == + err({line: 1u, col: 2u, msg: @~"invalid syntax"}); + assert from_str(~"faz") == + err({line: 1u, col: 3u, msg: @~"invalid syntax"}); - assert from_str("null") == ok(null); - assert from_str("true") == ok(boolean(true)); - assert from_str("false") == ok(boolean(false)); - assert from_str(" null ") == ok(null); - assert from_str(" true ") == ok(boolean(true)); - assert from_str(" false ") == ok(boolean(false)); + assert from_str(~"null") == ok(null); + assert from_str(~"true") == ok(boolean(true)); + assert from_str(~"false") == ok(boolean(false)); + assert from_str(~" null ") == ok(null); + assert from_str(~" true ") == ok(boolean(true)); + assert from_str(~" false ") == ok(boolean(false)); } #[test] fn test_read_num() { - assert from_str("+") == - err({line: 1u, col: 1u, msg: @"invalid syntax"}); - assert from_str(".") == - err({line: 1u, col: 1u, msg: @"invalid syntax"}); + assert from_str(~"+") == + err({line: 1u, col: 1u, msg: @~"invalid syntax"}); + assert from_str(~".") == + err({line: 1u, col: 1u, msg: @~"invalid syntax"}); - assert from_str("-") == - err({line: 1u, col: 2u, msg: @"invalid number"}); - assert from_str("00") == - err({line: 1u, col: 2u, msg: @"invalid number"}); - assert from_str("1.") == - err({line: 1u, col: 3u, msg: @"invalid number"}); - assert from_str("1e") == - err({line: 1u, col: 3u, msg: @"invalid number"}); - assert from_str("1e+") == - err({line: 1u, col: 4u, msg: @"invalid number"}); + assert from_str(~"-") == + err({line: 1u, col: 2u, msg: @~"invalid number"}); + assert from_str(~"00") == + err({line: 1u, col: 2u, msg: @~"invalid number"}); + assert from_str(~"1.") == + err({line: 1u, col: 3u, msg: @~"invalid number"}); + assert from_str(~"1e") == + err({line: 1u, col: 3u, msg: @~"invalid number"}); + assert from_str(~"1e+") == + err({line: 1u, col: 4u, msg: @~"invalid number"}); - assert from_str("3") == ok(num(3f)); - assert from_str("3.1") == ok(num(3.1f)); - assert from_str("-1.2") == ok(num(-1.2f)); - assert from_str("0.4") == ok(num(0.4f)); - assert from_str("0.4e5") == ok(num(0.4e5f)); - assert from_str("0.4e+15") == ok(num(0.4e15f)); - assert from_str("0.4e-01") == ok(num(0.4e-01f)); - assert from_str(" 3 ") == ok(num(3f)); + assert from_str(~"3") == ok(num(3f)); + assert from_str(~"3.1") == ok(num(3.1f)); + assert from_str(~"-1.2") == ok(num(-1.2f)); + assert from_str(~"0.4") == ok(num(0.4f)); + assert from_str(~"0.4e5") == ok(num(0.4e5f)); + assert from_str(~"0.4e+15") == ok(num(0.4e15f)); + assert from_str(~"0.4e-01") == ok(num(0.4e-01f)); + assert from_str(~" 3 ") == ok(num(3f)); } #[test] fn test_read_str() { - assert from_str("\"") == - err({line: 1u, col: 2u, msg: @"EOF while parsing string"}); - assert from_str("\"lol") == - err({line: 1u, col: 5u, msg: @"EOF while parsing string"}); + assert from_str(~"\"") == + err({line: 1u, col: 2u, msg: @~"EOF while parsing string"}); + assert from_str(~"\"lol") == + err({line: 1u, col: 5u, msg: @~"EOF while parsing string"}); - assert from_str("\"\"") == ok(string(@"")); - assert from_str("\"foo\"") == ok(string(@"foo")); - assert from_str("\"\\\"\"") == ok(string(@"\"")); - assert from_str("\"\\b\"") == ok(string(@"\x08")); - assert from_str("\"\\n\"") == ok(string(@"\n")); - assert from_str("\"\\r\"") == ok(string(@"\r")); - assert from_str("\"\\t\"") == ok(string(@"\t")); - assert from_str(" \"foo\" ") == ok(string(@"foo")); + assert from_str(~"\"\"") == ok(string(@~"")); + assert from_str(~"\"foo\"") == ok(string(@~"foo")); + assert from_str(~"\"\\\"\"") == ok(string(@~"\"")); + assert from_str(~"\"\\b\"") == ok(string(@~"\x08")); + assert from_str(~"\"\\n\"") == ok(string(@~"\n")); + assert from_str(~"\"\\r\"") == ok(string(@~"\r")); + assert from_str(~"\"\\t\"") == ok(string(@~"\t")); + assert from_str(~" \"foo\" ") == ok(string(@~"foo")); } #[test] fn test_read_list() { - assert from_str("[") == - err({line: 1u, col: 2u, msg: @"EOF while parsing value"}); - assert from_str("[1") == - err({line: 1u, col: 3u, msg: @"EOF while parsing list"}); - assert from_str("[1,") == - err({line: 1u, col: 4u, msg: @"EOF while parsing value"}); - assert from_str("[1,]") == - err({line: 1u, col: 4u, msg: @"invalid syntax"}); - assert from_str("[6 7]") == - err({line: 1u, col: 4u, msg: @"expected `,` or `]`"}); + assert from_str(~"[") == + err({line: 1u, col: 2u, msg: @~"EOF while parsing value"}); + assert from_str(~"[1") == + err({line: 1u, col: 3u, msg: @~"EOF while parsing list"}); + assert from_str(~"[1,") == + err({line: 1u, col: 4u, msg: @~"EOF while parsing value"}); + assert from_str(~"[1,]") == + err({line: 1u, col: 4u, msg: @~"invalid syntax"}); + assert from_str(~"[6 7]") == + err({line: 1u, col: 4u, msg: @~"expected `,` or `]`"}); - assert from_str("[]") == ok(list(@~[])); - assert from_str("[ ]") == ok(list(@~[])); - assert from_str("[true]") == ok(list(@~[boolean(true)])); - assert from_str("[ false ]") == ok(list(@~[boolean(false)])); - assert from_str("[null]") == ok(list(@~[null])); - assert from_str("[3, 1]") == ok(list(@~[num(3f), num(1f)])); - assert from_str("\n[3, 2]\n") == ok(list(@~[num(3f), num(2f)])); - assert from_str("[2, [4, 1]]") == + assert from_str(~"[]") == ok(list(@~[])); + assert from_str(~"[ ]") == ok(list(@~[])); + assert from_str(~"[true]") == ok(list(@~[boolean(true)])); + assert from_str(~"[ false ]") == ok(list(@~[boolean(false)])); + assert from_str(~"[null]") == ok(list(@~[null])); + assert from_str(~"[3, 1]") == ok(list(@~[num(3f), num(1f)])); + assert from_str(~"\n[3, 2]\n") == ok(list(@~[num(3f), num(2f)])); + assert from_str(~"[2, [4, 1]]") == ok(list(@~[num(2f), list(@~[num(4f), num(1f)])])); } #[test] fn test_read_dict() { - assert from_str("{") == - err({line: 1u, col: 2u, msg: @"EOF while parsing object"}); - assert from_str("{ ") == - err({line: 1u, col: 3u, msg: @"EOF while parsing object"}); - assert from_str("{1") == - err({line: 1u, col: 2u, msg: @"key must be a string"}); - assert from_str("{ \"a\"") == - err({line: 1u, col: 6u, msg: @"EOF while parsing object"}); - assert from_str("{\"a\"") == - err({line: 1u, col: 5u, msg: @"EOF while parsing object"}); - assert from_str("{\"a\" ") == - err({line: 1u, col: 6u, msg: @"EOF while parsing object"}); + assert from_str(~"{") == + err({line: 1u, col: 2u, msg: @~"EOF while parsing object"}); + assert from_str(~"{ ") == + err({line: 1u, col: 3u, msg: @~"EOF while parsing object"}); + assert from_str(~"{1") == + err({line: 1u, col: 2u, msg: @~"key must be a string"}); + assert from_str(~"{ \"a\"") == + err({line: 1u, col: 6u, msg: @~"EOF while parsing object"}); + assert from_str(~"{\"a\"") == + err({line: 1u, col: 5u, msg: @~"EOF while parsing object"}); + assert from_str(~"{\"a\" ") == + err({line: 1u, col: 6u, msg: @~"EOF while parsing object"}); - assert from_str("{\"a\" 1") == - err({line: 1u, col: 6u, msg: @"expected `:`"}); - assert from_str("{\"a\":") == - err({line: 1u, col: 6u, msg: @"EOF while parsing value"}); - assert from_str("{\"a\":1") == - err({line: 1u, col: 7u, msg: @"EOF while parsing object"}); - assert from_str("{\"a\":1 1") == - err({line: 1u, col: 8u, msg: @"expected `,` or `}`"}); - assert from_str("{\"a\":1,") == - err({line: 1u, col: 8u, msg: @"EOF while parsing object"}); + assert from_str(~"{\"a\" 1") == + err({line: 1u, col: 6u, msg: @~"expected `:`"}); + assert from_str(~"{\"a\":") == + err({line: 1u, col: 6u, msg: @~"EOF while parsing value"}); + assert from_str(~"{\"a\":1") == + err({line: 1u, col: 7u, msg: @~"EOF while parsing object"}); + assert from_str(~"{\"a\":1 1") == + err({line: 1u, col: 8u, msg: @~"expected `,` or `}`"}); + assert from_str(~"{\"a\":1,") == + err({line: 1u, col: 8u, msg: @~"EOF while parsing object"}); - assert eq(result::get(from_str("{}")), mk_dict(~[])); - assert eq(result::get(from_str("{\"a\": 3}")), - mk_dict(~[("a", num(3.0f))])); + assert eq(result::get(from_str(~"{}")), mk_dict(~[])); + assert eq(result::get(from_str(~"{\"a\": 3}")), + mk_dict(~[(~"a", num(3.0f))])); - assert eq(result::get(from_str("{ \"a\": null, \"b\" : true }")), + assert eq(result::get(from_str(~"{ \"a\": null, \"b\" : true }")), mk_dict(~[ - ("a", null), - ("b", boolean(true))])); - assert eq(result::get(from_str("\n{ \"a\": null, \"b\" : true }\n")), + (~"a", null), + (~"b", boolean(true))])); + assert eq(result::get(from_str(~"\n{ \"a\": null, \"b\" : true }\n")), mk_dict(~[ - ("a", null), - ("b", boolean(true))])); - assert eq(result::get(from_str("{\"a\" : 1.0 ,\"b\": [ true ]}")), + (~"a", null), + (~"b", boolean(true))])); + assert eq(result::get(from_str(~"{\"a\" : 1.0 ,\"b\": [ true ]}")), mk_dict(~[ - ("a", num(1.0)), - ("b", list(@~[boolean(true)])) + (~"a", num(1.0)), + (~"b", list(@~[boolean(true)])) ])); assert eq(result::get(from_str( - "{" + - "\"a\": 1.0, " + - "\"b\": [" + - "true," + - "\"foo\\nbar\", " + - "{ \"c\": {\"d\": null} } " + - "]" + - "}")), + ~"{" + + ~"\"a\": 1.0, " + + ~"\"b\": [" + + ~"true," + + ~"\"foo\\nbar\", " + + ~"{ \"c\": {\"d\": null} } " + + ~"]" + + ~"}")), mk_dict(~[ - ("a", num(1.0f)), - ("b", list(@~[ + (~"a", num(1.0f)), + (~"b", list(@~[ boolean(true), - string(@"foo\nbar"), + string(@~"foo\nbar"), mk_dict(~[ - ("c", mk_dict(~[("d", null)])) + (~"c", mk_dict(~[(~"d", null)])) ]) ])) ])); @@ -876,7 +877,7 @@ fn test_read_dict() { #[test] fn test_multiline_errors() { - assert from_str("{\n \"foo\":\n \"bar\"") == - err({line: 3u, col: 8u, msg: @"EOF while parsing object"}); + assert from_str(~"{\n \"foo\":\n \"bar\"") == + err({line: 3u, col: 8u, msg: @~"EOF while parsing object"}); } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 3a7b0ffd79a2..46bb01250fe8 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -85,7 +85,7 @@ fn len(ls: @list) -> uint { pure fn tail(ls: @list) -> @list { alt *ls { cons(_, tl) { ret tl; } - nil { fail "list empty" } + nil { fail ~"list empty" } } } diff --git a/src/libstd/map.rs b/src/libstd/map.rs index cc88a91bcf24..bce843224d1f 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -237,7 +237,7 @@ fn find(k: K) -> option { } fn get(k: K) -> V { - self.find(k).expect("Key not found in table") + self.find(k).expect(~"Key not found in table") } fn [](k: K) -> V { @@ -305,13 +305,13 @@ fn hashmap(hasher: hashfn, eqer: eqfn) } /// Construct a hashmap for string keys -fn str_hash() -> hashmap { +fn str_hash() -> hashmap<~str, V> { ret hashmap(str::hash, str::eq); } /// Construct a hashmap for boxed string keys -fn box_str_hash() -> hashmap<@str/~, V> { - ret hashmap(|x: @str/~| str::hash(*x), |x,y| str::eq(*x,*y)); +fn box_str_hash() -> hashmap<@~str, V> { + ret hashmap(|x: @~str| str::hash(*x), |x,y| str::eq(*x,*y)); } /// Construct a hashmap for byte string keys @@ -356,7 +356,7 @@ fn hash_from_vec(hasher: hashfn, eqer: eqfn, } /// Construct a hashmap from a vector with string keys -fn hash_from_strs(items: ~[(str, V)]) -> hashmap { +fn hash_from_strs(items: ~[(~str, V)]) -> hashmap<~str, V> { hash_from_vec(str::hash, str::eq, items) } @@ -385,8 +385,8 @@ fn test_simple() { fn uint_id(&&x: uint) -> uint { x } let hasher_uint: map::hashfn = uint_id; let eqer_uint: map::eqfn = eq_uint; - let hasher_str: map::hashfn = str::hash; - let eqer_str: map::eqfn = str::eq; + let hasher_str: map::hashfn<~str> = str::hash; + let eqer_str: map::eqfn<~str> = str::eq; #debug("uint -> uint"); let hm_uu: map::hashmap = map::hashmap::(hasher_uint, eqer_uint); @@ -400,49 +400,49 @@ fn uint_id(&&x: uint) -> uint { x } assert (hm_uu.get(12u) == 14u); assert (!hm_uu.insert(12u, 12u)); assert (hm_uu.get(12u) == 12u); - let ten: str = "ten"; - let eleven: str = "eleven"; - let twelve: str = "twelve"; + let ten: ~str = ~"ten"; + let eleven: ~str = ~"eleven"; + let twelve: ~str = ~"twelve"; #debug("str -> uint"); - let hm_su: map::hashmap = - map::hashmap::(hasher_str, eqer_str); - assert (hm_su.insert("ten", 12u)); + let hm_su: map::hashmap<~str, uint> = + map::hashmap::<~str, uint>(hasher_str, eqer_str); + assert (hm_su.insert(~"ten", 12u)); assert (hm_su.insert(eleven, 13u)); - assert (hm_su.insert("twelve", 14u)); + assert (hm_su.insert(~"twelve", 14u)); assert (hm_su.get(eleven) == 13u); - assert (hm_su.get("eleven") == 13u); - assert (hm_su.get("twelve") == 14u); - assert (hm_su.get("ten") == 12u); - assert (!hm_su.insert("twelve", 14u)); - assert (hm_su.get("twelve") == 14u); - assert (!hm_su.insert("twelve", 12u)); - assert (hm_su.get("twelve") == 12u); + assert (hm_su.get(~"eleven") == 13u); + assert (hm_su.get(~"twelve") == 14u); + assert (hm_su.get(~"ten") == 12u); + assert (!hm_su.insert(~"twelve", 14u)); + assert (hm_su.get(~"twelve") == 14u); + assert (!hm_su.insert(~"twelve", 12u)); + assert (hm_su.get(~"twelve") == 12u); #debug("uint -> str"); - let hm_us: map::hashmap = - map::hashmap::(hasher_uint, eqer_uint); - assert (hm_us.insert(10u, "twelve")); - assert (hm_us.insert(11u, "thirteen")); - assert (hm_us.insert(12u, "fourteen")); - assert (str::eq(hm_us.get(11u), "thirteen")); - assert (str::eq(hm_us.get(12u), "fourteen")); - assert (str::eq(hm_us.get(10u), "twelve")); - assert (!hm_us.insert(12u, "fourteen")); - assert (str::eq(hm_us.get(12u), "fourteen")); - assert (!hm_us.insert(12u, "twelve")); - assert (str::eq(hm_us.get(12u), "twelve")); + let hm_us: map::hashmap = + map::hashmap::(hasher_uint, eqer_uint); + assert (hm_us.insert(10u, ~"twelve")); + assert (hm_us.insert(11u, ~"thirteen")); + assert (hm_us.insert(12u, ~"fourteen")); + assert (str::eq(hm_us.get(11u), ~"thirteen")); + assert (str::eq(hm_us.get(12u), ~"fourteen")); + assert (str::eq(hm_us.get(10u), ~"twelve")); + assert (!hm_us.insert(12u, ~"fourteen")); + assert (str::eq(hm_us.get(12u), ~"fourteen")); + assert (!hm_us.insert(12u, ~"twelve")); + assert (str::eq(hm_us.get(12u), ~"twelve")); #debug("str -> str"); - let hm_ss: map::hashmap = - map::hashmap::(hasher_str, eqer_str); - assert (hm_ss.insert(ten, "twelve")); - assert (hm_ss.insert(eleven, "thirteen")); - assert (hm_ss.insert(twelve, "fourteen")); - assert (str::eq(hm_ss.get("eleven"), "thirteen")); - assert (str::eq(hm_ss.get("twelve"), "fourteen")); - assert (str::eq(hm_ss.get("ten"), "twelve")); - assert (!hm_ss.insert("twelve", "fourteen")); - assert (str::eq(hm_ss.get("twelve"), "fourteen")); - assert (!hm_ss.insert("twelve", "twelve")); - assert (str::eq(hm_ss.get("twelve"), "twelve")); + let hm_ss: map::hashmap<~str, ~str> = + map::hashmap::<~str, ~str>(hasher_str, eqer_str); + assert (hm_ss.insert(ten, ~"twelve")); + assert (hm_ss.insert(eleven, ~"thirteen")); + assert (hm_ss.insert(twelve, ~"fourteen")); + assert (str::eq(hm_ss.get(~"eleven"), ~"thirteen")); + assert (str::eq(hm_ss.get(~"twelve"), ~"fourteen")); + assert (str::eq(hm_ss.get(~"ten"), ~"twelve")); + assert (!hm_ss.insert(~"twelve", ~"fourteen")); + assert (str::eq(hm_ss.get(~"twelve"), ~"fourteen")); + assert (!hm_ss.insert(~"twelve", ~"twelve")); + assert (str::eq(hm_ss.get(~"twelve"), ~"twelve")); #debug("*** finished test_simple"); } @@ -484,10 +484,10 @@ fn uint_id(&&x: uint) -> uint { x } i += 1u; } #debug("str -> str"); - let hasher_str: map::hashfn = str::hash; - let eqer_str: map::eqfn = str::eq; - let hm_ss: map::hashmap = - map::hashmap::(hasher_str, eqer_str); + let hasher_str: map::hashfn<~str> = str::hash; + let eqer_str: map::eqfn<~str> = str::eq; + let hm_ss: map::hashmap<~str, ~str> = + map::hashmap::<~str, ~str>(hasher_str, eqer_str); i = 0u; while i < num_to_insert { assert hm_ss.insert(uint::to_str(i, 2u), uint::to_str(i * i, 2u)); @@ -602,27 +602,27 @@ fn hash(&&u: uint) -> uint { #[test] fn test_contains_key() { - let key = "k"; - let map = map::hashmap::(str::hash, str::eq); + let key = ~"k"; + let map = map::hashmap::<~str, ~str>(str::hash, str::eq); assert (!map.contains_key(key)); - map.insert(key, "val"); + map.insert(key, ~"val"); assert (map.contains_key(key)); } #[test] fn test_find() { - let key = "k"; - let map = map::hashmap::(str::hash, str::eq); + let key = ~"k"; + let map = map::hashmap::<~str, ~str>(str::hash, str::eq); assert (option::is_none(map.find(key))); - map.insert(key, "val"); - assert (option::get(map.find(key)) == "val"); + map.insert(key, ~"val"); + assert (option::get(map.find(key)) == ~"val"); } #[test] fn test_clear() { - let key = "k"; - let map = map::hashmap::(str::hash, str::eq); - map.insert(key, "val"); + let key = ~"k"; + let map = map::hashmap::<~str, ~str>(str::hash, str::eq); + map.insert(key, ~"val"); assert (map.size() == 1); assert (map.contains_key(key)); map.clear(); @@ -633,13 +633,13 @@ fn test_clear() { #[test] fn test_hash_from_vec() { let map = map::hash_from_strs(~[ - ("a", 1), - ("b", 2), - ("c", 3) + (~"a", 1), + (~"b", 2), + (~"c", 3) ]); assert map.size() == 3u; - assert map.get("a") == 1; - assert map.get("b") == 2; - assert map.get("c") == 3; + assert map.get(~"a") == 1; + assert map.get(~"b") == 2; + assert map.get(~"c") == 3; } } diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index d7bd7ed811a7..134091dfd1dc 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -82,17 +82,17 @@ fn rot(r: int, x: u32) -> u32 { ret {a: a, b: b, c: c, d: d}; } -fn md4_str(msg: ~[u8]) -> str { +fn md4_str(msg: ~[u8]) -> ~str { let {a, b, c, d} = md4(msg); fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { f(a); f(b); f(c); f(d); } - let mut result = ""; + let mut result = ~""; do app(a, b, c, d) |u| { let mut i = 0u32; while i < 4u32 { let byte = (u >> (i * 8u32)) as u8; - if byte <= 16u8 { result += "0"; } + if byte <= 16u8 { result += ~"0"; } result += uint::to_str(byte as uint, 16u); i += 1u32; } @@ -100,19 +100,19 @@ fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { result } -fn md4_text(msg: str) -> str { md4_str(str::bytes(msg)) } +fn md4_text(msg: ~str) -> ~str { md4_str(str::bytes(msg)) } #[test] fn test_md4() { - assert md4_text("") == "31d6cfe0d16ae931b73c59d7e0c089c0"; - assert md4_text("a") == "bde52cb31de33e46245e05fbdbd6fb24"; - assert md4_text("abc") == "a448017aaf21d8525fc10ae87aa6729d"; - assert md4_text("message digest") == "d9130a8164549fe818874806e1c7014b"; - assert md4_text("abcdefghijklmnopqrstuvwxyz") == - "d79e1c308aa5bbcdeea8ed63df412da9"; - assert md4_text("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123\ - 456789") == "043f8582f241db351ce627e153e7f0e4"; - assert md4_text("12345678901234567890123456789012345678901234567890123456\ - 789012345678901234567890") == - "e33b4ddc9c38f2199c3e7b164fcc0536"; + assert md4_text(~"") == ~"31d6cfe0d16ae931b73c59d7e0c089c0"; + assert md4_text(~"a") == ~"bde52cb31de33e46245e05fbdbd6fb24"; + assert md4_text(~"abc") == ~"a448017aaf21d8525fc10ae87aa6729d"; + assert md4_text(~"message digest") == ~"d9130a8164549fe818874806e1c7014b"; + assert md4_text(~"abcdefghijklmnopqrstuvwxyz") == + ~"d79e1c308aa5bbcdeea8ed63df412da9"; + assert md4_text(~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ + 0123456789") == ~"043f8582f241db351ce627e153e7f0e4"; + assert md4_text(~"1234567890123456789012345678901234567890123456789\ + 0123456789012345678901234567890") == + ~"e33b4ddc9c38f2199c3e7b164fcc0536"; } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index abb548655d47..a78b6a5f1723 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -36,7 +36,7 @@ enum ip_addr { /// Human-friendly feedback on why a parse_addr attempt failed type parse_addr_err = { - err_msg: str + err_msg: ~str }; /** @@ -46,13 +46,13 @@ enum ip_addr { * * * ip - a `std::net::ip::ip_addr` */ -fn format_addr(ip: ip_addr) -> str { +fn format_addr(ip: ip_addr) -> ~str { alt ip { ipv4(addr) { unsafe { let result = uv_ip4_name(&addr); - if result == "" { - fail "failed to convert inner sockaddr_in address to str" + if result == ~"" { + fail ~"failed to convert inner sockaddr_in address to str" } result } @@ -60,8 +60,8 @@ fn format_addr(ip: ip_addr) -> str { ipv6(addr) { unsafe { let result = uv_ip6_name(&addr); - if result == "" { - fail "failed to convert inner sockaddr_in address to str" + if result == ~"" { + fail ~"failed to convert inner sockaddr_in address to str" } result } @@ -88,7 +88,7 @@ enum ip_get_addr_err { * a vector of `ip_addr` results, in the case of success, or an error * object in the case of failure */ -fn get_addr(++node: str, iotask: iotask) +fn get_addr(++node: ~str, iotask: iotask) -> result::result<~[ip_addr], ip_get_addr_err> unsafe { do comm::listen |output_ch| { do str::unpack_slice(node) |node_ptr, len| { @@ -137,7 +137,7 @@ mod v4 { * * * an `ip_addr` of the `ipv4` variant */ - fn parse_addr(ip: str) -> ip_addr { + fn parse_addr(ip: ~str) -> ip_addr { alt try_parse_addr(ip) { result::ok(addr) { copy(addr) } result::err(err_data) { @@ -154,7 +154,7 @@ unsafe fn as_u32() -> u32 { *((ptr::addr_of(self)) as *u32) } } - fn parse_to_ipv4_rep(ip: str) -> result::result { + fn parse_to_ipv4_rep(ip: ~str) -> result::result { let parts = vec::map(str::split_char(ip, '.'), |s| { alt uint::from_str(s) { some(n) if n <= 255u { n } @@ -172,7 +172,7 @@ fn parse_to_ipv4_rep(ip: str) -> result::result { c: parts[2] as u8, d: parts[3] as u8}) } } - fn try_parse_addr(ip: str) -> result::result { + fn try_parse_addr(ip: ~str) -> result::result { unsafe { let INADDR_NONE = ll::get_INADDR_NONE(); let ip_rep_result = parse_to_ipv4_rep(ip); @@ -196,7 +196,7 @@ fn try_parse_addr(ip: str) -> result::result { if result::get(ref_ip_rep_result).as_u32() == INADDR_NONE && !input_is_inaddr_none { ret result::err( - {err_msg: "uv_ip4_name produced invalid result."}) + {err_msg: ~"uv_ip4_name produced invalid result."}) } else { result::ok(ipv4(copy(new_addr))) @@ -220,7 +220,7 @@ mod v6 { * * * an `ip_addr` of the `ipv6` variant */ - fn parse_addr(ip: str) -> ip_addr { + fn parse_addr(ip: ~str) -> ip_addr { alt try_parse_addr(ip) { result::ok(addr) { copy(addr) } result::err(err_data) { @@ -228,7 +228,7 @@ fn parse_addr(ip: str) -> ip_addr { } } } - fn try_parse_addr(ip: str) -> result::result { + fn try_parse_addr(ip: ~str) -> result::result { unsafe { // need to figure out how to establish a parse failure.. let new_addr = uv_ip6_addr(ip, 22); @@ -237,7 +237,7 @@ fn try_parse_addr(ip: str) -> result::result { ip, reparsed_name)); // '::' appears to be uv_ip6_name() returns for bogus // parses.. - if ip != "::" && reparsed_name == "::" { + if ip != ~"::" && reparsed_name == ~"::" { result::err({err_msg:#fmt("failed to parse '%s'", ip)}) } @@ -254,7 +254,7 @@ fn try_parse_addr(ip: str) -> result::result { extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int, res: *addrinfo) unsafe { - log(debug, "in get_addr_cb"); + log(debug, ~"in get_addr_cb"); let handle_data = get_data_for_req(handle) as *get_addr_data; if status == 0i32 { @@ -272,8 +272,8 @@ fn try_parse_addr(ip: str) -> result::result { *ll::addrinfo_as_sockaddr_in6(curr_addr)))) } else { - log(debug, "curr_addr is not of family AF_INET or "+ - "AF_INET6. Error."); + log(debug, ~"curr_addr is not of family AF_INET or "+ + ~"AF_INET6. Error."); (*handle_data).output_ch.send( result::err(get_addr_unknown_error)); break; @@ -282,7 +282,7 @@ fn try_parse_addr(ip: str) -> result::result { let next_addr = ll::get_next_addrinfo(curr_addr); if next_addr == ptr::null::() as *addrinfo { - log(debug, "null next_addr encountered. no mas"); + log(debug, ~"null next_addr encountered. no mas"); break; } else { @@ -295,33 +295,33 @@ fn try_parse_addr(ip: str) -> result::result { (*handle_data).output_ch.send(result::ok(out_vec)); } else { - log(debug, "addrinfo pointer is NULL"); + log(debug, ~"addrinfo pointer is NULL"); (*handle_data).output_ch.send( result::err(get_addr_unknown_error)); } } else { - log(debug, "status != 0 error in get_addr_cb"); + log(debug, ~"status != 0 error in get_addr_cb"); (*handle_data).output_ch.send( result::err(get_addr_unknown_error)); } if res != (ptr::null::()) { uv_freeaddrinfo(res); } - log(debug, "leaving get_addr_cb"); + log(debug, ~"leaving get_addr_cb"); } #[cfg(test)] mod test { #[test] fn test_ip_ipv4_parse_and_format_ip() { - let localhost_str = "127.0.0.1"; + let localhost_str = ~"127.0.0.1"; assert (format_addr(v4::parse_addr(localhost_str)) == localhost_str) } #[test] fn test_ip_ipv6_parse_and_format_ip() { - let localhost_str = "::1"; + let localhost_str = ~"::1"; let format_result = format_addr(v6::parse_addr(localhost_str)); log(debug, #fmt("results: expected: '%s' actual: '%s'", localhost_str, format_result)); @@ -329,7 +329,7 @@ fn test_ip_ipv6_parse_and_format_ip() { } #[test] fn test_ip_ipv4_bad_parse() { - alt v4::try_parse_addr("b4df00d") { + alt v4::try_parse_addr(~"b4df00d") { result::err(err_info) { log(debug, #fmt("got error as expected %?", err_info)); assert true; @@ -342,7 +342,7 @@ fn test_ip_ipv4_bad_parse() { #[test] #[ignore(target_os="win32")] fn test_ip_ipv6_bad_parse() { - alt v6::try_parse_addr("::,~2234k;") { + alt v6::try_parse_addr(~"::,~2234k;") { result::err(err_info) { log(debug, #fmt("got error as expected %?", err_info)); assert true; @@ -355,11 +355,11 @@ fn test_ip_ipv6_bad_parse() { #[test] #[ignore(reason = "valgrind says it's leaky")] fn test_ip_get_addr() { - let localhost_name = "localhost"; + let localhost_name = ~"localhost"; let iotask = uv::global_loop::get(); let ga_result = get_addr(localhost_name, iotask); if result::is_err(ga_result) { - fail "got err result from net::ip::get_addr();" + fail ~"got err result from net::ip::get_addr();" } // note really sure how to realiably test/assert // this.. mostly just wanting to see it work, atm. @@ -369,10 +369,10 @@ fn test_ip_get_addr() { for vec::each(results) |r| { let ipv_prefix = alt r { ipv4(_) { - "IPv4" + ~"IPv4" } ipv6(_) { - "IPv6" + ~"IPv6" } }; log(debug, #fmt("test_get_addr: result %s: '%s'", @@ -385,7 +385,7 @@ fn test_ip_get_addr() { #[test] #[ignore(reason = "valgrind says it's leaky")] fn test_ip_get_addr_bad_input() { - let localhost_name = "sjkl234m,./sdf"; + let localhost_name = ~"sjkl234m,./sdf"; let iotask = uv::global_loop::get(); let ga_result = get_addr(localhost_name, iotask); assert result::is_err(ga_result); diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 17ffae1b5f44..31b8841933bc 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -62,8 +62,8 @@ /// Contains raw, string-based, error information returned from libuv type tcp_err_data = { - err_name: str, - err_msg: str + err_name: ~str, + err_msg: ~str }; /// Details returned as part of a `result::err` result from `tcp::listen` enum tcp_listen_err_data { @@ -71,7 +71,7 @@ enum tcp_listen_err_data { * Some unplanned-for error. The first and second fields correspond * to libuv's `err_name` and `err_msg` fields, respectively. */ - generic_listen_err(str, str), + generic_listen_err(~str, ~str), /** * Failed to bind to the requested IP/Port, because it is already in use. * @@ -98,7 +98,7 @@ enum tcp_connect_err_data { * Some unplanned-for error. The first and second fields correspond * to libuv's `err_name` and `err_msg` fields, respectively. */ - generic_connect_err(str, str), + generic_connect_err(~str, ~str), /// Invalid IP or invalid port connection_refused } @@ -147,15 +147,15 @@ fn connect(-input_ip: ip::ip_addr, port: uint, log(debug, #fmt("stream_handle_ptr outside interact %?", stream_handle_ptr)); do iotask::interact(iotask) |loop_ptr| { - log(debug, "in interact cb for tcp client connect.."); + log(debug, ~"in interact cb for tcp client connect.."); log(debug, #fmt("stream_handle_ptr in interact %?", stream_handle_ptr)); alt uv::ll::tcp_init( loop_ptr, stream_handle_ptr) { 0i32 { - log(debug, "tcp_init successful"); + log(debug, ~"tcp_init successful"); alt input_ip { ipv4 { - log(debug, "dealing w/ ipv4 connection.."); + log(debug, ~"dealing w/ ipv4 connection.."); let connect_req_ptr = ptr::addr_of((*socket_data_ptr).connect_req); let addr_str = ip::format_addr(input_ip); @@ -186,7 +186,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint, }; alt connect_result { 0i32 { - log(debug, "tcp_connect successful"); + log(debug, ~"tcp_connect successful"); // reusable data that we'll have for the // duration.. uv::ll::set_data_for_uv_handle(stream_handle_ptr, @@ -196,7 +196,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint, // outcome.. uv::ll::set_data_for_req(connect_req_ptr, conn_data_ptr); - log(debug, "leaving tcp_connect interact cb..."); + log(debug, ~"leaving tcp_connect interact cb..."); // let tcp_connect_on_connect_cb send on // the result_ch, now.. } @@ -224,17 +224,17 @@ fn connect(-input_ip: ip::ip_addr, port: uint, }; alt comm::recv(result_po) { conn_success { - log(debug, "tcp::connect - received success on result_po"); + log(debug, ~"tcp::connect - received success on result_po"); result::ok(tcp_socket(socket_data)) } conn_failure(err_data) { comm::recv(closed_signal_po); - log(debug, "tcp::connect - received failure on result_po"); + log(debug, ~"tcp::connect - received failure on result_po"); // still have to free the malloc'd stream handle.. rustrt::rust_uv_current_kernel_free(stream_handle_ptr as *libc::c_void); let tcp_conn_err = alt err_data.err_name { - "ECONNREFUSED" { connection_refused } + ~"ECONNREFUSED" { connection_refused } _ { generic_connect_err(err_data.err_name, err_data.err_msg) } }; result::err(tcp_conn_err) @@ -497,31 +497,31 @@ fn accept(new_conn: tcp_new_connection) // the rules here because this always has to be // called within the context of a listen() new_connect_cb // callback (or it will likely fail and drown your cat) - log(debug, "in interact cb for tcp::accept"); + log(debug, ~"in interact cb for tcp::accept"); let loop_ptr = uv::ll::get_loop_for_uv_handle( server_handle_ptr); alt uv::ll::tcp_init(loop_ptr, client_stream_handle_ptr) { 0i32 { - log(debug, "uv_tcp_init successful for client stream"); + log(debug, ~"uv_tcp_init successful for client stream"); alt uv::ll::accept( server_handle_ptr as *libc::c_void, client_stream_handle_ptr as *libc::c_void) { 0i32 { - log(debug, "successfully accepted client connection"); + log(debug, ~"successfully accepted client connection"); uv::ll::set_data_for_uv_handle(client_stream_handle_ptr, client_socket_data_ptr as *libc::c_void); comm::send(result_ch, none); } _ { - log(debug, "failed to accept client conn"); + log(debug, ~"failed to accept client conn"); comm::send(result_ch, some( uv::ll::get_last_err_data(loop_ptr).to_tcp_err())); } } } _ { - log(debug, "failed to init client stream"); + log(debug, ~"failed to init client stream"); comm::send(result_ch, some( uv::ll::get_last_err_data(loop_ptr).to_tcp_err())); } @@ -642,21 +642,21 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint, comm::send(setup_ch, none); } _ { - log(debug, "failure to uv_listen()"); + log(debug, ~"failure to uv_listen()"); let err_data = uv::ll::get_last_err_data(loop_ptr); comm::send(setup_ch, some(err_data)); } } } _ { - log(debug, "failure to uv_tcp_bind"); + log(debug, ~"failure to uv_tcp_bind"); let err_data = uv::ll::get_last_err_data(loop_ptr); comm::send(setup_ch, some(err_data)); } } } _ { - log(debug, "failure to uv_tcp_init"); + log(debug, ~"failure to uv_tcp_init"); let err_data = uv::ll::get_last_err_data(loop_ptr); comm::send(setup_ch, some(err_data)); } @@ -674,12 +674,12 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint, }; stream_closed_po.recv(); alt err_data.err_name { - "EACCES" { - log(debug, "Got EACCES error"); + ~"EACCES" { + log(debug, ~"Got EACCES error"); result::err(access_denied) } - "EADDRINUSE" { - log(debug, "Got EADDRINUSE error"); + ~"EADDRINUSE" { + log(debug, ~"Got EADDRINUSE error"); result::err(address_in_use) } _ { @@ -855,13 +855,13 @@ fn tear_down_socket_data(socket_data: @tcp_socket_data) unsafe { log(debug, #fmt("about to free socket_data at %?", socket_data)); rustrt::rust_uv_current_kernel_free(stream_handle_ptr as *libc::c_void); - log(debug, "exiting dtor for tcp_socket"); + log(debug, ~"exiting dtor for tcp_socket"); } // shared implementation for tcp::read fn read_common_impl(socket_data: *tcp_socket_data, timeout_msecs: uint) -> result::result<~[u8],tcp_err_data> unsafe { - log(debug, "starting tcp::read"); + log(debug, ~"starting tcp::read"); let iotask = (*socket_data).iotask; let rs_result = read_start_common_impl(socket_data); if result::is_err(rs_result) { @@ -869,26 +869,26 @@ fn read_common_impl(socket_data: *tcp_socket_data, timeout_msecs: uint) result::err(err_data) } else { - log(debug, "tcp::read before recv_timeout"); + log(debug, ~"tcp::read before recv_timeout"); let read_result = if timeout_msecs > 0u { timer::recv_timeout( iotask, timeout_msecs, result::get(rs_result)) } else { some(comm::recv(result::get(rs_result))) }; - log(debug, "tcp::read after recv_timeout"); + log(debug, ~"tcp::read after recv_timeout"); alt read_result { none { - log(debug, "tcp::read: timed out.."); + log(debug, ~"tcp::read: timed out.."); let err_data = { - err_name: "TIMEOUT", - err_msg: "req timed out" + err_name: ~"TIMEOUT", + err_msg: ~"req timed out" }; read_stop_common_impl(socket_data); result::err(err_data) } some(data_result) { - log(debug, "tcp::read got data"); + log(debug, ~"tcp::read got data"); read_stop_common_impl(socket_data); data_result } @@ -903,14 +903,14 @@ fn read_stop_common_impl(socket_data: *tcp_socket_data) -> let stop_po = comm::port::>(); let stop_ch = comm::chan(stop_po); do iotask::interact((*socket_data).iotask) |loop_ptr| { - log(debug, "in interact cb for tcp::read_stop"); + log(debug, ~"in interact cb for tcp::read_stop"); alt uv::ll::read_stop(stream_handle_ptr as *uv::ll::uv_stream_t) { 0i32 { - log(debug, "successfully called uv_read_stop"); + log(debug, ~"successfully called uv_read_stop"); comm::send(stop_ch, none); } _ { - log(debug, "failure in calling uv_read_stop"); + log(debug, ~"failure in calling uv_read_stop"); let err_data = uv::ll::get_last_err_data(loop_ptr); comm::send(stop_ch, some(err_data.to_tcp_err())); } @@ -933,18 +933,18 @@ fn read_start_common_impl(socket_data: *tcp_socket_data) let stream_handle_ptr = (*socket_data).stream_handle_ptr; let start_po = comm::port::>(); let start_ch = comm::chan(start_po); - log(debug, "in tcp::read_start before interact loop"); + log(debug, ~"in tcp::read_start before interact loop"); do iotask::interact((*socket_data).iotask) |loop_ptr| { log(debug, #fmt("in tcp::read_start interact cb %?", loop_ptr)); alt uv::ll::read_start(stream_handle_ptr as *uv::ll::uv_stream_t, on_alloc_cb, on_tcp_read_cb) { 0i32 { - log(debug, "success doing uv_read_start"); + log(debug, ~"success doing uv_read_start"); comm::send(start_ch, none); } _ { - log(debug, "error attempting uv_read_start"); + log(debug, ~"error attempting uv_read_start"); let err_data = uv::ll::get_last_err_data(loop_ptr); comm::send(start_ch, some(err_data)); } @@ -985,11 +985,11 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data, write_buf_vec_ptr, tcp_write_complete_cb) { 0i32 { - log(debug, "uv_write() invoked successfully"); + log(debug, ~"uv_write() invoked successfully"); uv::ll::set_data_for_req(write_req_ptr, write_data_ptr); } _ { - log(debug, "error invoking uv_write()"); + log(debug, ~"error invoking uv_write()"); let err_data = uv::ll::get_last_err_data(loop_ptr); comm::send((*write_data_ptr).result_ch, tcp_write_error(err_data.to_tcp_err())); @@ -1113,13 +1113,13 @@ fn to_tcp_err() -> tcp_err_data { } } uv::ll::free_base_of_buf(buf); - log(debug, "exiting on_tcp_read_cb"); + log(debug, ~"exiting on_tcp_read_cb"); } extern fn on_alloc_cb(handle: *libc::c_void, ++suggested_size: size_t) -> uv::ll::uv_buf_t unsafe { - log(debug, "tcp read on_alloc_cb!"); + log(debug, ~"tcp read on_alloc_cb!"); let char_ptr = uv::ll::malloc_buf_base_of(suggested_size); log(debug, #fmt("tcp read on_alloc_cb h: %? char_ptr: %u sugsize: %u", handle, @@ -1137,7 +1137,7 @@ fn to_tcp_err() -> tcp_err_data { as *tcp_socket_close_data; let closed_ch = (*data).closed_ch; comm::send(closed_ch, ()); - log(debug, "tcp_socket_dtor_close_cb exiting.."); + log(debug, ~"tcp_socket_dtor_close_cb exiting.."); } extern fn tcp_write_complete_cb(write_req: *uv::ll::uv_write_t, @@ -1145,14 +1145,14 @@ fn to_tcp_err() -> tcp_err_data { let write_data_ptr = uv::ll::get_data_for_req(write_req) as *write_req_data; if status == 0i32 { - log(debug, "successful write complete"); + log(debug, ~"successful write complete"); comm::send((*write_data_ptr).result_ch, tcp_write_success); } else { let stream_handle_ptr = uv::ll::get_stream_handle_from_write_req( write_req); let loop_ptr = uv::ll::get_loop_for_uv_handle(stream_handle_ptr); let err_data = uv::ll::get_last_err_data(loop_ptr); - log(debug, "failure to write"); + log(debug, ~"failure to write"); comm::send((*write_data_ptr).result_ch, tcp_write_error(err_data)); } } @@ -1187,11 +1187,11 @@ fn to_tcp_err() -> tcp_err_data { uv::ll::get_stream_handle_from_connect_req(connect_req_ptr); alt status { 0i32 { - log(debug, "successful tcp connection!"); + log(debug, ~"successful tcp connection!"); comm::send(result_ch, conn_success); } _ { - log(debug, "error in tcp_connect_on_connect_cb"); + log(debug, ~"error in tcp_connect_on_connect_cb"); let loop_ptr = uv::ll::get_loop_for_uv_handle(tcp_stream_ptr); let err_data = uv::ll::get_last_err_data(loop_ptr); log(debug, #fmt("err_data %? %?", err_data.err_name, @@ -1202,7 +1202,7 @@ fn to_tcp_err() -> tcp_err_data { uv::ll::close(tcp_stream_ptr, stream_error_close_cb); } } - log(debug, "leaving tcp_connect_on_connect_cb"); + log(debug, ~"leaving tcp_connect_on_connect_cb"); } enum conn_attempt { @@ -1287,12 +1287,12 @@ fn test_gl_tcp_ipv4_server_client_reader_writer() { } fn impl_gl_tcp_ipv4_server_and_client() { let hl_loop = uv::global_loop::get(); - let server_ip = "127.0.0.1"; + let server_ip = ~"127.0.0.1"; let server_port = 8888u; - let expected_req = "ping"; - let expected_resp = "pong"; + let expected_req = ~"ping"; + let expected_resp = ~"pong"; - let server_result_po = comm::port::(); + let server_result_po = comm::port::<~str>(); let server_result_ch = comm::chan(server_result_po); let cont_po = comm::port::<()>(); @@ -1312,7 +1312,7 @@ fn impl_gl_tcp_ipv4_server_and_client() { }; comm::recv(cont_po); // client - log(debug, "server started, firing up client.."); + log(debug, ~"server started, firing up client.."); let actual_resp_result = do comm::listen |client_ch| { run_tcp_test_client( server_ip, @@ -1333,11 +1333,11 @@ fn impl_gl_tcp_ipv4_server_and_client() { } fn impl_gl_tcp_ipv4_client_error_connection_refused() { let hl_loop = uv::global_loop::get(); - let server_ip = "127.0.0.1"; + let server_ip = ~"127.0.0.1"; let server_port = 8889u; - let expected_req = "ping"; + let expected_req = ~"ping"; // client - log(debug, "firing up client.."); + log(debug, ~"firing up client.."); let actual_resp_result = do comm::listen |client_ch| { run_tcp_test_client( server_ip, @@ -1350,18 +1350,18 @@ fn impl_gl_tcp_ipv4_client_error_connection_refused() { connection_refused { } _ { - fail "unknown error.. expected connection_refused" + fail ~"unknown error.. expected connection_refused" } } } fn impl_gl_tcp_ipv4_server_address_in_use() { let hl_loop = uv::global_loop::get(); - let server_ip = "127.0.0.1"; + let server_ip = ~"127.0.0.1"; let server_port = 8890u; - let expected_req = "ping"; - let expected_resp = "pong"; + let expected_req = ~"ping"; + let expected_resp = ~"pong"; - let server_result_po = comm::port::(); + let server_result_po = comm::port::<~str>(); let server_result_ch = comm::chan(server_result_po); let cont_po = comm::port::<()>(); @@ -1386,7 +1386,7 @@ fn impl_gl_tcp_ipv4_server_address_in_use() { server_port, hl_loop); // client.. just doing this so that the first server tears down - log(debug, "server started, firing up client.."); + log(debug, ~"server started, firing up client.."); do comm::listen |client_ch| { run_tcp_test_client( server_ip, @@ -1400,14 +1400,14 @@ fn impl_gl_tcp_ipv4_server_address_in_use() { assert true; } _ { - fail "expected address_in_use listen error,"+ - "but got a different error varient. check logs."; + fail ~"expected address_in_use listen error,"+ + ~"but got a different error varient. check logs."; } } } fn impl_gl_tcp_ipv4_server_access_denied() { let hl_loop = uv::global_loop::get(); - let server_ip = "127.0.0.1"; + let server_ip = ~"127.0.0.1"; let server_port = 80u; // this one should fail.. let listen_err = run_tcp_test_server_fail( @@ -1419,19 +1419,19 @@ fn impl_gl_tcp_ipv4_server_access_denied() { assert true; } _ { - fail "expected address_in_use listen error,"+ - "but got a different error varient. check logs."; + fail ~"expected address_in_use listen error,"+ + ~"but got a different error varient. check logs."; } } } fn impl_gl_tcp_ipv4_server_client_reader_writer() { let iotask = uv::global_loop::get(); - let server_ip = "127.0.0.1"; + let server_ip = ~"127.0.0.1"; let server_port = 8891u; - let expected_req = "ping"; - let expected_resp = "pong"; + let expected_req = ~"ping"; + let expected_resp = ~"pong"; - let server_result_po = comm::port::(); + let server_result_po = comm::port::<~str>(); let server_result_ch = comm::chan(server_result_po); let cont_po = comm::port::<()>(); @@ -1474,7 +1474,7 @@ fn impl_gl_tcp_ipv4_server_client_reader_writer() { assert str::contains(actual_resp, expected_resp); } - fn buf_write(+w: io::writer, val: str) { + fn buf_write(+w: io::writer, val: ~str) { log(debug, #fmt("BUF_WRITE: val len %?", str::len(val))); do str::byte_slice(val) |b_slice| { log(debug, #fmt("BUF_WRITE: b_slice len %?", @@ -1483,17 +1483,17 @@ fn buf_write(+w: io::writer, val: str) { } } - fn buf_read(+r: io::reader, len: uint) -> str { + fn buf_read(+r: io::reader, len: uint) -> ~str { let new_bytes = r.read_bytes(len); log(debug, #fmt("in buf_read.. new_bytes len: %?", vec::len(new_bytes))); str::from_bytes(new_bytes) } - fn run_tcp_test_server(server_ip: str, server_port: uint, resp: str, - server_ch: comm::chan, + fn run_tcp_test_server(server_ip: ~str, server_port: uint, resp: ~str, + server_ch: comm::chan<~str>, cont_ch: comm::chan<()>, - iotask: iotask) -> str { + iotask: iotask) -> ~str { let server_ip_addr = ip::v4::parse_addr(server_ip); let listen_result = listen(server_ip_addr, server_port, 128u, iotask, // on_establish_cb -- called when listener is set up @@ -1505,55 +1505,55 @@ fn run_tcp_test_server(server_ip: str, server_port: uint, resp: str, // risky to run this on the loop, but some users // will want the POWER |new_conn, kill_ch| { - log(debug, "SERVER: new connection!"); + log(debug, ~"SERVER: new connection!"); do comm::listen |cont_ch| { do task::spawn_sched(task::manual_threads(1u)) { - log(debug, "SERVER: starting worker for new req"); + log(debug, ~"SERVER: starting worker for new req"); let accept_result = accept(new_conn); - log(debug, "SERVER: after accept()"); + log(debug, ~"SERVER: after accept()"); if result::is_err(accept_result) { - log(debug, "SERVER: error accept connection"); + log(debug, ~"SERVER: error accept connection"); let err_data = result::get_err(accept_result); comm::send(kill_ch, some(err_data)); log(debug, - "SERVER/WORKER: send on err cont ch"); + ~"SERVER/WORKER: send on err cont ch"); cont_ch.send(()); } else { log(debug, - "SERVER/WORKER: send on cont ch"); + ~"SERVER/WORKER: send on cont ch"); cont_ch.send(()); let sock = result::unwrap(accept_result); - log(debug, "SERVER: successfully accepted"+ - "connection!"); + log(debug, ~"SERVER: successfully accepted"+ + ~"connection!"); let received_req_bytes = read(sock, 0u); alt received_req_bytes { result::ok(data) { - log(debug, "SERVER: got REQ str::from_bytes.."); + log(debug, ~"SERVER: got REQ str::from_bytes.."); log(debug, #fmt("SERVER: REQ data len: %?", vec::len(data))); server_ch.send( str::from_bytes(data)); - log(debug, "SERVER: before write"); + log(debug, ~"SERVER: before write"); tcp_write_single(sock, str::bytes(resp)); - log(debug, "SERVER: after write.. die"); + log(debug, ~"SERVER: after write.. die"); comm::send(kill_ch, none); } result::err(err_data) { log(debug, #fmt("SERVER: error recvd: %s %s", err_data.err_name, err_data.err_msg)); comm::send(kill_ch, some(err_data)); - server_ch.send(""); + server_ch.send(~""); } } - log(debug, "SERVER: worker spinning down"); + log(debug, ~"SERVER: worker spinning down"); } } - log(debug, "SERVER: waiting to recv on cont_ch"); + log(debug, ~"SERVER: waiting to recv on cont_ch"); cont_ch.recv() }; - log(debug, "SERVER: recv'd on cont_ch..leaving listen cb"); + log(debug, ~"SERVER: recv'd on cont_ch..leaving listen cb"); }); // err check on listen_result if result::is_err(listen_result) { @@ -1563,10 +1563,10 @@ fn run_tcp_test_server(server_ip: str, server_port: uint, resp: str, name, msg); } access_denied { - fail "SERVER: exited abnormally, got access denied.."; + fail ~"SERVER: exited abnormally, got access denied.."; } address_in_use { - fail "SERVER: exited abnormally, got address in use..."; + fail ~"SERVER: exited abnormally, got address in use..."; } } } @@ -1575,7 +1575,7 @@ fn run_tcp_test_server(server_ip: str, server_port: uint, resp: str, ret_val } - fn run_tcp_test_server_fail(server_ip: str, server_port: uint, + fn run_tcp_test_server_fail(server_ip: ~str, server_port: uint, iotask: iotask) -> tcp_listen_err_data { let server_ip_addr = ip::v4::parse_addr(server_ip); let listen_result = listen(server_ip_addr, server_port, 128u, iotask, @@ -1593,20 +1593,20 @@ fn run_tcp_test_server_fail(server_ip: str, server_port: uint, result::get_err(listen_result) } else { - fail "SERVER: did not fail as expected" + fail ~"SERVER: did not fail as expected" } } - fn run_tcp_test_client(server_ip: str, server_port: uint, resp: str, - client_ch: comm::chan, - iotask: iotask) -> result::result, + iotask: iotask) -> result::result<~str, tcp_connect_err_data> { let server_ip_addr = ip::v4::parse_addr(server_ip); - log(debug, "CLIENT: starting.."); + log(debug, ~"CLIENT: starting.."); let connect_result = connect(server_ip_addr, server_port, iotask); if result::is_err(connect_result) { - log(debug, "CLIENT: failed to connect"); + log(debug, ~"CLIENT: failed to connect"); let err_data = result::get_err(connect_result); err(err_data) } @@ -1616,8 +1616,8 @@ fn run_tcp_test_client(server_ip: str, server_port: uint, resp: str, tcp_write_single(sock, resp_bytes); let read_result = sock.read(0u); if read_result.is_err() { - log(debug, "CLIENT: failure to read"); - ok("") + log(debug, ~"CLIENT: failure to read"); + ok(~"") } else { client_ch.send(str::from_bytes(read_result.get())); @@ -1633,12 +1633,12 @@ fn tcp_write_single(sock: tcp_socket, val: ~[u8]) { let write_result_future = sock.write_future(val); let write_result = write_result_future.get(); if result::is_err(write_result) { - log(debug, "tcp_write_single: write failed!"); + log(debug, ~"tcp_write_single: write failed!"); let err_data = result::get_err(write_result); log(debug, #fmt("tcp_write_single err name: %s msg: %s", err_data.err_name, err_data.err_msg)); // meh. torn on what to do here. - fail "tcp_write_single failed"; + fail ~"tcp_write_single failed"; } } } diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 9bf6a0212828..ce78bc945db7 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -31,7 +31,7 @@ fn map_slices( let len = xs.len(); if len < min_granularity { - log(info, "small slice"); + log(info, ~"small slice"); // This is a small vector, fall back on the normal map. ~[f()(0u, xs)] } @@ -42,7 +42,7 @@ fn map_slices( let mut futures = ~[]; let mut base = 0u; - log(info, "spawning tasks"); + log(info, ~"spawning tasks"); while base < len { let end = uint::min(len, base + items_per_task); // FIXME: why is the :: annotation required here? (#2617) @@ -66,7 +66,7 @@ fn map_slices( }; base += items_per_task; } - log(info, "tasks spawned"); + log(info, ~"tasks spawned"); log(info, #fmt("num_tasks: %?", (num_tasks, futures.len()))); assert(num_tasks == futures.len()); diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index 497ed8f0c063..dbeb5ab63810 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -4,7 +4,7 @@ impl of serializer for writer { fn emit_nil() { - self.write_str("()") + self.write_str(~"()") } fn emit_uint(v: uint) { @@ -63,68 +63,68 @@ fn emit_f32(v: f32) { self.write_str(#fmt["%?_f32", v]); } - fn emit_str(v: str) { + fn emit_str(v: ~str) { self.write_str(#fmt["%?", v]); } - fn emit_enum(_name: str, f: fn()) { + fn emit_enum(_name: ~str, f: fn()) { f(); } - fn emit_enum_variant(v_name: str, _v_id: uint, sz: uint, f: fn()) { + fn emit_enum_variant(v_name: ~str, _v_id: uint, sz: uint, f: fn()) { self.write_str(v_name); - if sz > 0u { self.write_str("("); } + if sz > 0u { self.write_str(~"("); } f(); - if sz > 0u { self.write_str(")"); } + if sz > 0u { self.write_str(~")"); } } fn emit_enum_variant_arg(idx: uint, f: fn()) { - if idx > 0u { self.write_str(", "); } + if idx > 0u { self.write_str(~", "); } f(); } fn emit_vec(_len: uint, f: fn()) { - self.write_str("["); + self.write_str(~"["); f(); - self.write_str("]"); + self.write_str(~"]"); } fn emit_vec_elt(idx: uint, f: fn()) { - if idx > 0u { self.write_str(", "); } + if idx > 0u { self.write_str(~", "); } f(); } fn emit_box(f: fn()) { - self.write_str("@"); + self.write_str(~"@"); f(); } fn emit_uniq(f: fn()) { - self.write_str("~"); + self.write_str(~"~"); f(); } fn emit_rec(f: fn()) { - self.write_str("{"); + self.write_str(~"{"); f(); - self.write_str("}"); + self.write_str(~"}"); } - fn emit_rec_field(f_name: str, f_idx: uint, f: fn()) { - if f_idx > 0u { self.write_str(", "); } + fn emit_rec_field(f_name: ~str, f_idx: uint, f: fn()) { + if f_idx > 0u { self.write_str(~", "); } self.write_str(f_name); - self.write_str(": "); + self.write_str(~": "); f(); } fn emit_tup(_sz: uint, f: fn()) { - self.write_str("("); + self.write_str(~"("); f(); - self.write_str(")"); + self.write_str(~")"); } fn emit_tup_elt(idx: uint, f: fn()) { - if idx > 0u { self.write_str(", "); } + if idx > 0u { self.write_str(~", "); } f(); } } \ No newline at end of file diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 91f63fe938c7..dbca5ae4e764 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -53,7 +53,7 @@ fn empty() -> rope { * * this operation does not copy the string; * * the function runs in linear time. */ -fn of_str(str: @str/~) -> rope { +fn of_str(str: @~str) -> rope { ret of_substr(str, 0u, str::len(*str)); } @@ -79,7 +79,7 @@ fn of_str(str: @str/~) -> rope { * * this function does _not_ check the validity of the substring; * * this function fails if `byte_offset` or `byte_len` do not match `str`. */ -fn of_substr(str: @str/~, byte_offset: uint, byte_len: uint) -> rope { +fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> rope { if byte_len == 0u { ret node::empty; } if byte_offset + byte_len > str::len(*str) { fail; } ret node::content(node::of_substr(str, byte_offset, byte_len)); @@ -107,7 +107,7 @@ fn append_char(rope: rope, char: char) -> rope { * * * this function executes in near-linear time */ -fn append_str(rope: rope, str: @str/~) -> rope { +fn append_str(rope: rope, str: @~str) -> rope { ret append_rope(rope, of_str(str)) } @@ -127,7 +127,7 @@ fn prepend_char(rope: rope, char: char) -> rope { * # Performance note * * this function executes in near-linear time */ -fn prepend_str(rope: rope, str: @str/~) -> rope { +fn prepend_str(rope: rope, str: @~str) -> rope { ret append_rope(of_str(str), rope) } @@ -567,7 +567,7 @@ enum root { byte_offset: uint, byte_len: uint, char_len: uint, - content: @str/~ + content: @~str }; /** @@ -627,7 +627,7 @@ enum node { * Performance note: The complexity of this function is linear in * the length of `str`. */ - fn of_str(str: @str/~) -> @node { + fn of_str(str: @~str) -> @node { ret of_substr(str, 0u, str::len(*str)); } @@ -648,7 +648,7 @@ fn of_str(str: @str/~) -> @node { * Behavior is undefined if `byte_start` or `byte_len` do not represent * valid positions in `str` */ - fn of_substr(str: @str/~, byte_start: uint, byte_len: uint) -> @node { + fn of_substr(str: @~str, byte_start: uint, byte_len: uint) -> @node { ret of_substr_unsafer(str, byte_start, byte_len, str::count_chars(*str, byte_start, byte_len)); } @@ -674,7 +674,7 @@ fn of_substr(str: @str/~, byte_start: uint, byte_len: uint) -> @node { * * Behavior is undefined if `char_len` does not accurately represent the * number of chars between byte_start and byte_start+byte_len */ - fn of_substr_unsafer(str: @str/~, byte_start: uint, byte_len: uint, + fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint, char_len: uint) -> @node { assert(byte_start + byte_len <= str::len(*str)); let candidate = @leaf({ @@ -799,7 +799,7 @@ fn tree_from_forest_destructive(forest: ~[mut @node]) -> @node { ret forest[0]; } - fn serialize_node(node: @node) -> str unsafe { + fn serialize_node(node: @node) -> ~str unsafe { let mut buf = vec::to_mut(vec::from_elem(byte_len(node), 0u8)); let mut offset = 0u;//Current position in the buffer let it = leaf_iterator::start(node); @@ -1237,11 +1237,11 @@ fn get_next_char_in_leaf(it: t) -> option { mod tests { //Utility function, used for sanity check - fn rope_to_string(r: rope) -> str { + fn rope_to_string(r: rope) -> ~str { alt(r) { - node::empty { ret "" } + node::empty { ret ~"" } node::content(x) { - let str = @mut ""; + let str = @mut ~""; fn aux(str: @mut str, node: @node::node) unsafe { alt(*node) { node::leaf(x) { @@ -1270,7 +1270,7 @@ fn trivial() { #[test] fn of_string1() { - let sample = @"0123456789ABCDE"; + let sample = @~"0123456789ABCDE"; let r = of_str(sample); assert char_len(r) == str::char_len(*sample); @@ -1279,7 +1279,7 @@ fn of_string1() { #[test] fn of_string2() { - let buf = @ mut "1234567890"; + let buf = @ mut ~"1234567890"; let mut i = 0; while i < 10 { *buf = *buf + *buf; i+=1;} let sample = @*buf; @@ -1310,7 +1310,7 @@ fn of_string2() { #[test] fn iter1() { - let buf = @ mut "1234567890"; + let buf = @ mut ~"1234567890"; let mut i = 0; while i < 10 { *buf = *buf + *buf; i+=1;} let sample = @*buf; @@ -1330,8 +1330,8 @@ fn iter1() { #[test] fn bal1() { - let init = @ "1234567890"; - let buf = @ mut * init; + let init = @~"1234567890"; + let buf = @mut * init; let mut i = 0; while i < 8 { *buf = *buf + *buf; i+=1;} let sample = @*buf; @@ -1352,7 +1352,7 @@ fn bal1() { #[ignore] fn char_at1() { //Generate a large rope - let mut r = of_str(@ "123456789"); + let mut r = of_str(@~"123456789"); for uint::range(0u, 10u) |_i| { r = append_rope(r, r); } @@ -1384,7 +1384,7 @@ fn char_at1() { #[test] fn concat1() { //Generate a reasonable rope - let chunk = of_str(@ "123456789"); + let chunk = of_str(@~"123456789"); let mut r = empty(); for uint::range(0u, 10u) |_i| { r = append_rope(r, chunk); diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs index aafe31ec0118..ba20ff88e3db 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -23,18 +23,18 @@ fn emit_float(v: float); fn emit_f64(v: f64); fn emit_f32(v: f32); - fn emit_str(v: str); + fn emit_str(v: ~str); // Compound types: - fn emit_enum(name: str, f: fn()); - fn emit_enum_variant(v_name: str, v_id: uint, sz: uint, f: fn()); + fn emit_enum(name: ~str, f: fn()); + fn emit_enum_variant(v_name: ~str, v_id: uint, sz: uint, f: fn()); fn emit_enum_variant_arg(idx: uint, f: fn()); fn emit_vec(len: uint, f: fn()); fn emit_vec_elt(idx: uint, f: fn()); fn emit_box(f: fn()); fn emit_uniq(f: fn()); fn emit_rec(f: fn()); - fn emit_rec_field(f_name: str, f_idx: uint, f: fn()); + fn emit_rec_field(f_name: ~str, f_idx: uint, f: fn()); fn emit_tup(sz: uint, f: fn()); fn emit_tup_elt(idx: uint, f: fn()); } @@ -58,14 +58,14 @@ fn read_bool() -> bool; - fn read_str() -> str; + fn read_str() -> ~str; fn read_f64() -> f64; fn read_f32() -> f32; fn read_float() -> float; // Compound types: - fn read_enum(name: str, f: fn() -> T) -> T; + fn read_enum(name: ~str, f: fn() -> T) -> T; fn read_enum_variant(f: fn(uint) -> T) -> T; fn read_enum_variant_arg(idx: uint, f: fn() -> T) -> T; fn read_vec(f: fn(uint) -> T) -> T; @@ -73,7 +73,7 @@ fn read_box(f: fn() -> T) -> T; fn read_uniq(f: fn() -> T) -> T; fn read_rec(f: fn() -> T) -> T; - fn read_rec_field(f_name: str, f_idx: uint, f: fn() -> T) -> T; + fn read_rec_field(f_name: ~str, f_idx: uint, f: fn() -> T) -> T; fn read_tup(sz: uint, f: fn() -> T) -> T; fn read_tup_elt(idx: uint, f: fn() -> T) -> T; } @@ -193,11 +193,11 @@ fn deserialize_i64(d: D) -> i64 { d.read_i64() } -fn serialize_str(s: S, v: str) { +fn serialize_str(s: S, v: ~str) { s.emit_str(v); } -fn deserialize_str(d: D) -> str { +fn deserialize_str(d: D) -> ~str { d.read_str() } @@ -234,15 +234,15 @@ fn deserialize_bool(d: D) -> bool { } fn serialize_option(s: S, v: option, st: fn(T)) { - do s.emit_enum("option") { + do s.emit_enum(~"option") { alt v { none { - do s.emit_enum_variant("none", 0u, 0u) { + do s.emit_enum_variant(~"none", 0u, 0u) { } } some(v) { - do s.emit_enum_variant("some", 1u, 1u) { + do s.emit_enum_variant(~"some", 1u, 1u) { do s.emit_enum_variant_arg(0u) { st(v) } @@ -254,7 +254,7 @@ fn serialize_option(s: S, v: option, st: fn(T)) { fn deserialize_option(d: D, st: fn() -> T) -> option { - do d.read_enum("option") { + do d.read_enum(~"option") { do d.read_enum_variant |i| { alt check i { 0u { // none diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index dc136af639a8..71f8fff28577 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -24,7 +24,7 @@ /// Provide message input as bytes fn input(~[u8]); /// Provide message input as string - fn input_str(str); + fn input_str(~str); /** * Read the digest as a vector of 20 bytes. After calling this no further * input may be provided until reset is called. @@ -34,7 +34,7 @@ * Read the digest as a hex string. After calling this no further * input may be provided until reset is called. */ - fn result_str() -> str; + fn result_str() -> ~str; /// Reset the SHA-1 state for reuse fn reset(); } @@ -232,11 +232,11 @@ fn reset() { self.computed = false; } fn input(msg: ~[u8]) { add_input(self, msg); } - fn input_str(msg: str) { add_input(self, str::bytes(msg)); } + fn input_str(msg: ~str) { add_input(self, str::bytes(msg)); } fn result() -> ~[u8] { ret mk_result(self); } - fn result_str() -> str { + fn result_str() -> ~str { let r = mk_result(self); - let mut s = ""; + let mut s = ~""; for vec::each(r) |b| { s += uint::to_str(b as uint, 16u); } ret s; } @@ -260,18 +260,18 @@ mod tests { #[test] fn test() unsafe { - type test = {input: str, output: ~[u8]}; + type test = {input: ~str, output: ~[u8]}; - fn a_million_letter_a() -> str { + fn a_million_letter_a() -> ~str { let mut i = 0; - let mut rs = ""; - while i < 100000 { str::push_str(rs, "aaaaaaaaaa"); i += 1; } + let mut rs = ~""; + while i < 100000 { str::push_str(rs, ~"aaaaaaaaaa"); i += 1; } ret rs; } // Test messages from FIPS 180-1 let fips_180_1_tests: ~[test] = - ~[{input: "abc", + ~[{input: ~"abc", output: ~[0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, 0x47u8, 0x06u8, 0x81u8, 0x6Au8, @@ -279,8 +279,8 @@ fn a_million_letter_a() -> str { 0x78u8, 0x50u8, 0xC2u8, 0x6Cu8, 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8]}, {input: - "abcdbcdecdefdefgefghfghighij" + - "hijkijkljklmklmnlmnomnopnopq", + ~"abcdbcdecdefdefgefghfghighij" + + ~"hijkijkljklmklmnlmnomnopnopq", output: ~[0x84u8, 0x98u8, 0x3Eu8, 0x44u8, 0x1Cu8, 0x3Bu8, 0xD2u8, 0x6Eu8, @@ -297,14 +297,14 @@ fn a_million_letter_a() -> str { // Examples from wikipedia let wikipedia_tests: ~[test] = - ~[{input: "The quick brown fox jumps over the lazy dog", + ~[{input: ~"The quick brown fox jumps over the lazy dog", output: ~[0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, 0x7au8, 0x2du8, 0x28u8, 0xfcu8, 0xedu8, 0x84u8, 0x9eu8, 0xe1u8, 0xbbu8, 0x76u8, 0xe7u8, 0x39u8, 0x1bu8, 0x93u8, 0xebu8, 0x12u8]}, - {input: "The quick brown fox jumps over the lazy cog", + {input: ~"The quick brown fox jumps over the lazy cog", output: ~[0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, 0xd2u8, 0x5eu8, 0x1bu8, 0x3au8, diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 536f633f8a76..b6f5c81f57e7 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -5,7 +5,7 @@ import rand; import core::rand::extensions; -fn mkdtemp(prefix: str, suffix: str) -> option { +fn mkdtemp(prefix: ~str, suffix: ~str) -> option<~str> { let r = rand::rng(); let mut i = 0u; while (i < 1000u) { @@ -20,11 +20,11 @@ fn mkdtemp(prefix: str, suffix: str) -> option { #[test] fn test_mkdtemp() { - let r = mkdtemp("./", "foobar"); + let r = mkdtemp(~"./", ~"foobar"); alt r { some(p) { os::remove_dir(p); - assert(str::ends_with(p, "foobar")); + assert(str::ends_with(p, ~"foobar")); } _ { assert(false); } } diff --git a/src/libstd/term.rs b/src/libstd/term.rs index 24d0442dfe2e..aa2d52822be6 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -33,9 +33,9 @@ fn reset(writer: io::writer) { /// Returns true if the terminal supports color fn color_supported() -> bool { - let supported_terms = ~["xterm-color", "xterm", - "screen-bce", "xterm-256color"]; - ret alt os::getenv("TERM") { + let supported_terms = ~[~"xterm-color", ~"xterm", + ~"screen-bce", ~"xterm-256color"]; + ret alt os::getenv(~"TERM") { option::some(env) { for vec::each(supported_terms) |term| { if str::eq(term, env) { ret true; } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index a4acc097ab26..d42bca745088 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -30,7 +30,7 @@ // paths; i.e. it should be a series of identifiers seperated by double // colons. This way if some test runner wants to arrange the tests // hierarchically it may. -type test_name = str; +type test_name = ~str; // A function that runs a test. If the function returns successfully, // the test succeeds; if the function fails then the test fails. We @@ -49,24 +49,24 @@ // The default console test runner. It accepts the command line // arguments and a vector of test_descs (generated at compile time). -fn test_main(args: ~[str], tests: ~[test_desc]) { +fn test_main(args: ~[~str], tests: ~[test_desc]) { let opts = alt parse_opts(args) { either::left(o) { o } either::right(m) { fail m } }; - if !run_tests_console(opts, tests) { fail "Some tests failed"; } + if !run_tests_console(opts, tests) { fail ~"Some tests failed"; } } -type test_opts = {filter: option, run_ignored: bool, - logfile: option}; +type test_opts = {filter: option<~str>, run_ignored: bool, + logfile: option<~str>}; -type opt_res = either; +type opt_res = either; // Parses command line arguments into test options -fn parse_opts(args: ~[str]) -> opt_res { +fn parse_opts(args: ~[~str]) -> opt_res { let args_ = vec::tail(args); - let opts = ~[getopts::optflag("ignored"), getopts::optopt("logfile")]; + let opts = ~[getopts::optflag(~"ignored"), getopts::optopt(~"logfile")]; let match = alt getopts::getopts(args_, opts) { ok(m) { m } @@ -78,8 +78,8 @@ fn parse_opts(args: ~[str]) -> opt_res { option::some(match.free[0]) } else { option::none }; - let run_ignored = getopts::opt_present(match, "ignored"); - let logfile = getopts::opt_maybe_str(match, "logfile"); + let run_ignored = getopts::opt_present(match, ~"ignored"); + let logfile = getopts::opt_maybe_str(match, ~"logfile"); let test_opts = {filter: filter, run_ignored: run_ignored, logfile: logfile}; @@ -107,7 +107,7 @@ fn callback(event: testevent, st: console_test_state) { alt event { te_filtered(filtered_tests) { st.total = vec::len(filtered_tests); - let noun = if st.total != 1u { "tests" } else { "test" }; + let noun = if st.total != 1u { ~"tests" } else { ~"test" }; st.out.write_line(#fmt["\nrunning %u %s", st.total, noun]); } te_wait(test) { st.out.write_str(#fmt["test %s ... ", test.name]); } @@ -122,18 +122,18 @@ fn callback(event: testevent, st: console_test_state) { tr_ok { st.passed += 1u; write_ok(st.out, st.use_color); - st.out.write_line(""); + st.out.write_line(~""); } tr_failed { st.failed += 1u; write_failed(st.out, st.use_color); - st.out.write_line(""); + st.out.write_line(~""); vec::push(st.failures, copy test); } tr_ignored { st.ignored += 1u; write_ignored(st.out, st.use_color); - st.out.write_line(""); + st.out.write_line(~""); } } } @@ -184,25 +184,25 @@ fn callback(event: testevent, st: console_test_state) { fn write_log(out: io::writer, result: test_result, test: test_desc) { out.write_line(#fmt("%s %s", alt result { - tr_ok { "ok" } - tr_failed { "failed" } - tr_ignored { "ignored" } + tr_ok { ~"ok" } + tr_failed { ~"failed" } + tr_ignored { ~"ignored" } }, test.name)); } fn write_ok(out: io::writer, use_color: bool) { - write_pretty(out, "ok", term::color_green, use_color); + write_pretty(out, ~"ok", term::color_green, use_color); } fn write_failed(out: io::writer, use_color: bool) { - write_pretty(out, "FAILED", term::color_red, use_color); + write_pretty(out, ~"FAILED", term::color_red, use_color); } fn write_ignored(out: io::writer, use_color: bool) { - write_pretty(out, "ignored", term::color_yellow, use_color); + write_pretty(out, ~"ignored", term::color_yellow, use_color); } - fn write_pretty(out: io::writer, word: str, color: u8, use_color: bool) { + fn write_pretty(out: io::writer, word: ~str, color: u8, use_color: bool) { if use_color && term::color_supported() { term::fg(out, color); } @@ -214,7 +214,7 @@ fn write_pretty(out: io::writer, word: str, color: u8, use_color: bool) { } fn print_failures(st: console_test_state) { - st.out.write_line("\nfailures:"); + st.out.write_line(~"\nfailures:"); let failures = copy st.failures; let failures = vec::map(failures, |test| test.name); let failures = sort::merge_sort(str::le, failures); @@ -229,14 +229,14 @@ fn should_sort_failures_before_printing_them() { let writer = io::mem_buffer_writer(buffer); let test_a = { - name: "a", + name: ~"a", fn: fn~() { }, ignore: false, should_fail: false }; let test_b = { - name: "b", + name: ~"b", fn: fn~() { }, ignore: false, should_fail: false @@ -256,8 +256,8 @@ fn should_sort_failures_before_printing_them() { let s = io::mem_buffer_str(buffer); - let apos = option::get(str::find_str(s, "a")); - let bpos = option::get(str::find_str(s, "b")); + let apos = option::get(str::find_str(s, ~"a")); + let bpos = option::get(str::find_str(s, ~"b")); assert apos < bpos; } @@ -339,10 +339,10 @@ fn filter_tests(opts: test_opts, let filter_str = alt opts.filter { option::some(f) { f } - option::none { "" } + option::none { ~"" } }; - fn filter_fn(test: test_desc, filter_str: str) -> + fn filter_fn(test: test_desc, filter_str: ~str) -> option { if str::contains(test.name, filter_str) { ret option::some(copy test); @@ -419,7 +419,7 @@ mod tests { fn do_not_run_ignored_tests() { fn f() { fail; } let desc = { - name: "whatever", + name: ~"whatever", fn: f, ignore: true, should_fail: false @@ -435,7 +435,7 @@ fn do_not_run_ignored_tests() { fn ignored_tests_result_in_ignored() { fn f() { } let desc = { - name: "whatever", + name: ~"whatever", fn: f, ignore: true, should_fail: false @@ -452,7 +452,7 @@ fn f() { } fn test_should_fail() { fn f() { fail; } let desc = { - name: "whatever", + name: ~"whatever", fn: f, ignore: false, should_fail: true @@ -468,7 +468,7 @@ fn test_should_fail() { fn test_should_fail_but_succeeds() { fn f() { } let desc = { - name: "whatever", + name: ~"whatever", fn: f, ignore: false, should_fail: true @@ -482,17 +482,17 @@ fn f() { } #[test] fn first_free_arg_should_be_a_filter() { - let args = ~["progname", "filter"]; + let args = ~[~"progname", ~"filter"]; let opts = alt parse_opts(args) { either::left(o) { o } - _ { fail "Malformed arg in first_free_arg_should_be_a_filter"; } }; - assert (str::eq("filter", option::get(opts.filter))); + _ { fail ~"Malformed arg in first_free_arg_should_be_a_filter"; } }; + assert (str::eq(~"filter", option::get(opts.filter))); } #[test] fn parse_ignored_flag() { - let args = ~["progname", "filter", "--ignored"]; + let args = ~[~"progname", ~"filter", ~"--ignored"]; let opts = alt parse_opts(args) { either::left(o) { o } - _ { fail "Malformed arg in parse_ignored_flag"; } }; + _ { fail ~"Malformed arg in parse_ignored_flag"; } }; assert (opts.run_ignored); } @@ -504,12 +504,12 @@ fn filter_for_ignored_option() { let opts = {filter: option::none, run_ignored: true, logfile: option::none}; let tests = - ~[{name: "1", fn: fn~() { }, ignore: true, should_fail: false}, - {name: "2", fn: fn~() { }, ignore: false, should_fail: false}]; + ~[{name: ~"1", fn: fn~() { }, ignore: true, should_fail: false}, + {name: ~"2", fn: fn~() { }, ignore: false, should_fail: false}]; let filtered = filter_tests(opts, tests); assert (vec::len(filtered) == 1u); - assert (filtered[0].name == "1"); + assert (filtered[0].name == ~"1"); assert (filtered[0].ignore == false); } @@ -519,12 +519,12 @@ fn sort_tests() { logfile: option::none}; let names = - ~["sha1::test", "int::test_to_str", "int::test_pow", - "test::do_not_run_ignored_tests", - "test::ignored_tests_result_in_ignored", - "test::first_free_arg_should_be_a_filter", - "test::parse_ignored_flag", "test::filter_for_ignored_option", - "test::sort_tests"]; + ~[~"sha1::test", ~"int::test_to_str", ~"int::test_pow", + ~"test::do_not_run_ignored_tests", + ~"test::ignored_tests_result_in_ignored", + ~"test::first_free_arg_should_be_a_filter", + ~"test::parse_ignored_flag", ~"test::filter_for_ignored_option", + ~"test::sort_tests"]; let tests = { let testfn = fn~() { }; @@ -539,11 +539,13 @@ fn sort_tests() { let filtered = filter_tests(opts, tests); let expected = - ~["int::test_pow", "int::test_to_str", "sha1::test", - "test::do_not_run_ignored_tests", "test::filter_for_ignored_option", - "test::first_free_arg_should_be_a_filter", - "test::ignored_tests_result_in_ignored", "test::parse_ignored_flag", - "test::sort_tests"]; + ~[~"int::test_pow", ~"int::test_to_str", ~"sha1::test", + ~"test::do_not_run_ignored_tests", + ~"test::filter_for_ignored_option", + ~"test::first_free_arg_should_be_a_filter", + ~"test::ignored_tests_result_in_ignored", + ~"test::parse_ignored_flag", + ~"test::sort_tests"]; let pairs = vec::zip(expected, filtered); diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 3f3749cb0648..553592b10bdc 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -76,7 +76,7 @@ fn tzset() { tm_yday: i32, // days since January 1 ~[0-365] tm_isdst: i32, // Daylight Savings Time flag tm_gmtoff: i32, // offset from UTC in seconds - tm_zone: str, // timezone abbreviation + tm_zone: ~str, // timezone abbreviation tm_nsec: i32, // nanoseconds }; @@ -92,7 +92,7 @@ fn empty_tm() -> tm { tm_yday: 0_i32, tm_isdst: 0_i32, tm_gmtoff: 0_i32, - tm_zone: "", + tm_zone: ~"", tm_nsec: 0_i32, } } @@ -124,7 +124,7 @@ fn now() -> tm { } /// Parses the time from the string according to the format string. -fn strptime(s: str, format: str) -> result { +fn strptime(s: ~str, format: ~str) -> result { type tm_mut = { mut tm_sec: i32, mut tm_min: i32, @@ -136,11 +136,11 @@ fn strptime(s: str, format: str) -> result { mut tm_yday: i32, mut tm_isdst: i32, mut tm_gmtoff: i32, - mut tm_zone: str, + mut tm_zone: ~str, mut tm_nsec: i32, }; - fn match_str(s: str, pos: uint, needle: str) -> bool { + fn match_str(s: ~str, pos: uint, needle: ~str) -> bool { let mut i = pos; for str::each(needle) |ch| { if s[i] != ch { @@ -151,7 +151,7 @@ fn match_str(s: str, pos: uint, needle: str) -> bool { ret true; } - fn match_strs(s: str, pos: uint, strs: ~[(str, i32)]) + fn match_strs(s: ~str, pos: uint, strs: ~[(~str, i32)]) -> option<(i32, uint)> { let mut i = 0u; let len = vec::len(strs); @@ -167,7 +167,7 @@ fn match_strs(s: str, pos: uint, strs: ~[(str, i32)]) none } - fn match_digits(s: str, pos: uint, digits: uint, ws: bool) + fn match_digits(s: ~str, pos: uint, digits: uint, ws: bool) -> option<(i32, uint)> { let mut pos = pos; let mut value = 0_i32; @@ -190,7 +190,7 @@ fn match_digits(s: str, pos: uint, digits: uint, ws: bool) some((value, pos)) } - fn parse_char(s: str, pos: uint, c: char) -> result { + fn parse_char(s: ~str, pos: uint, c: char) -> result { let {ch, next} = str::char_range_at(s, pos); if c == ch { @@ -202,73 +202,73 @@ fn parse_char(s: str, pos: uint, c: char) -> result { } } - fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) - -> result { + fn parse_type(s: ~str, pos: uint, ch: char, tm: tm_mut) + -> result { alt ch { 'A' { alt match_strs(s, pos, ~[ - ("Sunday", 0_i32), - ("Monday", 1_i32), - ("Tuesday", 2_i32), - ("Wednesday", 3_i32), - ("Thursday", 4_i32), - ("Friday", 5_i32), - ("Saturday", 6_i32) + (~"Sunday", 0_i32), + (~"Monday", 1_i32), + (~"Tuesday", 2_i32), + (~"Wednesday", 3_i32), + (~"Thursday", 4_i32), + (~"Friday", 5_i32), + (~"Saturday", 6_i32) ]) { some(item) { let (v, pos) = item; tm.tm_wday = v; ok(pos) } - none { err("Invalid day") } + none { err(~"Invalid day") } } } 'a' { alt match_strs(s, pos, ~[ - ("Sun", 0_i32), - ("Mon", 1_i32), - ("Tue", 2_i32), - ("Wed", 3_i32), - ("Thu", 4_i32), - ("Fri", 5_i32), - ("Sat", 6_i32) + (~"Sun", 0_i32), + (~"Mon", 1_i32), + (~"Tue", 2_i32), + (~"Wed", 3_i32), + (~"Thu", 4_i32), + (~"Fri", 5_i32), + (~"Sat", 6_i32) ]) { some(item) { let (v, pos) = item; tm.tm_wday = v; ok(pos) } - none { err("Invalid day") } + none { err(~"Invalid day") } } } 'B' { alt match_strs(s, pos, ~[ - ("January", 0_i32), - ("February", 1_i32), - ("March", 2_i32), - ("April", 3_i32), - ("May", 4_i32), - ("June", 5_i32), - ("July", 6_i32), - ("August", 7_i32), - ("September", 8_i32), - ("October", 9_i32), - ("November", 10_i32), - ("December", 11_i32) + (~"January", 0_i32), + (~"February", 1_i32), + (~"March", 2_i32), + (~"April", 3_i32), + (~"May", 4_i32), + (~"June", 5_i32), + (~"July", 6_i32), + (~"August", 7_i32), + (~"September", 8_i32), + (~"October", 9_i32), + (~"November", 10_i32), + (~"December", 11_i32) ]) { some(item) { let (v, pos) = item; tm.tm_mon = v; ok(pos) } - none { err("Invalid month") } + none { err(~"Invalid month") } } } 'b' | 'h' { alt match_strs(s, pos, ~[ - ("Jan", 0_i32), - ("Feb", 1_i32), - ("Mar", 2_i32), - ("Apr", 3_i32), - ("May", 4_i32), - ("Jun", 5_i32), - ("Jul", 6_i32), - ("Aug", 7_i32), - ("Sep", 8_i32), - ("Oct", 9_i32), - ("Nov", 10_i32), - ("Dec", 11_i32) + (~"Jan", 0_i32), + (~"Feb", 1_i32), + (~"Mar", 2_i32), + (~"Apr", 3_i32), + (~"May", 4_i32), + (~"Jun", 5_i32), + (~"Jul", 6_i32), + (~"Aug", 7_i32), + (~"Sep", 8_i32), + (~"Oct", 9_i32), + (~"Nov", 10_i32), + (~"Dec", 11_i32) ]) { some(item) { let (v, pos) = item; tm.tm_mon = v; ok(pos) } - none { err("Invalid month") } + none { err(~"Invalid month") } } } 'C' { @@ -278,7 +278,7 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_year += (v * 100_i32) - 1900_i32; ok(pos) } - none { err("Invalid year") } + none { err(~"Invalid year") } } } 'c' { @@ -302,13 +302,13 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) 'd' { alt match_digits(s, pos, 2u, false) { some(item) { let (v, pos) = item; tm.tm_mday = v; ok(pos) } - none { err("Invalid day of the month") } + none { err(~"Invalid day of the month") } } } 'e' { alt match_digits(s, pos, 2u, true) { some(item) { let (v, pos) = item; tm.tm_mday = v; ok(pos) } - none { err("Invalid day of the month") } + none { err(~"Invalid day of the month") } } } 'F' { @@ -322,7 +322,7 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) // FIXME (#2350): range check. alt match_digits(s, pos, 2u, false) { some(item) { let (v, pos) = item; tm.tm_hour = v; ok(pos) } - none { err("Invalid hour") } + none { err(~"Invalid hour") } } } 'I' { @@ -333,7 +333,7 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_hour = if v == 12_i32 { 0_i32 } else { v }; ok(pos) } - none { err("Invalid hour") } + none { err(~"Invalid hour") } } } 'j' { @@ -344,14 +344,14 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_yday = v - 1_i32; ok(pos) } - none { err("Invalid year") } + none { err(~"Invalid year") } } } 'k' { // FIXME (#2350): range check. alt match_digits(s, pos, 2u, true) { some(item) { let (v, pos) = item; tm.tm_hour = v; ok(pos) } - none { err("Invalid hour") } + none { err(~"Invalid hour") } } } 'l' { @@ -362,14 +362,14 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_hour = if v == 12_i32 { 0_i32 } else { v }; ok(pos) } - none { err("Invalid hour") } + none { err(~"Invalid hour") } } } 'M' { // FIXME (#2350): range check. alt match_digits(s, pos, 2u, false) { some(item) { let (v, pos) = item; tm.tm_min = v; ok(pos) } - none { err("Invalid minute") } + none { err(~"Invalid minute") } } } 'm' { @@ -380,20 +380,20 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_mon = v - 1_i32; ok(pos) } - none { err("Invalid month") } + none { err(~"Invalid month") } } } 'n' { parse_char(s, pos, '\n') } 'P' { - alt match_strs(s, pos, ~[("am", 0_i32), ("pm", 12_i32)]) { + alt match_strs(s, pos, ~[(~"am", 0_i32), (~"pm", 12_i32)]) { some(item) { let (v, pos) = item; tm.tm_hour += v; ok(pos) } - none { err("Invalid hour") } + none { err(~"Invalid hour") } } } 'p' { - alt match_strs(s, pos, ~[("AM", 0_i32), ("PM", 12_i32)]) { + alt match_strs(s, pos, ~[(~"AM", 0_i32), (~"PM", 12_i32)]) { some(item) { let (v, pos) = item; tm.tm_hour += v; ok(pos) } - none { err("Invalid hour") } + none { err(~"Invalid hour") } } } 'R' { @@ -418,7 +418,7 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_sec = v; ok(pos) } - none { err("Invalid second") } + none { err(~"Invalid second") } } } //'s' {} @@ -438,7 +438,7 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_wday = v; ok(pos) } - none { err("Invalid weekday") } + none { err(~"Invalid weekday") } } } 'v' { @@ -453,7 +453,7 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) // FIXME (#2350): range check. alt match_digits(s, pos, 1u, false) { some(item) { let (v, pos) = item; tm.tm_wday = v; ok(pos) } - none { err("Invalid weekday") } + none { err(~"Invalid weekday") } } } //'X' {} @@ -466,7 +466,7 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_year = v - 1900_i32; ok(pos) } - none { err("Invalid weekday") } + none { err(~"Invalid weekday") } } } 'y' { @@ -477,13 +477,13 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) tm.tm_year = v - 1900_i32; ok(pos) } - none { err("Invalid weekday") } + none { err(~"Invalid weekday") } } } 'Z' { - if match_str(s, pos, "UTC") || match_str(s, pos, "GMT") { + if match_str(s, pos, ~"UTC") || match_str(s, pos, ~"GMT") { tm.tm_gmtoff = 0_i32; - tm.tm_zone = "UTC"; + tm.tm_zone = ~"UTC"; ok(pos + 3u) } else { // It's odd, but to maintain compatibility with c's @@ -508,15 +508,15 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) let (v, pos) = item; if v == 0_i32 { tm.tm_gmtoff = 0_i32; - tm.tm_zone = "UTC"; + tm.tm_zone = ~"UTC"; } ok(pos) } - none { err("Invalid zone offset") } + none { err(~"Invalid zone offset") } } } else { - err("Invalid zone offset") + err(~"Invalid zone offset") } } '%' { parse_char(s, pos, '%') } @@ -538,12 +538,12 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) mut tm_yday: 0_i32, mut tm_isdst: 0_i32, mut tm_gmtoff: 0_i32, - mut tm_zone: "", + mut tm_zone: ~"", mut tm_nsec: 0_i32, }; let mut pos = 0u; let len = str::len(s); - let mut result = err("Invalid time"); + let mut result = err(~"Invalid time"); while !rdr.eof() && pos < len { let {ch, next} = str::char_range_at(s, pos); @@ -581,62 +581,62 @@ fn parse_type(s: str, pos: uint, ch: char, tm: tm_mut) } } -fn strftime(format: str, tm: tm) -> str { - fn parse_type(ch: char, tm: tm) -> str { +fn strftime(format: ~str, tm: tm) -> ~str { + fn parse_type(ch: char, tm: tm) -> ~str { //FIXME (#2350): Implement missing types. alt check ch { 'A' { alt check tm.tm_wday as int { - 0 { "Sunday" } - 1 { "Monday" } - 2 { "Tuesday" } - 3 { "Wednesday" } - 4 { "Thursday" } - 5 { "Friday" } - 6 { "Saturday" } + 0 { ~"Sunday" } + 1 { ~"Monday" } + 2 { ~"Tuesday" } + 3 { ~"Wednesday" } + 4 { ~"Thursday" } + 5 { ~"Friday" } + 6 { ~"Saturday" } } } 'a' { alt check tm.tm_wday as int { - 0 { "Sun" } - 1 { "Mon" } - 2 { "Tue" } - 3 { "Wed" } - 4 { "Thu" } - 5 { "Fri" } - 6 { "Sat" } + 0 { ~"Sun" } + 1 { ~"Mon" } + 2 { ~"Tue" } + 3 { ~"Wed" } + 4 { ~"Thu" } + 5 { ~"Fri" } + 6 { ~"Sat" } } } 'B' { alt check tm.tm_mon as int { - 0 { "January" } - 1 { "February" } - 2 { "March" } - 3 { "April" } - 4 { "May" } - 5 { "June" } - 6 { "July" } - 7 { "August" } - 8 { "September" } - 9 { "October" } - 10 { "November" } - 11 { "December" } + 0 { ~"January" } + 1 { ~"February" } + 2 { ~"March" } + 3 { ~"April" } + 4 { ~"May" } + 5 { ~"June" } + 6 { ~"July" } + 7 { ~"August" } + 8 { ~"September" } + 9 { ~"October" } + 10 { ~"November" } + 11 { ~"December" } } } 'b' | 'h' { alt check tm.tm_mon as int { - 0 { "Jan" } - 1 { "Feb" } - 2 { "Mar" } - 3 { "Apr" } - 4 { "May" } - 5 { "Jun" } - 6 { "Jul" } - 7 { "Aug" } - 8 { "Sep" } - 9 { "Oct" } - 10 { "Nov" } - 11 { "Dec" } + 0 { ~"Jan" } + 1 { ~"Feb" } + 2 { ~"Mar" } + 3 { ~"Apr" } + 4 { ~"May" } + 5 { ~"Jun" } + 6 { ~"Jul" } + 7 { ~"Aug" } + 8 { ~"Sep" } + 9 { ~"Oct" } + 10 { ~"Nov" } + 11 { ~"Dec" } } } 'C' { #fmt("%02d", (tm.tm_year as int + 1900) / 100) } @@ -681,9 +681,9 @@ fn parse_type(ch: char, tm: tm) -> str { } 'M' { #fmt("%02d", tm.tm_min as int) } 'm' { #fmt("%02d", tm.tm_mon as int + 1) } - 'n' { "\n" } - 'P' { if tm.tm_hour as int < 12 { "am" } else { "pm" } } - 'p' { if tm.tm_hour as int < 12 { "AM" } else { "PM" } } + 'n' { ~"\n" } + 'P' { if tm.tm_hour as int < 12 { ~"am" } else { ~"pm" } } + 'p' { if tm.tm_hour as int < 12 { ~"AM" } else { ~"PM" } } 'R' { #fmt("%s:%s", parse_type('H', tm), @@ -704,7 +704,7 @@ fn parse_type(ch: char, tm: tm) -> str { parse_type('M', tm), parse_type('S', tm)) } - 't' { "\t" } + 't' { ~"\t" } //'U' {} 'u' { let i = tm.tm_wday as int; @@ -732,11 +732,11 @@ fn parse_type(ch: char, tm: tm) -> str { #fmt("%c%02d%02d", sign, h as int, m as int) } //'+' {} - '%' { "%" } + '%' { ~"%" } } } - let mut buf = ""; + let mut buf = ~""; do io::with_str_reader(format) |rdr| { while !rdr.eof() { @@ -776,10 +776,10 @@ fn to_utc() -> tm { * Return a string of the current time in the form * "Thu Jan 1 00:00:00 1970". */ - fn ctime() -> str { self.strftime("%c") } + fn ctime() -> ~str { self.strftime(~"%c") } /// Formats the time according to the format string. - fn strftime(format: str) -> str { strftime(format, self) } + fn strftime(format: ~str) -> ~str { strftime(format, self) } /** * Returns a time string formatted according to RFC 822. @@ -787,11 +787,11 @@ fn strftime(format: str) -> str { strftime(format, self) } * local: "Thu, 22 Mar 2012 07:53:18 PST" * utc: "Thu, 22 Mar 2012 14:53:18 UTC" */ - fn rfc822() -> str { + fn rfc822() -> ~str { if self.tm_gmtoff == 0_i32 { - self.strftime("%a, %d %b %Y %T GMT") + self.strftime(~"%a, %d %b %Y %T GMT") } else { - self.strftime("%a, %d %b %Y %T %Z") + self.strftime(~"%a, %d %b %Y %T %Z") } } @@ -801,8 +801,8 @@ fn rfc822() -> str { * local: "Thu, 22 Mar 2012 07:53:18 -0700" * utc: "Thu, 22 Mar 2012 14:53:18 -0000" */ - fn rfc822z() -> str { - self.strftime("%a, %d %b %Y %T %z") + fn rfc822z() -> ~str { + self.strftime(~"%a, %d %b %Y %T %z") } /** @@ -811,11 +811,11 @@ fn rfc822z() -> str { * local: "2012-02-22T07:53:18-07:00" * utc: "2012-02-22T14:53:18Z" */ - fn rfc3339() -> str { + fn rfc3339() -> ~str { if self.tm_gmtoff == 0_i32 { - self.strftime("%Y-%m-%dT%H:%M:%SZ") + self.strftime(~"%Y-%m-%dT%H:%M:%SZ") } else { - let s = self.strftime("%Y-%m-%dT%H:%M:%S"); + let s = self.strftime(~"%Y-%m-%dT%H:%M:%S"); let sign = if self.tm_gmtoff > 0_i32 { '+' } else { '-' }; let mut m = i32::abs(self.tm_gmtoff) / 60_i32; let h = m / 60_i32; @@ -835,15 +835,15 @@ fn test_get_time() { const some_future_date: i64 = 1577836800i64; // 2020-01-01T00:00:00Z let tv1 = get_time(); - log(debug, "tv1=" + uint::str(tv1.sec as uint) + " sec + " - + uint::str(tv1.nsec as uint) + " nsec"); + log(debug, ~"tv1=" + uint::str(tv1.sec as uint) + ~" sec + " + + uint::str(tv1.nsec as uint) + ~" nsec"); assert tv1.sec > some_recent_date; assert tv1.nsec < 1000000000i32; let tv2 = get_time(); - log(debug, "tv2=" + uint::str(tv2.sec as uint) + " sec + " - + uint::str(tv2.nsec as uint) + " nsec"); + log(debug, ~"tv2=" + uint::str(tv2.sec as uint) + ~" sec + " + + uint::str(tv2.nsec as uint) + ~" nsec"); assert tv2.sec >= tv1.sec; assert tv2.sec < some_future_date; @@ -858,22 +858,22 @@ fn test_precise_time() { let s0 = precise_time_s(); let ns1 = precise_time_ns(); - log(debug, "s0=" + float::to_str(s0, 9u) + " sec"); + log(debug, ~"s0=" + float::to_str(s0, 9u) + ~" sec"); assert s0 > 0.; let ns0 = (s0 * 1000000000.) as u64; - log(debug, "ns0=" + u64::str(ns0) + " ns"); + log(debug, ~"ns0=" + u64::str(ns0) + ~" ns"); - log(debug, "ns1=" + u64::str(ns1) + " ns"); + log(debug, ~"ns1=" + u64::str(ns1) + ~" ns"); assert ns1 >= ns0; let ns2 = precise_time_ns(); - log(debug, "ns2=" + u64::str(ns2) + " ns"); + log(debug, ~"ns2=" + u64::str(ns2) + ~" ns"); assert ns2 >= ns1; } #[test] fn test_at_utc() { - os::setenv("TZ", "America/Los_Angeles"); + os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); let time = { sec: 1234567890_i64, nsec: 54321_i32 }; @@ -889,13 +889,13 @@ fn test_at_utc() { assert utc.tm_yday == 43_i32; assert utc.tm_isdst == 0_i32; assert utc.tm_gmtoff == 0_i32; - assert utc.tm_zone == "UTC"; + assert utc.tm_zone == ~"UTC"; assert utc.tm_nsec == 54321_i32; } #[test] fn test_at() { - os::setenv("TZ", "America/Los_Angeles"); + os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); let time = { sec: 1234567890_i64, nsec: 54321_i32 }; @@ -917,14 +917,14 @@ fn test_at() { // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let zone = local.tm_zone; - assert zone == "PST" || zone == "Pacific Standard Time"; + assert zone == ~"PST" || zone == ~"Pacific Standard Time"; assert local.tm_nsec == 54321_i32; } #[test] fn test_to_timespec() { - os::setenv("TZ", "America/Los_Angeles"); + os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); let time = { sec: 1234567890_i64, nsec: 54321_i32 }; @@ -936,7 +936,7 @@ fn test_to_timespec() { #[test] fn test_conversions() { - os::setenv("TZ", "America/Los_Angeles"); + os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); let time = { sec: 1234567890_i64, nsec: 54321_i32 }; @@ -953,10 +953,10 @@ fn test_conversions() { #[test] fn test_strptime() { - os::setenv("TZ", "America/Los_Angeles"); + os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); - alt strptime("", "") { + alt strptime(~"", ~"") { ok(tm) { assert tm.tm_sec == 0_i32; assert tm.tm_min == 0_i32; @@ -967,17 +967,18 @@ fn test_strptime() { assert tm.tm_wday == 0_i32; assert tm.tm_isdst== 0_i32; assert tm.tm_gmtoff == 0_i32; - assert tm.tm_zone == ""; + assert tm.tm_zone == ~""; assert tm.tm_nsec == 0_i32; } err(_) {} } - let format = "%a %b %e %T %Y"; - assert strptime("", format) == err("Invalid time"); - assert strptime("Fri Feb 13 15:31:30", format) == err("Invalid time"); + let format = ~"%a %b %e %T %Y"; + assert strptime(~"", format) == err(~"Invalid time"); + assert strptime(~"Fri Feb 13 15:31:30", format) + == err(~"Invalid time"); - alt strptime("Fri Feb 13 15:31:30 2009", format) { + alt strptime(~"Fri Feb 13 15:31:30 2009", format) { err(e) { fail e } ok(tm) { assert tm.tm_sec == 30_i32; @@ -990,12 +991,12 @@ fn test_strptime() { assert tm.tm_yday == 0_i32; assert tm.tm_isdst == 0_i32; assert tm.tm_gmtoff == 0_i32; - assert tm.tm_zone == ""; + assert tm.tm_zone == ~""; assert tm.tm_nsec == 0_i32; } } - fn test(s: str, format: str) -> bool { + fn test(s: ~str, format: ~str) -> bool { alt strptime(s, format) { ok(tm) { tm.strftime(format) == s } err(e) { fail e } @@ -1003,103 +1004,103 @@ fn test(s: str, format: str) -> bool { } [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday" - ]/_.iter(|day| assert test(day, "%A")); + ~"Sunday", + ~"Monday", + ~"Tuesday", + ~"Wednesday", + ~"Thursday", + ~"Friday", + ~"Saturday" + ]/_.iter(|day| assert test(day, ~"%A")); [ - "Sun", - "Mon", - "Tue", - "Wed", - "Thu", - "Fri", - "Sat" - ]/_.iter(|day| assert test(day, "%a")); + ~"Sun", + ~"Mon", + ~"Tue", + ~"Wed", + ~"Thu", + ~"Fri", + ~"Sat" + ]/_.iter(|day| assert test(day, ~"%a")); [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" - ]/_.iter(|day| assert test(day, "%B")); + ~"January", + ~"February", + ~"March", + ~"April", + ~"May", + ~"June", + ~"July", + ~"August", + ~"September", + ~"October", + ~"November", + ~"December" + ]/_.iter(|day| assert test(day, ~"%B")); [ - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec" - ]/_.iter(|day| assert test(day, "%b")); + ~"Jan", + ~"Feb", + ~"Mar", + ~"Apr", + ~"May", + ~"Jun", + ~"Jul", + ~"Aug", + ~"Sep", + ~"Oct", + ~"Nov", + ~"Dec" + ]/_.iter(|day| assert test(day, ~"%b")); - assert test("19", "%C"); - assert test("Fri Feb 13 23:31:30 2009", "%c"); - assert test("02/13/09", "%D"); - assert test("03", "%d"); - assert test("13", "%d"); - assert test(" 3", "%e"); - assert test("13", "%e"); - assert test("2009-02-13", "%F"); - assert test("03", "%H"); - assert test("13", "%H"); - assert test("03", "%I"); // FIXME (#2350): flesh out - assert test("11", "%I"); // FIXME (#2350): flesh out - assert test("044", "%j"); - assert test(" 3", "%k"); - assert test("13", "%k"); - assert test(" 1", "%l"); - assert test("11", "%l"); - assert test("03", "%M"); - assert test("13", "%M"); - assert test("\n", "%n"); - assert test("am", "%P"); - assert test("pm", "%P"); - assert test("AM", "%p"); - assert test("PM", "%p"); - assert test("23:31", "%R"); - assert test("11:31:30 AM", "%r"); - assert test("11:31:30 PM", "%r"); - assert test("03", "%S"); - assert test("13", "%S"); - assert test("15:31:30", "%T"); - assert test("\t", "%t"); - assert test("1", "%u"); - assert test("7", "%u"); - assert test("13-Feb-2009", "%v"); - assert test("0", "%w"); - assert test("6", "%w"); - assert test("2009", "%Y"); - assert test("09", "%y"); - assert strptime("UTC", "%Z").get().tm_zone == "UTC"; - assert strptime("PST", "%Z").get().tm_zone == ""; - assert strptime("-0000", "%z").get().tm_gmtoff == 0_i32; - assert strptime("-0800", "%z").get().tm_gmtoff == 0_i32; - assert test("%", "%%"); + assert test(~"19", ~"%C"); + assert test(~"Fri Feb 13 23:31:30 2009", ~"%c"); + assert test(~"02/13/09", ~"%D"); + assert test(~"03", ~"%d"); + assert test(~"13", ~"%d"); + assert test(~" 3", ~"%e"); + assert test(~"13", ~"%e"); + assert test(~"2009-02-13", ~"%F"); + assert test(~"03", ~"%H"); + assert test(~"13", ~"%H"); + assert test(~"03", ~"%I"); // FIXME (#2350): flesh out + assert test(~"11", ~"%I"); // FIXME (#2350): flesh out + assert test(~"044", ~"%j"); + assert test(~" 3", ~"%k"); + assert test(~"13", ~"%k"); + assert test(~" 1", ~"%l"); + assert test(~"11", ~"%l"); + assert test(~"03", ~"%M"); + assert test(~"13", ~"%M"); + assert test(~"\n", ~"%n"); + assert test(~"am", ~"%P"); + assert test(~"pm", ~"%P"); + assert test(~"AM", ~"%p"); + assert test(~"PM", ~"%p"); + assert test(~"23:31", ~"%R"); + assert test(~"11:31:30 AM", ~"%r"); + assert test(~"11:31:30 PM", ~"%r"); + assert test(~"03", ~"%S"); + assert test(~"13", ~"%S"); + assert test(~"15:31:30", ~"%T"); + assert test(~"\t", ~"%t"); + assert test(~"1", ~"%u"); + assert test(~"7", ~"%u"); + assert test(~"13-Feb-2009", ~"%v"); + assert test(~"0", ~"%w"); + assert test(~"6", ~"%w"); + assert test(~"2009", ~"%Y"); + assert test(~"09", ~"%y"); + assert strptime(~"UTC", ~"%Z").get().tm_zone == ~"UTC"; + assert strptime(~"PST", ~"%Z").get().tm_zone == ~""; + assert strptime(~"-0000", ~"%z").get().tm_gmtoff == 0_i32; + assert strptime(~"-0800", ~"%z").get().tm_gmtoff == 0_i32; + assert test(~"%", ~"%%"); } #[test] fn test_ctime() { - os::setenv("TZ", "America/Los_Angeles"); + os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); let time = { sec: 1234567890_i64, nsec: 54321_i32 }; @@ -1108,81 +1109,81 @@ fn test_ctime() { #error("test_ctime: %? %?", utc.ctime(), local.ctime()); - assert utc.ctime() == "Fri Feb 13 23:31:30 2009"; - assert local.ctime() == "Fri Feb 13 15:31:30 2009"; + assert utc.ctime() == ~"Fri Feb 13 23:31:30 2009"; + assert local.ctime() == ~"Fri Feb 13 15:31:30 2009"; } #[test] fn test_strftime() { - os::setenv("TZ", "America/Los_Angeles"); + os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); let time = { sec: 1234567890_i64, nsec: 54321_i32 }; let utc = at_utc(time); let local = at(time); - assert local.strftime("") == ""; - assert local.strftime("%A") == "Friday"; - assert local.strftime("%a") == "Fri"; - assert local.strftime("%B") == "February"; - assert local.strftime("%b") == "Feb"; - assert local.strftime("%C") == "20"; - assert local.strftime("%c") == "Fri Feb 13 15:31:30 2009"; - assert local.strftime("%D") == "02/13/09"; - assert local.strftime("%d") == "13"; - assert local.strftime("%e") == "13"; - assert local.strftime("%F") == "2009-02-13"; + assert local.strftime(~"") == ~""; + assert local.strftime(~"%A") == ~"Friday"; + assert local.strftime(~"%a") == ~"Fri"; + assert local.strftime(~"%B") == ~"February"; + assert local.strftime(~"%b") == ~"Feb"; + assert local.strftime(~"%C") == ~"20"; + assert local.strftime(~"%c") == ~"Fri Feb 13 15:31:30 2009"; + assert local.strftime(~"%D") == ~"02/13/09"; + assert local.strftime(~"%d") == ~"13"; + assert local.strftime(~"%e") == ~"13"; + assert local.strftime(~"%F") == ~"2009-02-13"; // assert local.strftime("%G") == "2009"; // assert local.strftime("%g") == "09"; - assert local.strftime("%H") == "15"; - assert local.strftime("%I") == "03"; - assert local.strftime("%j") == "044"; - assert local.strftime("%k") == "15"; - assert local.strftime("%l") == " 3"; - assert local.strftime("%M") == "31"; - assert local.strftime("%m") == "02"; - assert local.strftime("%n") == "\n"; - assert local.strftime("%P") == "pm"; - assert local.strftime("%p") == "PM"; - assert local.strftime("%R") == "15:31"; - assert local.strftime("%r") == "03:31:30 PM"; - assert local.strftime("%S") == "30"; - assert local.strftime("%s") == "1234567890"; - assert local.strftime("%T") == "15:31:30"; - assert local.strftime("%t") == "\t"; + assert local.strftime(~"%H") == ~"15"; + assert local.strftime(~"%I") == ~"03"; + assert local.strftime(~"%j") == ~"044"; + assert local.strftime(~"%k") == ~"15"; + assert local.strftime(~"%l") == ~" 3"; + assert local.strftime(~"%M") == ~"31"; + assert local.strftime(~"%m") == ~"02"; + assert local.strftime(~"%n") == ~"\n"; + assert local.strftime(~"%P") == ~"pm"; + assert local.strftime(~"%p") == ~"PM"; + assert local.strftime(~"%R") == ~"15:31"; + assert local.strftime(~"%r") == ~"03:31:30 PM"; + assert local.strftime(~"%S") == ~"30"; + assert local.strftime(~"%s") == ~"1234567890"; + assert local.strftime(~"%T") == ~"15:31:30"; + assert local.strftime(~"%t") == ~"\t"; // assert local.strftime("%U") == "06"; - assert local.strftime("%u") == "5"; + assert local.strftime(~"%u") == ~"5"; // assert local.strftime("%V") == "07"; - assert local.strftime("%v") == "13-Feb-2009"; + assert local.strftime(~"%v") == ~"13-Feb-2009"; // assert local.strftime("%W") == "06"; - assert local.strftime("%w") == "5"; + assert local.strftime(~"%w") == ~"5"; // handle "%X" // handle "%x" - assert local.strftime("%Y") == "2009"; - assert local.strftime("%y") == "09"; + assert local.strftime(~"%Y") == ~"2009"; + assert local.strftime(~"%y") == ~"09"; // FIXME (#2350): We should probably standardize on the timezone // abbreviation. - let zone = local.strftime("%Z"); - assert zone == "PST" || zone == "Pacific Standard Time"; + let zone = local.strftime(~"%Z"); + assert zone == ~"PST" || zone == ~"Pacific Standard Time"; - assert local.strftime("%z") == "-0800"; - assert local.strftime("%%") == "%"; + assert local.strftime(~"%z") == ~"-0800"; + assert local.strftime(~"%%") == ~"%"; // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let rfc822 = local.rfc822(); - let prefix = "Fri, 13 Feb 2009 15:31:30 "; - assert rfc822 == prefix + "PST" || - rfc822 == prefix + "Pacific Standard Time"; + let prefix = ~"Fri, 13 Feb 2009 15:31:30 "; + assert rfc822 == prefix + ~"PST" || + rfc822 == prefix + ~"Pacific Standard Time"; - assert local.ctime() == "Fri Feb 13 15:31:30 2009"; - assert local.rfc822z() == "Fri, 13 Feb 2009 15:31:30 -0800"; - assert local.rfc3339() == "2009-02-13T15:31:30-08:00"; + assert local.ctime() == ~"Fri Feb 13 15:31:30 2009"; + assert local.rfc822z() == ~"Fri, 13 Feb 2009 15:31:30 -0800"; + assert local.rfc3339() == ~"2009-02-13T15:31:30-08:00"; - assert utc.ctime() == "Fri Feb 13 23:31:30 2009"; - assert utc.rfc822() == "Fri, 13 Feb 2009 23:31:30 GMT"; - assert utc.rfc822z() == "Fri, 13 Feb 2009 23:31:30 -0000"; - assert utc.rfc3339() == "2009-02-13T23:31:30Z"; + assert utc.ctime() == ~"Fri Feb 13 23:31:30 2009"; + assert utc.rfc822() == ~"Fri, 13 Feb 2009 23:31:30 GMT"; + assert utc.rfc822z() == ~"Fri, 13 Feb 2009 23:31:30 -0000"; + assert utc.rfc3339() == ~"2009-02-13T23:31:30Z"; } } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 87d7dd67577b..b72e2c475392 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -41,12 +41,13 @@ fn delayed_send(iotask: iotask, } else { let error_msg = uv::ll::get_last_err_info(loop_ptr); - fail "timer::delayed_send() start failed: "+error_msg; + fail ~"timer::delayed_send() start failed: " + + error_msg; } } else { let error_msg = uv::ll::get_last_err_info(loop_ptr); - fail "timer::delayed_send() init failed: "+error_msg; + fail ~"timer::delayed_send() init failed: "+error_msg; } }; // delayed_send_cb has been processed by libuv @@ -128,7 +129,7 @@ fn recv_timeout(iotask: iotask, else { let loop_ptr = uv::ll::get_loop_for_uv_handle(handle); let error_msg = uv::ll::get_last_err_info(loop_ptr); - fail "timer::sleep() init failed: "+error_msg; + fail ~"timer::sleep() init failed: "+error_msg; } } @@ -232,7 +233,7 @@ fn test_gl_timer_recv_timeout_after_time_passes() { for iter::repeat(times as uint) { let expected = rand::rng().gen_str(16u); - let test_po = comm::port::(); + let test_po = comm::port::<~str>(); let test_ch = comm::chan(test_po); do task::spawn() { diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 1a3626e46603..3def5fbd0d15 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -132,13 +132,13 @@ fn t(n: @mut int, &&k: int, &&_v: ()) { fn u8_map() { let m = treemap(); - let k1 = str::bytes("foo"); - let k2 = str::bytes("bar"); + let k1 = str::bytes(~"foo"); + let k2 = str::bytes(~"bar"); - insert(m, k1, "foo"); - insert(m, k2, "bar"); + insert(m, k1, ~"foo"); + insert(m, k2, ~"bar"); - assert (find(m, k2) == some("bar")); - assert (find(m, k1) == some("foo")); + assert (find(m, k2) == some(~"bar")); + assert (find(m, k1) == some(~"foo")); } } diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 53769757f62f..4a7962a977f8 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -118,16 +118,16 @@ mod test { } extern fn simple_timer_cb(timer_ptr: *ll::uv_timer_t, _status: libc::c_int) unsafe { - log(debug, "in simple timer cb"); + log(debug, ~"in simple timer cb"); ll::timer_stop(timer_ptr); let hl_loop = get_gl(); do iotask::interact(hl_loop) |_loop_ptr| { - log(debug, "closing timer"); + log(debug, ~"closing timer"); ll::close(timer_ptr, simple_timer_close_cb); - log(debug, "about to deref exit_ch_ptr"); - log(debug, "after msg sent on deref'd exit_ch"); + log(debug, ~"about to deref exit_ch_ptr"); + log(debug, ~"after msg sent on deref'd exit_ch"); }; - log(debug, "exiting simple timer cb"); + log(debug, ~"exiting simple timer cb"); } fn impl_uv_hl_simple_timer(iotask: iotask) unsafe { @@ -139,7 +139,7 @@ fn impl_uv_hl_simple_timer(iotask: iotask) unsafe { let timer_handle = ll::timer_t(); let timer_ptr = ptr::addr_of(timer_handle); do iotask::interact(iotask) |loop_ptr| { - log(debug, "user code inside interact loop!!!"); + log(debug, ~"user code inside interact loop!!!"); let init_status = ll::timer_init(loop_ptr, timer_ptr); if(init_status == 0i32) { ll::set_data_for_uv_handle( @@ -150,15 +150,15 @@ fn impl_uv_hl_simple_timer(iotask: iotask) unsafe { if(start_status == 0i32) { } else { - fail "failure on ll::timer_start()"; + fail ~"failure on ll::timer_start()"; } } else { - fail "failure on ll::timer_init()"; + fail ~"failure on ll::timer_init()"; } }; comm::recv(exit_po); - log(debug, "global_loop timer test: msg recv on exit_po, done.."); + log(debug, ~"global_loop timer test: msg recv on exit_po, done.."); } #[test] @@ -192,7 +192,7 @@ fn test_stress_gl_uv_global_loop_high_level_global_timer() unsafe { for iter::repeat(cycles) { comm::recv(exit_po); }; - log(debug, "test_stress_gl_uv_global_loop_high_level_global_timer"+ - " exiting sucessfully!"); + log(debug, ~"test_stress_gl_uv_global_loop_high_level_global_timer"+ + ~" exiting sucessfully!"); } } diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index e38fae0fa72f..d049c6f7c7b5 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -114,10 +114,10 @@ fn run_loop(iotask_ch: chan) unsafe { }); iotask_ch.send(iotask); - log(debug, "about to run uv loop"); + log(debug, ~"about to run uv loop"); // enter the loop... this blocks until the loop is done.. ll::run(loop_ptr); - log(debug, "uv loop ended"); + log(debug, ~"uv loop ended"); ll::loop_delete(loop_ptr); } @@ -157,7 +157,7 @@ fn send_msg(iotask: iotask, } fn begin_teardown(data: *iotask_loop_data) unsafe { - log(debug, "iotask begin_teardown() called, close async_handle"); + log(debug, ~"iotask begin_teardown() called, close async_handle"); let async_handle = (*data).async_handle; ll::close(async_handle as *c_void, tear_down_close_cb); } @@ -250,9 +250,9 @@ fn test_uv_iotask_async() unsafe { for iter::repeat(7u) { comm::recv(work_exit_po); }; - log(debug, "sending teardown_loop msg.."); + log(debug, ~"sending teardown_loop msg.."); exit(iotask); comm::recv(exit_po); - log(debug, "after recv on exit_po.. exiting.."); + log(debug, ~"after recv on exit_po.. exiting.."); } } diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index 8407a18c5498..56365514da92 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -793,7 +793,7 @@ unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t { // yuck :/ rustrt::rust_uv_buf_init(out_buf_ptr, input, len as size_t); //let result = rustrt::rust_uv_buf_init_2(input, len as size_t); - log(debug, "after rust_uv_buf_init"); + log(debug, ~"after rust_uv_buf_init"); let res_base = get_base_from_buf(out_buf); let res_len = get_len_from_buf(out_buf); //let res_base = get_base_from_buf(result); @@ -803,21 +803,21 @@ unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t { ret out_buf; //ret result; } -unsafe fn ip4_addr(ip: str, port: int) +unsafe fn ip4_addr(ip: ~str, port: int) -> sockaddr_in { do str::as_c_str(ip) |ip_buf| { rustrt::rust_uv_ip4_addr(ip_buf as *u8, port as libc::c_int) } } -unsafe fn ip6_addr(ip: str, port: int) +unsafe fn ip6_addr(ip: ~str, port: int) -> sockaddr_in6 { do str::as_c_str(ip) |ip_buf| { rustrt::rust_uv_ip6_addr(ip_buf as *u8, port as libc::c_int) } } -unsafe fn ip4_name(src: &sockaddr_in) -> str { +unsafe fn ip4_name(src: &sockaddr_in) -> ~str { // ipv4 addr max size: 15 + 1 trailing null byte let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8, 0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8]; @@ -834,7 +834,7 @@ unsafe fn ip4_name(src: &sockaddr_in) -> str { str::unsafe::from_buf(dst_buf) } } -unsafe fn ip6_name(src: &sockaddr_in6) -> str { +unsafe fn ip6_name(src: &sockaddr_in6) -> ~str { // ipv6 addr max size: 45 + 1 trailing null byte let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8, 0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8, @@ -854,7 +854,7 @@ unsafe fn ip6_name(src: &sockaddr_in6) -> str { str::unsafe::from_buf(dst_buf) } _ { - "" + ~"" } } } @@ -961,7 +961,7 @@ unsafe fn free_base_of_buf(buf: uv_buf_t) { rustrt::rust_uv_free_base_of_buf(buf); } -unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> str { +unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str { let err = last_error(uv_loop); let err_ptr = ptr::addr_of(err); let err_name = str::unsafe::from_c_str(err_name(err_ptr)); @@ -979,8 +979,8 @@ unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data { } type uv_err_data = { - err_name: str, - err_msg: str + err_name: ~str, + err_msg: ~str }; unsafe fn is_ipv4_addrinfo(input: *addrinfo) -> bool { @@ -1013,7 +1013,7 @@ enum tcp_read_data { type request_wrapper = { write_req: *uv_write_t, req_buf: *~[uv_buf_t], - read_chan: *comm::chan + read_chan: *comm::chan<~str> }; extern fn after_close_cb(handle: *libc::c_void) { @@ -1024,7 +1024,7 @@ enum tcp_read_data { extern fn on_alloc_cb(handle: *libc::c_void, ++suggested_size: libc::size_t) -> uv_buf_t unsafe { - log(debug, "on_alloc_cb!"); + log(debug, ~"on_alloc_cb!"); let char_ptr = malloc_buf_base_of(suggested_size); log(debug, #fmt("on_alloc_cb h: %? char_ptr: %u sugsize: %u", handle, @@ -1056,15 +1056,15 @@ enum tcp_read_data { } else if (nread == -1) { // err .. possibly EOF - log(debug, "read: eof!"); + log(debug, ~"read: eof!"); } else { // nread == 0 .. do nothing, just free buf as below - log(debug, "read: do nothing!"); + log(debug, ~"read: do nothing!"); } // when we're done free_base_of_buf(buf); - log(debug, "CLIENT exiting on_read_cb"); + log(debug, ~"CLIENT exiting on_read_cb"); } extern fn on_write_complete_cb(write_req: *uv_write_t, @@ -1086,7 +1086,7 @@ enum tcp_read_data { let stream = get_stream_handle_from_connect_req(connect_req_ptr); if (status == 0i32) { - log(debug, "on_connect_cb: in status=0 if.."); + log(debug, ~"on_connect_cb: in status=0 if.."); let client_data = get_data_for_req( connect_req_ptr as *libc::c_void) as *request_wrapper; @@ -1107,11 +1107,11 @@ enum tcp_read_data { log(debug, err_msg); assert false; } - log(debug, "finishing on_connect_cb"); + log(debug, ~"finishing on_connect_cb"); } - fn impl_uv_tcp_request(ip: str, port: int, req_str: str, - client_chan: *comm::chan) unsafe { + fn impl_uv_tcp_request(ip: ~str, port: int, req_str: ~str, + client_chan: *comm::chan<~str>) unsafe { let test_loop = loop_new(); let tcp_handle = tcp_t(); let tcp_handle_ptr = ptr::addr_of(tcp_handle); @@ -1143,9 +1143,9 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, let tcp_init_result = tcp_init( test_loop as *libc::c_void, tcp_handle_ptr); if (tcp_init_result == 0i32) { - log(debug, "sucessful tcp_init_result"); + log(debug, ~"sucessful tcp_init_result"); - log(debug, "building addr..."); + log(debug, ~"building addr..."); let addr = ip4_addr(ip, port); // FIXME ref #2064 let addr_ptr = ptr::addr_of(addr); @@ -1167,17 +1167,17 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, set_data_for_uv_handle( tcp_handle_ptr as *libc::c_void, ptr::addr_of(client_data) as *libc::c_void); - log(debug, "before run tcp req loop"); + log(debug, ~"before run tcp req loop"); run(test_loop); - log(debug, "after run tcp req loop"); + log(debug, ~"after run tcp req loop"); } else { - log(debug, "tcp_connect() failure"); + log(debug, ~"tcp_connect() failure"); assert false; } } else { - log(debug, "tcp_init() failure"); + log(debug, ~"tcp_init() failure"); assert false; } loop_delete(test_loop); @@ -1191,7 +1191,8 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, extern fn client_stream_after_close_cb(handle: *libc::c_void) unsafe { - log(debug, "SERVER: closed client stream, now closing server stream"); + log(debug, + ~"SERVER: closed client stream, now closing server stream"); let client_data = get_data_for_uv_handle( handle) as *tcp_server_data; @@ -1202,7 +1203,7 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, extern fn after_server_resp_write(req: *uv_write_t) unsafe { let client_stream_ptr = get_stream_handle_from_write_req(req); - log(debug, "SERVER: resp sent... closing client stream"); + log(debug, ~"SERVER: resp sent... closing client stream"); close(client_stream_ptr as *libc::c_void, client_stream_after_close_cb) } @@ -1231,8 +1232,8 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, let server_kill_msg = (*client_data).server_kill_msg; let write_req = (*client_data).server_write_req; if (str::contains(request_str, server_kill_msg)) { - log(debug, "SERVER: client req contains kill_msg!"); - log(debug, "SERVER: sending response to client"); + log(debug, ~"SERVER: client req contains kill_msg!"); + log(debug, ~"SERVER: sending response to client"); read_stop(client_stream_ptr); let server_chan = *((*client_data).server_chan); comm::send(server_chan, request_str); @@ -1244,7 +1245,7 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, log(debug, #fmt("SERVER: resp write result: %d", write_result as int)); if (write_result != 0i32) { - log(debug, "bad result for server resp write()"); + log(debug, ~"bad result for server resp write()"); log(debug, get_last_err_info( get_loop_for_uv_handle(client_stream_ptr as *libc::c_void))); @@ -1252,26 +1253,26 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, } } else { - log(debug, "SERVER: client req !contain kill_msg!"); + log(debug, ~"SERVER: client req !contain kill_msg!"); } } else if (nread == -1) { // err .. possibly EOF - log(debug, "read: eof!"); + log(debug, ~"read: eof!"); } else { // nread == 0 .. do nothing, just free buf as below - log(debug, "read: do nothing!"); + log(debug, ~"read: do nothing!"); } // when we're done free_base_of_buf(buf); - log(debug, "SERVER exiting on_read_cb"); + log(debug, ~"SERVER exiting on_read_cb"); } extern fn server_connection_cb(server_stream_ptr: *uv_stream_t, status: libc::c_int) unsafe { - log(debug, "client connecting!"); + log(debug, ~"client connecting!"); let test_loop = get_loop_for_uv_handle( server_stream_ptr as *libc::c_void); if status != 0i32 { @@ -1289,7 +1290,7 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, client_stream_ptr as *libc::c_void, server_data as *libc::c_void); if (client_init_result == 0i32) { - log(debug, "successfully initialized client stream"); + log(debug, ~"successfully initialized client stream"); let accept_result = accept(server_stream_ptr as *libc::c_void, client_stream_ptr as @@ -1301,7 +1302,7 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, on_alloc_cb, on_server_read_cb); if (read_result == 0i32) { - log(debug, "successful server read start"); + log(debug, ~"successful server read start"); } else { log(debug, #fmt("server_connection_cb: bad read:%d", @@ -1325,9 +1326,9 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, type tcp_server_data = { client: *uv_tcp_t, server: *uv_tcp_t, - server_kill_msg: str, + server_kill_msg: ~str, server_resp_buf: *~[uv_buf_t], - server_chan: *comm::chan, + server_chan: *comm::chan<~str>, server_write_req: *uv_write_t }; @@ -1354,11 +1355,11 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str, close(async_handle as *libc::c_void, async_close_cb); } - fn impl_uv_tcp_server(server_ip: str, + fn impl_uv_tcp_server(server_ip: ~str, server_port: int, - kill_server_msg: str, - server_resp_msg: str, - server_chan: *comm::chan, + kill_server_msg: ~str, + server_resp_msg: ~str, + server_chan: *comm::chan<~str>, continue_chan: *comm::chan) unsafe { let test_loop = loop_new(); let tcp_server = tcp_t(); @@ -1408,7 +1409,7 @@ fn impl_uv_tcp_server(server_ip: str, let bind_result = tcp_bind(tcp_server_ptr, server_addr_ptr); if (bind_result == 0i32) { - log(debug, "successful uv_tcp_bind, listening"); + log(debug, ~"successful uv_tcp_bind, listening"); // uv_listen() let listen_result = listen(tcp_server_ptr as @@ -1428,7 +1429,7 @@ fn impl_uv_tcp_server(server_ip: str, async_send(continue_async_handle_ptr); // uv_run() run(test_loop); - log(debug, "server uv::run() has returned"); + log(debug, ~"server uv::run() has returned"); } else { log(debug, #fmt("uv_async_init failure: %d", @@ -1459,15 +1460,15 @@ fn impl_uv_tcp_server(server_ip: str, // this is the impl for a test that is (maybe) ran on a // per-platform/arch basis below fn impl_uv_tcp_server_and_request() unsafe { - let bind_ip = "0.0.0.0"; - let request_ip = "127.0.0.1"; + let bind_ip = ~"0.0.0.0"; + let request_ip = ~"127.0.0.1"; let port = 8887; - let kill_server_msg = "does a dog have buddha nature?"; - let server_resp_msg = "mu!"; - let client_port = comm::port::(); - let client_chan = comm::chan::(client_port); - let server_port = comm::port::(); - let server_chan = comm::chan::(server_port); + let kill_server_msg = ~"does a dog have buddha nature?"; + let server_resp_msg = ~"mu!"; + let client_port = comm::port::<~str>(); + let client_chan = comm::chan::<~str>(client_port); + let server_port = comm::port::<~str>(); + let server_chan = comm::chan::<~str>(server_port); let continue_port = comm::port::(); let continue_chan = comm::chan::(continue_port); @@ -1482,9 +1483,9 @@ fn impl_uv_tcp_server_and_request() unsafe { }; // block until the server up is.. possibly a race? - log(debug, "before receiving on server continue_port"); + log(debug, ~"before receiving on server continue_port"); comm::recv(continue_port); - log(debug, "received on continue port, set up tcp client"); + log(debug, ~"received on continue port, set up tcp client"); do task::spawn_sched(task::manual_threads(1u)) { impl_uv_tcp_request(request_ip, port, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 095038f02e3d..30535b45529b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -32,7 +32,7 @@ fn deserialize_span(_d: D) -> span { type spanned = {node: T, span: span}; #[auto_serialize] -type ident = @str/~; +type ident = @~str; // Functions may or may not have names. #[auto_serialize] @@ -428,11 +428,11 @@ enum mac_ { #[auto_serialize] enum lit_ { - lit_str(@str/~), + lit_str(@~str), lit_int(i64, int_ty), lit_uint(u64, uint_ty), lit_int_unsuffixed(i64), - lit_float(@str/~, float_ty), + lit_float(@~str, float_ty), lit_nil, lit_bool(bool), } diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index a5ae45d54eef..7f1899792d70 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -10,7 +10,7 @@ enum path_elt { path_mod(ident), path_name(ident) } type path = ~[path_elt]; /* FIXMEs that say "bad" are as per #2543 */ -fn path_to_str_with_sep(p: path, sep: str) -> str { +fn path_to_str_with_sep(p: path, sep: ~str) -> ~str { let strs = do vec::map(p) |e| { alt e { path_mod(s) { /* FIXME (#2543) */ copy *s } @@ -20,7 +20,7 @@ fn path_to_str_with_sep(p: path, sep: str) -> str { str::connect(strs, sep) } -fn path_ident_to_str(p: path, i: ident) -> str { +fn path_ident_to_str(p: path, i: ident) -> ~str { if vec::is_empty(p) { /* FIXME (#2543) */ copy *i } else { @@ -28,8 +28,8 @@ fn path_ident_to_str(p: path, i: ident) -> str { } } -fn path_to_str(p: path) -> str { - path_to_str_with_sep(p, "::") +fn path_to_str(p: path) -> ~str { + path_to_str_with_sep(p, ~"::") } enum ast_node { @@ -267,7 +267,7 @@ fn map_expr(ex: @expr, cx: ctx, v: vt) { visit::visit_expr(ex, cx, v); } -fn node_id_to_str(map: map, id: node_id) -> str { +fn node_id_to_str(map: map, id: node_id) -> ~str { alt map.find(id) { none { #fmt["unknown node (id=%d)", id] diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 5675ecadf628..556239769da5 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -21,11 +21,11 @@ // make this a const, once the compiler supports it pure fn dummy_sp() -> span { ret mk_sp(0u, 0u); } -pure fn path_name(p: @path) -> str { path_name_i(p.idents) } +pure fn path_name(p: @path) -> ~str { path_name_i(p.idents) } -pure fn path_name_i(idents: ~[ident]) -> str { +pure fn path_name_i(idents: ~[ident]) -> ~str { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") - str::connect(idents.map(|i|*i), "::") + str::connect(idents.map(|i|*i), ~"::") } pure fn path_to_ident(p: @path) -> ident { vec::last(p.idents) } @@ -45,7 +45,7 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { alt d { def_variant(enum_id, var_id) { ret {enm: enum_id, var: var_id}; } - _ { fail "non-variant in variant_def_ids"; } } + _ { fail ~"non-variant in variant_def_ids"; } } } pure fn def_id_of_def(d: def) -> def_id { @@ -63,26 +63,26 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { } } -pure fn binop_to_str(op: binop) -> str { +pure fn binop_to_str(op: binop) -> ~str { alt op { - add { ret "+"; } - subtract { ret "-"; } - mul { ret "*"; } - div { ret "/"; } - rem { ret "%"; } - and { ret "&&"; } - or { ret "||"; } - bitxor { ret "^"; } - bitand { ret "&"; } - bitor { ret "|"; } - shl { ret "<<"; } - shr { ret ">>"; } - eq { ret "=="; } - lt { ret "<"; } - le { ret "<="; } - ne { ret "!="; } - ge { ret ">="; } - gt { ret ">"; } + add { ret ~"+"; } + subtract { ret ~"-"; } + mul { ret ~"*"; } + div { ret ~"/"; } + rem { ret ~"%"; } + and { ret ~"&&"; } + or { ret ~"||"; } + bitxor { ret ~"^"; } + bitand { ret ~"&"; } + bitor { ret ~"|"; } + shl { ret ~"<<"; } + shr { ret ~">>"; } + eq { ret ~"=="; } + lt { ret ~"<"; } + le { ret ~"<="; } + ne { ret ~"!="; } + ge { ret ~">="; } + gt { ret ~">"; } } } @@ -98,13 +98,13 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { } } -pure fn unop_to_str(op: unop) -> str { +pure fn unop_to_str(op: unop) -> ~str { alt op { - box(mt) { if mt == m_mutbl { ret "@mut "; } ret "@"; } - uniq(mt) { if mt == m_mutbl { ret "~mut "; } ret "~"; } - deref { ret "*"; } - not { ret "!"; } - neg { ret "-"; } + box(mt) { if mt == m_mutbl { ret ~"@mut "; } ret ~"@"; } + uniq(mt) { if mt == m_mutbl { ret ~"~mut "; } ret ~"~"; } + deref { ret ~"*"; } + not { ret ~"!"; } + neg { ret ~"-"; } } } @@ -112,11 +112,11 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { ret alt e.node { expr_path(_) { true } _ { false } }; } -pure fn int_ty_to_str(t: int_ty) -> str { +pure fn int_ty_to_str(t: int_ty) -> ~str { alt t { - ty_char { "u8" } // ??? - ty_i { "" } ty_i8 { "i8" } ty_i16 { "i16" } - ty_i32 { "i32" } ty_i64 { "i64" } + ty_char { ~"u8" } // ??? + ty_i { ~"" } ty_i8 { ~"i8" } ty_i16 { ~"i16" } + ty_i32 { ~"i32" } ty_i64 { ~"i64" } } } @@ -129,10 +129,10 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { } } -pure fn uint_ty_to_str(t: uint_ty) -> str { +pure fn uint_ty_to_str(t: uint_ty) -> ~str { alt t { - ty_u { "u" } ty_u8 { "u8" } ty_u16 { "u16" } - ty_u32 { "u32" } ty_u64 { "u64" } + ty_u { ~"u" } ty_u8 { ~"u8" } ty_u16 { ~"u16" } + ty_u32 { ~"u32" } ty_u64 { ~"u64" } } } @@ -145,8 +145,8 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { } } -pure fn float_ty_to_str(t: float_ty) -> str { - alt t { ty_f { "" } ty_f32 { "f32" } ty_f64 { "f64" } } +pure fn float_ty_to_str(t: float_ty) -> ~str { + alt t { ty_f { ~"" } ty_f32 { ~"f32" } ty_f64 { ~"f64" } } } fn is_exported(i: ident, m: _mod) -> bool { @@ -191,7 +191,7 @@ fn is_exported(i: ident, m: _mod) -> bool { if id.node.name == i { ret true; } } } else { - fail "export of path-qualified list"; + fail ~"export of path-qualified list"; } } @@ -381,7 +381,7 @@ fn dtor_dec() -> fn_decl { let nil_t = @{id: 0, node: ty_nil, span: dummy_sp()}; // dtor has one argument, of type () {inputs: ~[{mode: ast::expl(ast::by_ref), - ty: nil_t, ident: @"_", id: 0}], + ty: nil_t, ident: @~"_", id: 0}], output: nil_t, purity: impure_fn, cf: return_val, constraints: ~[]} } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index aac0b1f4d76d..859bc70bfd64 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -49,7 +49,8 @@ /* Constructors */ -fn mk_name_value_item_str(+name: ast::ident, +value: str) -> @ast::meta_item { +fn mk_name_value_item_str(+name: ast::ident, +value: ~str) -> + @ast::meta_item { let value_lit = dummy_spanned(ast::lit_str(@value)); ret mk_name_value_item(name, value_lit); } @@ -73,11 +74,11 @@ fn mk_attr(item: @ast::meta_item) -> ast::attribute { is_sugared_doc: false}); } -fn mk_sugared_doc_attr(text: str, lo: uint, hi: uint) -> ast::attribute { +fn mk_sugared_doc_attr(text: ~str, lo: uint, hi: uint) -> ast::attribute { let lit = spanned(lo, hi, ast::lit_str(@text)); let attr = { style: doc_comment_style(text), - value: spanned(lo, hi, ast::meta_name_value(@"doc", lit)), + value: spanned(lo, hi, ast::meta_name_value(@~"doc", lit)), is_sugared_doc: true }; ret spanned(lo, hi, attr); @@ -97,7 +98,7 @@ fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { fn desugar_doc_attr(attr: ast::attribute) -> ast::attribute { if attr.node.is_sugared_doc { let comment = get_meta_item_value_str(@attr.node.value).get(); - let meta = mk_name_value_item_str(@"doc", + let meta = mk_name_value_item_str(@~"doc", strip_doc_comment_decoration(*comment)); ret mk_attr(meta); } else { @@ -124,7 +125,7 @@ fn get_meta_item_name(meta: @ast::meta_item) -> ast::ident { * Gets the string value if the meta_item is a meta_name_value variant * containing a string, otherwise none */ -fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@str/~> { +fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@~str> { alt meta.node { ast::meta_name_value(_, v) { alt v.node { @@ -154,7 +155,7 @@ fn get_meta_item_list(meta: @ast::meta_item) -> option<~[@ast::meta_item]> { */ fn get_name_value_str_pair( item: @ast::meta_item -) -> option<(ast::ident, @str/~)> { +) -> option<(ast::ident, @~str)> { alt attr::get_meta_item_value_str(item) { some(value) { let name = attr::get_meta_item_name(item); @@ -168,7 +169,7 @@ fn get_name_value_str_pair( /* Searching */ /// Search a list of attributes and return only those with a specific name -fn find_attrs_by_name(attrs: ~[ast::attribute], +name: str) -> +fn find_attrs_by_name(attrs: ~[ast::attribute], +name: ~str) -> ~[ast::attribute] { let filter = ( fn@(a: ast::attribute) -> option { @@ -181,7 +182,7 @@ fn find_attrs_by_name(attrs: ~[ast::attribute], +name: str) -> } /// Searcha list of meta items and return only those with a specific name -fn find_meta_items_by_name(metas: ~[@ast::meta_item], +name: str) -> +fn find_meta_items_by_name(metas: ~[@ast::meta_item], +name: ~str) -> ~[@ast::meta_item] { let filter = fn@(&&m: @ast::meta_item) -> option<@ast::meta_item> { if *get_meta_item_name(m) == name { @@ -224,22 +225,22 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { // FIXME (#607): Needs implementing // This involves probably sorting the list by name and // meta_item variant - fail "unimplemented meta_item variant" + fail ~"unimplemented meta_item variant" } } } -fn contains_name(metas: ~[@ast::meta_item], +name: str) -> bool { +fn contains_name(metas: ~[@ast::meta_item], +name: ~str) -> bool { let matches = find_meta_items_by_name(metas, name); ret vec::len(matches) > 0u; } -fn attrs_contains_name(attrs: ~[ast::attribute], +name: str) -> bool { +fn attrs_contains_name(attrs: ~[ast::attribute], +name: ~str) -> bool { vec::is_not_empty(find_attrs_by_name(attrs, name)) } -fn first_attr_value_str_by_name(attrs: ~[ast::attribute], +name: str) - -> option<@str/~> { +fn first_attr_value_str_by_name(attrs: ~[ast::attribute], +name: ~str) + -> option<@~str> { let mattrs = find_attrs_by_name(attrs, name); if vec::len(mattrs) > 0u { ret get_meta_item_value_str(attr_meta(mattrs[0])); @@ -249,7 +250,7 @@ fn first_attr_value_str_by_name(attrs: ~[ast::attribute], +name: str) fn last_meta_item_by_name( items: ~[@ast::meta_item], - +name: str + +name: ~str ) -> option<@ast::meta_item> { let items = attr::find_meta_items_by_name(items, name); vec::last_opt(items) @@ -257,8 +258,8 @@ fn last_meta_item_by_name( fn last_meta_item_value_str_by_name( items: ~[@ast::meta_item], - +name: str -) -> option<@str/~> { + +name: ~str +) -> option<@~str> { alt last_meta_item_by_name(items, name) { some(item) { alt attr::get_meta_item_value_str(item) { @@ -272,7 +273,7 @@ fn last_meta_item_value_str_by_name( fn last_meta_item_list_by_name( items: ~[@ast::meta_item], - +name: str + +name: ~str ) -> option<~[@ast::meta_item]> { alt last_meta_item_by_name(items, name) { some(item) { @@ -319,7 +320,7 @@ fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ast::ident) -> fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] { let mut found = ~[]; - for find_attrs_by_name(attrs, "link").each |attr| { + for find_attrs_by_name(attrs, ~"link").each |attr| { alt attr.node.value.node { ast::meta_list(_, _) { vec::push(found, attr) } _ { #debug("ignoring link attribute that has incorrect type"); } @@ -340,22 +341,22 @@ fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { } } -fn foreign_abi(attrs: ~[ast::attribute]) -> either { - ret alt attr::first_attr_value_str_by_name(attrs, "abi") { +fn foreign_abi(attrs: ~[ast::attribute]) -> either<~str, ast::foreign_abi> { + ret alt attr::first_attr_value_str_by_name(attrs, ~"abi") { option::none { either::right(ast::foreign_abi_cdecl) } - option::some(@"rust-intrinsic") { + option::some(@~"rust-intrinsic") { either::right(ast::foreign_abi_rust_intrinsic) } - option::some(@"cdecl") { + option::some(@~"cdecl") { either::right(ast::foreign_abi_cdecl) } - option::some(@"stdcall") { + option::some(@~"stdcall") { either::right(ast::foreign_abi_stdcall) } option::some(t) { - either::left("unsupported abi: " + *t) + either::left(~"unsupported abi: " + *t) } }; } @@ -371,9 +372,9 @@ fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr { // FIXME (#2809)---validate the usage of #[inline] and #[inline(always)] do vec::foldl(ia_none, attrs) |ia,attr| { alt attr.node.value.node { - ast::meta_word(@"inline") { ia_hint } - ast::meta_list(@"inline", items) { - if !vec::is_empty(find_meta_items_by_name(items, "always")) { + ast::meta_word(@~"inline") { ia_hint } + ast::meta_list(@~"inline", items) { + if !vec::is_empty(find_meta_items_by_name(items, ~"always")) { ia_always } else { ia_hint diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 867d2d7e45a9..76625d3f918c 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -28,7 +28,7 @@ export get_filemap; export new_codemap; -type filename = str; +type filename = ~str; type file_pos = {ch: uint, byte: uint}; @@ -41,11 +41,11 @@ enum file_substr { fss_none, fss_internal(span), - fss_external({filename: str, line: uint, col: uint}) + fss_external({filename: ~str, line: uint, col: uint}) } type filemap = - @{name: filename, substr: file_substr, src: @str/~, + @{name: filename, substr: file_substr, src: @~str, start_pos: file_pos, mut lines: ~[file_pos]}; type codemap = @{files: dvec}; @@ -55,7 +55,7 @@ enum file_substr { fn new_codemap() -> codemap { @{files: dvec()} } fn new_filemap_w_substr(+filename: filename, +substr: file_substr, - src: @str/~, + src: @~str, start_pos_ch: uint, start_pos_byte: uint) -> filemap { ret @{name: filename, substr: substr, src: src, @@ -63,14 +63,14 @@ fn new_filemap_w_substr(+filename: filename, +substr: file_substr, mut lines: ~[{ch: start_pos_ch, byte: start_pos_byte}]}; } -fn new_filemap(+filename: filename, src: @str/~, +fn new_filemap(+filename: filename, src: @~str, start_pos_ch: uint, start_pos_byte: uint) -> filemap { ret new_filemap_w_substr(filename, fss_none, src, start_pos_ch, start_pos_byte); } -fn mk_substr_filename(cm: codemap, sp: span) -> str +fn mk_substr_filename(cm: codemap, sp: span) -> ~str { let pos = lookup_char_pos(cm, sp.lo); ret #fmt("<%s:%u:%u>", pos.file.name, pos.line, pos.col); @@ -121,7 +121,7 @@ fn lookup_byte_pos(map: codemap, pos: uint) -> loc { } fn lookup_char_pos_adj(map: codemap, pos: uint) - -> {filename: str, line: uint, col: uint, file: option} + -> {filename: ~str, line: uint, col: uint, file: option} { let loc = lookup_char_pos(map, pos); alt (loc.file.substr) { @@ -158,19 +158,19 @@ fn adjust_span(map: codemap, sp: span) -> span { enum expn_info_ { expanded_from({call_site: span, - callie: {name: str, span: option}}) + callie: {name: ~str, span: option}}) } type expn_info = option<@expn_info_>; type span = {lo: uint, hi: uint, expn_info: expn_info}; -fn span_to_str_no_adj(sp: span, cm: codemap) -> str { +fn span_to_str_no_adj(sp: span, cm: codemap) -> ~str { let lo = lookup_char_pos(cm, sp.lo); let hi = lookup_char_pos(cm, sp.hi); ret #fmt("%s:%u:%u: %u:%u", lo.file.name, lo.line, lo.col, hi.line, hi.col) } -fn span_to_str(sp: span, cm: codemap) -> str { +fn span_to_str(sp: span, cm: codemap) -> ~str { let lo = lookup_char_pos_adj(cm, sp.lo); let hi = lookup_char_pos_adj(cm, sp.hi); ret #fmt("%s:%u:%u: %u:%u", lo.filename, @@ -194,7 +194,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { ret @{file: lo.file, lines: lines}; } -fn get_line(fm: filemap, line: int) -> str unsafe { +fn get_line(fm: filemap, line: int) -> ~str unsafe { let begin: uint = fm.lines[line].byte - fm.start_pos.byte; let end = alt str::find_char_from(*fm.src, '\n', begin) { some(e) { e } @@ -213,20 +213,20 @@ fn lookup_byte_offset(cm: codemap::codemap, chpos: uint) {fm: fm, pos: line_offset + col_offset} } -fn span_to_snippet(sp: span, cm: codemap::codemap) -> str { +fn span_to_snippet(sp: span, cm: codemap::codemap) -> ~str { let begin = lookup_byte_offset(cm, sp.lo); let end = lookup_byte_offset(cm, sp.hi); assert begin.fm == end.fm; ret str::slice(*begin.fm.src, begin.pos, end.pos); } -fn get_snippet(cm: codemap::codemap, fidx: uint, lo: uint, hi: uint) -> str +fn get_snippet(cm: codemap::codemap, fidx: uint, lo: uint, hi: uint) -> ~str { let fm = cm.files[fidx]; ret str::slice(*fm.src, lo, hi) } -fn get_filemap(cm: codemap, filename: str) -> filemap { +fn get_filemap(cm: codemap, filename: ~str) -> filemap { for cm.files.each |fm| { if fm.name == filename { ret fm; } } //XXjdm the following triggers a mismatched type bug // (or expected function, found _|_) diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 4e1d8f824e15..cda49de8dd07 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -10,30 +10,30 @@ export expect; type emitter = fn@(cmsp: option<(codemap::codemap, span)>, - msg: str, lvl: level); + msg: ~str, lvl: level); iface span_handler { - fn span_fatal(sp: span, msg: str) -> !; - fn span_err(sp: span, msg: str); - fn span_warn(sp: span, msg: str); - fn span_note(sp: span, msg: str); - fn span_bug(sp: span, msg: str) -> !; - fn span_unimpl(sp: span, msg: str) -> !; + fn span_fatal(sp: span, msg: ~str) -> !; + fn span_err(sp: span, msg: ~str); + fn span_warn(sp: span, msg: ~str); + fn span_note(sp: span, msg: ~str); + fn span_bug(sp: span, msg: ~str) -> !; + fn span_unimpl(sp: span, msg: ~str) -> !; fn handler() -> handler; } iface handler { - fn fatal(msg: str) -> !; - fn err(msg: str); + fn fatal(msg: ~str) -> !; + fn err(msg: ~str); fn bump_err_count(); fn has_errors() -> bool; fn abort_if_errors(); - fn warn(msg: str); - fn note(msg: str); - fn bug(msg: str) -> !; - fn unimpl(msg: str) -> !; - fn emit(cmsp: option<(codemap::codemap, span)>, msg: str, lvl: level); + fn warn(msg: ~str); + fn note(msg: ~str); + fn bug(msg: ~str) -> !; + fn unimpl(msg: ~str) -> !; + fn emit(cmsp: option<(codemap::codemap, span)>, msg: ~str, lvl: level); } type handler_t = @{ @@ -47,25 +47,25 @@ }; impl codemap_span_handler of span_handler for codemap_t { - fn span_fatal(sp: span, msg: str) -> ! { + fn span_fatal(sp: span, msg: ~str) -> ! { self.handler.emit(some((self.cm, sp)), msg, fatal); fail; } - fn span_err(sp: span, msg: str) { + fn span_err(sp: span, msg: ~str) { self.handler.emit(some((self.cm, sp)), msg, error); self.handler.bump_err_count(); } - fn span_warn(sp: span, msg: str) { + fn span_warn(sp: span, msg: ~str) { self.handler.emit(some((self.cm, sp)), msg, warning); } - fn span_note(sp: span, msg: str) { + fn span_note(sp: span, msg: ~str) { self.handler.emit(some((self.cm, sp)), msg, note); } - fn span_bug(sp: span, msg: str) -> ! { + fn span_bug(sp: span, msg: ~str) -> ! { self.span_fatal(sp, ice_msg(msg)); } - fn span_unimpl(sp: span, msg: str) -> ! { - self.span_bug(sp, "unimplemented " + msg); + fn span_unimpl(sp: span, msg: ~str) -> ! { + self.span_bug(sp, ~"unimplemented " + msg); } fn handler() -> handler { self.handler @@ -73,11 +73,11 @@ fn handler() -> handler { } impl codemap_handler of handler for handler_t { - fn fatal(msg: str) -> ! { + fn fatal(msg: ~str) -> ! { self.emit(none, msg, fatal); fail; } - fn err(msg: str) { + fn err(msg: ~str) { self.emit(none, msg, error); self.bump_err_count(); } @@ -89,28 +89,28 @@ fn abort_if_errors() { let s; alt self.err_count { 0u { ret; } - 1u { s = "aborting due to previous error"; } + 1u { s = ~"aborting due to previous error"; } _ { s = #fmt["aborting due to %u previous errors", self.err_count]; } } self.fatal(s); } - fn warn(msg: str) { + fn warn(msg: ~str) { self.emit(none, msg, warning); } - fn note(msg: str) { + fn note(msg: ~str) { self.emit(none, msg, note); } - fn bug(msg: str) -> ! { + fn bug(msg: ~str) -> ! { self.fatal(ice_msg(msg)); } - fn unimpl(msg: str) -> ! { self.bug("unimplemented " + msg); } - fn emit(cmsp: option<(codemap::codemap, span)>, msg: str, lvl: level) { + fn unimpl(msg: ~str) -> ! { self.bug(~"unimplemented " + msg); } + fn emit(cmsp: option<(codemap::codemap, span)>, msg: ~str, lvl: level) { self.emit(cmsp, msg, lvl); } } -fn ice_msg(msg: str) -> str { +fn ice_msg(msg: ~str) -> ~str { #fmt["internal compiler error: %s", msg] } @@ -124,7 +124,7 @@ fn mk_handler(emitter: option) -> handler { some(e) { e } none { let f = fn@(cmsp: option<(codemap::codemap, span)>, - msg: str, t: level) { + msg: ~str, t: level) { emit(cmsp, msg, t); }; f @@ -144,12 +144,12 @@ enum level { note, } -fn diagnosticstr(lvl: level) -> str { +fn diagnosticstr(lvl: level) -> ~str { alt lvl { - fatal { "error" } - error { "error" } - warning { "warning" } - note { "note" } + fatal { ~"error" } + error { ~"error" } + warning { ~"warning" } + note { ~"note" } } } @@ -162,7 +162,7 @@ fn diagnosticcolor(lvl: level) -> u8 { } } -fn print_diagnostic(topic: str, lvl: level, msg: str) { +fn print_diagnostic(topic: ~str, lvl: level, msg: ~str) { if str::is_not_empty(topic) { io::stderr().write_str(#fmt["%s ", topic]); } @@ -177,7 +177,7 @@ fn print_diagnostic(topic: str, lvl: level, msg: str) { } fn emit(cmsp: option<(codemap::codemap, span)>, - msg: str, lvl: level) { + msg: ~str, lvl: level) { alt cmsp { some((cm, sp)) { let sp = codemap::adjust_span(cm,sp); @@ -188,7 +188,7 @@ fn emit(cmsp: option<(codemap::codemap, span)>, print_macro_backtrace(cm, sp); } none { - print_diagnostic("", lvl, msg); + print_diagnostic(~"", lvl, msg); } } } @@ -209,16 +209,16 @@ fn highlight_lines(cm: codemap::codemap, sp: span, // Print the offending lines for display_lines.each |line| { io::stderr().write_str(#fmt["%s:%u ", fm.name, line + 1u]); - let s = codemap::get_line(fm, line as int) + "\n"; + let s = codemap::get_line(fm, line as int) + ~"\n"; io::stderr().write_str(s); } if elided { let last_line = display_lines[vec::len(display_lines) - 1u]; let s = #fmt["%s:%u ", fm.name, last_line + 1u]; let mut indent = str::len(s); - let mut out = ""; - while indent > 0u { out += " "; indent -= 1u; } - out += "...\n"; + let mut out = ~""; + while indent > 0u { out += ~" "; indent -= 1u; } + out += ~"...\n"; io::stderr().write_str(out); } @@ -234,34 +234,34 @@ fn highlight_lines(cm: codemap::codemap, sp: span, // indent past |name:## | and the 0-offset column location let mut left = str::len(fm.name) + digits + lo.col + 3u; - let mut s = ""; + let mut s = ~""; while left > 0u { str::push_char(s, ' '); left -= 1u; } - s += "^"; + s += ~"^"; let hi = codemap::lookup_char_pos(cm, sp.hi); if hi.col != lo.col { // the ^ already takes up one space let mut width = hi.col - lo.col - 1u; while width > 0u { str::push_char(s, '~'); width -= 1u; } } - io::stderr().write_str(s + "\n"); + io::stderr().write_str(s + ~"\n"); } } fn print_macro_backtrace(cm: codemap::codemap, sp: span) { do option::iter (sp.expn_info) |ei| { - let ss = option::map_default(ei.callie.span, @"", + let ss = option::map_default(ei.callie.span, @~"", |span| @codemap::span_to_str(span, cm)); print_diagnostic(*ss, note, #fmt("in expansion of #%s", ei.callie.name)); let ss = codemap::span_to_str(ei.call_site, cm); - print_diagnostic(ss, note, "expansion site"); + print_diagnostic(ss, note, ~"expansion site"); print_macro_backtrace(cm, ei.call_site); } } fn expect(diag: span_handler, - opt: option, msg: fn() -> str) -> T { + opt: option, msg: fn() -> ~str) -> T { alt opt { some(t) { t } none { diag.handler().bug(msg()); } diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 119dbb59109c..ac2829643bec 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -84,15 +84,15 @@ mod syntax { export parse; } -type ser_tps_map = map::hashmap ~[@ast::stmt]>; -type deser_tps_map = map::hashmap @ast::expr>; +type ser_tps_map = map::hashmap<~str, fn@(@ast::expr) -> ~[@ast::stmt]>; +type deser_tps_map = map::hashmap<~str, fn@() -> @ast::expr>; fn expand(cx: ext_ctxt, span: span, _mitem: ast::meta_item, in_items: ~[@ast::item]) -> ~[@ast::item] { fn not_auto_serialize(a: ast::attribute) -> bool { - attr::get_attr_name(a) != @"auto_serialize" + attr::get_attr_name(a) != @~"auto_serialize" } fn filter_attrs(item: @ast::item) -> @ast::item { @@ -114,7 +114,7 @@ fn filter_attrs(item: @ast::item) -> @ast::item { } _ { - cx.span_err(span, "#[auto_serialize] can only be \ + cx.span_err(span, ~"#[auto_serialize] can only be \ applied to type and enum \ definitions"); ~[in_item] @@ -125,11 +125,11 @@ fn filter_attrs(item: @ast::item) -> @ast::item { impl helpers for ext_ctxt { fn helper_path(base_path: @ast::path, - helper_name: str) -> @ast::path { + helper_name: ~str) -> @ast::path { let head = vec::init(base_path.idents); let tail = vec::last(base_path.idents); self.path(base_path.span, - vec::append(head, ~[@(helper_name + "_" + *tail)])) + vec::append(head, ~[@(helper_name + ~"_" + *tail)])) } fn path(span: span, strs: ~[ast::ident]) -> @ast::path { @@ -154,7 +154,7 @@ fn ty_fn(span: span, let args = do vec::map(input_tys) |ty| { {mode: ast::expl(ast::by_ref), ty: ty, - ident: @"", + ident: @~"", id: self.next_id()} }; @@ -219,12 +219,16 @@ fn alt_stmt(arms: ~[ast::arm], ast::expr_alt(v, arms, ast::alt_exhaustive))) } - fn lit_str(span: span, s: @str/~) -> @ast::expr { + fn lit_str(span: span, s: @~str) -> @ast::expr { self.expr( span, - ast::expr_lit( - @{node: ast::lit_str(s), - span: span})) + ast::expr_vstore( + self.expr( + span, + ast::expr_lit( + @{node: ast::lit_str(s), + span: span})), + ast::vstore_uniq)) } fn lit_uint(span: span, i: uint) -> @ast::expr { @@ -293,7 +297,7 @@ fn ser_path(cx: ext_ctxt, tps: ser_tps_map, path: @ast::path, cx.expr( path.span, ast::expr_path( - cx.helper_path(path, "serialize"))); + cx.helper_path(path, ~"serialize"))); let ty_args = do vec::map(path.types) |ty| { let sv_stmts = ser_ty(cx, tps, ty, cx.clone(s), #ast{ __v }); @@ -350,7 +354,7 @@ fn is_vec_or_str(ty: @ast::ty) -> bool { // This may be wrong if the user has shadowed (!) str ast::ty_path(@{span: _, global: _, idents: ids, rp: none, types: _}, _) - if ids == ~[@"str"] { true } + if ids == ~[@~"str"] { true } _ { false } } } @@ -388,7 +392,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_ptr(_) | ast::ty_rptr(_, _) { - cx.span_err(ty.span, "cannot serialize pointer types"); + cx.span_err(ty.span, ~"cannot serialize pointer types"); ~[] } @@ -410,7 +414,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_fn(_, _) { - cx.span_err(ty.span, "cannot serialize function types"); + cx.span_err(ty.span, ~"cannot serialize function types"); ~[] } @@ -467,12 +471,12 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_mac(_) { - cx.span_err(ty.span, "cannot serialize macro types"); + cx.span_err(ty.span, ~"cannot serialize macro types"); ~[] } ast::ty_infer { - cx.span_err(ty.span, "cannot serialize inferred types"); + cx.span_err(ty.span, ~"cannot serialize inferred types"); ~[] } @@ -499,7 +503,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_vstore(_, _) { - cx.span_unimpl(ty.span, "serialization for vstore types"); + cx.span_unimpl(ty.span, ~"serialization for vstore types"); } } @@ -521,7 +525,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, ty: cx.ty_fn(span, ~[cx.ty_path(span, ~[tp.ident], ~[])], cx.ty_nil(span)), - ident: @("__s" + *tp.ident), + ident: @(~"__s" + *tp.ident), id: cx.next_id()}); #debug["tp_inputs = %?", tp_inputs]; @@ -529,12 +533,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, let ser_inputs: ~[ast::arg] = vec::append(~[{mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ~[@"__S"], ~[]), - ident: @"__s", + ty: cx.ty_path(span, ~[@~"__S"], ~[]), + ident: @~"__s", id: cx.next_id()}, {mode: ast::expl(ast::by_ref), ty: v_ty, - ident: @"__v", + ident: @~"__v", id: cx.next_id()}], tp_inputs); @@ -552,12 +556,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, let ser_bnds = @~[ ast::bound_trait(cx.ty_path(span, - ~[@"std", @"serialization", - @"serializer"], + ~[@~"std", @~"serialization", + @~"serializer"], ~[]))]; let ser_tps: ~[ast::ty_param] = - vec::append(~[{ident: @"__S", + vec::append(~[{ident: @~"__S", id: cx.next_id(), bounds: ser_bnds}], vec::map(tps, |tp| cx.clone_ty_param(tp))); @@ -569,7 +573,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, let ser_blk = cx.blk(span, f(cx, tps_map, #ast{ __s }, #ast{ __v })); - @{ident: @("serialize_" + *name), + @{ident: @(~"serialize_" + *name), attrs: ~[], id: cx.next_id(), node: ast::item_fn({inputs: ser_inputs, @@ -594,7 +598,7 @@ fn deser_path(cx: ext_ctxt, tps: deser_tps_map, path: @ast::path, cx.expr( path.span, ast::expr_path( - cx.helper_path(path, "deserialize"))); + cx.helper_path(path, ~"deserialize"))); let ty_args = do vec::map(path.types) |ty| { let dv_expr = deser_ty(cx, tps, ty, cx.clone(d)); @@ -722,7 +726,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, } ast::ty_vstore(_, _) { - cx.span_unimpl(ty.span, "deserialization for vstore types"); + cx.span_unimpl(ty.span, ~"deserialization for vstore types"); } } } @@ -742,15 +746,15 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, ty: cx.ty_fn(span, ~[], cx.ty_path(span, ~[tp.ident], ~[])), - ident: @("__d" + *tp.ident), + ident: @(~"__d" + *tp.ident), id: cx.next_id()}); #debug["tp_inputs = %?", tp_inputs]; let deser_inputs: ~[ast::arg] = vec::append(~[{mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ~[@"__D"], ~[]), - ident: @"__d", + ty: cx.ty_path(span, ~[@~"__D"], ~[]), + ident: @~"__d", id: cx.next_id()}], tp_inputs); @@ -768,11 +772,11 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, let deser_bnds = @~[ ast::bound_trait(cx.ty_path( span, - ~[@"std", @"serialization", @"deserializer"], + ~[@~"std", @~"serialization", @~"deserializer"], ~[]))]; let deser_tps: ~[ast::ty_param] = - vec::append(~[{ident: @"__D", + vec::append(~[{ident: @~"__D", id: cx.next_id(), bounds: deser_bnds}], vec::map(tps, |tp| { @@ -784,7 +788,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d})); - @{ident: @("deserialize_" + *name), + @{ident: @(~"deserialize_" + *name), attrs: ~[], id: cx.next_id(), node: ast::item_fn({inputs: deser_inputs, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 7b08b18596e7..b7d17a9d6520 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -42,47 +42,47 @@ enum syntax_extension { // A temporary hard-coded map of methods for expanding syntax extension // AST nodes into full ASTs -fn syntax_expander_table() -> hashmap { +fn syntax_expander_table() -> hashmap<~str, syntax_extension> { fn builtin(f: syntax_expander_) -> syntax_extension {normal({expander: f, span: none})} fn builtin_item_tt(f: syntax_expander_tt_item_) -> syntax_extension { item_tt({expander: f, span: none}) } let syntax_expanders = str_hash::(); - syntax_expanders.insert("macro", + syntax_expanders.insert(~"macro", macro_defining(ext::simplext::add_new_extension)); - syntax_expanders.insert("macro_rules", + syntax_expanders.insert(~"macro_rules", builtin_item_tt( ext::tt::macro_rules::add_new_extension)); - syntax_expanders.insert("fmt", builtin(ext::fmt::expand_syntax_ext)); - syntax_expanders.insert("auto_serialize", + syntax_expanders.insert(~"fmt", builtin(ext::fmt::expand_syntax_ext)); + syntax_expanders.insert(~"auto_serialize", item_decorator(ext::auto_serialize::expand)); - syntax_expanders.insert("env", builtin(ext::env::expand_syntax_ext)); - syntax_expanders.insert("concat_idents", + syntax_expanders.insert(~"env", builtin(ext::env::expand_syntax_ext)); + syntax_expanders.insert(~"concat_idents", builtin(ext::concat_idents::expand_syntax_ext)); - syntax_expanders.insert("ident_to_str", + syntax_expanders.insert(~"ident_to_str", builtin(ext::ident_to_str::expand_syntax_ext)); - syntax_expanders.insert("log_syntax", + syntax_expanders.insert(~"log_syntax", builtin(ext::log_syntax::expand_syntax_ext)); - syntax_expanders.insert("ast", + syntax_expanders.insert(~"ast", builtin(ext::qquote::expand_ast)); - syntax_expanders.insert("line", + syntax_expanders.insert(~"line", builtin(ext::source_util::expand_line)); - syntax_expanders.insert("col", + syntax_expanders.insert(~"col", builtin(ext::source_util::expand_col)); - syntax_expanders.insert("file", + syntax_expanders.insert(~"file", builtin(ext::source_util::expand_file)); - syntax_expanders.insert("stringify", + syntax_expanders.insert(~"stringify", builtin(ext::source_util::expand_stringify)); - syntax_expanders.insert("include", + syntax_expanders.insert(~"include", builtin(ext::source_util::expand_include)); - syntax_expanders.insert("include_str", + syntax_expanders.insert(~"include_str", builtin(ext::source_util::expand_include_str)); - syntax_expanders.insert("include_bin", + syntax_expanders.insert(~"include_bin", builtin(ext::source_util::expand_include_bin)); - syntax_expanders.insert("mod", + syntax_expanders.insert(~"mod", builtin(ext::source_util::expand_mod)); - syntax_expanders.insert("proto", + syntax_expanders.insert(~"proto", builtin_item_tt(ext::pipes::expand_proto)); ret syntax_expanders; } @@ -98,11 +98,11 @@ fn builtin_item_tt(f: syntax_expander_tt_item_) -> syntax_extension { fn mod_path() -> ~[ast::ident]; fn bt_push(ei: codemap::expn_info_); fn bt_pop(); - fn span_fatal(sp: span, msg: str) -> !; - fn span_err(sp: span, msg: str); - fn span_unimpl(sp: span, msg: str) -> !; - fn span_bug(sp: span, msg: str) -> !; - fn bug(msg: str) -> !; + fn span_fatal(sp: span, msg: ~str) -> !; + fn span_err(sp: span, msg: ~str); + fn span_unimpl(sp: span, msg: ~str) -> !; + fn span_bug(sp: span, msg: ~str) -> !; + fn bug(msg: ~str) -> !; fn next_id() -> ast::node_id; } @@ -137,26 +137,26 @@ fn bt_pop() { some(@expanded_from({call_site: {expn_info: prev, _}, _})) { self.backtrace = prev } - _ { self.bug("tried to pop without a push"); } + _ { self.bug(~"tried to pop without a push"); } } } - fn span_fatal(sp: span, msg: str) -> ! { + fn span_fatal(sp: span, msg: ~str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.span_fatal(sp, msg); } - fn span_err(sp: span, msg: str) { + fn span_err(sp: span, msg: ~str) { self.print_backtrace(); self.parse_sess.span_diagnostic.span_err(sp, msg); } - fn span_unimpl(sp: span, msg: str) -> ! { + fn span_unimpl(sp: span, msg: ~str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.span_unimpl(sp, msg); } - fn span_bug(sp: span, msg: str) -> ! { + fn span_bug(sp: span, msg: ~str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.span_bug(sp, msg); } - fn bug(msg: str) -> ! { + fn bug(msg: ~str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.handler().bug(msg); } @@ -173,7 +173,7 @@ fn next_id() -> ast::node_id { ret imp as ext_ctxt } -fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: str) -> str { +fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str { alt expr.node { ast::expr_lit(l) { alt l.node { @@ -185,7 +185,7 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: str) -> str { } } -fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: str) -> ast::ident { +fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ast::ident { alt expr.node { ast::expr_path(p) { if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { @@ -197,12 +197,12 @@ fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: str) -> ast::ident { } fn get_mac_args_no_max(cx: ext_ctxt, sp: span, arg: ast::mac_arg, - min: uint, name: str) -> ~[@ast::expr] { + min: uint, name: ~str) -> ~[@ast::expr] { ret get_mac_args(cx, sp, arg, min, none, name); } fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, - min: uint, max: option, name: str) -> ~[@ast::expr] { + min: uint, max: option, name: ~str) -> ~[@ast::expr] { alt arg { some(expr) { alt expr.node { @@ -235,7 +235,7 @@ fn get_mac_body(cx: ext_ctxt, sp: span, args: ast::mac_body) { alt (args) { some(body) {body} - none {cx.span_fatal(sp, "missing macro body")} + none {cx.span_fatal(sp, ~"missing macro body")} } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 342ecac22626..5eca1e8e17c3 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -11,10 +11,6 @@ fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr { let sp_lit = @{node: lit, span: sp}; mk_expr(cx, sp, ast::expr_lit(sp_lit)) } -fn mk_str(cx: ext_ctxt, sp: span, s: str) -> @ast::expr { - let lit = ast::lit_str(@s); - ret mk_lit(cx, sp, lit); -} fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr { let lit = ast::lit_int(i as i64, ast::ty_i); ret mk_lit(cx, sp, lit); @@ -23,6 +19,10 @@ fn mk_uint(cx: ext_ctxt, sp: span, u: uint) -> @ast::expr { let lit = ast::lit_uint(u as u64, ast::ty_u); ret mk_lit(cx, sp, lit); } +fn mk_u8(cx: ext_ctxt, sp: span, u: u8) -> @ast::expr { + let lit = ast::lit_uint(u as u64, ast::ty_u8); + ret mk_lit(cx, sp, lit); +} fn mk_binary(cx: ext_ctxt, sp: span, op: ast::binop, lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr { @@ -77,6 +77,13 @@ fn mk_fixed_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) -> @ast::expr { mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::vstore_fixed(none)) } +fn mk_base_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { + let lit = ast::lit_str(@s); + ret mk_lit(cx, sp, lit); +} +fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { + mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::vstore_uniq) +} fn mk_rec_e(cx: ext_ctxt, sp: span, fields: ~[{ident: ast::ident, ex: @ast::expr}]) -> diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index f5d13df75d63..b3545cc635d4 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -2,10 +2,10 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args_no_max(cx,sp,arg,1u,"concat_idents"); - let mut res = ""; + let args = get_mac_args_no_max(cx,sp,arg,1u,~"concat_idents"); + let mut res = ~""; for args.each |e| { - res += *expr_to_ident(cx, e, "expected an ident"); + res += *expr_to_ident(cx, e, ~"expected an ident"); } ret @{id: cx.next_id(), diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index b8aa69b77355..e03fc2ce47b0 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -5,26 +5,23 @@ * interface. */ import base::*; -import build::mk_lit; +import build::mk_uniq_str; export expand_syntax_ext; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "env"); + let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"env"); // FIXME (#2248): if this was more thorough it would manufacture an // option rather than just an maybe-empty string. - let var = expr_to_str(cx, args[0], "#env requires a string"); + let var = expr_to_str(cx, args[0], ~"#env requires a string"); alt os::getenv(var) { - option::none { ret make_new_str(cx, sp, ""); } - option::some(s) { ret make_new_str(cx, sp, s); } + option::none { ret mk_uniq_str(cx, sp, ~""); } + option::some(s) { ret mk_uniq_str(cx, sp, s); } } } -fn make_new_str(cx: ext_ctxt, sp: codemap::span, +s: str) -> @ast::expr { - ret mk_lit(cx, sp, ast::lit_str(@s)); -} // // Local Variables: // mode: rust diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 05c7e6f1c5af..2a41afc97430 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -10,7 +10,7 @@ import codemap::{span, expanded_from}; -fn expand_expr(exts: hashmap, cx: ext_ctxt, +fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, e: expr_, s: span, fld: ast_fold, orig: fn@(expr_, span, ast_fold) -> (expr_, span)) -> (expr_, span) @@ -54,7 +54,7 @@ fn expand_expr(exts: hashmap, cx: ext_ctxt, } some(item_tt(*)) { cx.span_fatal(pth.span, - "cannot use item macros in this context"); + ~"cannot use item macros in this context"); } } } @@ -91,14 +91,14 @@ fn expand_expr(exts: hashmap, cx: ext_ctxt, } } - _ { cx.span_bug(mac.span, "naked syntactic bit") } + _ { cx.span_bug(mac.span, ~"naked syntactic bit") } } } _ { orig(e, s, fld) } }; } -fn expand_mod_items(exts: hashmap, cx: ext_ctxt, +fn expand_mod_items(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, module: ast::_mod, fld: ast_fold, orig: fn@(ast::_mod, ast_fold) -> ast::_mod) -> ast::_mod @@ -133,7 +133,7 @@ fn expand_mod_items(exts: hashmap, cx: ext_ctxt, } /* record module we enter for `#mod` */ -fn expand_item(exts: hashmap, +fn expand_item(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, &&it: @ast::item, fld: ast_fold, orig: fn@(&&@ast::item, ast_fold) -> option<@ast::item>) -> option<@ast::item> @@ -160,7 +160,7 @@ fn expand_item(exts: hashmap, } } -fn expand_item_mac(exts: hashmap, +fn expand_item_mac(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, &&it: @ast::item, fld: ast_fold) -> option<@ast::item> { alt it.node { @@ -179,7 +179,7 @@ fn expand_item_mac(exts: hashmap, let maybe_it = alt expanded { mr_item(it) { fld.fold_item(it) } mr_expr(e) { cx.span_fatal(pth.span, - "expr macro in item position: " + + ~"expr macro in item position: " + *extname) } mr_def(mdef) { exts.insert(*mdef.ident, mdef.ext); @@ -194,7 +194,7 @@ fn expand_item_mac(exts: hashmap, } } _ { - cx.span_bug(it.span, "invalid item macro invocation"); + cx.span_bug(it.span, ~"invalid item macro invocation"); } } } @@ -209,9 +209,9 @@ fn new_span(cx: ext_ctxt, sp: span) -> span { // is substantially more mature, these should move from here, into a // compiled part of libcore at very least. -fn core_macros() -> str { +fn core_macros() -> ~str { ret -"{ +~"{ #macro([#error[f, ...], log(core::error, #fmt[f, ...])]); #macro([#warn[f, ...], log(core::warn, #fmt[f, ...])]); #macro([#info[f, ...], log(core::info, #fmt[f, ...])]); @@ -231,7 +231,7 @@ fn expand_crate(parse_sess: parse::parse_sess, new_span: |a|new_span(cx, a) with *afp}; let f = make_fold(f_pre); - let cm = parse_expr_from_source_str("", + let cm = parse_expr_from_source_str(~"", @core_macros(), cfg, parse_sess); diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index acf055ccabda..53b5db8b6a61 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -13,17 +13,17 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args_no_max(cx, sp, arg, 1u, "fmt"); + let args = get_mac_args_no_max(cx, sp, arg, 1u, ~"fmt"); let fmt = expr_to_str(cx, args[0], - "first argument to #fmt must be a string literal."); + ~"first argument to #fmt must be a string literal."); let fmtspan = args[0].span; #debug("Format string:"); log(debug, fmt); - fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: str) -> ! { + fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: ~str) -> ! { cx.span_fatal(sp, msg); } - let parse_fmt_err = fn@(s: str) -> ! { + let parse_fmt_err = fn@(s: ~str) -> ! { parse_fmt_err_(cx, fmtspan, s) }; let pieces = parse_fmt_string(fmt, parse_fmt_err); @@ -38,7 +38,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: ~[piece], args: ~[@ast::expr]) -> @ast::expr { fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> ~[ast::ident] { - ret ~[@"extfmt", @"rt", ident]; + ret ~[@~"extfmt", @~"rt", ident]; } fn make_rt_path_expr(cx: ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr { @@ -50,14 +50,14 @@ fn make_rt_path_expr(cx: ext_ctxt, sp: span, fn make_rt_conv_expr(cx: ext_ctxt, sp: span, cnv: conv) -> @ast::expr { fn make_flags(cx: ext_ctxt, sp: span, flags: ~[flag]) -> @ast::expr { - let mut tmp_expr = make_rt_path_expr(cx, sp, @"flag_none"); + let mut tmp_expr = make_rt_path_expr(cx, sp, @~"flag_none"); for flags.each |f| { let fstr = alt f { - flag_left_justify { "flag_left_justify" } - flag_left_zero_pad { "flag_left_zero_pad" } - flag_space_for_sign { "flag_space_for_sign" } - flag_sign_always { "flag_sign_always" } - flag_alternate { "flag_alternate" } + flag_left_justify { ~"flag_left_justify" } + flag_left_zero_pad { ~"flag_left_zero_pad" } + flag_space_for_sign { ~"flag_space_for_sign" } + flag_sign_always { ~"flag_sign_always" } + flag_alternate { ~"flag_alternate" } }; tmp_expr = mk_binary(cx, sp, ast::bitor, tmp_expr, make_rt_path_expr(cx, sp, @fstr)); @@ -67,15 +67,15 @@ fn make_flags(cx: ext_ctxt, sp: span, flags: ~[flag]) -> @ast::expr { fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr { alt cnt { count_implied { - ret make_rt_path_expr(cx, sp, @"count_implied"); + ret make_rt_path_expr(cx, sp, @~"count_implied"); } count_is(c) { let count_lit = mk_int(cx, sp, c); - let count_is_path = make_path_vec(cx, @"count_is"); + let count_is_path = make_path_vec(cx, @~"count_is"); let count_is_args = ~[count_lit]; ret mk_call(cx, sp, count_is_path, count_is_args); } - _ { cx.span_unimpl(sp, "unimplemented #fmt conversion"); } + _ { cx.span_unimpl(sp, ~"unimplemented #fmt conversion"); } } } fn make_ty(cx: ext_ctxt, sp: span, t: ty) -> @ast::expr { @@ -83,13 +83,13 @@ fn make_ty(cx: ext_ctxt, sp: span, t: ty) -> @ast::expr { alt t { ty_hex(c) { alt c { - case_upper { rt_type = "ty_hex_upper"; } - case_lower { rt_type = "ty_hex_lower"; } + case_upper { rt_type = ~"ty_hex_upper"; } + case_lower { rt_type = ~"ty_hex_lower"; } } } - ty_bits { rt_type = "ty_bits"; } - ty_octal { rt_type = "ty_octal"; } - _ { rt_type = "ty_default"; } + ty_bits { rt_type = ~"ty_bits"; } + ty_octal { rt_type = ~"ty_octal"; } + _ { rt_type = ~"ty_default"; } } ret make_rt_path_expr(cx, sp, @rt_type); } @@ -97,10 +97,10 @@ fn make_conv_rec(cx: ext_ctxt, sp: span, flags_expr: @ast::expr, width_expr: @ast::expr, precision_expr: @ast::expr, ty_expr: @ast::expr) -> @ast::expr { ret mk_rec_e(cx, sp, - ~[{ident: @"flags", ex: flags_expr}, - {ident: @"width", ex: width_expr}, - {ident: @"precision", ex: precision_expr}, - {ident: @"ty", ex: ty_expr}]); + ~[{ident: @~"flags", ex: flags_expr}, + {ident: @~"width", ex: width_expr}, + {ident: @~"precision", ex: precision_expr}, + {ident: @~"ty", ex: ty_expr}]); } let rt_conv_flags = make_flags(cx, sp, cnv.flags); let rt_conv_width = make_count(cx, sp, cnv.width); @@ -109,9 +109,9 @@ fn make_conv_rec(cx: ext_ctxt, sp: span, flags_expr: @ast::expr, ret make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width, rt_conv_precision, rt_conv_ty); } - fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: str, cnv: conv, + fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: ~str, cnv: conv, arg: @ast::expr) -> @ast::expr { - let fname = "conv_" + conv_type; + let fname = ~"conv_" + conv_type; let path = make_path_vec(cx, @fname); let cnv_expr = make_rt_conv_expr(cx, sp, cnv); let args = ~[cnv_expr, arg]; @@ -131,7 +131,7 @@ fn is_signed_type(cnv: conv) -> bool { _ { ret false; } } } - let unsupported = "conversion not supported in #fmt string"; + let unsupported = ~"conversion not supported in #fmt string"; alt cnv.param { option::none { } _ { cx.span_unimpl(sp, unsupported); } @@ -142,15 +142,15 @@ fn is_signed_type(cnv: conv) -> bool { flag_sign_always { if !is_signed_type(cnv) { cx.span_fatal(sp, - "+ flag only valid in " + - "signed #fmt conversion"); + ~"+ flag only valid in " + + ~"signed #fmt conversion"); } } flag_space_for_sign { if !is_signed_type(cnv) { cx.span_fatal(sp, - "space flag only valid in " + - "signed #fmt conversions"); + ~"space flag only valid in " + + ~"signed #fmt conversions"); } } flag_left_zero_pad { } @@ -168,27 +168,27 @@ fn is_signed_type(cnv: conv) -> bool { _ { cx.span_unimpl(sp, unsupported); } } alt cnv.ty { - ty_str { ret make_conv_call(cx, arg.span, "str", cnv, arg); } + ty_str { ret make_conv_call(cx, arg.span, ~"str", cnv, arg); } ty_int(sign) { alt sign { - signed { ret make_conv_call(cx, arg.span, "int", cnv, arg); } + signed { ret make_conv_call(cx, arg.span, ~"int", cnv, arg); } unsigned { - ret make_conv_call(cx, arg.span, "uint", cnv, arg); + ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } } } - ty_bool { ret make_conv_call(cx, arg.span, "bool", cnv, arg); } - ty_char { ret make_conv_call(cx, arg.span, "char", cnv, arg); } - ty_hex(_) { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } - ty_bits { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } - ty_octal { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } - ty_float { ret make_conv_call(cx, arg.span, "float", cnv, arg); } - ty_poly { ret make_conv_call(cx, arg.span, "poly", cnv, arg); } + ty_bool { ret make_conv_call(cx, arg.span, ~"bool", cnv, arg); } + ty_char { ret make_conv_call(cx, arg.span, ~"char", cnv, arg); } + ty_hex(_) { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_bits { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_octal { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_float { ret make_conv_call(cx, arg.span, ~"float", cnv, arg); } + ty_poly { ret make_conv_call(cx, arg.span, ~"poly", cnv, arg); } } } fn log_conv(c: conv) { alt c.param { - some(p) { log(debug, "param: " + int::to_str(p, 10u)); } + some(p) { log(debug, ~"param: " + int::to_str(p, 10u)); } _ { #debug("param: none"); } } for c.flags.each |f| { @@ -202,20 +202,20 @@ fn log_conv(c: conv) { } alt c.width { count_is(i) { log(debug, - "width: count is " + int::to_str(i, 10u)); } + ~"width: count is " + int::to_str(i, 10u)); } count_is_param(i) { log(debug, - "width: count is param " + int::to_str(i, 10u)); + ~"width: count is param " + int::to_str(i, 10u)); } count_is_next_param { #debug("width: count is next param"); } count_implied { #debug("width: count is implied"); } } alt c.precision { count_is(i) { log(debug, - "prec: count is " + int::to_str(i, 10u)); } + ~"prec: count is " + int::to_str(i, 10u)); } count_is_param(i) { log(debug, - "prec: count is param " + int::to_str(i, 10u)); + ~"prec: count is param " + int::to_str(i, 10u)); } count_is_next_param { #debug("prec: count is next param"); } count_implied { #debug("prec: count is implied"); } @@ -249,14 +249,14 @@ fn log_conv(c: conv) { for pieces.each |pc| { alt pc { piece_string(s) { - vec::push(piece_exprs, mk_str(cx, fmt_sp, s)); + vec::push(piece_exprs, mk_uniq_str(cx, fmt_sp, s)); } piece_conv(conv) { n += 1u; if n >= nargs { cx.span_fatal(sp, - "not enough arguments to #fmt " + - "for the given format string"); + ~"not enough arguments to #fmt " + + ~"for the given format string"); } #debug("Building conversion:"); log_conv(conv); @@ -275,7 +275,7 @@ fn log_conv(c: conv) { } let arg_vec = mk_fixed_vec_e(cx, fmt_sp, piece_exprs); - ret mk_call(cx, fmt_sp, ~[@"str", @"concat"], ~[arg_vec]); + ret mk_call(cx, fmt_sp, ~[@~"str", @~"concat"], ~[arg_vec]); } // // Local Variables: diff --git a/src/libsyntax/ext/ident_to_str.rs b/src/libsyntax/ext/ident_to_str.rs index 2cff86d98a7e..54f97912f3d5 100644 --- a/src/libsyntax/ext/ident_to_str.rs +++ b/src/libsyntax/ext/ident_to_str.rs @@ -1,12 +1,11 @@ import base::*; -import build::mk_lit; +import build::mk_uniq_str; import option; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),"ident_to_str"); + let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"ident_to_str"); - ret mk_lit(cx, sp, - ast::lit_str(expr_to_ident(cx, args[0u], - "expected an ident"))); + ret mk_uniq_str(cx, sp, *expr_to_ident(cx, args[0u], + ~"expected an ident")); } diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 06941fc5d38f..70d83b164c84 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -3,11 +3,11 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args_no_max(cx,sp,arg,0u,"log_syntax"); + let args = get_mac_args_no_max(cx,sp,arg,0u,~"log_syntax"); cx.print_backtrace(); io::stdout().write_line( str::connect(vec::map(args, - |&&ex| print::pprust::expr_to_str(ex)), ", ") + |&&ex| print::pprust::expr_to_str(ex)), ~", ") ); //trivial expression diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index fda557f15b68..cb0abe9e8e5a 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -7,7 +7,7 @@ import codemap::span; import ext::base::mk_ctxt; -fn ident(s: str) -> ast::ident { +fn ident(s: ~str) -> ast::ident { @(copy s) } diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 420de449a5cb..cf29c409e6ba 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -28,8 +28,8 @@ fn parse_state(proto: protocol) { }; self.bump(); let dir = alt dir { - @"send" { send } - @"recv" { recv } + @~"send" { send } + @~"recv" { recv } _ { fail } }; diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 9f46e6b10ae0..9406458d1acd 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -23,10 +23,10 @@ enum direction { } impl of to_str for direction { - fn to_str() -> str { + fn to_str() -> ~str { alt self { - send { "send" } - recv { "recv" } + send { ~"send" } + recv { ~"recv" } } } } @@ -68,35 +68,35 @@ fn gen_send(cx: ext_ctxt) -> @ast::item { message(id, tys, this, next, next_tys) { let next = this.proto.get_state(next); assert next_tys.len() == next.ty_params.len(); - let arg_names = tys.mapi(|i, _ty| @("x_" + i.to_str())); + let arg_names = tys.mapi(|i, _ty| @(~"x_" + i.to_str())); let args_ast = (arg_names, tys).map( |n, t| cx.arg_mode(n, t, ast::by_copy) ); let args_ast = vec::append( - ~[cx.arg_mode(@"pipe", + ~[cx.arg_mode(@~"pipe", cx.ty_path(path(this.data_name()) .add_tys(cx.ty_vars(this.ty_params))), ast::by_copy)], args_ast); let pat = alt (this.dir, next.dir) { - (send, send) { "(c, s)" } - (send, recv) { "(s, c)" } - (recv, send) { "(s, c)" } - (recv, recv) { "(c, s)" } + (send, send) { ~"(c, s)" } + (send, recv) { ~"(s, c)" } + (recv, send) { ~"(s, c)" } + (recv, recv) { ~"(c, s)" } }; let mut body = #fmt("{ let %s = pipes::entangle();\n", pat); body += #fmt("let message = %s::%s(%s);\n", *this.proto.name, *self.name(), - str::connect(vec::append_one(arg_names, @"s") + str::connect(vec::append_one(arg_names, @~"s") .map(|x| *x), - ", ")); + ~", ")); body += #fmt("pipes::send(pipe, message);\n"); - body += "c }"; + body += ~"c }"; let body = cx.parse_expr(body); @@ -127,7 +127,7 @@ fn add_message(name: ident, +data: ~[@ast::ty], next: ident, self.messages.push(message(name, data, self, next, next_tys)); } - fn filename() -> str { + fn filename() -> ~str { (*self).proto.filename() } @@ -158,8 +158,8 @@ fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] { let next_name = next.data_name(); let dir = alt this.dir { - send { @"server" } - recv { @"client" } + send { @~"server" } + recv { @~"client" } }; let v = cx.variant(name, @@ -190,7 +190,7 @@ fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] { cx.item_ty_poly( self.data_name(), cx.ty_path( - (@"pipes" + @(dir.to_str() + "_packet")) + (@~"pipes" + @(dir.to_str() + ~"_packet")) .add_ty(cx.ty_path( (self.proto.name + self.data_name()) .add_tys(cx.ty_vars(self.ty_params))))), @@ -236,17 +236,17 @@ fn add_state_poly(name: ident, dir: direction, state } - fn filename() -> str { - "proto://" + *self.name + fn filename() -> ~str { + ~"proto://" + *self.name } fn gen_init(cx: ext_ctxt) -> @ast::item { let start_state = self.states[0]; let body = alt start_state.dir { - send { cx.parse_expr("pipes::entangle()") } + send { cx.parse_expr(~"pipes::entangle()") } recv { - cx.parse_expr("{ \ + cx.parse_expr(~"{ \ let (s, c) = pipes::entangle(); \ (c, s) \ }") @@ -281,10 +281,10 @@ fn compile(cx: ext_ctxt) -> @ast::item { } vec::push(items, - cx.item_mod(@"client", + cx.item_mod(@~"client", client_states)); vec::push(items, - cx.item_mod(@"server", + cx.item_mod(@~"server", server_states)); cx.item_mod(self.name, items) @@ -293,49 +293,49 @@ fn compile(cx: ext_ctxt) -> @ast::item { iface to_source { // Takes a thing and generates a string containing rust code for it. - fn to_source() -> str; + fn to_source() -> ~str; } impl of to_source for @ast::item { - fn to_source() -> str { + fn to_source() -> ~str { item_to_str(self) } } impl of to_source for ~[@ast::item] { - fn to_source() -> str { - str::connect(self.map(|i| i.to_source()), "\n\n") + fn to_source() -> ~str { + str::connect(self.map(|i| i.to_source()), ~"\n\n") } } impl of to_source for @ast::ty { - fn to_source() -> str { + fn to_source() -> ~str { ty_to_str(self) } } impl of to_source for ~[@ast::ty] { - fn to_source() -> str { - str::connect(self.map(|i| i.to_source()), ", ") + fn to_source() -> ~str { + str::connect(self.map(|i| i.to_source()), ~", ") } } impl of to_source for ~[ast::ty_param] { - fn to_source() -> str { + fn to_source() -> ~str { pprust::typarams_to_str(self) } } impl of to_source for @ast::expr { - fn to_source() -> str { + fn to_source() -> ~str { pprust::expr_to_str(self) } } impl parse_utils for ext_ctxt { - fn parse_item(s: str) -> @ast::item { + fn parse_item(s: ~str) -> @ast::item { let res = parse::parse_item_from_source_str( - "***protocol expansion***", + ~"***protocol expansion***", @(copy s), self.cfg(), ~[], @@ -350,9 +350,9 @@ fn parse_item(s: str) -> @ast::item { } } - fn parse_expr(s: str) -> @ast::expr { + fn parse_expr(s: ~str) -> @ast::expr { parse::parse_expr_from_source_str( - "***protocol expansion***", + ~"***protocol expansion***", @(copy s), self.cfg(), self.parse_sess()) diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index e82901f2b3f7..4fd896e65bb6 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -16,7 +16,7 @@ type aq_ctxt = @{lo: uint, gather: dvec<{lo: uint, hi: uint, e: @ast::expr, - constr: str}>}; + constr: ~str}>}; enum fragment { from_expr(@ast::expr), from_ty(@ast::ty) @@ -27,7 +27,7 @@ enum fragment { fn visit(aq_ctxt, vt); fn extract_mac() -> option; fn mk_parse_fn(ext_ctxt,span) -> @ast::expr; - fn get_fold_fn() -> str; + fn get_fold_fn() -> ~str; } impl of qq_helper for @ast::crate { @@ -35,9 +35,10 @@ fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_crate(*self, cx, v);} fn extract_mac() -> option {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ~[@"syntax", @"ext", @"qquote", @"parse_crate"]) + mk_path(cx, sp, + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_crate"]) } - fn get_fold_fn() -> str {"fold_crate"} + fn get_fold_fn() -> ~str {~"fold_crate"} } impl of qq_helper for @ast::expr { fn span() -> span {self.span} @@ -49,9 +50,10 @@ fn extract_mac() -> option { } } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ~[@"syntax", @"ext", @"qquote", @"parse_expr"]) + mk_path(cx, sp, + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_expr"]) } - fn get_fold_fn() -> str {"fold_expr"} + fn get_fold_fn() -> ~str {~"fold_expr"} } impl of qq_helper for @ast::ty { fn span() -> span {self.span} @@ -63,42 +65,45 @@ fn extract_mac() -> option { } } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ~[@"syntax", @"ext", @"qquote", @"parse_ty"]) + mk_path(cx, sp, + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_ty"]) } - fn get_fold_fn() -> str {"fold_ty"} + fn get_fold_fn() -> ~str {~"fold_ty"} } impl of qq_helper for @ast::item { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_item(self, cx, v);} fn extract_mac() -> option {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ~[@"syntax", @"ext", @"qquote", @"parse_item"]) + mk_path(cx, sp, + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_item"]) } - fn get_fold_fn() -> str {"fold_item"} + fn get_fold_fn() -> ~str {~"fold_item"} } impl of qq_helper for @ast::stmt { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_stmt(self, cx, v);} fn extract_mac() -> option {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ~[@"syntax", @"ext", @"qquote", @"parse_stmt"]) + mk_path(cx, sp, + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_stmt"]) } - fn get_fold_fn() -> str {"fold_stmt"} + fn get_fold_fn() -> ~str {~"fold_stmt"} } impl of qq_helper for @ast::pat { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_pat(self, cx, v);} fn extract_mac() -> option {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ~[@"syntax", @"ext", @"qquote", @"parse_pat"]) + mk_path(cx, sp, ~[@~"syntax", @~"ext", @~"qquote", @~"parse_pat"]) } - fn get_fold_fn() -> str {"fold_pat"} + fn get_fold_fn() -> ~str {~"fold_pat"} } fn gather_anti_quotes(lo: uint, node: N) -> aq_ctxt { - let v = @{visit_expr: |node, &&cx, v| visit_aq(node, "from_expr", cx, v), - visit_ty: |node, &&cx, v| visit_aq(node, "from_ty", cx, v) + let v = @{visit_expr: |node, &&cx, v| visit_aq(node, ~"from_expr", cx, v), + visit_ty: |node, &&cx, v| visit_aq(node, ~"from_ty", cx, v) with *default_visitor()}; let cx = @{lo:lo, gather: dvec()}; node.visit(cx, mk_vt(v)); @@ -110,7 +115,7 @@ fn gather_anti_quotes(lo: uint, node: N) -> aq_ctxt ret cx; } -fn visit_aq(node: T, constr: str, &&cx: aq_ctxt, v: vt) +fn visit_aq(node: T, constr: ~str, &&cx: aq_ctxt, v: vt) { alt (node.extract_mac()) { some(mac_aq(sp, e)) { @@ -129,35 +134,35 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, arg: ast::mac_arg, body: ast::mac_body) -> @ast::expr { - let mut what = "expr"; + let mut what = ~"expr"; do option::iter(arg) |arg| { let args: ~[@ast::expr] = alt arg.node { ast::expr_vec(elts, _) { elts } _ { ecx.span_fatal - (_sp, "#ast requires arguments of the form `~[...]`.") + (_sp, ~"#ast requires arguments of the form `~[...]`.") } }; if vec::len::<@ast::expr>(args) != 1u { - ecx.span_fatal(_sp, "#ast requires exactly one arg"); + ecx.span_fatal(_sp, ~"#ast requires exactly one arg"); } alt (args[0].node) { ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u {what = *id[0]} - _ {ecx.span_fatal(args[0].span, "expected an identifier");} + _ {ecx.span_fatal(args[0].span, ~"expected an identifier");} } } let body = get_mac_body(ecx,_sp,body); ret alt what { - "crate" {finish(ecx, body, parse_crate)} - "expr" {finish(ecx, body, parse_expr)} - "ty" {finish(ecx, body, parse_ty)} - "item" {finish(ecx, body, parse_item)} - "stmt" {finish(ecx, body, parse_stmt)} - "pat" {finish(ecx, body, parse_pat)} - _ {ecx.span_fatal(_sp, "unsupported ast type")} + ~"crate" {finish(ecx, body, parse_crate)} + ~"expr" {finish(ecx, body, parse_expr)} + ~"ty" {finish(ecx, body, parse_ty)} + ~"item" {finish(ecx, body, parse_item)} + ~"stmt" {finish(ecx, body, parse_stmt)} + ~"pat" {finish(ecx, body, parse_pat)} + _ {ecx.span_fatal(_sp, ~"unsupported ast type")} }; } @@ -170,7 +175,7 @@ fn parse_pat(p: parser) -> @ast::pat { p.parse_pat() } fn parse_item(p: parser) -> @ast::item { alt p.parse_item(~[], ast::public) { some(item) { item } - none { fail "parse_item: parsing an item failed"; } + none { fail ~"parse_item: parsing an item failed"; } } } @@ -198,7 +203,7 @@ fn finish // ^^ check that the spans are non-overlapping } - let mut str2 = ""; + let mut str2 = ~""; enum state {active, skip(uint), blank}; let mut state = active; let mut i = 0u, j = 0u; @@ -228,39 +233,39 @@ fn finish let cx = ecx; let cfg_call = || mk_call_( - cx, sp, mk_access(cx, sp, ~[@"ext_cx"], @"cfg"), ~[]); + cx, sp, mk_access(cx, sp, ~[@~"ext_cx"], @~"cfg"), ~[]); let parse_sess_call = || mk_call_( - cx, sp, mk_access(cx, sp, ~[@"ext_cx"], @"parse_sess"), ~[]); + cx, sp, mk_access(cx, sp, ~[@~"ext_cx"], @~"parse_sess"), ~[]); let pcall = mk_call(cx,sp, - ~[@"syntax", @"parse", @"parser", - @"parse_from_source_str"], + ~[@~"syntax", @~"parse", @~"parser", + @~"parse_from_source_str"], ~[node.mk_parse_fn(cx,sp), - mk_str(cx,sp, fname), + mk_uniq_str(cx,sp, fname), mk_call(cx,sp, - ~[@"syntax",@"ext", - @"qquote", @"mk_file_substr"], - ~[mk_str(cx,sp, loc.file.name), + ~[@~"syntax",@~"ext", + @~"qquote", @~"mk_file_substr"], + ~[mk_uniq_str(cx,sp, loc.file.name), mk_uint(cx,sp, loc.line), mk_uint(cx,sp, loc.col)]), mk_unary(cx,sp, ast::box(ast::m_imm), - mk_str(cx,sp, str2)), + mk_uniq_str(cx,sp, str2)), cfg_call(), parse_sess_call()] ); let mut rcall = pcall; if (g_len > 0u) { rcall = mk_call(cx,sp, - ~[@"syntax", @"ext", @"qquote", @"replace"], + ~[@~"syntax", @~"ext", @~"qquote", @~"replace"], ~[pcall, mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec(|g| { mk_call(cx,sp, - ~[@"syntax", @"ext", - @"qquote", @g.constr], + ~[@~"syntax", @~"ext", + @~"qquote", @g.constr], ~[g.e])})), mk_path(cx,sp, - ~[@"syntax", @"ext", @"qquote", + ~[@~"syntax", @~"ext", @~"qquote", @node.get_fold_fn()])]); } ret rcall; @@ -321,10 +326,11 @@ fn print_expr(expr: @ast::expr) { let pp = pprust::rust_printer(stdout); pprust::print_expr(pp, expr); pp::eof(pp.s); - stdout.write_str("\n"); + stdout.write_str(~"\n"); } -fn mk_file_substr(fname: str, line: uint, col: uint) -> codemap::file_substr { +fn mk_file_substr(fname: ~str, line: uint, col: uint) -> + codemap::file_substr { codemap::fss_external({filename: fname, line: line, col: col}) } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 6ccbabd748e9..333c510b7cd8 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -35,29 +35,29 @@ enum matchable { } /* for when given an incompatible bit of AST */ -fn match_error(cx: ext_ctxt, m: matchable, expected: str) -> ! { +fn match_error(cx: ext_ctxt, m: matchable, expected: ~str) -> ! { alt m { match_expr(x) { cx.span_fatal(x.span, - "this argument is an expr, expected " + expected); + ~"this argument is an expr, expected " + expected); } match_path(x) { cx.span_fatal(x.span, - "this argument is a path, expected " + expected); + ~"this argument is a path, expected " + expected); } match_ident(x) { cx.span_fatal(x.span, - "this argument is an ident, expected " + expected); + ~"this argument is an ident, expected " + expected); } match_ty(x) { cx.span_fatal(x.span, - "this argument is a type, expected " + expected); + ~"this argument is a type, expected " + expected); } match_block(x) { cx.span_fatal(x.span, - "this argument is a block, expected " + expected); + ~"this argument is a block, expected " + expected); } - match_exact { cx.bug("what is a match_exact doing in a bindings?"); } + match_exact { cx.bug(~"what is a match_exact doing in a bindings?"); } } } @@ -80,7 +80,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> alt m.node { ast::mac_ellipsis { if res != none { - cx.span_fatal(m.span, "only one ellipsis allowed"); + cx.span_fatal(m.span, ~"only one ellipsis allowed"); } res = some({pre: vec::slice(elts, 0u, idx - 1u), @@ -234,8 +234,8 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option>, ret alt follow(m, idx_path) { seq(_, sp) { cx.span_fatal(sp, - "syntax matched under ... but not " + - "used that way.") + ~"syntax matched under ... but not " + + ~"used that way.") } leaf(m) { ret some(m) } } @@ -302,8 +302,8 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], alt repeat { none { cx.span_fatal(repeat_me.span, - "'...' surrounds an expression without any" + - " repeating syntax variables"); + ~"'...' surrounds an expression without any" + + ~" repeating syntax variables"); } some({rep_count: rc, _}) { /* Whew, we now know how how many times to repeat */ @@ -331,7 +331,7 @@ fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], &&i: ident, _fld: ast_fold) -> ident { ret alt follow_for_trans(cx, b.find(i), idx_path) { some(match_ident(a_id)) { a_id.node } - some(m) { match_error(cx, m, "an identifier") } + some(m) { match_error(cx, m, ~"an identifier") } none { i } } } @@ -347,7 +347,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], rp: none, types: ~[]} } some(match_path(a_pth)) { *a_pth } - some(m) { match_error(cx, m, "a path") } + some(m) { match_error(cx, m, ~"a path") } none { p } } } @@ -374,7 +374,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], } some(match_path(a_pth)) { (expr_path(a_pth), s) } some(match_expr(a_exp)) { (a_exp.node, a_exp.span) } - some(m) { match_error(cx, m, "an expression") } + some(m) { match_error(cx, m, ~"an expression") } none { orig(e, s, fld) } } } @@ -393,7 +393,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], some(id) { alt follow_for_trans(cx, b.find(id), idx_path) { some(match_ty(ty)) { (ty.node, ty.span) } - some(m) { match_error(cx, m, "a type") } + some(m) { match_error(cx, m, ~"a type") } none { orig(t, s, fld) } } } @@ -424,7 +424,7 @@ fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], // possibly allow promotion of ident/path/expr to blocks? some(m) { - match_error(cx, m, "a block") + match_error(cx, m, ~"a block") } none { orig(blk, s, fld) } } @@ -455,12 +455,12 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { if vec::len(post) > 0u { cx.span_unimpl(e.span, - "matching after `...` not yet supported"); + ~"matching after `...` not yet supported"); } } {pre: pre, rep: none, post: post} { if post != ~[] { - cx.bug("elts_to_ell provided an invalid result"); + cx.bug(~"elts_to_ell provided an invalid result"); } p_t_s_r_length(cx, vec::len(pre), false, s, b); p_t_s_r_actual_vector(cx, pre, false, s, b); @@ -478,7 +478,7 @@ fn select(cx: ext_ctxt, m: matchable, pat: @expr) -> match_expr(e) { if e == pat { some(leaf(match_exact)) } else { none } } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } b.literal_ast_matchers.push(|x| select(cx, x, e)); @@ -486,7 +486,7 @@ fn select(cx: ext_ctxt, m: matchable, pat: @expr) -> } } _ { - cx.bug("undocumented invariant in p_t_s_rec"); + cx.bug(~"undocumented invariant in p_t_s_rec"); } } } @@ -517,11 +517,11 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { fn select(cx: ext_ctxt, m: matchable) -> match_result { ret alt m { match_expr(e) { some(leaf(specialize_match(m))) } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } if b.real_binders.contains_key(p_id) { - cx.span_fatal(p.span, "duplicate binding identifier"); + cx.span_fatal(p.span, ~"duplicate binding identifier"); } b.real_binders.insert(p_id, compose_sels(s, |x| select(cx, x))); } @@ -546,16 +546,16 @@ fn select_pt_1(cx: ext_ctxt, m: matchable, match_expr(e) { alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } - fn no_des(cx: ext_ctxt, sp: span, syn: str) -> ! { - cx.span_fatal(sp, "destructuring " + syn + " is not yet supported"); + fn no_des(cx: ext_ctxt, sp: span, syn: ~str) -> ! { + cx.span_fatal(sp, ~"destructuring " + syn + ~" is not yet supported"); } alt mac.node { - ast::mac_ellipsis { cx.span_fatal(mac.span, "misused `...`"); } - ast::mac_invoc(_, _, _) { no_des(cx, mac.span, "macro calls"); } - ast::mac_invoc_tt(_, _) { no_des(cx, mac.span, "macro calls"); } + ast::mac_ellipsis { cx.span_fatal(mac.span, ~"misused `...`"); } + ast::mac_invoc(_, _, _) { no_des(cx, mac.span, ~"macro calls"); } + ast::mac_invoc_tt(_, _) { no_des(cx, mac.span, ~"macro calls"); } ast::mac_embed_type(ty) { alt ty.node { ast::ty_path(pth, _) { @@ -571,10 +571,10 @@ fn select_pt_2(m: ast::mac) -> match_result { let final_step = |x| select_pt_1(cx, x, select_pt_2); b.real_binders.insert(id, compose_sels(s, final_step)); } - none { no_des(cx, pth.span, "under `#<>`"); } + none { no_des(cx, pth.span, ~"under `#<>`"); } } } - _ { no_des(cx, ty.span, "under `#<>`"); } + _ { no_des(cx, ty.span, ~"under `#<>`"); } } } ast::mac_embed_block(blk) { @@ -591,11 +591,11 @@ fn select_pt_2(m: ast::mac) -> match_result { let final_step = |x| select_pt_1(cx, x, select_pt_2); b.real_binders.insert(id, compose_sels(s, final_step)); } - none { no_des(cx, blk.span, "under `#{}`"); } + none { no_des(cx, blk.span, ~"under `#{}`"); } } } - ast::mac_aq(_,_) { no_des(cx, mac.span, "antiquotes"); } - ast::mac_var(_) { no_des(cx, mac.span, "antiquote variables"); } + ast::mac_aq(_,_) { no_des(cx, mac.span, ~"antiquotes"); } + ast::mac_var(_) { no_des(cx, mac.span, ~"antiquote variables"); } } } @@ -621,7 +621,7 @@ fn select(cx: ext_ctxt, repeat_me: @expr, offset: uint, m: matchable) -> _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } p_t_s_rec(cx, match_expr(repeat_me), @@ -666,7 +666,7 @@ fn select(cx: ext_ctxt, m: matchable, idx: uint) -> match_result { _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } p_t_s_rec(cx, match_expr(elts[idx]), @@ -677,17 +677,17 @@ fn select(cx: ext_ctxt, m: matchable, idx: uint) -> match_result { fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> base::macro_def { - let args = get_mac_args_no_max(cx, sp, arg, 0u, "macro"); + let args = get_mac_args_no_max(cx, sp, arg, 0u, ~"macro"); - let mut macro_name: option<@str/~> = none; + let mut macro_name: option<@~str> = none; let mut clauses: ~[@clause] = ~[]; for args.each |arg| { alt arg.node { expr_vec(elts, mutbl) { if vec::len(elts) != 2u { cx.span_fatal((*arg).span, - "extension clause must consist of ~[" + - "macro invocation, expansion body]"); + ~"extension clause must consist of ~[" + + ~"macro invocation, expansion body]"); } @@ -702,21 +702,21 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, some(other_id) { if id != other_id { cx.span_fatal(pth.span, - "macro name must be " + - "consistent"); + ~"macro name must be " + + ~"consistent"); } } } } none { cx.span_fatal(pth.span, - "macro name must not be a path"); + ~"macro name must not be a path"); } } let arg = alt invoc_arg { some(arg) { arg } none { cx.span_fatal(mac.span, - "macro must have arguments")} + ~"macro must have arguments")} }; vec::push(clauses, @{params: pattern_to_selectors(cx, arg), @@ -726,21 +726,21 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, // the macro arg situation) } _ { - cx.span_bug(mac.span, "undocumented invariant in \ + cx.span_bug(mac.span, ~"undocumented invariant in \ add_extension"); } } } _ { cx.span_fatal(elts[0u].span, - "extension clause must" + - " start with a macro invocation."); + ~"extension clause must" + + ~" start with a macro invocation."); } } } _ { cx.span_fatal((*arg).span, - "extension must be ~[clause, " + " ...]"); + ~"extension must be ~[clause, " + ~" ...]"); } } } @@ -751,8 +751,8 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, alt macro_name { some(id) { id } none { - cx.span_fatal(sp, "macro definition must have " + - "at least one clause") + cx.span_fatal(sp, ~"macro definition must have " + + ~"at least one clause") } }, ext: normal({expander: ext, span: some(option::get(arg).span)})}; @@ -762,7 +762,7 @@ fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, clauses: ~[@clause]) -> @expr { let arg = alt arg { some(arg) { arg } - none { cx.span_fatal(sp, "macro must have arguments")} + none { cx.span_fatal(sp, ~"macro must have arguments")} }; for clauses.each |c| { alt use_selectors_to_bind(c.params, arg) { @@ -770,7 +770,7 @@ fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, none { again; } } } - cx.span_fatal(sp, "no clauses match macro invocation"); + cx.span_fatal(sp, ~"no clauses match macro invocation"); } } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index ee5e96cc0e44..ff7fedde34e9 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -2,7 +2,7 @@ import ast; import codemap::span; import print::pprust; -import build::{mk_lit,mk_uniq_vec_e}; +import build::{mk_uint,mk_u8,mk_uniq_str,mk_uniq_vec_e}; export expand_line; export expand_col; @@ -16,17 +16,17 @@ /* #line(): expands to the current line number */ fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), "line"); + get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"line"); let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo); - ret mk_lit(cx, sp, ast::lit_uint(loc.line as u64, ast::ty_u)); + ret mk_uint(cx, sp, loc.line); } /* #col(): expands to the current column number */ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), "col"); + get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"col"); let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo); - ret mk_lit(cx, sp, ast::lit_uint(loc.col as u64, ast::ty_u)); + ret mk_uint(cx, sp, loc.col); } /* #file(): expands to the current filename */ @@ -34,29 +34,29 @@ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg, * out if we wanted. */ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); + get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"file"); let { file: @{ name: filename, _ }, _ } = codemap::lookup_char_pos(cx.codemap(), sp.lo); - ret mk_lit(cx, sp, ast::lit_str(@filename)); + ret mk_uniq_str(cx, sp, filename); } fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "stringify"); - ret mk_lit(cx, sp, ast::lit_str(@pprust::expr_to_str(args[0]))); + let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"stringify"); + ret mk_uniq_str(cx, sp, pprust::expr_to_str(args[0])); } fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); - ret mk_lit(cx, sp, ast::lit_str( - @str::connect(cx.mod_path().map(|x|*x), "::"))); + get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"file"); + ret mk_uniq_str(cx, sp, + str::connect(cx.mod_path().map(|x|*x), ~"::")); } fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "include"); - let file = expr_to_str(cx, args[0], "#include_str requires a string"); + let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"include"); + let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(), res_rel_file(cx, sp, file), parse::parser::SOURCE_FILE); @@ -65,9 +65,9 @@ fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),"include_str"); + let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"include_str"); - let file = expr_to_str(cx, args[0], "#include_str requires a string"); + let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let res = io::read_whole_file_str(res_rel_file(cx, sp, file)); alt res { @@ -77,19 +77,19 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, } } - ret mk_lit(cx, sp, ast::lit_str(@result::unwrap(res))); + ret mk_uniq_str(cx, sp, result::unwrap(res)); } fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),"include_bin"); + let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"include_bin"); - let file = expr_to_str(cx, args[0], "#include_bin requires a string"); + let file = expr_to_str(cx, args[0], ~"#include_bin requires a string"); alt io::read_whole_file(res_rel_file(cx, sp, file)) { result::ok(src) { let u8_exprs = vec::map(src, |char: u8| { - mk_lit(cx, sp, ast::lit_uint(char as u64, ast::ty_u8)) + mk_u8(cx, sp, char) }); ret mk_uniq_vec_e(cx, sp, u8_exprs); } diff --git a/src/libsyntax/ext/tt/earley_parser.rs b/src/libsyntax/ext/tt/earley_parser.rs index f830330e182d..3f604aafb3d0 100644 --- a/src/libsyntax/ext/tt/earley_parser.rs +++ b/src/libsyntax/ext/tt/earley_parser.rs @@ -83,7 +83,7 @@ fn n_rec(p_s: parse_sess, m: matcher, res: ~[@arb_depth], } {node: mtc_bb(bind_name, _, idx), span: sp} { if ret_val.contains_key(bind_name) { - p_s.span_diagnostic.span_fatal(sp, "Duplicated bind name: " + p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: " + *bind_name) } ret_val.insert(bind_name, res[idx]); @@ -97,7 +97,7 @@ fn n_rec(p_s: parse_sess, m: matcher, res: ~[@arb_depth], enum parse_result { success(hashmap), - failure(codemap::span, str) + failure(codemap::span, ~str) } fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) @@ -207,9 +207,9 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) nameize(sess, ms, vec::map(eof_eis[0u].matches, |dv| dv.pop()))); } else if eof_eis.len() > 1u { - ret failure(sp, "Ambiguity: multiple successful parses"); + ret failure(sp, ~"Ambiguity: multiple successful parses"); } else { - ret failure(sp, "Unexpected end of macro invocation"); + ret failure(sp, ~"Unexpected end of macro invocation"); } } else { if (bb_eis.len() > 0u && next_eis.len() > 0u) @@ -217,13 +217,13 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) let nts = str::connect(vec::map(bb_eis, |ei| { alt ei.elts[ei.idx].node { mtc_bb(_,name,_) { *name } _ { fail; } } - }), " or "); + }), ~" or "); ret failure(sp, #fmt[ "Local ambiguity: multiple parsing options: \ built-in NTs %s or %u other options.", nts, next_eis.len()]); } else if (bb_eis.len() == 0u && next_eis.len() == 0u) { - ret failure(sp, "No rules expected the token " + ret failure(sp, ~"No rules expected the token " + to_str(*rdr.interner(), tok)); } else if (next_eis.len() > 0u) { /* Now process the next token */ @@ -259,32 +259,32 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } } -fn parse_nt(p: parser, name: str) -> whole_nt { +fn parse_nt(p: parser, name: ~str) -> whole_nt { alt name { - "item" { alt p.parse_item(~[], ast::public) { + ~"item" { alt p.parse_item(~[], ast::public) { some(i) { token::w_item(i) } - none { p.fatal("expected an item keyword") } + none { p.fatal(~"expected an item keyword") } }} - "block" { token::w_block(p.parse_block()) } - "stmt" { token::w_stmt(p.parse_stmt(~[])) } - "pat" { token::w_pat(p.parse_pat()) } - "expr" { token::w_expr(p.parse_expr()) } - "ty" { token::w_ty(p.parse_ty(false /* no need to disambiguate*/)) } + ~"block" { token::w_block(p.parse_block()) } + ~"stmt" { token::w_stmt(p.parse_stmt(~[])) } + ~"pat" { token::w_pat(p.parse_pat()) } + ~"expr" { token::w_expr(p.parse_expr()) } + ~"ty" { token::w_ty(p.parse_ty(false /* no need to disambiguate*/)) } // this could be handled like a token, since it is one - "ident" { alt copy p.token { + ~"ident" { alt copy p.token { token::IDENT(sn,b) { p.bump(); token::w_ident(sn,b) } - _ { p.fatal("expected ident, found " + _ { p.fatal(~"expected ident, found " + token::to_str(*p.reader.interner(), copy p.token)) } } } - "path" { token::w_path(p.parse_path_with_tps(false)) } - "tt" { + ~"path" { token::w_path(p.parse_path_with_tps(false)) } + ~"tt" { p.quote_depth += 1u; //but in theory, non-quoted tts might be useful let res = token::w_tt(@p.parse_token_tree()); p.quote_depth -= 1u; res } - "mtcs" { token::w_mtcs(p.parse_matchers()) } - _ { p.fatal("Unsupported builtin nonterminal parser: " + name)} + ~"mtcs" { token::w_mtcs(p.parse_matchers()) } + _ { p.fatal(~"Unsupported builtin nonterminal parser: " + name)} } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 822e8e0d6973..7bed3107f533 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -18,9 +18,9 @@ fn ms(m: matcher_) -> matcher { let argument_gram = ~[ ms(mtc_rep(~[ - ms(mtc_bb(@"lhs",@"mtcs", 0u)), + ms(mtc_bb(@~"lhs",@~"mtcs", 0u)), ms(mtc_tok(FAT_ARROW)), - ms(mtc_bb(@"rhs",@"tt", 1u)), + ms(mtc_bb(@~"rhs",@~"tt", 1u)), ], some(SEMI), false))]; let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic, @@ -31,20 +31,20 @@ fn ms(m: matcher_) -> matcher { failure(sp, msg) { cx.span_fatal(sp, msg); } }; - let lhses = alt arguments.get(@"lhs") { + let lhses = alt arguments.get(@~"lhs") { @seq(s, sp) { s } - _ { cx.span_bug(sp, "wrong-structured lhs") } + _ { cx.span_bug(sp, ~"wrong-structured lhs") } }; - let rhses = alt arguments.get(@"rhs") { + let rhses = alt arguments.get(@~"rhs") { @seq(s, sp) { s } - _ { cx.span_bug(sp, "wrong-structured rhs") } + _ { cx.span_bug(sp, ~"wrong-structured rhs") } }; fn generic_extension(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree], lhses: ~[@arb_depth], rhses: ~[@arb_depth]) -> mac_result { let mut best_fail_spot = {lo: 0u, hi: 0u, expn_info: none}; - let mut best_fail_msg = "internal error: ran no matchers"; + let mut best_fail_msg = ~"internal error: ran no matchers"; let s_d = cx.parse_sess().span_diagnostic; let itr = cx.parse_sess().interner; @@ -57,7 +57,7 @@ fn generic_extension(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree], success(m) { let rhs = alt rhses[i] { @leaf(w_tt(@tt)) { tt } - _ { cx.span_bug(sp, "bad thing in rhs") } + _ { cx.span_bug(sp, ~"bad thing in rhs") } }; let trncbr = new_tt_reader(s_d, itr, some(m), ~[rhs]); let p = parser(cx.parse_sess(), cx.cfg(), @@ -71,7 +71,7 @@ fn generic_extension(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree], } } } - _ { cx.bug("non-matcher found in parsed lhses"); } + _ { cx.bug(~"non-matcher found in parsed lhses"); } } } cx.span_fatal(best_fail_spot, best_fail_msg); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index df0c39bb266f..a9bc124b6051 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -25,7 +25,7 @@ enum tt_frame_up { /* to break a circularity */ type tt_reader = @{ sp_diag: span_handler, - interner: @interner<@str/~>, + interner: @interner<@~str>, mut cur: tt_frame, /* for MBE-style macro transcription */ interpolations: std::map::hashmap, @@ -39,7 +39,7 @@ enum tt_frame_up { /* to break a circularity */ /** This can do Macro-By-Example transcription. On the other hand, if * `src` contains no `tt_dotdotdot`s and `tt_interpolate`s, `interp` can (and * should) be none. */ -fn new_tt_reader(sp_diag: span_handler, itr: @interner<@str/~>, +fn new_tt_reader(sp_diag: span_handler, itr: @interner<@~str>, interp: option>, src: ~[ast::token_tree]) -> tt_reader { @@ -93,7 +93,7 @@ fn lookup_cur_ad(r: tt_reader, name: ident) -> @arb_depth { lookup_cur_ad_by_ad(r, r.interpolations.get(name)) } enum lis { - lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(str) + lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str) } fn lockstep_iter_size(&&t: token_tree, &&r: tt_reader) -> lis { @@ -183,7 +183,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { lis_unconstrained { r.sp_diag.span_fatal( sp, /* blame macro writer */ - "attempted to repeat an expression containing no syntax \ + ~"attempted to repeat an expression containing no syntax \ variables matched as repeating at this depth"); } lis_contradiction(msg) { /* FIXME #2887 blame macro invoker @@ -200,7 +200,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { if !zerok { r.sp_diag.span_fatal(sp, /* FIXME #2887 blame invoker */ - "this must repeat at least \ + ~"this must repeat at least \ once"); } /* we need to pop before we proceed, so recur */ diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 7ccc9c5a4386..9d56754e5d4c 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -25,7 +25,7 @@ cm: codemap::codemap, mut next_id: node_id, span_diagnostic: span_handler, - interner: @interner::interner<@str/~>, + interner: @interner::interner<@~str>, // these two must be kept up to date mut chpos: uint, mut byte_pos: uint @@ -36,7 +36,7 @@ fn new_parse_sess(demitter: option) -> parse_sess { ret @{cm: cm, mut next_id: 1, span_diagnostic: mk_span_handler(mk_handler(demitter), cm), - interner: @interner::mk::<@str/~>(|x| str::hash(*x), + interner: @interner::mk::<@~str>(|x| str::hash(*x), |x,y| str::eq(*x, *y)), mut chpos: 0u, mut byte_pos: 0u}; } @@ -46,24 +46,24 @@ fn new_parse_sess_special_handler(sh: span_handler, cm: codemap::codemap) ret @{cm: cm, mut next_id: 1, span_diagnostic: sh, - interner: @interner::mk::<@str/~>(|x| str::hash(*x), + interner: @interner::mk::<@~str>(|x| str::hash(*x), |x,y| str::eq(*x, *y)), mut chpos: 0u, mut byte_pos: 0u}; } -fn parse_crate_from_file(input: str, cfg: ast::crate_cfg, sess: parse_sess) -> - @ast::crate { - if str::ends_with(input, ".rc") { +fn parse_crate_from_file(input: ~str, cfg: ast::crate_cfg, + sess: parse_sess) -> @ast::crate { + if str::ends_with(input, ~".rc") { parse_crate_from_crate_file(input, cfg, sess) - } else if str::ends_with(input, ".rs") { + } else if str::ends_with(input, ~".rs") { parse_crate_from_source_file(input, cfg, sess) } else { - sess.span_diagnostic.handler().fatal("unknown input file type: " + + sess.span_diagnostic.handler().fatal(~"unknown input file type: " + input) } } -fn parse_crate_from_crate_file(input: str, cfg: ast::crate_cfg, +fn parse_crate_from_crate_file(input: ~str, cfg: ast::crate_cfg, sess: parse_sess) -> @ast::crate { let (p, rdr) = new_parser_etc_from_file(sess, cfg, input, parser::CRATE_FILE); @@ -87,7 +87,7 @@ fn parse_crate_from_crate_file(input: str, cfg: ast::crate_cfg, config: /* FIXME (#2543) */ copy p.cfg}); } -fn parse_crate_from_source_file(input: str, cfg: ast::crate_cfg, +fn parse_crate_from_source_file(input: ~str, cfg: ast::crate_cfg, sess: parse_sess) -> @ast::crate { let (p, rdr) = new_parser_etc_from_file(sess, cfg, input, parser::SOURCE_FILE); @@ -97,7 +97,7 @@ fn parse_crate_from_source_file(input: str, cfg: ast::crate_cfg, ret r; } -fn parse_crate_from_source_str(name: str, source: @str/~, cfg: ast::crate_cfg, +fn parse_crate_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, sess: parse_sess) -> @ast::crate { let (p, rdr) = new_parser_etc_from_source_str(sess, cfg, name, codemap::fss_none, source); @@ -107,7 +107,7 @@ fn parse_crate_from_source_str(name: str, source: @str/~, cfg: ast::crate_cfg, ret r; } -fn parse_expr_from_source_str(name: str, source: @str/~, cfg: ast::crate_cfg, +fn parse_expr_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, sess: parse_sess) -> @ast::expr { let (p, rdr) = new_parser_etc_from_source_str(sess, cfg, name, codemap::fss_none, source); @@ -117,7 +117,7 @@ fn parse_expr_from_source_str(name: str, source: @str/~, cfg: ast::crate_cfg, ret r; } -fn parse_item_from_source_str(name: str, source: @str/~, cfg: ast::crate_cfg, +fn parse_item_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, +attrs: ~[ast::attribute], vis: ast::visibility, sess: parse_sess) -> option<@ast::item> { @@ -130,8 +130,8 @@ fn parse_item_from_source_str(name: str, source: @str/~, cfg: ast::crate_cfg, } fn parse_from_source_str(f: fn (p: parser) -> T, - name: str, ss: codemap::file_substr, - source: @str/~, cfg: ast::crate_cfg, + name: ~str, ss: codemap::file_substr, + source: @~str, cfg: ast::crate_cfg, sess: parse_sess) -> T { @@ -139,7 +139,7 @@ fn parse_from_source_str(f: fn (p: parser) -> T, source); let r = f(p); if !p.reader.is_eof() { - p.reader.fatal("expected end-of-string"); + p.reader.fatal(~"expected end-of-string"); } sess.chpos = rdr.chpos; sess.byte_pos = sess.byte_pos + rdr.pos; @@ -155,8 +155,8 @@ fn next_node_id(sess: parse_sess) -> node_id { } fn new_parser_etc_from_source_str(sess: parse_sess, cfg: ast::crate_cfg, - +name: str, +ss: codemap::file_substr, - source: @str/~) -> (parser, string_reader) { + +name: ~str, +ss: codemap::file_substr, + source: @~str) -> (parser, string_reader) { let ftype = parser::SOURCE_FILE; let filemap = codemap::new_filemap_w_substr (name, ss, source, sess.chpos, sess.byte_pos); @@ -167,15 +167,15 @@ fn new_parser_etc_from_source_str(sess: parse_sess, cfg: ast::crate_cfg, } fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg, - +name: str, +ss: codemap::file_substr, - source: @str/~) -> parser { + +name: ~str, +ss: codemap::file_substr, + source: @~str) -> parser { let (p, _) = new_parser_etc_from_source_str(sess, cfg, name, ss, source); ret p; } -fn new_parser_etc_from_file(sess: parse_sess, cfg: ast::crate_cfg, +path: str, - ftype: parser::file_type) -> +fn new_parser_etc_from_file(sess: parse_sess, cfg: ast::crate_cfg, + +path: ~str, ftype: parser::file_type) -> (parser, string_reader) { let res = io::read_whole_file_str(path); alt res { @@ -190,7 +190,7 @@ fn new_parser_etc_from_file(sess: parse_sess, cfg: ast::crate_cfg, +path: str, ret (parser(sess, cfg, srdr as reader, ftype), srdr); } -fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, +path: str, +fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, +path: ~str, ftype: parser::file_type) -> parser { let (p, _) = new_parser_etc_from_file(sess, cfg, path, ftype); ret p; diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index b10a05d8ca45..995feff0b70a 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -56,7 +56,7 @@ fn parse_outer_attributes() -> ~[ast::attribute] { let attr = ::attr::mk_sugared_doc_attr( *self.get_str(s), self.span.lo, self.span.hi); if attr.node.style != ast::attr_outer { - self.fatal("expected outer comment"); + self.fatal(~"expected outer comment"); } attrs += ~[attr]; self.bump(); diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index aa3e808f63e4..737307bb6484 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -18,28 +18,28 @@ enum cmnt_style { blank_line, // Just a manual blank line "\n\n", for layout } -type cmnt = {style: cmnt_style, lines: ~[str], pos: uint}; +type cmnt = {style: cmnt_style, lines: ~[~str], pos: uint}; -fn is_doc_comment(s: str) -> bool { - s.starts_with("///") || - s.starts_with("//!") || - s.starts_with("/**") || - s.starts_with("/*!") +fn is_doc_comment(s: ~str) -> bool { + s.starts_with(~"///") || + s.starts_with(~"//!") || + s.starts_with(~"/**") || + s.starts_with(~"/*!") } -fn doc_comment_style(comment: str) -> ast::attr_style { +fn doc_comment_style(comment: ~str) -> ast::attr_style { assert is_doc_comment(comment); - if comment.starts_with("//!") || comment.starts_with("/*!") { + if comment.starts_with(~"//!") || comment.starts_with(~"/*!") { ast::attr_inner } else { ast::attr_outer } } -fn strip_doc_comment_decoration(comment: str) -> str { +fn strip_doc_comment_decoration(comment: ~str) -> ~str { /// remove whitespace-only lines from the start/end of lines - fn vertical_trim(lines: ~[str]) -> ~[str] { + fn vertical_trim(lines: ~[~str]) -> ~[~str] { let mut i = 0u, j = lines.len(); while i < j && lines[i].trim().is_empty() { i += 1u; @@ -51,7 +51,7 @@ fn vertical_trim(lines: ~[str]) -> ~[str] { } // drop leftmost columns that contain only values in chars - fn block_trim(lines: ~[str], chars: str, max: option) -> ~[str] { + fn block_trim(lines: ~[~str], chars: ~str, max: option) -> ~[~str] { let mut i = max.get_default(uint::max_value); for lines.each |line| { @@ -72,31 +72,31 @@ fn block_trim(lines: ~[str], chars: str, max: option) -> ~[str] { ret do lines.map |line| { let chars = str::chars(line); if i > chars.len() { - "" + ~"" } else { str::from_chars(chars.slice(i, chars.len())) } }; } - if comment.starts_with("//") { + if comment.starts_with(~"//") { ret comment.slice(3u, comment.len()).trim(); } - if comment.starts_with("/*") { + if comment.starts_with(~"/*") { let lines = str::lines_any(comment.slice(3u, comment.len() - 2u)); let lines = vertical_trim(lines); - let lines = block_trim(lines, "\t ", none); - let lines = block_trim(lines, "*", some(1u)); - let lines = block_trim(lines, "\t ", none); - ret str::connect(lines, "\n"); + let lines = block_trim(lines, ~"\t ", none); + let lines = block_trim(lines, ~"*", some(1u)); + let lines = block_trim(lines, ~"\t ", none); + ret str::connect(lines, ~"\n"); } - fail "not a doc-comment: " + comment; + fail ~"not a doc-comment: " + comment; } -fn read_to_eol(rdr: string_reader) -> str { - let mut val = ""; +fn read_to_eol(rdr: string_reader) -> ~str { + let mut val = ~""; while rdr.curr != '\n' && !is_eof(rdr) { str::push_char(val, rdr.curr); bump(rdr); @@ -105,7 +105,7 @@ fn read_to_eol(rdr: string_reader) -> str { ret val; } -fn read_one_line_comment(rdr: string_reader) -> str { +fn read_one_line_comment(rdr: string_reader) -> ~str { let val = read_to_eol(rdr); assert ((val[0] == '/' as u8 && val[1] == '/' as u8) || (val[0] == '#' as u8 && val[1] == '!' as u8)); @@ -120,7 +120,7 @@ fn consume_non_eol_whitespace(rdr: string_reader) { fn push_blank_line_comment(rdr: string_reader, &comments: ~[cmnt]) { #debug(">>> blank-line comment"); - let v: ~[str] = ~[]; + let v: ~[~str] = ~[]; vec::push(comments, {style: blank_line, lines: v, pos: rdr.chpos}); } @@ -151,7 +151,7 @@ fn read_line_comments(rdr: string_reader, code_to_the_left: bool, &comments: ~[cmnt]) { #debug(">>> line comments"); let p = rdr.chpos; - let mut lines: ~[str] = ~[]; + let mut lines: ~[~str] = ~[]; while rdr.curr == '/' && nextch(rdr) == '/' { let line = read_one_line_comment(rdr); log(debug, line); @@ -171,22 +171,22 @@ fn read_line_comments(rdr: string_reader, code_to_the_left: bool, } } -fn all_whitespace(s: str, begin: uint, end: uint) -> bool { +fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool { let mut i: uint = begin; while i != end { if !is_whitespace(s[i] as char) { ret false; } i += 1u; } ret true; } -fn trim_whitespace_prefix_and_push_line(&lines: ~[str], - s: str, col: uint) unsafe { +fn trim_whitespace_prefix_and_push_line(&lines: ~[~str], + s: ~str, col: uint) unsafe { let mut s1; let len = str::len(s); if all_whitespace(s, 0u, uint::min(len, col)) { if col < len { s1 = str::slice(s, col, len); - } else { s1 = ""; } + } else { s1 = ~""; } } else { s1 = s; } - log(debug, "pushing line: " + s1); + log(debug, ~"pushing line: " + s1); vec::push(lines, s1); } @@ -194,7 +194,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool, &comments: ~[cmnt]) { #debug(">>> block comment"); let p = rdr.chpos; - let mut lines: ~[str] = ~[]; + let mut lines: ~[~str] = ~[]; let mut col: uint = rdr.col; bump(rdr); bump(rdr); @@ -211,27 +211,27 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool, ret; } - let mut curr_line = "/*"; + let mut curr_line = ~"/*"; let mut level: int = 1; while level > 0 { #debug("=== block comment level %d", level); - if is_eof(rdr) {(rdr as reader).fatal("unterminated block comment");} + if is_eof(rdr) {(rdr as reader).fatal(~"unterminated block comment");} if rdr.curr == '\n' { trim_whitespace_prefix_and_push_line(lines, curr_line, col); - curr_line = ""; + curr_line = ~""; bump(rdr); } else { str::push_char(curr_line, rdr.curr); if rdr.curr == '/' && nextch(rdr) == '*' { bump(rdr); bump(rdr); - curr_line += "*"; + curr_line += ~"*"; level += 1; } else { if rdr.curr == '*' && nextch(rdr) == '/' { bump(rdr); bump(rdr); - curr_line += "/"; + curr_line += ~"/"; level -= 1; } else { bump(rdr); } } @@ -268,14 +268,14 @@ fn consume_comment(rdr: string_reader, code_to_the_left: bool, #debug("<<< consume comment"); } -type lit = {lit: str, pos: uint}; +type lit = {lit: ~str, pos: uint}; fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler, - path: str, + path: ~str, srdr: io::reader) -> {cmnts: ~[cmnt], lits: ~[lit]} { let src = @str::from_bytes(srdr.read_whole_stream()); - let itr = @interner::mk::<@str/~>( + let itr = @interner::mk::<@~str>( |x| str::hash(*x), |x,y| str::eq(*x, *y) ); @@ -308,9 +308,9 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler, if token::is_lit(tok) { let s = get_str_from(rdr, bstart); vec::push(literals, {lit: s, pos: sp.lo}); - log(debug, "tok lit: " + s); + log(debug, ~"tok lit: " + s); } else { - log(debug, "tok: " + token::to_str(*rdr.interner, tok)); + log(debug, ~"tok: " + token::to_str(*rdr.interner, tok)); } first_read = false; } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 9e5f2ac2c9ba..79ac3aeaf8b0 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -18,7 +18,7 @@ fn seq_sep_none() -> seq_sep { ret {sep: option::none, trailing_sep_allowed: false}; } -fn token_to_str(reader: reader, ++token: token::token) -> str { +fn token_to_str(reader: reader, ++token: token::token) -> ~str { token::to_str(*reader.interner(), token) } @@ -28,23 +28,23 @@ impl parser_common for parser { fn unexpected_last(t: token::token) -> ! { self.span_fatal( copy self.last_span, - "unexpected token: `" + token_to_str(self.reader, t) + "`"); + ~"unexpected token: `" + token_to_str(self.reader, t) + ~"`"); } fn unexpected() -> ! { - self.fatal("unexpected token: `" - + token_to_str(self.reader, self.token) + "`"); + self.fatal(~"unexpected token: `" + + token_to_str(self.reader, self.token) + ~"`"); } fn expect(t: token::token) { if self.token == t { self.bump(); } else { - let mut s: str = "expected `"; + let mut s: ~str = ~"expected `"; s += token_to_str(self.reader, t); - s += "` but found `"; + s += ~"` but found `"; s += token_to_str(self.reader, self.token); - self.fatal(s + "`"); + self.fatal(s + ~"`"); } } @@ -52,10 +52,10 @@ fn parse_ident() -> ast::ident { alt copy self.token { token::IDENT(i, _) { self.bump(); ret self.get_str(i); } token::ACTUALLY(token::w_ident(*)) { self.bug( - "ident interpolation not converted to real token"); } - _ { self.fatal("expected ident, found `" + ~"ident interpolation not converted to real token"); } + _ { self.fatal(~"expected ident, found `" + token_to_str(self.reader, self.token) - + "`"); } + + ~"`"); } } } @@ -76,13 +76,13 @@ fn eat(tok: token::token) -> bool { } // A sanity check that the word we are asking for is a known keyword - fn require_keyword(word: str) { + fn require_keyword(word: ~str) { if !self.keywords.contains_key(word) { self.bug(#fmt("unknown keyword: %s", word)); } } - fn token_is_keyword(word: str, ++tok: token::token) -> bool { + fn token_is_keyword(word: ~str, ++tok: token::token) -> bool { self.require_keyword(word); alt tok { token::IDENT(sid, false) { str::eq(word, *self.get_str(sid)) } @@ -90,7 +90,7 @@ fn token_is_keyword(word: str, ++tok: token::token) -> bool { } } - fn is_keyword(word: str) -> bool { + fn is_keyword(word: ~str) -> bool { self.token_is_keyword(word, self.token) } @@ -103,7 +103,7 @@ fn is_any_keyword(tok: token::token) -> bool { } } - fn eat_keyword(word: str) -> bool { + fn eat_keyword(word: ~str) -> bool { self.require_keyword(word); // FIXME (#13042): this gratuitous use of @ is to @@ -119,16 +119,16 @@ fn eat_keyword(word: str) -> bool { } } - fn expect_keyword(word: str) { + fn expect_keyword(word: ~str) { self.require_keyword(word); if !self.eat_keyword(word) { - self.fatal("expected `" + word + "`, found `" + + self.fatal(~"expected `" + word + ~"`, found `" + token_to_str(self.reader, self.token) + - "`"); + ~"`"); } } - fn is_restricted_keyword(word: str) -> bool { + fn is_restricted_keyword(word: ~str) -> bool { self.restricted_keywords.contains_key(word) } @@ -142,9 +142,9 @@ fn check_restricted_keywords() { } } - fn check_restricted_keywords_(w: str) { + fn check_restricted_keywords_(w: ~str) { if self.is_restricted_keyword(w) { - self.fatal("found `" + w + "` in restricted position"); + self.fatal(~"found `" + w + ~"` in restricted position"); } } @@ -154,11 +154,11 @@ fn expect_gt() { } else if self.token == token::BINOP(token::SHR) { self.swap(token::GT, self.span.lo + 1u, self.span.hi); } else { - let mut s: str = "expected `"; + let mut s: ~str = ~"expected `"; s += token_to_str(self.reader, token::GT); - s += "`, found `"; + s += ~"`, found `"; s += token_to_str(self.reader, self.token); - s += "`"; + s += ~"`"; self.fatal(s); } } diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 54a2abf20c93..125dc809079e 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -9,7 +9,7 @@ fn eval_crate_directives(cx: ctx, cdirs: ~[@ast::crate_directive], - prefix: str, + prefix: ~str, &view_items: ~[@ast::view_item], &items: ~[@ast::item]) { for cdirs.each |sub_cdir| { @@ -18,11 +18,11 @@ fn eval_crate_directives(cx: ctx, } fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive], - prefix: str, suffix: option) + prefix: ~str, suffix: option<~str>) -> (ast::_mod, ~[ast::attribute]) { #debug("eval crate prefix: %s", prefix); #debug("eval crate suffix: %s", - option::get_default(suffix, "none")); + option::get_default(suffix, ~"none")); let (cview_items, citems, cattrs) = parse_companion_mod(cx, prefix, suffix); let mut view_items: ~[@ast::view_item] = ~[]; @@ -43,17 +43,17 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive], We build the path to the companion mod by combining the prefix and the optional suffix then adding the .rs extension. */ -fn parse_companion_mod(cx: ctx, prefix: str, suffix: option) +fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>) -> (~[@ast::view_item], ~[@ast::item], ~[ast::attribute]) { - fn companion_file(+prefix: str, suffix: option) -> str { + fn companion_file(+prefix: ~str, suffix: option<~str>) -> ~str { ret alt suffix { option::some(s) { path::connect(prefix, s) } option::none { prefix } - } + ".rs"; + } + ~".rs"; } - fn file_exists(path: str) -> bool { + fn file_exists(path: ~str) -> bool { // Crude, but there's no lib function for this and I'm not // up to writing it just now alt io::file_reader(path) { @@ -78,8 +78,8 @@ fn file_exists(path: str) -> bool { } } -fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @str/~ { - alt ::attr::first_attr_value_str_by_name(attrs, "path") { +fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @~str { + alt ::attr::first_attr_value_str_by_name(attrs, ~"path") { some(d) { ret d; } @@ -87,12 +87,12 @@ fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @str/~ { } } -fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str, +fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: ~str, &view_items: ~[@ast::view_item], &items: ~[@ast::item]) { alt cdir.node { ast::cdir_src_mod(id, attrs) { - let file_path = cdir_path_opt(@(*id + ".rs"), attrs); + let file_path = cdir_path_opt(@(*id + ~".rs"), attrs); let full_path = if path::path_is_absolute(*file_path) { *file_path diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index d7f9fc12840b..7afdc301b023 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -12,22 +12,22 @@ iface reader { fn is_eof() -> bool; fn next_token() -> {tok: token::token, sp: span}; - fn fatal(str) -> !; + fn fatal(~str) -> !; fn span_diag() -> span_handler; - fn interner() -> @interner<@str/~>; + fn interner() -> @interner<@~str>; fn peek() -> {tok: token::token, sp: span}; fn dup() -> reader; } type string_reader = @{ span_diagnostic: span_handler, - src: @str/~, + src: @~str, mut col: uint, mut pos: uint, mut curr: char, mut chpos: uint, filemap: codemap::filemap, - interner: @interner<@str/~>, + interner: @interner<@~str>, /* cached: */ mut peek_tok: token::token, mut peek_span: span @@ -35,7 +35,7 @@ fn new_string_reader(span_diagnostic: span_handler, filemap: codemap::filemap, - itr: @interner<@str/~>) -> string_reader { + itr: @interner<@~str>) -> string_reader { let r = new_low_level_string_reader(span_diagnostic, filemap, itr); string_advance_token(r); /* fill in peek_* */ ret r; @@ -44,7 +44,7 @@ fn new_string_reader(span_diagnostic: span_handler, /* For comments.rs, which hackily pokes into 'pos' and 'curr' */ fn new_low_level_string_reader(span_diagnostic: span_handler, filemap: codemap::filemap, - itr: @interner<@str/~>) + itr: @interner<@~str>) -> string_reader { let r = @{span_diagnostic: span_diagnostic, src: filemap.src, mut col: 0u, mut pos: 0u, mut curr: -1 as char, @@ -75,11 +75,11 @@ fn next_token() -> {tok: token::token, sp: span} { string_advance_token(self); ret ret_val; } - fn fatal(m: str) -> ! { + fn fatal(m: ~str) -> ! { self.span_diagnostic.span_fatal(copy self.peek_span, m) } fn span_diag() -> span_handler { self.span_diagnostic } - fn interner() -> @interner<@str/~> { self.interner } + fn interner() -> @interner<@~str> { self.interner } fn peek() -> {tok: token::token, sp: span} { {tok: self.peek_tok, sp: self.peek_span} } @@ -97,11 +97,11 @@ fn next_token() -> {tok: token::token, sp: span} { } tt_next_token(self) } - fn fatal(m: str) -> ! { + fn fatal(m: ~str) -> ! { self.sp_diag.span_fatal(copy self.cur_span, m); } fn span_diag() -> span_handler { self.sp_diag } - fn interner() -> @interner<@str/~> { self.interner } + fn interner() -> @interner<@~str> { self.interner } fn peek() -> {tok: token::token, sp: span} { { tok: self.cur_tok, sp: self.cur_span } } @@ -125,7 +125,7 @@ fn string_advance_token(&&r: string_reader) { } -fn get_str_from(rdr: string_reader, start: uint) -> str unsafe { +fn get_str_from(rdr: string_reader, start: uint) -> ~str unsafe { // I'm pretty skeptical about this subtraction. What if there's a // multi-byte character before the mark? ret str::slice(*rdr.src, start - 1u, rdr.pos - 1u); @@ -211,7 +211,7 @@ fn consume_any_line_comment(rdr: string_reader) // line comments starting with "///" or "//!" are doc-comments if rdr.curr == '/' || rdr.curr == '!' { let start_chpos = rdr.chpos - 2u; - let mut acc = "//"; + let mut acc = ~"//"; while rdr.curr != '\n' && !is_eof(rdr) { str::push_char(acc, rdr.curr); bump(rdr); @@ -250,15 +250,15 @@ fn consume_block_comment(rdr: string_reader) // block comments starting with "/**" or "/*!" are doc-comments if rdr.curr == '*' || rdr.curr == '!' { let start_chpos = rdr.chpos - 2u; - let mut acc = "/*"; + let mut acc = ~"/*"; while !(rdr.curr == '*' && nextch(rdr) == '/') && !is_eof(rdr) { str::push_char(acc, rdr.curr); bump(rdr); } if is_eof(rdr) { - rdr.fatal("unterminated block doc-comment"); + rdr.fatal(~"unterminated block doc-comment"); } else { - acc += "*/"; + acc += ~"*/"; bump(rdr); bump(rdr); ret some({ @@ -270,7 +270,7 @@ fn consume_block_comment(rdr: string_reader) let mut level: int = 1; while level > 0 { - if is_eof(rdr) { rdr.fatal("unterminated block comment"); } + if is_eof(rdr) { rdr.fatal(~"unterminated block comment"); } if rdr.curr == '/' && nextch(rdr) == '*' { bump(rdr); bump(rdr); @@ -288,9 +288,9 @@ fn consume_block_comment(rdr: string_reader) ret consume_whitespace_and_comments(rdr); } -fn scan_exponent(rdr: string_reader) -> option { +fn scan_exponent(rdr: string_reader) -> option<~str> { let mut c = rdr.curr; - let mut rslt = ""; + let mut rslt = ~""; if c == 'e' || c == 'E' { str::push_char(rslt, c); bump(rdr); @@ -302,12 +302,12 @@ fn scan_exponent(rdr: string_reader) -> option { let exponent = scan_digits(rdr, 10u); if str::len(exponent) > 0u { ret some(rslt + exponent); - } else { rdr.fatal("scan_exponent: bad fp literal"); } - } else { ret none::; } + } else { rdr.fatal(~"scan_exponent: bad fp literal"); } + } else { ret none::<~str>; } } -fn scan_digits(rdr: string_reader, radix: uint) -> str { - let mut rslt = ""; +fn scan_digits(rdr: string_reader, radix: uint) -> ~str { + let mut rslt = ~""; loop { let c = rdr.curr; if c == '_' { bump(rdr); again; } @@ -366,7 +366,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { else { either::right(ast::ty_u64) }; } if str::len(num_str) == 0u { - rdr.fatal("no valid digits found for number"); + rdr.fatal(~"no valid digits found for number"); } let parsed = option::get(u64::from_str_radix(num_str, base as u64)); alt tp { @@ -379,7 +379,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { is_float = true; bump(rdr); let dec_part = scan_digits(rdr, 10u); - num_str += "." + dec_part; + num_str += ~"." + dec_part; } alt scan_exponent(rdr) { some(s) { @@ -414,7 +414,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { ast::ty_f); } else { if str::len(num_str) == 0u { - rdr.fatal("no valid digits found for number"); + rdr.fatal(~"no valid digits found for number"); } let parsed = option::get(u64::from_str_radix(num_str, base as u64)); @@ -440,7 +440,7 @@ fn scan_numeric_escape(rdr: string_reader, n_hex_digits: uint) -> char { } fn next_token_inner(rdr: string_reader) -> token::token { - let mut accum_str = ""; + let mut accum_str = ~""; let mut c = rdr.curr; if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') @@ -455,7 +455,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { bump(rdr); c = rdr.curr; } - if str::eq(accum_str, "_") { ret token::UNDERSCORE; } + if str::eq(accum_str, ~"_") { ret token::UNDERSCORE; } let is_mod_name = c == ':' && nextch(rdr) == ':'; // FIXME: perform NFKC normalization here. (Issue #2253) @@ -578,7 +578,7 @@ fn binop(rdr: string_reader, op: token::binop) -> token::token { } } if rdr.curr != '\'' { - rdr.fatal("unterminated character constant"); + rdr.fatal(~"unterminated character constant"); } bump(rdr); // advance curr past token ret token::LIT_INT(c2 as i64, ast::ty_char); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 5effab943977..a19ea2d25e97 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -160,8 +160,8 @@ fn dummy() { let mut restriction: restriction; let mut quote_depth: uint; // not (yet) related to the quasiquoter let reader: reader; - let keywords: hashmap; - let restricted_keywords: hashmap; + let keywords: hashmap<~str, ()>; + let restricted_keywords: hashmap<~str, ()>; new(sess: parse_sess, cfg: ast::crate_cfg, +rdr: reader, ftype: file_type) { @@ -220,29 +220,29 @@ fn look_ahead(distance: uint) -> token::token { } ret copy self.buffer[(self.buffer_start + dist - 1) & 3].tok; } - fn fatal(m: str) -> ! { + fn fatal(m: ~str) -> ! { self.sess.span_diagnostic.span_fatal(copy self.span, m) } - fn span_fatal(sp: span, m: str) -> ! { + fn span_fatal(sp: span, m: ~str) -> ! { self.sess.span_diagnostic.span_fatal(sp, m) } - fn bug(m: str) -> ! { + fn bug(m: ~str) -> ! { self.sess.span_diagnostic.span_bug(copy self.span, m) } - fn warn(m: str) { + fn warn(m: ~str) { self.sess.span_diagnostic.span_warn(copy self.span, m) } - fn get_str(i: token::str_num) -> @str/~ { + fn get_str(i: token::str_num) -> @~str { interner::get(*self.reader.interner(), i) } fn get_id() -> node_id { next_node_id(self.sess) } fn parse_ty_fn(purity: ast::purity) -> ty_ { - let proto = if self.eat_keyword("extern") { - self.expect_keyword("fn"); + let proto = if self.eat_keyword(~"extern") { + self.expect_keyword(~"fn"); ast::proto_bare } else { - self.expect_keyword("fn"); + self.expect_keyword(~"fn"); self.parse_fn_ty_proto() }; ty_fn(proto, self.parse_ty_fn_decl(purity)) @@ -259,7 +259,7 @@ fn parse_ty_fn_decl(purity: ast::purity) -> fn_decl { let name = self.parse_value_ident(); p.bump(); name - } else { @"" }; + } else { @~"" }; {mode: mode, ty: p.parse_ty(false), ident: name, id: p.get_id()} @@ -317,8 +317,8 @@ fn parse_trait_methods() -> ~[trait_method] { vis: vis}) } - _ { p.fatal("expected `;` or `}` but found `" + - token_to_str(p.reader, p.token) + "`"); + _ { p.fatal(~"expected `;` or `}` but found `" + + token_to_str(p.reader, p.token) + ~"`"); } } } @@ -345,7 +345,7 @@ fn parse_ty_field() -> ty_field { fn ident_index(args: ~[arg], i: ident) -> uint { let mut j = 0u; for args.each |a| { if a.ident == i { ret j; } j += 1u; } - self.fatal("unbound variable `" + *i + "` in constraint arg"); + self.fatal(~"unbound variable `" + *i + ~"` in constraint arg"); } fn parse_type_constr_arg() -> @ty_constr_arg { @@ -431,7 +431,7 @@ fn parse_ret_ty() -> (ret_style, @ty) { } } - fn region_from_name(s: option<@str/~>) -> @region { + fn region_from_name(s: option<@~str>) -> @region { let r = alt s { some (string) { re_named(string) } none { re_anon } @@ -538,19 +538,19 @@ fn parse_ty(colons_before_params: bool) -> @ty { let region = self.parse_region_with_sep(); let mt = self.parse_mt(); ty_rptr(region, mt) - } else if self.eat_keyword("pure") { + } else if self.eat_keyword(~"pure") { self.parse_ty_fn(ast::pure_fn) - } else if self.eat_keyword("unsafe") { + } else if self.eat_keyword(~"unsafe") { self.parse_ty_fn(ast::unsafe_fn) - } else if self.is_keyword("fn") { + } else if self.is_keyword(~"fn") { self.parse_ty_fn(ast::impure_fn) - } else if self.eat_keyword("extern") { - self.expect_keyword("fn"); + } else if self.eat_keyword(~"extern") { + self.expect_keyword(~"fn"); ty_fn(proto_bare, self.parse_ty_fn_decl(ast::impure_fn)) } else if self.token == token::MOD_SEP || is_ident(self.token) { let path = self.parse_path_with_tps(colons_before_params); ty_path(path, self.get_id()) - } else { self.fatal("expected type"); }; + } else { self.fatal(~"expected type"); }; let sp = mk_sp(lo, self.last_span.hi); ret @{id: self.get_id(), @@ -588,9 +588,9 @@ fn parse_capture_item(p:parser, is_move: bool) -> capture_item { @{id: p.get_id(), is_move: is_move, name: ident, span: sp} } - if self.eat_keyword("move") { + if self.eat_keyword(~"move") { either::right(parse_capture_item(self, true)) - } else if self.eat_keyword("copy") { + } else if self.eat_keyword(~"copy") { either::right(parse_capture_item(self, false)) } else { parse_arg_fn(self) @@ -642,7 +642,7 @@ fn maybe_parse_dollar_mac() -> option { some(mac_aq(mk_sp(lo,hi), e)) } _ { - self.fatal("expected `(` or unsuffixed integer literal"); + self.fatal(~"expected `(` or unsuffixed integer literal"); } } } @@ -654,21 +654,12 @@ fn maybe_parse_vstore() -> option { if self.token == token::BINOP(token::SLASH) { self.bump(); alt copy self.token { - token::AT { - self.bump(); some(vstore_box) - } - token::TILDE { - self.bump(); some(vstore_uniq) - } token::UNDERSCORE { self.bump(); some(vstore_fixed(none)) } token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 { self.bump(); some(vstore_fixed(some(i as uint))) } - token::BINOP(token::AND) { - some(vstore_slice(self.parse_region())) - } _ { none } @@ -692,9 +683,9 @@ fn lit_from_token(tok: token::token) -> lit_ { fn parse_lit() -> lit { let lo = self.span.lo; - let lit = if self.eat_keyword("true") { + let lit = if self.eat_keyword(~"true") { lit_bool(true) - } else if self.eat_keyword("false") { + } else if self.eat_keyword(~"false") { lit_bool(false) } else { let tok = self.token; @@ -753,7 +744,7 @@ fn parse_path_with_tps(colons: bool) -> @path { // Hack: avoid parsing vstores like /@ and /~. This is painful // because the notation for region bounds and the notation for // vstores is... um... the same. I guess that's my fault. This - // is still not ideal as for str/& we end up parsing more than we + // is still not ideal as for &str we end up parsing more than we // ought to and have to sort it out later. if self.token == token::BINOP(token::SLASH) && self.look_ahead(1u) == token::BINOP(token::AND) { @@ -781,9 +772,9 @@ fn parse_path_with_tps(colons: bool) -> @path { } fn parse_mutability() -> mutability { - if self.eat_keyword("mut") { + if self.eat_keyword(~"mut") { m_mutbl - } else if self.eat_keyword("const") { + } else if self.eat_keyword(~"const") { m_const } else { m_imm @@ -866,7 +857,7 @@ fn parse_bottom_expr() -> pexpr { ret self.mk_pexpr(lo, hi, expr_tup(es)); } else if self.token == token::LBRACE { self.bump(); - if self.is_keyword("mut") || + if self.is_keyword(~"mut") || is_plain_ident(self.token) && self.look_ahead(1u) == token::COLON { let mut fields = ~[self.parse_field(token::COLON)]; @@ -874,11 +865,11 @@ fn parse_bottom_expr() -> pexpr { while self.token != token::RBRACE { // optional comma before "with" if self.token == token::COMMA - && self.token_is_keyword("with", + && self.token_is_keyword(~"with", self.look_ahead(1u)) { self.bump(); } - if self.eat_keyword("with") { + if self.eat_keyword(~"with") { base = some(self.parse_expr()); break; } self.expect(token::COMMA); @@ -897,36 +888,38 @@ fn parse_bottom_expr() -> pexpr { } } else if token::is_bar(self.token) { ret pexpr(self.parse_lambda_expr()); - } else if self.eat_keyword("new") { + } else if self.eat_keyword(~"new") { self.expect(token::LPAREN); let r = self.parse_expr(); self.expect(token::RPAREN); let v = self.parse_expr(); ret self.mk_pexpr(lo, self.span.hi, expr_new(r, self.get_id(), v)); - } else if self.eat_keyword("if") { + } else if self.eat_keyword(~"if") { ret pexpr(self.parse_if_expr()); - } else if self.eat_keyword("for") { - ret pexpr(self.parse_sugary_call_expr("for", expr_loop_body)); - } else if self.eat_keyword("do") { - ret pexpr(self.parse_sugary_call_expr("do", expr_do_body)); - } else if self.eat_keyword("while") { + } else if self.eat_keyword(~"for") { + ret pexpr(self.parse_sugary_call_expr(~"for", expr_loop_body)); + } else if self.eat_keyword(~"do") { + ret pexpr(self.parse_sugary_call_expr(~"do", expr_do_body)); + } else if self.eat_keyword(~"while") { ret pexpr(self.parse_while_expr()); - } else if self.eat_keyword("loop") { + } else if self.eat_keyword(~"loop") { ret pexpr(self.parse_loop_expr()); - } else if self.eat_keyword("alt") { + } else if self.eat_keyword(~"alt") { ret pexpr(self.parse_alt_expr()); - } else if self.eat_keyword("fn") { + } else if self.eat_keyword(~"fn") { let proto = self.parse_fn_ty_proto(); alt proto { - proto_bare { self.fatal("fn expr are deprecated, use fn@"); } - proto_any { self.fatal("fn* cannot be used in an expression"); } + proto_bare { self.fatal(~"fn expr are deprecated, use fn@"); } + proto_any { + self.fatal(~"fn* cannot be used in an expression"); + } _ { /* fallthrough */ } } ret pexpr(self.parse_fn_expr(proto)); - } else if self.eat_keyword("unchecked") { + } else if self.eat_keyword(~"unchecked") { ret pexpr(self.parse_block_expr(lo, unchecked_blk)); - } else if self.eat_keyword("unsafe") { + } else if self.eat_keyword(~"unsafe") { ret pexpr(self.parse_block_expr(lo, unsafe_blk)); } else if self.token == token::LBRACKET { self.bump(); @@ -958,13 +951,13 @@ fn parse_bottom_expr() -> pexpr { let ex_ext = self.parse_syntax_ext(); hi = ex_ext.span.hi; ex = ex_ext.node; - } else if self.eat_keyword("fail") { + } else if self.eat_keyword(~"fail") { if can_begin_expr(self.token) { let e = self.parse_expr(); hi = e.span.hi; ex = expr_fail(some(e)); } else { ex = expr_fail(none); } - } else if self.eat_keyword("log") { + } else if self.eat_keyword(~"log") { self.expect(token::LPAREN); let lvl = self.parse_expr(); self.expect(token::COMMA); @@ -972,18 +965,18 @@ fn parse_bottom_expr() -> pexpr { ex = expr_log(2, lvl, e); hi = self.span.hi; self.expect(token::RPAREN); - } else if self.eat_keyword("assert") { + } else if self.eat_keyword(~"assert") { let e = self.parse_expr(); ex = expr_assert(e); hi = e.span.hi; - } else if self.eat_keyword("check") { + } else if self.eat_keyword(~"check") { /* Should be a predicate (pure boolean function) applied to arguments that are all either slot variables or literals. but the typechecker enforces that. */ let e = self.parse_expr(); hi = e.span.hi; ex = expr_check(checked_expr, e); - } else if self.eat_keyword("claim") { + } else if self.eat_keyword(~"claim") { /* Same rules as check, except that if check-claims is enabled (a command-line flag), then the parser turns claims into check */ @@ -991,25 +984,25 @@ fn parse_bottom_expr() -> pexpr { let e = self.parse_expr(); hi = e.span.hi; ex = expr_check(claimed_expr, e); - } else if self.eat_keyword("ret") { + } else if self.eat_keyword(~"ret") { if can_begin_expr(self.token) { let e = self.parse_expr(); hi = e.span.hi; ex = expr_ret(some(e)); } else { ex = expr_ret(none); } - } else if self.eat_keyword("break") { + } else if self.eat_keyword(~"break") { ex = expr_break; hi = self.span.hi; - } else if self.eat_keyword("again") { + } else if self.eat_keyword(~"again") { ex = expr_again; hi = self.span.hi; - } else if self.eat_keyword("copy") { + } else if self.eat_keyword(~"copy") { let e = self.parse_expr(); ex = expr_copy(e); hi = e.span.hi; } else if self.token == token::MOD_SEP || - is_ident(self.token) && !self.is_keyword("true") && - !self.is_keyword("false") { + is_ident(self.token) && !self.is_keyword(~"true") && + !self.is_keyword(~"false") { let pth = self.parse_path_with_tps(true); /* `!`, as an operator, is prefix, so we know this isn't that */ @@ -1065,7 +1058,7 @@ fn parse_syntax_ext() -> @expr { fn parse_syntax_ext_naked(lo: uint) -> @expr { alt self.token { token::IDENT(_, _) {} - _ { self.fatal("expected a syntax expander name"); } + _ { self.fatal(~"expected a syntax expander name"); } } let pth = self.parse_path_without_tps(); //temporary for a backwards-compatible cycle: @@ -1093,7 +1086,7 @@ fn parse_syntax_ext_naked(lo: uint) -> @expr { alt (self.token) { token::LBRACE {depth += 1u;} token::RBRACE {depth -= 1u;} - token::EOF {self.fatal("unexpected EOF in macro body");} + token::EOF {self.fatal(~"unexpected EOF in macro body");} _ {} } self.bump(); @@ -1181,7 +1174,7 @@ fn parse_sep_and_zerok() -> (option, bool) { self.bump(); ret (some(sep), zerok); } else { - self.fatal("expected `*` or `+`"); + self.fatal(~"expected `*` or `+`"); } } } @@ -1201,11 +1194,11 @@ fn parse_tt_flat(p: parser, delim_ok: bool) -> token_tree { alt p.token { token::RPAREN | token::RBRACE | token::RBRACKET if !delim_ok { - p.fatal("incorrect close delimiter: `" - + token_to_str(p.reader, p.token) + "`"); + p.fatal(~"incorrect close delimiter: `" + + token_to_str(p.reader, p.token) + ~"`"); } token::EOF { - p.fatal("file ended in the middle of a macro invocation"); + p.fatal(~"file ended in the middle of a macro invocation"); } /* we ought to allow different depths of unquotation */ token::DOLLAR if p.quote_depth > 0u { @@ -1280,7 +1273,7 @@ fn parse_matcher(name_idx: @mut uint) -> matcher { let ms = self.parse_matcher_subseq(name_idx, token::LPAREN, token::RPAREN); if ms.len() == 0u { - self.fatal("repetition body must be nonempty"); + self.fatal(~"repetition body must be nonempty"); } let (sep, zerok) = self.parse_sep_and_zerok(); mtc_rep(ms, sep, zerok) @@ -1337,7 +1330,8 @@ fn parse_prefix_expr() -> pexpr { hi = e.span.hi; // HACK: turn &[...] into a &-evec ex = alt e.node { - expr_vec(*) if m == m_imm { + expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) + if m == m_imm { expr_vstore(e, vstore_slice(self.region_from_name(none))) } _ { expr_addr_of(m, e) } @@ -1353,7 +1347,8 @@ fn parse_prefix_expr() -> pexpr { hi = e.span.hi; // HACK: turn @[...] into a @-evec ex = alt e.node { - expr_vec(*) if m == m_imm { expr_vstore(e, vstore_box) } + expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) + if m == m_imm { expr_vstore(e, vstore_box) } _ { expr_unary(box(m), e) } }; } @@ -1364,7 +1359,8 @@ fn parse_prefix_expr() -> pexpr { hi = e.span.hi; // HACK: turn ~[...] into a ~-evec ex = alt e.node { - expr_vec(*) if m == m_imm { expr_vstore(e, vstore_uniq) } + expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) + if m == m_imm { expr_vstore(e, vstore_uniq) } _ { expr_unary(uniq(m), e) } }; } @@ -1408,7 +1404,7 @@ fn parse_more_binops(plhs: pexpr, min_prec: uint) -> } _ {} } - if as_prec > min_prec && self.eat_keyword("as") { + if as_prec > min_prec && self.eat_keyword(~"as") { let rhs = self.parse_ty(true); let _as = self.mk_pexpr(lhs.span.lo, rhs.span.hi, expr_cast(lhs, rhs)); @@ -1471,7 +1467,7 @@ fn parse_if_expr_1() -> let thn = self.parse_block(); let mut els: option<@expr> = none; let mut hi = thn.span.hi; - if self.eat_keyword("else") { + if self.eat_keyword(~"else") { let elexpr = self.parse_else_expr(); els = some(elexpr); hi = elexpr.span.hi; @@ -1480,7 +1476,7 @@ fn parse_if_expr_1() -> } fn parse_if_expr() -> @expr { - if self.eat_keyword("check") { + if self.eat_keyword(~"check") { let q = self.parse_if_expr_1(); ret self.mk_expr(q.lo, q.hi, expr_if_check(q.cond, q.then, q.els)); @@ -1557,7 +1553,7 @@ fn parse_lambda_expr_(parse_decl: fn&() -> (fn_decl, capture_clause), } fn parse_else_expr() -> @expr { - if self.eat_keyword("if") { + if self.eat_keyword(~"if") { ret self.parse_if_expr(); } else { let blk = self.parse_block(); @@ -1565,7 +1561,7 @@ fn parse_else_expr() -> @expr { } } - fn parse_sugary_call_expr(keyword: str, + fn parse_sugary_call_expr(keyword: ~str, ctor: fn(+@expr) -> expr_) -> @expr { let lo = self.last_span; // Parse the callee `foo` in @@ -1622,7 +1618,7 @@ fn parse_loop_expr() -> @expr { fn parse_alt_expr() -> @expr { let lo = self.last_span.lo; - let mode = if self.eat_keyword("check") { alt_check } + let mode = if self.eat_keyword(~"check") { alt_check } else { alt_exhaustive }; let discriminant = self.parse_expr(); self.expect(token::LBRACE); @@ -1630,7 +1626,7 @@ fn parse_alt_expr() -> @expr { while self.token != token::RBRACE { let pats = self.parse_pats(); let mut guard = none; - if self.eat_keyword("if") { guard = some(self.parse_expr()); } + if self.eat_keyword(~"if") { guard = some(self.parse_expr()); } if self.token == token::FAT_ARROW { self.bump(); } let blk = self.parse_block(); vec::push(arms, {pats: pats, guard: guard, body: blk}); @@ -1693,14 +1689,33 @@ fn parse_pat() -> @pat { token::AT { self.bump(); let sub = self.parse_pat(); - pat = pat_box(sub); hi = sub.span.hi; + // HACK: parse @"..." as a literal of a vstore @str + pat = alt sub.node { + pat_lit(e@@{node: expr_lit(@{node: lit_str(_), span: _}), _}) { + let vst = @{id: self.get_id(), callee_id: self.get_id(), + node: expr_vstore(e, vstore_box), + span: mk_sp(lo, hi)}; + pat_lit(vst) + } + _ { pat_box(sub) } + }; } token::TILDE { self.bump(); let sub = self.parse_pat(); - pat = pat_uniq(sub); hi = sub.span.hi; + // HACK: parse ~"..." as a literal of a vstore ~str + pat = alt sub.node { + pat_lit(e@@{node: expr_lit(@{node: lit_str(_), span: _}), _}) { + let vst = @{id: self.get_id(), callee_id: self.get_id(), + node: expr_vstore(e, vstore_uniq), + span: mk_sp(lo, hi)}; + pat_lit(vst) + } + _ { pat_uniq(sub) } + }; + } token::LBRACE { self.bump(); @@ -1714,9 +1729,9 @@ fn parse_pat() -> @pat { if self.token == token::UNDERSCORE { self.bump(); if self.token != token::RBRACE { - self.fatal("expected `}`, found `" + + self.fatal(~"expected `}`, found `" + token_to_str(self.reader, self.token) + - "`"); + ~"`"); } etc = true; break; @@ -1767,10 +1782,10 @@ fn parse_pat() -> @pat { } } tok { - if !is_ident(tok) || self.is_keyword("true") - || self.is_keyword("false") { + if !is_ident(tok) || self.is_keyword(~"true") + || self.is_keyword(~"false") { let val = self.parse_expr_res(RESTRICT_NO_BAR_OP); - if self.eat_keyword("to") { + if self.eat_keyword(~"to") { let end = self.parse_expr_res(RESTRICT_NO_BAR_OP); hi = end.span.hi; pat = pat_range(val, end); @@ -1844,7 +1859,7 @@ fn parse_local(is_mutbl: bool, } fn parse_let() -> @decl { - let is_mutbl = self.eat_keyword("mut"); + let is_mutbl = self.eat_keyword(~"mut"); let lo = self.span.lo; let mut locals = ~[self.parse_local(is_mutbl, true)]; while self.eat(token::COMMA) { @@ -1857,11 +1872,11 @@ fn parse_let() -> @decl { fn parse_instance_var(pr: visibility) -> @class_member { let mut is_mutbl = class_immutable; let lo = self.span.lo; - if self.eat_keyword("mut") { + if self.eat_keyword(~"mut") { is_mutbl = class_mutable; } if !is_plain_ident(self.token) { - self.fatal("expected ident"); + self.fatal(~"expected ident"); } let name = self.parse_ident(); self.expect(token::COLON); @@ -1874,14 +1889,14 @@ fn parse_stmt(+first_item_attrs: ~[attribute]) -> @stmt { fn check_expected_item(p: parser, current_attrs: ~[attribute]) { // If we have attributes then we should have an item if vec::is_not_empty(current_attrs) { - p.fatal("expected item"); + p.fatal(~"expected item"); } } let lo = self.span.lo; - if self.is_keyword("let") { + if self.is_keyword(~"let") { check_expected_item(self, first_item_attrs); - self.expect_keyword("let"); + self.expect_keyword(~"let"); let decl = self.parse_let(); ret @spanned(lo, decl.span.hi, stmt_decl(decl, self.get_id())); } else { @@ -1914,7 +1929,7 @@ fn check_expected_item(p: parser, current_attrs: ~[attribute]) { } fn expr_is_complete(e: pexpr) -> bool { - log(debug, ("expr_is_complete", self.restriction, + log(debug, (~"expr_is_complete", self.restriction, print::pprust::expr_to_str(*e), classify::expr_requires_semi_to_be_stmt(*e))); ret self.restriction == RESTRICT_STMT_EXPR && @@ -1940,12 +1955,12 @@ fn maybe_parse_inner_attrs_and_next(p: parser, parse_attrs: bool) -> } let lo = self.span.lo; - if self.eat_keyword("unchecked") { + if self.eat_keyword(~"unchecked") { self.expect(token::LBRACE); let {inner, next} = maybe_parse_inner_attrs_and_next(self, parse_attrs); ret (inner, self.parse_block_tail_(lo, unchecked_blk, next)); - } else if self.eat_keyword("unsafe") { + } else if self.eat_keyword(~"unsafe") { self.expect(token::LBRACE); let {inner, next} = maybe_parse_inner_attrs_and_next(self, parse_attrs); @@ -1982,7 +1997,7 @@ fn parse_block_tail_(lo: uint, s: blk_check_mode, let mut initial_attrs = attrs_remaining; if self.token == token::RBRACE && !vec::is_empty(initial_attrs) { - self.fatal("expected item"); + self.fatal(~"expected item"); } while self.token != token::RBRACE { @@ -2006,9 +2021,9 @@ fn parse_block_tail_(lo: uint, s: blk_check_mode, } t { if classify::stmt_ends_with_semi(*stmt) { - self.fatal("expected `;` or `}` after expression \ - but found `" - + token_to_str(self.reader, t) + "`"); + self.fatal(~"expected `;` or `}` after \ + expression but found `" + + token_to_str(self.reader, t) + ~"`"); } vec::push(stmts, stmt); } @@ -2038,9 +2053,9 @@ fn parse_ty_param() -> ty_param { let ident = self.parse_ident(); if self.eat(token::COLON) { while self.token != token::COMMA && self.token != token::GT { - if self.eat_keyword("send") { push(bounds, bound_send); } - else if self.eat_keyword("copy") { push(bounds, bound_copy) } - else if self.eat_keyword("const") { + if self.eat_keyword(~"send") { push(bounds, bound_send); } + else if self.eat_keyword(~"copy") { push(bounds, bound_copy) } + else if self.eat_keyword(~"const") { push(bounds, bound_const) } else { push(bounds, bound_trait(self.parse_ty(false))); } @@ -2134,12 +2149,16 @@ fn parse_item_fn(purity: purity) -> item_info { fn parse_method_name() -> ident { alt copy self.token { token::BINOP(op) { self.bump(); @token::binop_to_str(op) } - token::NOT { self.bump(); @"!" } - token::LBRACKET { self.bump(); self.expect(token::RBRACKET); @"[]" } + token::NOT { self.bump(); @~"!" } + token::LBRACKET { + self.bump(); + self.expect(token::RBRACKET); + @~"[]" + } _ { let id = self.parse_value_ident(); - if id == @"unary" && self.eat(token::BINOP(token::MINUS)) { - @"unary-" + if id == @~"unary" && self.eat(token::BINOP(token::MINUS)) { + @~"unary-" } else { id } } @@ -2182,7 +2201,7 @@ fn wrap_path(p: parser, pt: @path) -> @ty { self.parse_region_param(); (none, self.parse_ty_params()) } - else if self.is_keyword("of") { + else if self.is_keyword(~"of") { (none, ~[]) } else { let id = self.parse_ident(); @@ -2190,7 +2209,7 @@ fn wrap_path(p: parser, pt: @path) -> @ty { (some(id), self.parse_ty_params()) } }; - let ifce = if self.eat_keyword("of") { + let ifce = if self.eat_keyword(~"of") { let path = self.parse_path_with_tps(false); if option::is_none(ident) { ident = some(vec::last(path.idents)); @@ -2199,9 +2218,9 @@ fn wrap_path(p: parser, pt: @path) -> @ty { } else { none }; let ident = alt ident { some(name) { name } - none { self.expect_keyword("of"); fail; } + none { self.expect_keyword(~"of"); fail; } }; - self.expect_keyword("for"); + self.expect_keyword(~"for"); let ty = self.parse_ty(false); let mut meths = ~[]; self.expect(token::LBRACE); @@ -2284,14 +2303,14 @@ fn parse_item_class() -> item_info { Is it strange for the parser to check this? */ none { - self.fatal("class with no constructor"); + self.fatal(~"class with no constructor"); } } } fn parse_single_class_item(vis: visibility) -> @class_member { - if self.eat_keyword("let") { + if self.eat_keyword(~"let") { let a_var = self.parse_instance_var(vis); self.expect(token::SEMI); ret a_var; @@ -2322,15 +2341,15 @@ fn parse_dtor() -> class_contents { fn parse_class_item(class_name_with_tps: @path) -> class_contents { - if self.eat_keyword("new") { + if self.eat_keyword(~"new") { // result type is always the type of the class ret self.parse_ctor(ty_path(class_name_with_tps, self.get_id())); } - else if self.eat_keyword("drop") { + else if self.eat_keyword(~"drop") { ret self.parse_dtor(); } - else if self.eat_keyword("priv") { + else if self.eat_keyword(~"priv") { self.expect(token::LBRACE); let mut results = ~[]; while self.token != token::RBRACE { @@ -2346,8 +2365,8 @@ fn parse_class_item(class_name_with_tps: @path) } fn parse_visibility(def: visibility) -> visibility { - if self.eat_keyword("pub") { public } - else if self.eat_keyword("priv") { private } + if self.eat_keyword(~"pub") { public } + else if self.eat_keyword(~"priv") { private } else { def } } @@ -2369,8 +2388,8 @@ fn parse_mod_items(term: token::token, alt self.parse_item(attrs, vis) { some(i) { vec::push(items, i); } _ { - self.fatal("expected item but found `" + - token_to_str(self.reader, self.token) + "`"); + self.fatal(~"expected item but found `" + + token_to_str(self.reader, self.token) + ~"`"); } } #debug["parse_mod_items: attrs=%?", attrs]; @@ -2378,7 +2397,7 @@ fn parse_mod_items(term: token::token, if first && attrs_remaining.len() > 0u { // We parsed attributes for the first item but didn't find it - self.fatal("expected item"); + self.fatal(~"expected item"); } ret {view_items: view_items, items: items}; @@ -2418,12 +2437,12 @@ fn parse_item_foreign_fn(+attrs: ~[attribute], } fn parse_fn_purity() -> purity { - if self.eat_keyword("fn") { impure_fn } - else if self.eat_keyword("pure") { - self.expect_keyword("fn"); + if self.eat_keyword(~"fn") { impure_fn } + else if self.eat_keyword(~"pure") { + self.expect_keyword(~"fn"); pure_fn - } else if self.eat_keyword("unsafe") { - self.expect_keyword("fn"); + } else if self.eat_keyword(~"unsafe") { + self.expect_keyword(~"fn"); unsafe_fn } else { self.unexpected(); } @@ -2452,7 +2471,7 @@ fn parse_foreign_mod_items(+first_item_attrs: ~[attribute]) -> } fn parse_item_foreign_mod() -> item_info { - self.expect_keyword("mod"); + self.expect_keyword(~"mod"); let id = self.parse_ident(); self.expect(token::LBRACE); let more_attrs = self.parse_inner_attrs_and_next(); @@ -2537,7 +2556,7 @@ fn parse_item_enum(default_vis: visibility) -> item_info { } self.expect(token::RBRACE); if (have_disr && !all_nullary) { - self.fatal("discriminator values can only be used with a c-like \ + self.fatal(~"discriminator values can only be used with a c-like \ enum"); } (id, item_enum(variants, ty_params), none) @@ -2577,39 +2596,39 @@ fn fn_expr_lookahead(tok: token::token) -> bool { fn parse_item(+attrs: ~[attribute], vis: visibility) -> option<@item> { let lo = self.span.lo; - let (ident, item_, extra_attrs) = if self.eat_keyword("const") { + let (ident, item_, extra_attrs) = if self.eat_keyword(~"const") { self.parse_item_const() - } else if self.is_keyword("fn") && + } else if self.is_keyword(~"fn") && !self.fn_expr_lookahead(self.look_ahead(1u)) { self.bump(); self.parse_item_fn(impure_fn) - } else if self.eat_keyword("pure") { - self.expect_keyword("fn"); + } else if self.eat_keyword(~"pure") { + self.expect_keyword(~"fn"); self.parse_item_fn(pure_fn) - } else if self.is_keyword("unsafe") + } else if self.is_keyword(~"unsafe") && self.look_ahead(1u) != token::LBRACE { self.bump(); - self.expect_keyword("fn"); + self.expect_keyword(~"fn"); self.parse_item_fn(unsafe_fn) - } else if self.eat_keyword("extern") { - if self.eat_keyword("fn") { + } else if self.eat_keyword(~"extern") { + if self.eat_keyword(~"fn") { self.parse_item_fn(extern_fn) } else { self.parse_item_foreign_mod() } - } else if self.eat_keyword("mod") { + } else if self.eat_keyword(~"mod") { self.parse_item_mod() - } else if self.eat_keyword("type") { + } else if self.eat_keyword(~"type") { self.parse_item_type() - } else if self.eat_keyword("enum") { + } else if self.eat_keyword(~"enum") { self.parse_item_enum(vis) - } else if self.eat_keyword("iface") { + } else if self.eat_keyword(~"iface") { self.parse_item_trait() - } else if self.eat_keyword("trait") { + } else if self.eat_keyword(~"trait") { self.parse_item_trait() - } else if self.eat_keyword("impl") { + } else if self.eat_keyword(~"impl") { self.parse_item_impl() - } else if self.eat_keyword("class") { + } else if self.eat_keyword(~"class") { self.parse_item_class() } else if !self.is_any_keyword(copy self.token) && self.look_ahead(1) == token::NOT @@ -2721,21 +2740,21 @@ fn parse_view_paths() -> ~[@view_path] { } fn is_view_item() -> bool { - let tok = if !self.is_keyword("pub") && !self.is_keyword("priv") { + let tok = if !self.is_keyword(~"pub") && !self.is_keyword(~"priv") { self.token } else { self.look_ahead(1u) }; - self.token_is_keyword("use", tok) - || self.token_is_keyword("import", tok) - || self.token_is_keyword("export", tok) + self.token_is_keyword(~"use", tok) + || self.token_is_keyword(~"import", tok) + || self.token_is_keyword(~"export", tok) } fn parse_view_item(+attrs: ~[attribute]) -> @view_item { let lo = self.span.lo, vis = self.parse_visibility(private); - let node = if self.eat_keyword("use") { + let node = if self.eat_keyword(~"use") { self.parse_use() - } else if self.eat_keyword("import") { + } else if self.eat_keyword(~"import") { view_item_import(self.parse_view_paths()) - } else if self.eat_keyword("export") { + } else if self.eat_keyword(~"export") { view_item_export(self.parse_view_paths()) } else { fail; }; self.expect(token::SEMI); @@ -2749,7 +2768,7 @@ fn parse_view(+first_item_attrs: ~[attribute], let mut attrs = vec::append(first_item_attrs, self.parse_outer_attributes()); let mut items = ~[]; - while if only_imports { self.is_keyword("import") } + while if only_imports { self.is_keyword(~"import") } else { self.is_view_item() } { vec::push(items, self.parse_view_item(attrs)); attrs = self.parse_outer_attributes(); @@ -2770,11 +2789,11 @@ fn parse_crate_mod(_cfg: crate_cfg) -> @crate { config: self.cfg}); } - fn parse_str() -> @str/~ { + fn parse_str() -> @~str { alt copy self.token { token::LIT_STR(s) { self.bump(); self.get_str(s) } _ { - self.fatal("expected string literal") + self.fatal(~"expected string literal") } } } @@ -2795,8 +2814,8 @@ fn parse_crate_directive(first_outer_attr: ~[attribute]) -> let expect_mod = vec::len(outer_attrs) > 0u; let lo = self.span.lo; - if expect_mod || self.is_keyword("mod") { - self.expect_keyword("mod"); + if expect_mod || self.is_keyword(~"mod") { + self.expect_keyword(~"mod"); let id = self.parse_ident(); alt self.token { // mod x = "foo.rs"; @@ -2823,7 +2842,7 @@ fn parse_crate_directive(first_outer_attr: ~[attribute]) -> } else if self.is_view_item() { let vi = self.parse_view_item(outer_attrs); ret spanned(lo, vi.span.hi, cdir_view_item(vi)); - } else { ret self.fatal("expected crate directive"); } + } else { ret self.fatal(~"expected crate directive"); } } fn parse_crate_directives(term: token::token, @@ -2834,7 +2853,7 @@ fn parse_crate_directives(term: token::token, // accept seeing the terminator next, so if we do see it then fail the // same way parse_crate_directive would if vec::len(first_outer_attr) > 0u && self.token == term { - self.expect_keyword("mod"); + self.expect_keyword(~"mod"); } let mut cdirs: ~[@crate_directive] = ~[]; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 2c7b14cfe11b..7db5af232668 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -100,61 +100,61 @@ enum whole_nt { w_mtcs(~[ast::matcher]) } -fn binop_to_str(o: binop) -> str { +fn binop_to_str(o: binop) -> ~str { alt o { - PLUS { "+" } - MINUS { "-" } - STAR { "*" } - SLASH { "/" } - PERCENT { "%" } - CARET { "^" } - AND { "&" } - OR { "|" } - SHL { "<<" } - SHR { ">>" } + PLUS { ~"+" } + MINUS { ~"-" } + STAR { ~"*" } + SLASH { ~"/" } + PERCENT { ~"%" } + CARET { ~"^" } + AND { ~"&" } + OR { ~"|" } + SHL { ~"<<" } + SHR { ~">>" } } } -fn to_str(in: interner<@str/~>, t: token) -> str { +fn to_str(in: interner<@~str>, t: token) -> ~str { alt t { - EQ { "=" } - LT { "<" } - LE { "<=" } - EQEQ { "==" } - NE { "!=" } - GE { ">=" } - GT { ">" } - NOT { "!" } - TILDE { "~" } - OROR { "||" } - ANDAND { "&&" } + EQ { ~"=" } + LT { ~"<" } + LE { ~"<=" } + EQEQ { ~"==" } + NE { ~"!=" } + GE { ~">=" } + GT { ~">" } + NOT { ~"!" } + TILDE { ~"~" } + OROR { ~"||" } + ANDAND { ~"&&" } BINOP(op) { binop_to_str(op) } - BINOPEQ(op) { binop_to_str(op) + "=" } + BINOPEQ(op) { binop_to_str(op) + ~"=" } /* Structural symbols */ - AT { "@" } - DOT { "." } - ELLIPSIS { "..." } - COMMA { "," } - SEMI { "" } - COLON { ":" } - MOD_SEP { "::" } - RARROW { "->" } - LARROW { "<-" } - DARROW { "<->" } - FAT_ARROW { "=>" } - LPAREN { "(" } - RPAREN { ")" } - LBRACKET { "[" } - RBRACKET { "]" } - LBRACE { "{" } - RBRACE { "}" } - POUND { "#" } - DOLLAR { "$" } + AT { ~"@" } + DOT { ~"." } + ELLIPSIS { ~"..." } + COMMA { ~"," } + SEMI { ~"" } + COLON { ~":" } + MOD_SEP { ~"::" } + RARROW { ~"->" } + LARROW { ~"<-" } + DARROW { ~"<->" } + FAT_ARROW { ~"=>" } + LPAREN { ~"(" } + RPAREN { ~")" } + LBRACKET { ~"[" } + RBRACKET { ~"]" } + LBRACE { ~"{" } + RBRACE { ~"}" } + POUND { ~"#" } + DOLLAR { ~"$" } /* Literals */ LIT_INT(c, ast::ty_char) { - "'" + char::escape_default(c as char) + "'" + ~"'" + char::escape_default(c as char) + ~"'" } LIT_INT(i, t) { int::to_str(i as int, 10u) + ast_util::int_ty_to_str(t) @@ -170,28 +170,28 @@ fn to_str(in: interner<@str/~>, t: token) -> str { ast_util::float_ty_to_str(t) } LIT_STR(s) { - "\"" + ~"\"" + str::escape_default(*interner::get(in, s)) - + "\"" + + ~"\"" } /* Name components */ IDENT(s, _) { *interner::get(in, s) } - UNDERSCORE { "_" } + UNDERSCORE { ~"_" } /* Other */ DOC_COMMENT(s) { *interner::get(in, s) } - EOF { "" } + EOF { ~"" } ACTUALLY(w_nt) { - "an interpolated " + + ~"an interpolated " + alt w_nt { - w_item(*) { "item" } w_block(*) { "block" } - w_stmt(*) { "statement" } w_pat(*) { "pattern" } - w_expr(*) { "expression" } w_ty(*) { "type" } - w_ident(*) { "identifier" } w_path(*) { "path" } - w_tt(*) { "tt" } w_mtcs(*) { "matcher sequence" } + w_item(*) { ~"item" } w_block(*) { ~"block" } + w_stmt(*) { ~"statement" } w_pat(*) { ~"pattern" } + w_expr(*) { ~"expression" } w_ty(*) { ~"type" } + w_ident(*) { ~"identifier" } w_path(*) { ~"path" } + w_tt(*) { ~"tt" } w_mtcs(*) { ~"matcher sequence" } } } } @@ -256,7 +256,7 @@ fn is_lit(t: token) -> bool { * the grammar is unambiguous. Restricted keywords may not appear * in positions that might otherwise contain _value identifiers_. */ -fn keyword_table() -> hashmap { +fn keyword_table() -> hashmap<~str, ()> { let keywords = str_hash(); for contextual_keyword_table().each_key |word| { keywords.insert(word, ()); @@ -268,18 +268,18 @@ fn keyword_table() -> hashmap { } /// Keywords that may be used as identifiers -fn contextual_keyword_table() -> hashmap { +fn contextual_keyword_table() -> hashmap<~str, ()> { let words = str_hash(); let keys = ~[ - "as", - "else", - "move", - "of", - "priv", "pub", - "self", "send", "static", - "to", - "use", - "with" + ~"as", + ~"else", + ~"move", + ~"of", + ~"priv", ~"pub", + ~"self", ~"send", ~"static", + ~"to", + ~"use", + ~"with" ]; for keys.each |word| { words.insert(word, ()); @@ -301,23 +301,23 @@ fn contextual_keyword_table() -> hashmap { * * `true` or `false` as identifiers would always be shadowed by * the boolean constants */ -fn restricted_keyword_table() -> hashmap { +fn restricted_keyword_table() -> hashmap<~str, ()> { let words = str_hash(); let keys = ~[ - "alt", "again", "assert", - "break", - "check", "claim", "class", "const", "copy", - "do", "drop", - "else", "enum", "export", "extern", - "fail", "false", "fn", "for", - "if", "iface", "impl", "import", - "let", "log", "loop", - "mod", "mut", - "new", - "pure", "ret", - "true", "trait", "type", - "unchecked", "unsafe", - "while" + ~"alt", ~"again", ~"assert", + ~"break", + ~"check", ~"claim", ~"class", ~"const", ~"copy", + ~"do", ~"drop", + ~"else", ~"enum", ~"export", ~"extern", + ~"fail", ~"false", ~"fn", ~"for", + ~"if", ~"iface", ~"impl", ~"import", + ~"let", ~"log", ~"loop", + ~"mod", ~"mut", + ~"new", + ~"pure", ~"ret", + ~"true", ~"trait", ~"type", + ~"unchecked", ~"unsafe", + ~"while" ]; for keys.each |word| { words.insert(word, ()); diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 09754d27e67b..1a318d53635e 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -59,33 +59,33 @@ enum breaks { consistent, inconsistent, } type begin_t = {offset: int, breaks: breaks}; -enum token { STRING(@str/~, int), BREAK(break_t), BEGIN(begin_t), END, EOF, } +enum token { STRING(@~str, int), BREAK(break_t), BEGIN(begin_t), END, EOF, } -fn tok_str(++t: token) -> str { +fn tok_str(++t: token) -> ~str { alt t { STRING(s, len) { ret #fmt["STR(%s,%d)", *s, len]; } - BREAK(_) { ret "BREAK"; } - BEGIN(_) { ret "BEGIN"; } - END { ret "END"; } - EOF { ret "EOF"; } + BREAK(_) { ret ~"BREAK"; } + BEGIN(_) { ret ~"BEGIN"; } + END { ret ~"END"; } + EOF { ret ~"EOF"; } } } fn buf_str(toks: ~[mut token], szs: ~[mut int], left: uint, right: uint, - lim: uint) -> str { + lim: uint) -> ~str { let n = vec::len(toks); assert (n == vec::len(szs)); let mut i = left; let mut L = lim; - let mut s = "["; + let mut s = ~"["; while i != right && L != 0u { L -= 1u; - if i != left { s += ", "; } + if i != left { s += ~", "; } s += #fmt["%d=%s", szs[i], tok_str(toks[i])]; i += 1u; i %= n; } - s += "]"; + s += ~"]"; ret s; } @@ -389,7 +389,7 @@ fn check_stack(k: int) { } fn print_newline(amount: int) { #debug("NEWLINE %d", amount); - self.out.write_str("\n"); + self.out.write_str(~"\n"); self.pending_indentation = 0; self.indent(amount); } @@ -405,9 +405,9 @@ fn get_top() -> print_stack_elt { {offset: 0, pbreak: broken(inconsistent)} } } - fn write_str(s: str) { + fn write_str(s: ~str) { while self.pending_indentation > 0 { - self.out.write_str(" "); + self.out.write_str(~" "); self.pending_indentation -= 1; } self.out.write_str(s); @@ -492,15 +492,15 @@ fn break_offset(p: printer, n: uint, off: int) { fn eof(p: printer) { p.pretty_print(EOF); } -fn word(p: printer, wrd: str) { +fn word(p: printer, wrd: ~str) { p.pretty_print(STRING(@wrd, str::len(wrd) as int)); } -fn huge_word(p: printer, wrd: str) { +fn huge_word(p: printer, wrd: ~str) { p.pretty_print(STRING(@wrd, size_infinity)); } -fn zero_word(p: printer, wrd: str) { p.pretty_print(STRING(@wrd, 0)); } +fn zero_word(p: printer, wrd: ~str) { p.pretty_print(STRING(@wrd, 0)); } fn spaces(p: printer, n: uint) { break_offset(p, n, 0); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c802e40dd053..29da51ec0839 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -64,7 +64,7 @@ fn rust_printer(writer: io::writer) -> ps { // it can scan the input text for comments and literals to // copy forward. fn print_crate(cm: codemap, span_diagnostic: diagnostic::span_handler, - crate: @ast::crate, filename: str, in: io::reader, + crate: @ast::crate, filename: ~str, in: io::reader, out: io::writer, ann: pp_ann, is_expanded: bool) { let r = comments::gather_comments_and_literals(span_diagnostic, filename, in); @@ -89,28 +89,28 @@ fn print_crate_(s: ps, &&crate: @ast::crate) { eof(s.s); } -fn ty_to_str(ty: @ast::ty) -> str { ret to_str(ty, print_type); } +fn ty_to_str(ty: @ast::ty) -> ~str { ret to_str(ty, print_type); } -fn pat_to_str(pat: @ast::pat) -> str { ret to_str(pat, print_pat); } +fn pat_to_str(pat: @ast::pat) -> ~str { ret to_str(pat, print_pat); } -fn expr_to_str(e: @ast::expr) -> str { ret to_str(e, print_expr); } +fn expr_to_str(e: @ast::expr) -> ~str { ret to_str(e, print_expr); } -fn stmt_to_str(s: ast::stmt) -> str { ret to_str(s, print_stmt); } +fn stmt_to_str(s: ast::stmt) -> ~str { ret to_str(s, print_stmt); } -fn item_to_str(i: @ast::item) -> str { ret to_str(i, print_item); } +fn item_to_str(i: @ast::item) -> ~str { ret to_str(i, print_item); } -fn attr_to_str(i: ast::attribute) -> str { ret to_str(i, print_attribute); } +fn attr_to_str(i: ast::attribute) -> ~str { ret to_str(i, print_attribute); } -fn typarams_to_str(tps: ~[ast::ty_param]) -> str { +fn typarams_to_str(tps: ~[ast::ty_param]) -> ~str { ret to_str(tps, print_type_params) } -fn path_to_str(&&p: @ast::path) -> str { +fn path_to_str(&&p: @ast::path) -> ~str { ret to_str(p, |a,b| print_path(a, b, false)); } fn fun_to_str(decl: ast::fn_decl, name: ast::ident, - params: ~[ast::ty_param]) -> str { + params: ~[ast::ty_param]) -> ~str { let buffer = io::mem_buffer(); let s = rust_printer(io::mem_buffer_writer(buffer)); print_fn(s, decl, name, params); @@ -134,7 +134,7 @@ fn test_fun_to_str() { assert fun_to_str(decl, "a", ~[]) == "fn a()"; } -fn block_to_str(blk: ast::blk) -> str { +fn block_to_str(blk: ast::blk) -> ~str { let buffer = io::mem_buffer(); let s = rust_printer(io::mem_buffer_writer(buffer)); // containing cbox, will be closed by print-block at } @@ -146,15 +146,15 @@ fn block_to_str(blk: ast::blk) -> str { io::mem_buffer_str(buffer) } -fn meta_item_to_str(mi: ast::meta_item) -> str { +fn meta_item_to_str(mi: ast::meta_item) -> ~str { ret to_str(@mi, print_meta_item); } -fn attribute_to_str(attr: ast::attribute) -> str { +fn attribute_to_str(attr: ast::attribute) -> ~str { ret to_str(attr, print_attribute); } -fn variant_to_str(var: ast::variant) -> str { +fn variant_to_str(var: ast::variant) -> ~str { ret to_str(var, print_variant); } @@ -182,17 +182,17 @@ fn box(s: ps, u: uint, b: pp::breaks) { pp::box(s.s, u, b); } -fn nbsp(s: ps) { word(s.s, " "); } +fn nbsp(s: ps) { word(s.s, ~" "); } -fn word_nbsp(s: ps, w: str) { word(s.s, w); nbsp(s); } +fn word_nbsp(s: ps, w: ~str) { word(s.s, w); nbsp(s); } -fn word_space(s: ps, w: str) { word(s.s, w); space(s.s); } +fn word_space(s: ps, w: ~str) { word(s.s, w); space(s.s); } -fn popen(s: ps) { word(s.s, "("); } +fn popen(s: ps) { word(s.s, ~"("); } -fn pclose(s: ps) { word(s.s, ")"); } +fn pclose(s: ps) { word(s.s, ~")"); } -fn head(s: ps, w: str) { +fn head(s: ps, w: ~str) { // outer-box is consistent cbox(s, indent_unit); // head-box is inconsistent @@ -202,14 +202,14 @@ fn head(s: ps, w: str) { } fn bopen(s: ps) { - word(s.s, "{"); + word(s.s, ~"{"); end(s); // close the head-box } fn bclose_(s: ps, span: codemap::span, indented: uint) { maybe_print_comment(s, span.hi); break_offset_if_not_bol(s, 1u, -(indented as int)); - word(s.s, "}"); + word(s.s, ~"}"); end(s); // close the outer-box } fn bclose(s: ps, span: codemap::span) { bclose_(s, span, indent_unit); } @@ -250,19 +250,19 @@ fn break_offset_if_not_bol(s: ps, n: uint, off: int) { // Synthesizes a comment that was not textually present in the original source // file. -fn synth_comment(s: ps, text: str) { - word(s.s, "/*"); +fn synth_comment(s: ps, text: ~str) { + word(s.s, ~"/*"); space(s.s); word(s.s, text); space(s.s); - word(s.s, "*/"); + word(s.s, ~"*/"); } fn commasep(s: ps, b: breaks, elts: ~[IN], op: fn(ps, IN)) { box(s, 0u, b); let mut first = true; for elts.each |elt| { - if first { first = false; } else { word_space(s, ","); } + if first { first = false; } else { word_space(s, ~","); } op(s, elt); } end(s); @@ -279,7 +279,7 @@ fn commasep_cmnt(s: ps, b: breaks, elts: ~[IN], op: fn(ps, IN), op(s, elt); i += 1u; if i < len { - word(s.s, ","); + word(s.s, ~","); maybe_print_trailing_comment(s, get_span(elt), some(get_span(elts[i]).hi)); space_if_not_bol(s); @@ -312,9 +312,9 @@ fn print_foreign_mod(s: ps, nmod: ast::foreign_mod, fn print_region(s: ps, region: @ast::region) { alt region.node { - ast::re_anon { word_space(s, "&"); } + ast::re_anon { word_space(s, ~"&"); } ast::re_named(name) { - word(s.s, "&"); + word(s.s, ~"&"); word(s.s, *name); } } @@ -328,41 +328,41 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) { maybe_print_comment(s, ty.span.lo); ibox(s, 0u); alt ty.node { - ast::ty_nil { word(s.s, "()"); } - ast::ty_bot { word(s.s, "!"); } - ast::ty_box(mt) { word(s.s, "@"); print_mt(s, mt); } - ast::ty_uniq(mt) { word(s.s, "~"); print_mt(s, mt); } + ast::ty_nil { word(s.s, ~"()"); } + ast::ty_bot { word(s.s, ~"!"); } + ast::ty_box(mt) { word(s.s, ~"@"); print_mt(s, mt); } + ast::ty_uniq(mt) { word(s.s, ~"~"); print_mt(s, mt); } ast::ty_vec(mt) { - word(s.s, "["); + word(s.s, ~"["); alt mt.mutbl { - ast::m_mutbl { word_space(s, "mut"); } - ast::m_const { word_space(s, "const"); } + ast::m_mutbl { word_space(s, ~"mut"); } + ast::m_const { word_space(s, ~"const"); } ast::m_imm { } } print_type(s, mt.ty); - word(s.s, "]"); + word(s.s, ~"]"); } - ast::ty_ptr(mt) { word(s.s, "*"); print_mt(s, mt); } + ast::ty_ptr(mt) { word(s.s, ~"*"); print_mt(s, mt); } ast::ty_rptr(region, mt) { alt region.node { - ast::re_anon { word(s.s, "&"); } - _ { print_region(s, region); word(s.s, "."); } + ast::re_anon { word(s.s, ~"&"); } + _ { print_region(s, region); word(s.s, ~"."); } } print_mt(s, mt); } ast::ty_rec(fields) { - word(s.s, "{"); + word(s.s, ~"{"); fn print_field(s: ps, f: ast::ty_field) { cbox(s, indent_unit); print_mutability(s, f.node.mt.mutbl); word(s.s, *f.node.ident); - word_space(s, ":"); + word_space(s, ~":"); print_type(s, f.node.mt.ty); end(s); } fn get_span(f: ast::ty_field) -> codemap::span { ret f.span; } commasep_cmnt(s, consistent, fields, print_field, get_span); - word(s.s, ",}"); + word(s.s, ~",}"); } ast::ty_tup(elts) { popen(s); @@ -379,26 +379,23 @@ fn print_field(s: ps, f: ast::ty_field) { word(s.s, constrs_str(cs, ty_constr_to_str)); } ast::ty_vstore(t, v) { - // If it is a vector, print it in prefix notation. - // Someday it will all be like this. - let is_fixed = alt v { ast::vstore_fixed(_) { true } _ { false } }; - alt t.node { - ast::ty_vec(*) if !is_fixed { - print_vstore(s, v); + alt v { + ast::vstore_fixed(_) { print_type(s, t); + word(s.s, ~"/"); + print_vstore(s, v); } _ { - print_type(s, t); - word(s.s, "/"); print_vstore(s, v); + print_type(s, t); } } } ast::ty_mac(_) { - fail "print_type doesn't know how to print a ty_mac"; + fail ~"print_type doesn't know how to print a ty_mac"; } ast::ty_infer { - fail "print_type shouldn't see a ty_infer"; + fail ~"print_type shouldn't see a ty_infer"; } } @@ -413,7 +410,7 @@ fn print_foreign_item(s: ps, item: @ast::foreign_item) { ast::foreign_item_fn(decl, typarams) { print_fn(s, decl, item.ident, typarams); end(s); // end head-ibox - word(s.s, ";"); + word(s.s, ~";"); end(s); // end the outer fn box } } @@ -427,33 +424,33 @@ fn print_item(s: ps, &&item: @ast::item) { s.ann.pre(ann_node); alt item.node { ast::item_const(ty, expr) { - head(s, "const"); - word_space(s, *item.ident + ":"); + head(s, ~"const"); + word_space(s, *item.ident + ~":"); print_type(s, ty); space(s.s); end(s); // end the head-ibox - word_space(s, "="); + word_space(s, ~"="); print_expr(s, expr); - word(s.s, ";"); + word(s.s, ~";"); end(s); // end the outer cbox } ast::item_fn(decl, typarams, body) { print_fn(s, decl, item.ident, typarams); - word(s.s, " "); + word(s.s, ~" "); print_block_with_attrs(s, body, item.attrs); } ast::item_mod(_mod) { - head(s, "mod"); + head(s, ~"mod"); word_nbsp(s, *item.ident); bopen(s); print_mod(s, _mod, item.attrs); bclose(s, item.span); } ast::item_foreign_mod(nmod) { - head(s, "extern"); - word_nbsp(s, "mod"); + head(s, ~"extern"); + word_nbsp(s, ~"mod"); word_nbsp(s, *item.ident); bopen(s); print_foreign_mod(s, nmod, item.attrs); @@ -462,15 +459,15 @@ fn print_item(s: ps, &&item: @ast::item) { ast::item_ty(ty, params) { ibox(s, indent_unit); ibox(s, 0u); - word_nbsp(s, "type"); + word_nbsp(s, ~"type"); word(s.s, *item.ident); print_type_params(s, params); end(s); // end the inner ibox space(s.s); - word_space(s, "="); + word_space(s, ~"="); print_type(s, ty); - word(s.s, ";"); + word(s.s, ~";"); end(s); // end the outer ibox } ast::item_enum(variants, params) { @@ -480,15 +477,15 @@ fn print_item(s: ps, &&item: @ast::item) { vec::len(variants[0].node.args) == 1u; if newtype { ibox(s, indent_unit); - word_space(s, "enum"); - } else { head(s, "enum"); } + word_space(s, ~"enum"); + } else { head(s, ~"enum"); } word(s.s, *item.ident); print_type_params(s, params); space(s.s); if newtype { - word_space(s, "="); + word_space(s, ~"="); print_type(s, variants[0].node.args[0].ty); - word(s.s, ";"); + word(s.s, ~";"); end(s); } else { bopen(s); @@ -498,7 +495,7 @@ fn print_item(s: ps, &&item: @ast::item) { print_outer_attributes(s, v.node.attrs); ibox(s, indent_unit); print_variant(s, v); - word(s.s, ","); + word(s.s, ~","); end(s); maybe_print_trailing_comment(s, v.span, none::); } @@ -506,25 +503,25 @@ fn print_item(s: ps, &&item: @ast::item) { } } ast::item_class(tps, traits, items, ctor, m_dtor) { - head(s, "class"); + head(s, ~"class"); word_nbsp(s, *item.ident); print_type_params(s, tps); if vec::len(traits) != 0u { - word_space(s, ":"); + word_space(s, ~":"); commasep(s, inconsistent, traits, |s, p| print_path(s, p.path, false)); } bopen(s); hardbreak_if_not_bol(s); maybe_print_comment(s, ctor.span.lo); - head(s, "new"); + head(s, ~"new"); print_fn_args_and_ret(s, ctor.node.dec, ~[]); space(s.s); print_block(s, ctor.node.body); do option::iter(m_dtor) |dtor| { hardbreak_if_not_bol(s); maybe_print_comment(s, dtor.span.lo); - head(s, "drop"); + head(s, ~"drop"); print_block(s, dtor.node.body); } for items.each |ci| { @@ -540,7 +537,7 @@ fn print_item(s: ps, &&item: @ast::item) { let pr = ast_util::class_member_visibility(ci); alt pr { ast::private { - head(s, "priv"); + head(s, ~"priv"); bopen(s); hardbreak_if_not_bol(s); } @@ -548,15 +545,15 @@ fn print_item(s: ps, &&item: @ast::item) { } alt ci.node { ast::instance_var(nm, t, mt, _,_) { - word_nbsp(s, "let"); + word_nbsp(s, ~"let"); alt mt { - ast::class_mutable { word_nbsp(s, "mut"); } + ast::class_mutable { word_nbsp(s, ~"mut"); } _ {} } word(s.s, *nm); - word_nbsp(s, ":"); + word_nbsp(s, ~":"); print_type(s, t); - word(s.s, ";"); + word(s.s, ~";"); } ast::class_method(m) { print_method(s, m); @@ -570,16 +567,16 @@ fn print_item(s: ps, &&item: @ast::item) { bclose(s, item.span); } ast::item_impl(tps, ifce, ty, methods) { - head(s, "impl"); + head(s, ~"impl"); word(s.s, *item.ident); print_type_params(s, tps); space(s.s); option::iter(ifce, |p| { - word_nbsp(s, "of"); + word_nbsp(s, ~"of"); print_path(s, p.path, false); space(s.s); }); - word_nbsp(s, "for"); + word_nbsp(s, ~"for"); print_type(s, ty); space(s.s); bopen(s); @@ -589,10 +586,10 @@ fn print_item(s: ps, &&item: @ast::item) { bclose(s, item.span); } ast::item_trait(tps, methods) { - head(s, "iface"); + head(s, ~"iface"); word(s.s, *item.ident); print_type_params(s, tps); - word(s.s, " "); + word(s.s, ~" "); bopen(s); for methods.each |meth| { print_trait_method(s, meth); } bclose(s, item.span); @@ -605,7 +602,7 @@ fn print_item(s: ps, &&item: @ast::item) { bclose(s, item.span); } ast::item_mac(_) { - fail "invalid item-position syntax bit" + fail ~"invalid item-position syntax bit" } } s.ann.post(ann_node); @@ -617,7 +614,7 @@ fn print_item(s: ps, &&item: @ast::item) { /// A prettier option would involve scraping the macro grammar for formatting /// advice. But that would be hard. fn print_tt(_s: ps, _tt: ast::token_tree) { - fail "token trees cannot be pretty-printed" + fail ~"token trees cannot be pretty-printed" } fn print_variant(s: ps, v: ast::variant) { @@ -633,7 +630,7 @@ fn print_variant_arg(s: ps, arg: ast::variant_arg) { alt v.node.disr_expr { some(d) { space(s.s); - word_space(s, "="); + word_space(s, ~"="); print_expr(s, d); } _ {} @@ -645,7 +642,7 @@ fn print_ty_method(s: ps, m: ast::ty_method) { maybe_print_comment(s, m.span.lo); print_outer_attributes(s, m.attrs); print_ty_fn(s, none, m.decl, some(m.ident), some(m.tps)); - word(s.s, ";"); + word(s.s, ~";"); } fn print_trait_method(s: ps, m: ast::trait_method) { @@ -660,7 +657,7 @@ fn print_method(s: ps, meth: @ast::method) { maybe_print_comment(s, meth.span.lo); print_outer_attributes(s, meth.attrs); print_fn(s, meth.decl, meth.ident, meth.tps); - word(s.s, " "); + word(s.s, ~" "); print_block_with_attrs(s, meth.body, meth.attrs); } @@ -682,7 +679,7 @@ fn print_inner_attributes(s: ps, attrs: ~[ast::attribute]) { ast::attr_inner { print_attribute(s, attr); if !attr.node.is_sugared_doc { - word(s.s, ";"); + word(s.s, ~";"); } count += 1; } @@ -700,9 +697,9 @@ fn print_attribute(s: ps, attr: ast::attribute) { let comment = attr::get_meta_item_value_str(meta).get(); word(s.s, *comment); } else { - word(s.s, "#["); + word(s.s, ~"#["); print_meta_item(s, @attr.node.value); - word(s.s, "]"); + word(s.s, ~"]"); } } @@ -720,10 +717,10 @@ fn print_stmt(s: ps, st: ast::stmt) { ast::stmt_semi(expr, _) { space_if_not_bol(s); print_expr(s, expr); - word(s.s, ";"); + word(s.s, ~";"); } } - if parse::classify::stmt_ends_with_semi(st) { word(s.s, ";"); } + if parse::classify::stmt_ends_with_semi(st) { word(s.s, ~";"); } maybe_print_trailing_comment(s, st.span, none::); } @@ -746,15 +743,15 @@ fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type, fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, indented: uint, attrs: ~[ast::attribute]) { alt blk.node.rules { - ast::unchecked_blk { word(s.s, "unchecked"); } - ast::unsafe_blk { word(s.s, "unsafe"); } + ast::unchecked_blk { word(s.s, ~"unchecked"); } + ast::unsafe_blk { word(s.s, ~"unsafe"); } ast::default_blk { } } maybe_print_comment(s, blk.span.lo); let ann_node = node_block(s, blk); s.ann.pre(ann_node); alt embedded { - block_macro { word(s.s, "#{"); end(s); } + block_macro { word(s.s, ~"#{"); end(s); } block_block_fn { end(s); } block_normal { bopen(s); } } @@ -791,8 +788,8 @@ fn print_maybe_parens_discrim(s: ps, e: @ast::expr) { fn print_if(s: ps, test: @ast::expr, blk: ast::blk, elseopt: option<@ast::expr>, chk: bool) { - head(s, "if"); - if chk { word_nbsp(s, "check"); } + head(s, ~"if"); + if chk { word_nbsp(s, ~"check"); } print_maybe_parens_discrim(s, test); space(s.s); print_block(s, blk); @@ -804,7 +801,7 @@ fn do_else(s: ps, els: option<@ast::expr>) { ast::expr_if(i, t, e) { cbox(s, indent_unit - 1u); ibox(s, 0u); - word(s.s, " else if "); + word(s.s, ~" else if "); print_maybe_parens_discrim(s, i); space(s.s); print_block(s, t); @@ -814,12 +811,12 @@ fn do_else(s: ps, els: option<@ast::expr>) { ast::expr_block(b) { cbox(s, indent_unit - 1u); ibox(s, 0u); - word(s.s, " else "); + word(s.s, ~" else "); print_block(s, b); } // BLEAH, constraints would be great here _ { - fail "print_if saw if with weird alternative"; + fail ~"print_if saw if with weird alternative"; } } } @@ -832,31 +829,31 @@ fn do_else(s: ps, els: option<@ast::expr>) { fn print_mac(s: ps, m: ast::mac) { alt m.node { ast::mac_invoc(path, arg, body) { - word(s.s, "#"); + word(s.s, ~"#"); print_path(s, path, false); alt arg { some(@{node: ast::expr_vec(_, _), _}) { } - _ { word(s.s, " "); } + _ { word(s.s, ~" "); } } option::iter(arg, |a| print_expr(s, a)); // FIXME: extension 'body' (#2339) } ast::mac_invoc_tt(path, tts) { print_path(s, path, false); - word(s.s, "!"); + word(s.s, ~"!"); bopen(s); for tts.each() |tt| { print_tt(s, tt); } bclose(s, m.span); } ast::mac_embed_type(ty) { - word(s.s, "#<"); + word(s.s, ~"#<"); print_type(s, ty); - word(s.s, ">"); + word(s.s, ~">"); } ast::mac_embed_block(blk) { print_possibly_embedded_block(s, blk, block_normal, indent_unit); } - ast::mac_ellipsis { word(s.s, "..."); } + ast::mac_ellipsis { word(s.s, ~"..."); } ast::mac_var(v) { word(s.s, #fmt("$%u", v)); } _ { /* fixme */ } } @@ -865,16 +862,16 @@ fn print_mac(s: ps, m: ast::mac) { fn print_vstore(s: ps, t: ast::vstore) { alt t { ast::vstore_fixed(some(i)) { word(s.s, #fmt("%u", i)); } - ast::vstore_fixed(none) { word(s.s, "_"); } - ast::vstore_uniq { word(s.s, "~"); } - ast::vstore_box { word(s.s, "@"); } + ast::vstore_fixed(none) { word(s.s, ~"_"); } + ast::vstore_uniq { word(s.s, ~"~"); } + ast::vstore_box { word(s.s, ~"@"); } ast::vstore_slice(r) { alt r.node { - ast::re_anon { word(s.s, "&"); } + ast::re_anon { word(s.s, ~"&"); } ast::re_named(name) { - word(s.s, "&"); + word(s.s, ~"&"); word(s.s, *name); - word(s.s, "."); + word(s.s, ~"."); } } } @@ -888,55 +885,52 @@ fn print_expr(s: ps, &&expr: @ast::expr) { s.ann.pre(ann_node); alt expr.node { ast::expr_vstore(e, v) { - // If it is a vector, print it in prefix notation. - // Someday it will all be like this. - let is_fixed = alt v { ast::vstore_fixed(_) { true } _ { false } }; - alt e.node { - ast::expr_vec(*) if !is_fixed { - print_vstore(s, v); + alt v { + ast::vstore_fixed(_) { print_expr(s, e); + word(s.s, ~"/"); + print_vstore(s, v); } _ { - print_expr(s, e); - word(s.s, "/"); print_vstore(s, v); + print_expr(s, e); } } } ast::expr_vec(exprs, mutbl) { ibox(s, indent_unit); - word(s.s, "["); + word(s.s, ~"["); if mutbl == ast::m_mutbl { - word(s.s, "mut"); + word(s.s, ~"mut"); if vec::len(exprs) > 0u { nbsp(s); } } commasep_exprs(s, inconsistent, exprs); - word(s.s, "]"); + word(s.s, ~"]"); end(s); } ast::expr_rec(fields, wth) { fn print_field(s: ps, field: ast::field) { ibox(s, indent_unit); - if field.node.mutbl == ast::m_mutbl { word_nbsp(s, "mut"); } + if field.node.mutbl == ast::m_mutbl { word_nbsp(s, ~"mut"); } word(s.s, *field.node.ident); - word_space(s, ":"); + word_space(s, ~":"); print_expr(s, field.node.expr); end(s); } fn get_span(field: ast::field) -> codemap::span { ret field.span; } - word(s.s, "{"); + word(s.s, ~"{"); commasep_cmnt(s, consistent, fields, print_field, get_span); alt wth { some(expr) { if vec::len(fields) > 0u { space(s.s); } ibox(s, indent_unit); - word_space(s, "with"); + word_space(s, ~"with"); print_expr(s, expr); end(s); } - _ { word(s.s, ","); } + _ { word(s.s, ~","); } } - word(s.s, "}"); + word(s.s, ~"}"); } ast::expr_tup(exprs) { popen(s); @@ -948,8 +942,8 @@ fn print_field(s: ps, field: ast::field) { let blk = if has_block { let blk_arg = vec::pop(base_args); alt blk_arg.node { - ast::expr_loop_body(_) { word_nbsp(s, "for"); } - ast::expr_do_body(_) { word_nbsp(s, "do"); } + ast::expr_loop_body(_) { word_nbsp(s, ~"for"); } + ast::expr_do_body(_) { word_nbsp(s, ~"do"); } _ {} } some(blk_arg) @@ -977,7 +971,7 @@ fn print_field(s: ps, field: ast::field) { print_op_maybe_parens(s, expr, parse::prec::unop_prec); } ast::expr_addr_of(m, expr) { - word(s.s, "&"); + word(s.s, ~"&"); print_mutability(s, m); print_expr(s, expr); } @@ -985,7 +979,7 @@ fn print_field(s: ps, field: ast::field) { ast::expr_cast(expr, ty) { print_op_maybe_parens(s, expr, parse::prec::as_prec); space(s.s); - word_space(s, "as"); + word_space(s, ~"as"); print_type_ex(s, ty, true); } ast::expr_if(test, blk, elseopt) { @@ -995,21 +989,21 @@ fn print_field(s: ps, field: ast::field) { print_if(s, test, blk, elseopt, true); } ast::expr_while(test, blk) { - head(s, "while"); + head(s, ~"while"); print_maybe_parens_discrim(s, test); space(s.s); print_block(s, blk); } ast::expr_loop(blk) { - head(s, "loop"); + head(s, ~"loop"); space(s.s); print_block(s, blk); } ast::expr_alt(expr, arms, mode) { cbox(s, alt_indent_unit); ibox(s, 4u); - word_nbsp(s, "alt"); - if mode == ast::alt_check { word_nbsp(s, "check"); } + word_nbsp(s, ~"alt"); + if mode == ast::alt_check { word_nbsp(s, ~"check"); } print_maybe_parens_discrim(s, expr); space(s.s); bopen(s); @@ -1021,12 +1015,12 @@ fn print_field(s: ps, field: ast::field) { for arm.pats.each |p| { if first { first = false; - } else { space(s.s); word_space(s, "|"); } + } else { space(s.s); word_space(s, ~"|"); } print_pat(s, p); } space(s.s); alt arm.guard { - some(e) { word_space(s, "if"); print_expr(s, e); space(s.s); } + some(e) { word_space(s, ~"if"); print_expr(s, e); space(s.s); } none { } } print_possibly_embedded_block(s, arm.body, block_normal, @@ -1066,30 +1060,30 @@ fn print_field(s: ps, field: ast::field) { ibox(s, 0u); print_block(s, blk); } - ast::expr_copy(e) { word_space(s, "copy"); print_expr(s, e); } + ast::expr_copy(e) { word_space(s, ~"copy"); print_expr(s, e); } ast::expr_move(lhs, rhs) { print_expr(s, lhs); space(s.s); - word_space(s, "<-"); + word_space(s, ~"<-"); print_expr(s, rhs); } ast::expr_assign(lhs, rhs) { print_expr(s, lhs); space(s.s); - word_space(s, "="); + word_space(s, ~"="); print_expr(s, rhs); } ast::expr_swap(lhs, rhs) { print_expr(s, lhs); space(s.s); - word_space(s, "<->"); + word_space(s, ~"<->"); print_expr(s, rhs); } ast::expr_assign_op(op, lhs, rhs) { print_expr(s, lhs); space(s.s); word(s.s, ast_util::binop_to_str(op)); - word_space(s, "="); + word_space(s, ~"="); print_expr(s, rhs); } ast::expr_field(expr, id, tys) { @@ -1099,46 +1093,46 @@ fn print_field(s: ps, field: ast::field) { } else { print_expr_parens_if_not_bot(s, expr); } - word(s.s, "."); + word(s.s, ~"."); word(s.s, *id); if vec::len(tys) > 0u { - word(s.s, "::<"); + word(s.s, ~"::<"); commasep(s, inconsistent, tys, print_type); - word(s.s, ">"); + word(s.s, ~">"); } } ast::expr_index(expr, index) { print_expr_parens_if_not_bot(s, expr); - word(s.s, "["); + word(s.s, ~"["); print_expr(s, index); - word(s.s, "]"); + word(s.s, ~"]"); } ast::expr_path(path) { print_path(s, path, true); } ast::expr_fail(maybe_fail_val) { - word(s.s, "fail"); + word(s.s, ~"fail"); alt maybe_fail_val { - some(expr) { word(s.s, " "); print_expr(s, expr); } + some(expr) { word(s.s, ~" "); print_expr(s, expr); } _ { } } } - ast::expr_break { word(s.s, "break"); } - ast::expr_again { word(s.s, "again"); } + ast::expr_break { word(s.s, ~"break"); } + ast::expr_again { word(s.s, ~"again"); } ast::expr_ret(result) { - word(s.s, "ret"); + word(s.s, ~"ret"); alt result { - some(expr) { word(s.s, " "); print_expr(s, expr); } + some(expr) { word(s.s, ~" "); print_expr(s, expr); } _ { } } } ast::expr_log(lvl, lexp, expr) { alt check lvl { - 1 { word_nbsp(s, "log"); print_expr(s, expr); } - 0 { word_nbsp(s, "log_err"); print_expr(s, expr); } + 1 { word_nbsp(s, ~"log"); print_expr(s, expr); } + 0 { word_nbsp(s, ~"log_err"); print_expr(s, expr); } 2 { - word_nbsp(s, "log"); + word_nbsp(s, ~"log"); popen(s); print_expr(s, lexp); - word(s.s, ","); + word(s.s, ~","); space_if_not_bol(s); print_expr(s, expr); pclose(s); @@ -1147,19 +1141,19 @@ fn print_field(s: ps, field: ast::field) { } ast::expr_check(m, expr) { alt m { - ast::claimed_expr { word_nbsp(s, "claim"); } - ast::checked_expr { word_nbsp(s, "check"); } + ast::claimed_expr { word_nbsp(s, ~"claim"); } + ast::checked_expr { word_nbsp(s, ~"check"); } } popen(s); print_expr(s, expr); pclose(s); } ast::expr_assert(expr) { - word_nbsp(s, "assert"); + word_nbsp(s, ~"assert"); print_expr(s, expr); } ast::expr_new(p, _, v) { - word_nbsp(s, "new"); + word_nbsp(s, ~"new"); popen(s); print_expr(s, p); pclose(s); @@ -1192,7 +1186,7 @@ fn print_local_decl(s: ps, loc: @ast::local) { print_pat(s, loc.node.pat); alt loc.node.ty.node { ast::ty_infer { } - _ { word_space(s, ":"); print_type(s, loc.node.ty); } + _ { word_space(s, ~":"); print_type(s, loc.node.ty); } } } @@ -1202,12 +1196,12 @@ fn print_decl(s: ps, decl: @ast::decl) { ast::decl_local(locs) { space_if_not_bol(s); ibox(s, indent_unit); - word_nbsp(s, "let"); + word_nbsp(s, ~"let"); // if any are mut, all are mut if vec::any(locs, |l| l.node.is_mutbl) { assert vec::all(locs, |l| l.node.is_mutbl); - word_nbsp(s, "mut"); + word_nbsp(s, ~"mut"); } fn print_local(s: ps, &&loc: @ast::local) { @@ -1218,8 +1212,8 @@ fn print_local(s: ps, &&loc: @ast::local) { some(init) { nbsp(s); alt init.op { - ast::init_assign { word_space(s, "="); } - ast::init_move { word_space(s, "<-"); } + ast::init_assign { word_space(s, ~"="); } + ast::init_move { word_space(s, ~"<-"); } } print_expr(s, init.expr); } @@ -1238,33 +1232,33 @@ fn print_local(s: ps, &&loc: @ast::local) { fn print_for_decl(s: ps, loc: @ast::local, coll: @ast::expr) { print_local_decl(s, loc); space(s.s); - word_space(s, "in"); + word_space(s, ~"in"); print_expr(s, coll); } fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) { maybe_print_comment(s, path.span.lo); - if path.global { word(s.s, "::"); } + if path.global { word(s.s, ~"::"); } let mut first = true; for path.idents.each |id| { - if first { first = false; } else { word(s.s, "::"); } + if first { first = false; } else { word(s.s, ~"::"); } word(s.s, *id); } if path.rp.is_some() || !path.types.is_empty() { - if colons_before_params { word(s.s, "::"); } + if colons_before_params { word(s.s, ~"::"); } alt path.rp { none { /* ok */ } some(r) { - word(s.s, "/"); + word(s.s, ~"/"); print_region(s, r); } } if !path.types.is_empty() { - word(s.s, "<"); + word(s.s, ~"<"); commasep(s, inconsistent, path.types, print_type); - word(s.s, ">"); + word(s.s, ~">"); } } } @@ -1276,18 +1270,18 @@ fn print_pat(s: ps, &&pat: @ast::pat) { /* Pat isn't normalized, but the beauty of it is that it doesn't matter */ alt pat.node { - ast::pat_wild { word(s.s, "_"); } + ast::pat_wild { word(s.s, ~"_"); } ast::pat_ident(path, sub) { print_path(s, path, true); alt sub { - some(p) { word(s.s, "@"); print_pat(s, p); } + some(p) { word(s.s, ~"@"); print_pat(s, p); } none {} } } ast::pat_enum(path, args_) { print_path(s, path, true); alt args_ { - none { word(s.s, "(*)"); } + none { word(s.s, ~"(*)"); } some(args) { if vec::len(args) > 0u { popen(s); @@ -1298,34 +1292,34 @@ fn print_pat(s: ps, &&pat: @ast::pat) { } } ast::pat_rec(fields, etc) { - word(s.s, "{"); + word(s.s, ~"{"); fn print_field(s: ps, f: ast::field_pat) { cbox(s, indent_unit); word(s.s, *f.ident); - word_space(s, ":"); + word_space(s, ~":"); print_pat(s, f.pat); end(s); } fn get_span(f: ast::field_pat) -> codemap::span { ret f.pat.span; } commasep_cmnt(s, consistent, fields, print_field, get_span); if etc { - if vec::len(fields) != 0u { word_space(s, ","); } - word(s.s, "_"); + if vec::len(fields) != 0u { word_space(s, ~","); } + word(s.s, ~"_"); } - word(s.s, "}"); + word(s.s, ~"}"); } ast::pat_tup(elts) { popen(s); commasep(s, inconsistent, elts, print_pat); pclose(s); } - ast::pat_box(inner) { word(s.s, "@"); print_pat(s, inner); } - ast::pat_uniq(inner) { word(s.s, "~"); print_pat(s, inner); } + ast::pat_box(inner) { word(s.s, ~"@"); print_pat(s, inner); } + ast::pat_uniq(inner) { word(s.s, ~"~"); print_pat(s, inner); } ast::pat_lit(e) { print_expr(s, e); } ast::pat_range(begin, end) { print_expr(s, begin); space(s.s); - word_space(s, "to"); + word_space(s, ~"to"); print_expr(s, end); } } @@ -1335,8 +1329,8 @@ fn print_field(s: ps, f: ast::field_pat) { fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident, typarams: ~[ast::ty_param]) { alt decl.purity { - ast::impure_fn { head(s, "fn") } - _ { head(s, purity_to_str(decl.purity) + " fn") } + ast::impure_fn { head(s, ~"fn") } + _ { head(s, purity_to_str(decl.purity) + ~" fn") } } word(s.s, *name); print_type_params(s, typarams); @@ -1349,9 +1343,9 @@ fn print_fn_args(s: ps, decl: ast::fn_decl, if cap_items.is_not_empty() { let mut first = decl.inputs.is_empty(); for cap_items.each |cap_item| { - if first { first = false; } else { word_space(s, ","); } - if cap_item.is_move { word_nbsp(s, "move") } - else { word_nbsp(s, "copy") } + if first { first = false; } else { word_space(s, ~","); } + if cap_item.is_move { word_nbsp(s, ~"move") } + else { word_nbsp(s, ~"copy") } word(s.s, *cap_item.name); } } @@ -1369,49 +1363,49 @@ fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl, maybe_print_comment(s, decl.output.span.lo); if decl.output.node != ast::ty_nil { space_if_not_bol(s); - word_space(s, "->"); + word_space(s, ~"->"); print_type(s, decl.output); } } fn print_fn_block_args(s: ps, decl: ast::fn_decl, cap_items: ~[ast::capture_item]) { - word(s.s, "|"); + word(s.s, ~"|"); print_fn_args(s, decl, cap_items); - word(s.s, "|"); + word(s.s, ~"|"); if decl.output.node != ast::ty_infer { space_if_not_bol(s); - word_space(s, "->"); + word_space(s, ~"->"); print_type(s, decl.output); } maybe_print_comment(s, decl.output.span.lo); } -fn mode_to_str(m: ast::mode) -> str { +fn mode_to_str(m: ast::mode) -> ~str { alt m { - ast::expl(ast::by_mutbl_ref) { "&" } - ast::expl(ast::by_move) { "-" } - ast::expl(ast::by_ref) { "&&" } - ast::expl(ast::by_val) { "++" } - ast::expl(ast::by_copy) { "+" } - ast::infer(_) { "" } + ast::expl(ast::by_mutbl_ref) { ~"&" } + ast::expl(ast::by_move) { ~"-" } + ast::expl(ast::by_ref) { ~"&&" } + ast::expl(ast::by_val) { ~"++" } + ast::expl(ast::by_copy) { ~"+" } + ast::infer(_) { ~"" } } } fn print_arg_mode(s: ps, m: ast::mode) { let ms = mode_to_str(m); - if ms != "" { word(s.s, ms); } + if ms != ~"" { word(s.s, ms); } } fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) { if vec::len(*bounds) > 0u { - word(s.s, ":"); + word(s.s, ~":"); for vec::each(*bounds) |bound| { nbsp(s); alt bound { - ast::bound_copy { word(s.s, "copy"); } - ast::bound_send { word(s.s, "send"); } - ast::bound_const { word(s.s, "const"); } + ast::bound_copy { word(s.s, ~"copy"); } + ast::bound_send { word(s.s, ~"send"); } + ast::bound_const { word(s.s, ~"const"); } ast::bound_trait(t) { print_type(s, t); } } } @@ -1420,13 +1414,13 @@ fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) { fn print_type_params(s: ps, &¶ms: ~[ast::ty_param]) { if vec::len(params) > 0u { - word(s.s, "<"); + word(s.s, ~"<"); fn printParam(s: ps, param: ast::ty_param) { word(s.s, *param.ident); print_bounds(s, param.bounds); } commasep(s, inconsistent, params, printParam); - word(s.s, ">"); + word(s.s, ~">"); } } @@ -1436,7 +1430,7 @@ fn print_meta_item(s: ps, &&item: @ast::meta_item) { ast::meta_word(name) { word(s.s, *name); } ast::meta_name_value(name, value) { word_space(s, *name); - word_space(s, "="); + word_space(s, ~"="); print_literal(s, @value); } ast::meta_list(name, items) { @@ -1454,23 +1448,23 @@ fn print_view_path(s: ps, &&vp: @ast::view_path) { ast::view_path_simple(ident, path, _) { if path.idents[vec::len(path.idents)-1u] != ident { word_space(s, *ident); - word_space(s, "="); + word_space(s, ~"="); } print_path(s, path, false); } ast::view_path_glob(path, _) { print_path(s, path, false); - word(s.s, "::*"); + word(s.s, ~"::*"); } ast::view_path_list(path, idents, _) { print_path(s, path, false); - word(s.s, "::{"); + word(s.s, ~"::{"); do commasep(s, inconsistent, idents) |s, w| { word(s.s, *w.node.name) } - word(s.s, "}"); + word(s.s, ~"}"); } } } @@ -1485,7 +1479,7 @@ fn print_view_item(s: ps, item: @ast::view_item) { print_outer_attributes(s, item.attrs); alt item.node { ast::view_item_use(id, mta, _) { - head(s, "use"); + head(s, ~"use"); word(s.s, *id); if vec::len(mta) > 0u { popen(s); @@ -1495,16 +1489,16 @@ fn print_view_item(s: ps, item: @ast::view_item) { } ast::view_item_import(vps) { - head(s, "import"); + head(s, ~"import"); print_view_paths(s, vps); } ast::view_item_export(vps) { - head(s, "export"); + head(s, ~"export"); print_view_paths(s, vps); } } - word(s.s, ";"); + word(s.s, ~";"); end(s); // end inner head-block end(s); // end outer head-block } @@ -1518,8 +1512,8 @@ fn print_op_maybe_parens(s: ps, expr: @ast::expr, outer_prec: uint) { fn print_mutability(s: ps, mutbl: ast::mutability) { alt mutbl { - ast::m_mutbl { word_nbsp(s, "mut"); } - ast::m_const { word_nbsp(s, "const"); } + ast::m_mutbl { word_nbsp(s, ~"mut"); } + ast::m_const { word_nbsp(s, ~"const"); } ast::m_imm {/* nothing */ } } } @@ -1538,7 +1532,7 @@ fn print_arg(s: ps, input: ast::arg) { } _ { if str::len(*input.ident) > 0u { - word_space(s, *input.ident + ":"); + word_space(s, *input.ident + ~":"); } print_type(s, input.ty); } @@ -1551,7 +1545,7 @@ fn print_ty_fn(s: ps, opt_proto: option, tps: option<~[ast::ty_param]>) { ibox(s, indent_unit); word(s.s, opt_proto_to_str(opt_proto)); - alt id { some(id) { word(s.s, " "); word(s.s, *id); } _ { } } + alt id { some(id) { word(s.s, ~" "); word(s.s, *id); } _ { } } alt tps { some(tps) { print_type_params(s, tps); } _ { } } zerobreak(s.s); popen(s); @@ -1561,8 +1555,8 @@ fn print_ty_fn(s: ps, opt_proto: option, if decl.output.node != ast::ty_nil { space_if_not_bol(s); ibox(s, indent_unit); - word_space(s, "->"); - if decl.cf == ast::noreturn { word_nbsp(s, "!"); } + word_space(s, ~"->"); + if decl.cf == ast::noreturn { word_nbsp(s, ~"!"); } else { print_type(s, decl.output); } end(s); } @@ -1615,12 +1609,12 @@ fn print_literal(s: ps, &&lit: @ast::lit) { alt lit.node { ast::lit_str(st) { print_string(s, *st); } ast::lit_int(ch, ast::ty_char) { - word(s.s, "'" + char::escape_default(ch as char) + "'"); + word(s.s, ~"'" + char::escape_default(ch as char) + ~"'"); } ast::lit_int(i, t) { if i < 0_i64 { word(s.s, - "-" + u64::to_str(-i as u64, 10u) + ~"-" + u64::to_str(-i as u64, 10u) + ast_util::int_ty_to_str(t)); } else { word(s.s, @@ -1635,7 +1629,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) { } ast::lit_int_unsuffixed(i) { if i < 0_i64 { - word(s.s, "-" + u64::to_str(-i as u64, 10u)); + word(s.s, ~"-" + u64::to_str(-i as u64, 10u)); } else { word(s.s, u64::to_str(i as u64, 10u)); } @@ -1643,14 +1637,14 @@ fn print_literal(s: ps, &&lit: @ast::lit) { ast::lit_float(f, t) { word(s.s, *f + ast_util::float_ty_to_str(t)); } - ast::lit_nil { word(s.s, "()"); } + ast::lit_nil { word(s.s, ~"()"); } ast::lit_bool(val) { - if val { word(s.s, "true"); } else { word(s.s, "false"); } + if val { word(s.s, ~"true"); } else { word(s.s, ~"false"); } } } } -fn lit_to_str(l: @ast::lit) -> str { ret to_str(l, print_literal); } +fn lit_to_str(l: @ast::lit) -> ~str { ret to_str(l, print_literal); } fn next_lit(s: ps, pos: uint) -> option { alt s.literals { @@ -1699,7 +1693,7 @@ fn print_comment(s: ps, cmnt: comments::cmnt) { } } comments::trailing { - word(s.s, " "); + word(s.s, ~" "); if vec::len(cmnt.lines) == 1u { word(s.s, cmnt.lines[0]); hardbreak(s.s); @@ -1716,7 +1710,7 @@ fn print_comment(s: ps, cmnt: comments::cmnt) { // We need to do at least one, possibly two hardbreaks. let is_semi = alt s.s.last_token() { - pp::STRING(s, _) { *s == ";" } + pp::STRING(s, _) { *s == ~";" } _ { false } }; if is_semi || is_begin(s) || is_end(s) { hardbreak(s.s); } @@ -1725,13 +1719,13 @@ fn print_comment(s: ps, cmnt: comments::cmnt) { } } -fn print_string(s: ps, st: str) { - word(s.s, "\""); +fn print_string(s: ps, st: ~str) { + word(s.s, ~"\""); word(s.s, str::escape_default(st)); - word(s.s, "\""); + word(s.s, ~"\""); } -fn to_str(t: T, f: fn@(ps, T)) -> str { +fn to_str(t: T, f: fn@(ps, T)) -> ~str { let buffer = io::mem_buffer(); let s = rust_printer(io::mem_buffer_writer(buffer)); f(s, t); @@ -1750,23 +1744,23 @@ fn next_comment(s: ps) -> option { } } -fn constr_args_to_str(f: fn@(T) -> str, +fn constr_args_to_str(f: fn@(T) -> ~str, args: ~[@ast::sp_constr_arg]) -> - str { + ~str { let mut comma = false; - let mut s = "("; + let mut s = ~"("; for args.each |a| { - if comma { s += ", "; } else { comma = true; } + if comma { s += ~", "; } else { comma = true; } s += constr_arg_to_str::(f, a.node); } - s += ")"; + s += ~")"; ret s; } -fn constr_arg_to_str(f: fn@(T) -> str, c: ast::constr_arg_general_) -> - str { +fn constr_arg_to_str(f: fn@(T) -> ~str, c: ast::constr_arg_general_) -> + ~str { alt c { - ast::carg_base { ret "*"; } + ast::carg_base { ret ~"*"; } ast::carg_ident(i) { ret f(i); } ast::carg_lit(l) { ret lit_to_str(l); } } @@ -1775,53 +1769,55 @@ fn constr_arg_to_str(f: fn@(T) -> str, c: ast::constr_arg_general_) -> // needed b/c constr_args_to_str needs // something that takes an alias // (argh) -fn uint_to_str(&&i: uint) -> str { ret uint::str(i); } +fn uint_to_str(&&i: uint) -> ~str { ret uint::str(i); } -fn ast_ty_fn_constr_to_str(&&c: @ast::constr) -> str { +fn ast_ty_fn_constr_to_str(&&c: @ast::constr) -> ~str { ret path_to_str(c.node.path) + constr_args_to_str(uint_to_str, c.node.args); } -fn ast_fn_constr_to_str(decl: ast::fn_decl, &&c: @ast::constr) -> str { +fn ast_fn_constr_to_str(decl: ast::fn_decl, &&c: @ast::constr) -> ~str { let arg_to_str = |a| fn_arg_idx_to_str(decl, a); ret path_to_str(c.node.path) + constr_args_to_str(arg_to_str, c.node.args); } -fn ty_constr_to_str(&&c: @ast::ty_constr) -> str { - fn ty_constr_path_to_str(&&p: @ast::path) -> str { "*." + path_to_str(p) } +fn ty_constr_to_str(&&c: @ast::ty_constr) -> ~str { + fn ty_constr_path_to_str(&&p: @ast::path) -> ~str { + ~"*." + path_to_str(p) + } ret path_to_str(c.node.path) + constr_args_to_str::<@ast::path>(ty_constr_path_to_str, c.node.args); } -fn constrs_str(constrs: ~[T], elt: fn(T) -> str) -> str { - let mut s = "", colon = true; +fn constrs_str(constrs: ~[T], elt: fn(T) -> ~str) -> ~str { + let mut s = ~"", colon = true; for constrs.each |c| { - if colon { s += " : "; colon = false; } else { s += ", "; } + if colon { s += ~" : "; colon = false; } else { s += ~", "; } s += elt(c); } ret s; } -fn fn_arg_idx_to_str(decl: ast::fn_decl, &&idx: uint) -> str { +fn fn_arg_idx_to_str(decl: ast::fn_decl, &&idx: uint) -> ~str { *decl.inputs[idx].ident } -fn opt_proto_to_str(opt_p: option) -> str { +fn opt_proto_to_str(opt_p: option) -> ~str { alt opt_p { - none { "fn" } + none { ~"fn" } some(p) { proto_to_str(p) } } } -fn purity_to_str(p: ast::purity) -> str { +fn purity_to_str(p: ast::purity) -> ~str { alt p { - ast::impure_fn {"impure"} - ast::unsafe_fn {"unsafe"} - ast::pure_fn {"pure"} - ast::extern_fn {"extern"} + ast::impure_fn {~"impure"} + ast::unsafe_fn {~"unsafe"} + ast::pure_fn {~"pure"} + ast::extern_fn {~"extern"} } } @@ -1832,13 +1828,13 @@ fn print_purity(s: ps, p: ast::purity) { } } -fn proto_to_str(p: ast::proto) -> str { +fn proto_to_str(p: ast::proto) -> ~str { ret alt p { - ast::proto_bare { "extern fn" } - ast::proto_any { "fn" } - ast::proto_block { "fn&" } - ast::proto_uniq { "fn~" } - ast::proto_box { "fn@" } + ast::proto_bare { ~"extern fn" } + ast::proto_any { ~"fn" } + ast::proto_block { ~"fn&" } + ast::proto_uniq { ~"fn~" } + ast::proto_box { ~"fn@" } }; } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index be9f76650daa..6d3c2ba74bc9 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -28,8 +28,8 @@ fn name_of_fn(fk: fn_kind) -> ident { alt fk { fk_item_fn(name, _) | fk_method(name, _, _) | fk_ctor(name, _, _, _) { /* FIXME (#2543) */ copy name } - fk_anon(*) | fk_fn_block(*) { @"anon" } - fk_dtor(*) { @"drop" } + fk_anon(*) | fk_fn_block(*) { @~"anon" } + fk_dtor(*) { @~"drop" } } } diff --git a/src/rustc/back/abi.rs b/src/rustc/back/abi.rs index d6c0c5fa2dd7..8213ff1576e8 100644 --- a/src/rustc/back/abi.rs +++ b/src/rustc/back/abi.rs @@ -66,13 +66,13 @@ const abi_version: uint = 1u; -fn memcpy_glue_name() -> str { ret "rust_memcpy_glue"; } +fn memcpy_glue_name() -> ~str { ret ~"rust_memcpy_glue"; } -fn bzero_glue_name() -> str { ret "rust_bzero_glue"; } +fn bzero_glue_name() -> ~str { ret ~"rust_bzero_glue"; } -fn yield_glue_name() -> str { ret "rust_yield_glue"; } +fn yield_glue_name() -> ~str { ret ~"rust_yield_glue"; } -fn no_op_type_glue_name() -> str { ret "rust_no_op_type_glue"; } +fn no_op_type_glue_name() -> ~str { ret ~"rust_no_op_type_glue"; } // // Local Variables: // mode: rust diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index 089bde357343..22a9150df565 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -25,11 +25,11 @@ enum output_type { output_type_exe, } -fn llvm_err(sess: session, msg: str) -> ! unsafe { +fn llvm_err(sess: session, msg: ~str) -> ! unsafe { let cstr = llvm::LLVMRustGetLastError(); if cstr == ptr::null() { sess.fatal(msg); - } else { sess.fatal(msg + ": " + str::unsafe::from_c_str(cstr)); } + } else { sess.fatal(msg + ~": " + str::unsafe::from_c_str(cstr)); } } mod write { @@ -43,15 +43,16 @@ fn is_object_or_assembly_or_exe(ot: output_type) -> bool { // Decides what to call an intermediate file, given the name of the output // and the extension to use. - fn mk_intermediate_name(output_path: str, extension: str) -> str unsafe { + fn mk_intermediate_name(output_path: ~str, extension: ~str) -> + ~str unsafe { let stem = alt str::find_char(output_path, '.') { some(dot_pos) { str::slice(output_path, 0u, dot_pos) } none { output_path } }; - ret stem + "." + extension; + ret stem + ~"." + extension; } - fn run_passes(sess: session, llmod: ModuleRef, output: str) { + fn run_passes(sess: session, llmod: ModuleRef, output: ~str) { let opts = sess.opts; if sess.time_llvm_passes() { llvm::LLVMRustEnableTimePasses(); } let mut pm = mk_pass_manager(); @@ -68,14 +69,14 @@ fn run_passes(sess: session, llmod: ModuleRef, output: str) { alt opts.output_type { output_type_bitcode { if opts.optimize != 0u { - let filename = mk_intermediate_name(output, "no-opt.bc"); + let filename = mk_intermediate_name(output, ~"no-opt.bc"); str::as_c_str(filename, |buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf) }); } } _ { - let filename = mk_intermediate_name(output, "bc"); + let filename = mk_intermediate_name(output, ~"bc"); str::as_c_str(filename, |buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf) }); @@ -147,7 +148,7 @@ fn run_passes(sess: session, llmod: ModuleRef, output: str) { if opts.save_temps { // Always output the bitcode file with --save-temps - let filename = mk_intermediate_name(output, "opt.bc"); + let filename = mk_intermediate_name(output, ~"opt.bc"); llvm::LLVMRunPassManager(pm.llpm, llmod); str::as_c_str(filename, |buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf) @@ -287,28 +288,28 @@ fn run_passes(sess: session, llmod: ModuleRef, output: str) { * */ -fn build_link_meta(sess: session, c: ast::crate, output: str, +fn build_link_meta(sess: session, c: ast::crate, output: ~str, sha: sha1) -> link_meta { type provided_metas = - {name: option<@str/~>, - vers: option<@str/~>, + {name: option<@~str>, + vers: option<@~str>, cmh_items: ~[@ast::meta_item]}; fn provided_link_metas(sess: session, c: ast::crate) -> provided_metas { - let mut name: option<@str/~> = none; - let mut vers: option<@str/~> = none; + let mut name: option<@~str> = none; + let mut vers: option<@~str> = none; let mut cmh_items: ~[@ast::meta_item] = ~[]; let linkage_metas = attr::find_linkage_metas(c.node.attrs); attr::require_unique_names(sess.diagnostic(), linkage_metas); for linkage_metas.each |meta| { - if *attr::get_meta_item_name(meta) == "name" { + if *attr::get_meta_item_name(meta) == ~"name" { alt attr::get_meta_item_value_str(meta) { some(v) { name = some(v); } none { vec::push(cmh_items, meta); } } - } else if *attr::get_meta_item_name(meta) == "vers" { + } else if *attr::get_meta_item_name(meta) == ~"vers" { alt attr::get_meta_item_value_str(meta) { some(v) { vers = some(v); } none { vec::push(cmh_items, meta); } @@ -321,12 +322,12 @@ fn provided_link_metas(sess: session, c: ast::crate) -> // This calculates CMH as defined above fn crate_meta_extras_hash(sha: sha1, _crate: ast::crate, metas: provided_metas, - dep_hashes: ~[@str/~]) -> str { - fn len_and_str(s: str) -> str { + dep_hashes: ~[@~str]) -> ~str { + fn len_and_str(s: ~str) -> ~str { ret #fmt["%u_%s", str::len(s), s]; } - fn len_and_str_lit(l: ast::lit) -> str { + fn len_and_str_lit(l: ast::lit) -> ~str { ret len_and_str(pprust::lit_to_str(@l)); } @@ -343,7 +344,7 @@ fn len_and_str_lit(l: ast::lit) -> str { ast::meta_word(name) { sha.input_str(len_and_str(*name)); } ast::meta_list(_, _) { // FIXME (#607): Implement this - fail "unimplemented meta_item variant"; + fail ~"unimplemented meta_item variant"; } } } @@ -355,14 +356,14 @@ fn len_and_str_lit(l: ast::lit) -> str { ret truncated_sha1_result(sha); } - fn warn_missing(sess: session, name: str, default: str) { + fn warn_missing(sess: session, name: ~str, default: ~str) { if !sess.building_library { ret; } sess.warn(#fmt["missing crate link meta `%s`, using `%s` as default", name, default]); } fn crate_meta_name(sess: session, _crate: ast::crate, - output: str, metas: provided_metas) -> @str/~ { + output: ~str, metas: provided_metas) -> @~str { ret alt metas.name { some(v) { v } none { @@ -375,21 +376,21 @@ fn crate_meta_name(sess: session, _crate: ast::crate, appear to have an extension", output)); } vec::pop(os); - str::connect(os, ".") + str::connect(os, ~".") }; - warn_missing(sess, "name", name); + warn_missing(sess, ~"name", name); @name } }; } fn crate_meta_vers(sess: session, _crate: ast::crate, - metas: provided_metas) -> @str/~ { + metas: provided_metas) -> @~str { ret alt metas.vers { some(v) { v } none { - let vers = "0.0"; - warn_missing(sess, "vers", vers); + let vers = ~"0.0"; + warn_missing(sess, ~"vers", vers); @vers } }; @@ -405,30 +406,30 @@ fn crate_meta_vers(sess: session, _crate: ast::crate, ret {name: name, vers: vers, extras_hash: extras_hash}; } -fn truncated_sha1_result(sha: sha1) -> str unsafe { +fn truncated_sha1_result(sha: sha1) -> ~str unsafe { ret str::slice(sha.result_str(), 0u, 16u); } // This calculates STH for a symbol, as defined above fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t, - link_meta: link_meta) -> str { + link_meta: link_meta) -> ~str { // NB: do *not* use abbrevs here as we want the symbol names // to be independent of one another in the crate. sha.reset(); sha.input_str(*link_meta.name); - sha.input_str("-"); + sha.input_str(~"-"); sha.input_str(link_meta.extras_hash); - sha.input_str("-"); + sha.input_str(~"-"); sha.input_str(encoder::encoded_ty(tcx, t)); let hash = truncated_sha1_result(sha); // Prefix with _ so that it never blends into adjacent digits - ret "_" + hash; + ret ~"_" + hash; } -fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str { +fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str { alt ccx.type_sha1s.find(t) { some(h) { ret h; } none { @@ -442,17 +443,17 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str { // Name sanitation. LLVM will happily accept identifiers with weird names, but // gas doesn't! -fn sanitize(s: str) -> str { - let mut result = ""; +fn sanitize(s: ~str) -> ~str { + let mut result = ~""; do str::chars_iter(s) |c| { alt c { - '@' { result += "_sbox_"; } - '~' { result += "_ubox_"; } - '*' { result += "_ptr_"; } - '&' { result += "_ref_"; } - ',' { result += "_"; } + '@' { result += ~"_sbox_"; } + '~' { result += ~"_ubox_"; } + '*' { result += ~"_ptr_"; } + '&' { result += ~"_ref_"; } + ',' { result += ~"_"; } - '{' | '(' { result += "_of_"; } + '{' | '(' { result += ~"_of_"; } 'a' to 'z' | 'A' to 'Z' | '0' to '9' @@ -469,16 +470,16 @@ fn sanitize(s: str) -> str { if result.len() > 0u && result[0] != '_' as u8 && ! char::is_XID_start(result[0] as char) { - ret "_" + result; + ret ~"_" + result; } ret result; } -fn mangle(ss: path) -> str { +fn mangle(ss: path) -> ~str { // Follow C++ namespace-mangling style - let mut n = "_ZN"; // Begin name-sequence. + let mut n = ~"_ZN"; // Begin name-sequence. for ss.each |s| { alt s { path_name(s) | path_mod(s) { @@ -486,52 +487,52 @@ fn mangle(ss: path) -> str { n += #fmt["%u%s", str::len(sani), sani]; } } } - n += "E"; // End name-sequence. + n += ~"E"; // End name-sequence. n } -fn exported_name(path: path, hash: @str/~, vers: @str/~) -> str { +fn exported_name(path: path, hash: @~str, vers: @~str) -> ~str { ret mangle( vec::append_one(vec::append_one(path, path_name(hash)), path_name(vers))); } -fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str { +fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> ~str { let hash = get_symbol_hash(ccx, t); ret exported_name(path, @hash, ccx.link_meta.vers); } fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, - t: ty::t, name: @str/~) -> - str { + t: ty::t, name: @~str) -> + ~str { let s = @util::ppaux::ty_to_short_str(ccx.tcx, t); let hash = get_symbol_hash(ccx, t); ret mangle(~[path_name(name), path_name(s), path_name(@hash)]); } fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path, - flav: @str/~) -> str { + flav: @~str) -> ~str { ret mangle(vec::append_one(path, path_name(@ccx.names(*flav)))); } -fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str { +fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> ~str { ret mangle(path); } -fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: @str/~) -> str { +fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: @~str) -> ~str { ret ccx.names(*flav); } // If the user wants an exe generated we need to invoke // cc to link the object file with some libs fn link_binary(sess: session, - obj_filename: str, - out_filename: str, + obj_filename: ~str, + out_filename: ~str, lm: link_meta) { // Converts a library file name into a cc -l argument - fn unlib(config: @session::config, filename: str) -> str unsafe { - let rmlib = fn@(filename: str) -> str { - let found = str::find_str(filename, "lib"); + fn unlib(config: @session::config, filename: ~str) -> ~str unsafe { + let rmlib = fn@(filename: ~str) -> ~str { + let found = str::find_str(filename, ~"lib"); if config.os == session::os_macos || (config.os == session::os_linux || config.os == session::os_freebsd) && @@ -539,10 +540,10 @@ fn unlib(config: @session::config, filename: str) -> str unsafe { ret str::slice(filename, 3u, str::len(filename)); } else { ret filename; } }; - fn rmext(filename: str) -> str { + fn rmext(filename: ~str) -> ~str { let mut parts = str::split_char(filename, '.'); vec::pop(parts); - ret str::connect(parts, "."); + ret str::connect(parts, ~"."); } ret alt config.os { session::os_macos { rmext(rmlib(filename)) } @@ -564,46 +565,46 @@ fn rmext(filename: str) -> str { path::connect(path::dirname(out_filename), long_libname) } else { out_filename }; - log(debug, "output: " + output); + log(debug, ~"output: " + output); // The default library location, we need this to find the runtime. // The location of crates will be determined as needed. - let stage: str = "-L" + sess.filesearch.get_target_lib_path(); + let stage: ~str = ~"-L" + sess.filesearch.get_target_lib_path(); // In the future, FreeBSD will use clang as default compiler. // It would be flexible to use cc (system's default C compiler) // instead of hard-coded gcc. // For win32, there is no cc command, // so we add a condition to make it use gcc. - let cc_prog: str = - if sess.targ_cfg.os == session::os_win32 { "gcc" } else { "cc" }; + let cc_prog: ~str = + if sess.targ_cfg.os == session::os_win32 { ~"gcc" } else { ~"cc" }; // The invocations of cc share some flags across platforms let mut cc_args = vec::append(~[stage], sess.targ_cfg.target_strs.cc_args); - vec::push(cc_args, "-o"); + vec::push(cc_args, ~"-o"); vec::push(cc_args, output); vec::push(cc_args, obj_filename); let mut lib_cmd; let os = sess.targ_cfg.os; if os == session::os_macos { - lib_cmd = "-dynamiclib"; - } else { lib_cmd = "-shared"; } + lib_cmd = ~"-dynamiclib"; + } else { lib_cmd = ~"-shared"; } // # Crate linking let cstore = sess.cstore; for cstore::get_used_crate_files(cstore).each |cratepath| { - if str::ends_with(cratepath, ".rlib") { + if str::ends_with(cratepath, ~".rlib") { vec::push(cc_args, cratepath); again; } let cratepath = cratepath; let dir = path::dirname(cratepath); - if dir != "" { vec::push(cc_args, "-L" + dir); } + if dir != ~"" { vec::push(cc_args, ~"-L" + dir); } let libarg = unlib(sess.targ_cfg, path::basename(cratepath)); - vec::push(cc_args, "-l" + libarg); + vec::push(cc_args, ~"-l" + libarg); } let ula = cstore::get_used_link_args(cstore); @@ -618,11 +619,11 @@ fn rmext(filename: str) -> str { // forces to make sure that library can be found at runtime. let addl_paths = sess.opts.addl_lib_search_paths; - for addl_paths.each |path| { vec::push(cc_args, "-L" + path); } + for addl_paths.each |path| { vec::push(cc_args, ~"-L" + path); } // The names of the extern libraries let used_libs = cstore::get_used_libraries(cstore); - for used_libs.each |l| { vec::push(cc_args, "-l" + l); } + for used_libs.each |l| { vec::push(cc_args, ~"-l" + l); } if sess.building_library { vec::push(cc_args, lib_cmd); @@ -630,35 +631,35 @@ fn rmext(filename: str) -> str { // On mac we need to tell the linker to let this library // be rpathed if sess.targ_cfg.os == session::os_macos { - vec::push(cc_args, "-Wl,-install_name,@rpath/" + vec::push(cc_args, ~"-Wl,-install_name,@rpath/" + path::basename(output)); } } if !sess.debugging_opt(session::no_rt) { // Always want the runtime linked in - vec::push(cc_args, "-lrustrt"); + vec::push(cc_args, ~"-lrustrt"); } // On linux librt and libdl are an indirect dependencies via rustrt, // and binutils 2.22+ won't add them automatically if sess.targ_cfg.os == session::os_linux { - vec::push_all(cc_args, ~["-lrt", "-ldl"]); + vec::push_all(cc_args, ~[~"-lrt", ~"-ldl"]); // LLVM implements the `frem` instruction as a call to `fmod`, // which lives in libm. Similar to above, on some linuxes we // have to be explicit about linking to it. See #2510 - vec::push(cc_args, "-lm"); + vec::push(cc_args, ~"-lm"); } if sess.targ_cfg.os == session::os_freebsd { - vec::push_all(cc_args, ~["-pthread", "-lrt", - "-L/usr/local/lib", "-lexecinfo", - "-L/usr/local/lib/gcc46", - "-L/usr/local/lib/gcc44", "-lstdc++", - "-Wl,-z,origin", - "-Wl,-rpath,/usr/local/lib/gcc46", - "-Wl,-rpath,/usr/local/lib/gcc44"]); + vec::push_all(cc_args, ~[~"-pthread", ~"-lrt", + ~"-L/usr/local/lib", ~"-lexecinfo", + ~"-L/usr/local/lib/gcc46", + ~"-L/usr/local/lib/gcc44", ~"-lstdc++", + ~"-Wl,-z,origin", + ~"-Wl,-rpath,/usr/local/lib/gcc46", + ~"-Wl,-rpath,/usr/local/lib/gcc44"]); } // OS X 10.6 introduced 'compact unwind info', which is produced by the @@ -666,31 +667,31 @@ fn rmext(filename: str) -> str { // understand how to unwind our __morestack frame, so we have to turn it // off. This has impacted some other projects like GHC. if sess.targ_cfg.os == session::os_macos { - vec::push(cc_args, "-Wl,-no_compact_unwind"); + vec::push(cc_args, ~"-Wl,-no_compact_unwind"); } // Stack growth requires statically linking a __morestack function - vec::push(cc_args, "-lmorestack"); + vec::push(cc_args, ~"-lmorestack"); // FIXME (#2397): At some point we want to rpath our guesses as to where // extern libraries might live, based on the addl_lib_search_paths vec::push_all(cc_args, rpath::get_rpath_flags(sess, output)); - #debug("%s link args: %s", cc_prog, str::connect(cc_args, " ")); + #debug("%s link args: %s", cc_prog, str::connect(cc_args, ~" ")); // We run 'cc' here let prog = run::program_output(cc_prog, cc_args); if 0 != prog.status { sess.err(#fmt["linking with `%s` failed with code %d", cc_prog, prog.status]); sess.note(#fmt["%s arguments: %s", - cc_prog, str::connect(cc_args, " ")]); + cc_prog, str::connect(cc_args, ~" ")]); sess.note(prog.err + prog.out); sess.abort_if_errors(); } // Clean up on Darwin if sess.targ_cfg.os == session::os_macos { - run::run_program("dsymutil", ~[output]); + run::run_program(~"dsymutil", ~[output]); } // Remove the temporary object file if we aren't saving temps diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index f29dc26ed390..2e16d92cec80 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -13,7 +13,7 @@ } } -fn get_rpath_flags(sess: session::session, out_filename: str) -> ~[str] { +fn get_rpath_flags(sess: session::session, out_filename: ~str) -> ~[~str] { let os = sess.targ_cfg.os; // No rpath on windows @@ -40,17 +40,17 @@ fn get_sysroot_absolute_rt_lib(sess: session::session) -> path::path { let mut path = vec::append(~[sess.filesearch.sysroot()], filesearch::relative_target_lib_path( sess.opts.target_triple)); - vec::push(path, os::dll_filename("rustrt")); + vec::push(path, os::dll_filename(~"rustrt")); path::connect_many(path) } -fn rpaths_to_flags(rpaths: ~[str]) -> ~[str] { +fn rpaths_to_flags(rpaths: ~[~str]) -> ~[~str] { vec::map(rpaths, |rpath| #fmt("-Wl,-rpath,%s",rpath) ) } fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path, output: path::path, libs: ~[path::path], - target_triple: str) -> ~[str] { + target_triple: ~str) -> ~[~str] { #debug("cwd: %s", cwd); #debug("sysroot: %s", sysroot); #debug("output: %s", output); @@ -72,16 +72,16 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path, // And a final backup rpath to the global library location. let fallback_rpaths = ~[get_install_prefix_rpath(cwd, target_triple)]; - fn log_rpaths(desc: str, rpaths: ~[str]) { + fn log_rpaths(desc: ~str, rpaths: ~[~str]) { #debug("%s rpaths:", desc); for rpaths.each |rpath| { #debug(" %s", rpath); } } - log_rpaths("relative", rel_rpaths); - log_rpaths("absolute", abs_rpaths); - log_rpaths("fallback", fallback_rpaths); + log_rpaths(~"relative", rel_rpaths); + log_rpaths(~"absolute", abs_rpaths); + log_rpaths(~"fallback", fallback_rpaths); let mut rpaths = rel_rpaths; vec::push_all(rpaths, abs_rpaths); @@ -95,7 +95,7 @@ fn log_rpaths(desc: str, rpaths: ~[str]) { fn get_rpaths_relative_to_output(os: session::os, cwd: path::path, output: path::path, - libs: ~[path::path]) -> ~[str] { + libs: ~[path::path]) -> ~[~str] { vec::map(libs, |a| { check not_win32(os); get_rpath_relative_to_output(os, cwd, output, a) @@ -105,12 +105,12 @@ fn get_rpaths_relative_to_output(os: session::os, fn get_rpath_relative_to_output(os: session::os, cwd: path::path, output: path::path, - &&lib: path::path) : not_win32(os) -> str { + &&lib: path::path) : not_win32(os) -> ~str { // Mac doesn't appear to support $ORIGIN let prefix = alt os { - session::os_linux { "$ORIGIN" + path::path_sep() } - session::os_freebsd { "$ORIGIN" + path::path_sep() } - session::os_macos { "@executable_path" + path::path_sep() } + session::os_linux { ~"$ORIGIN" + path::path_sep() } + session::os_freebsd { ~"$ORIGIN" + path::path_sep() } + session::os_macos { ~"@executable_path" + path::path_sep() } session::os_win32 { core::unreachable(); } }; @@ -142,7 +142,7 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { } let mut path = ~[]; - for uint::range(start_idx, len1 - 1u) |_i| { vec::push(path, ".."); }; + for uint::range(start_idx, len1 - 1u) |_i| { vec::push(path, ~".."); }; // FIXME (#2880): use view here. vec::push_all(path, vec::slice(split2, start_idx, len2 - 1u)); @@ -150,15 +150,15 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { if check vec::is_not_empty(path) { ret path::connect_many(path); } else { - ret "."; + ret ~"."; } } -fn get_absolute_rpaths(cwd: path::path, libs: ~[path::path]) -> ~[str] { +fn get_absolute_rpaths(cwd: path::path, libs: ~[path::path]) -> ~[~str] { vec::map(libs, |a| get_absolute_rpath(cwd, a) ) } -fn get_absolute_rpath(cwd: path::path, &&lib: path::path) -> str { +fn get_absolute_rpath(cwd: path::path, &&lib: path::path) -> ~str { path::dirname(get_absolute(cwd, lib)) } @@ -170,11 +170,11 @@ fn get_absolute(cwd: path::path, lib: path::path) -> path::path { } } -fn get_install_prefix_rpath(cwd: path::path, target_triple: str) -> str { +fn get_install_prefix_rpath(cwd: path::path, target_triple: ~str) -> ~str { let install_prefix = #env("CFG_PREFIX"); - if install_prefix == "" { - fail "rustc compiled without CFG_PREFIX environment variable"; + if install_prefix == ~"" { + fail ~"rustc compiled without CFG_PREFIX environment variable"; } let path = vec::append( @@ -183,7 +183,7 @@ fn get_install_prefix_rpath(cwd: path::path, target_triple: str) -> str { get_absolute(cwd, path::connect_many(path)) } -fn minimize_rpaths(rpaths: ~[str]) -> ~[str] { +fn minimize_rpaths(rpaths: ~[~str]) -> ~[~str] { let set = map::str_hash::<()>(); let mut minimized = ~[]; for rpaths.each |rpath| { @@ -199,116 +199,116 @@ fn minimize_rpaths(rpaths: ~[str]) -> ~[str] { mod test { #[test] fn test_rpaths_to_flags() { - let flags = rpaths_to_flags(~["path1", "path2"]); - assert flags == ~["-Wl,-rpath,path1", "-Wl,-rpath,path2"]; + let flags = rpaths_to_flags(~[~"path1", ~"path2"]); + assert flags == ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"]; } #[test] fn test_get_absolute1() { - let cwd = "/dir"; - let lib = "some/path/lib"; + let cwd = ~"/dir"; + let lib = ~"some/path/lib"; let res = get_absolute(cwd, lib); - assert res == "/dir/some/path/lib"; + assert res == ~"/dir/some/path/lib"; } #[test] fn test_get_absolute2() { - let cwd = "/dir"; - let lib = "/some/path/lib"; + let cwd = ~"/dir"; + let lib = ~"/some/path/lib"; let res = get_absolute(cwd, lib); - assert res == "/some/path/lib"; + assert res == ~"/some/path/lib"; } #[test] fn test_prefix_rpath() { - let res = get_install_prefix_rpath("/usr/lib", "triple"); - let d = path::connect(#env("CFG_PREFIX"), "/lib/rustc/triple/lib"); + let res = get_install_prefix_rpath(~"/usr/lib", ~"triple"); + let d = path::connect(#env("CFG_PREFIX"), ~"/lib/rustc/triple/lib"); assert str::ends_with(res, d); } #[test] fn test_prefix_rpath_abs() { - let res = get_install_prefix_rpath("/usr/lib", "triple"); + let res = get_install_prefix_rpath(~"/usr/lib", ~"triple"); assert path::path_is_absolute(res); } #[test] fn test_minimize1() { - let res = minimize_rpaths(~["rpath1", "rpath2", "rpath1"]); - assert res == ~["rpath1", "rpath2"]; + let res = minimize_rpaths(~[~"rpath1", ~"rpath2", ~"rpath1"]); + assert res == ~[~"rpath1", ~"rpath2"]; } #[test] fn test_minimize2() { - let res = minimize_rpaths(~["1a", "2", "2", "1a", "4a", - "1a", "2", "3", "4a", "3"]); - assert res == ~["1a", "2", "4a", "3"]; + let res = minimize_rpaths(~[~"1a", ~"2", ~"2", ~"1a", ~"4a", + ~"1a", ~"2", ~"3", ~"4a", ~"3"]); + assert res == ~[~"1a", ~"2", ~"4a", ~"3"]; } #[test] fn test_relative_to1() { - let p1 = "/usr/bin/rustc"; - let p2 = "/usr/lib/mylib"; + let p1 = ~"/usr/bin/rustc"; + let p2 = ~"/usr/lib/mylib"; let res = get_relative_to(p1, p2); - assert res == "../lib"; + assert res == ~"../lib"; } #[test] fn test_relative_to2() { - let p1 = "/usr/bin/rustc"; - let p2 = "/usr/bin/../lib/mylib"; + let p1 = ~"/usr/bin/rustc"; + let p2 = ~"/usr/bin/../lib/mylib"; let res = get_relative_to(p1, p2); - assert res == "../lib"; + assert res == ~"../lib"; } #[test] fn test_relative_to3() { - let p1 = "/usr/bin/whatever/rustc"; - let p2 = "/usr/lib/whatever/mylib"; + let p1 = ~"/usr/bin/whatever/rustc"; + let p2 = ~"/usr/lib/whatever/mylib"; let res = get_relative_to(p1, p2); - assert res == "../../lib/whatever"; + assert res == ~"../../lib/whatever"; } #[test] fn test_relative_to4() { - let p1 = "/usr/bin/whatever/../rustc"; - let p2 = "/usr/lib/whatever/mylib"; + let p1 = ~"/usr/bin/whatever/../rustc"; + let p2 = ~"/usr/lib/whatever/mylib"; let res = get_relative_to(p1, p2); - assert res == "../lib/whatever"; + assert res == ~"../lib/whatever"; } #[test] fn test_relative_to5() { - let p1 = "/usr/bin/whatever/../rustc"; - let p2 = "/usr/lib/whatever/../mylib"; + let p1 = ~"/usr/bin/whatever/../rustc"; + let p2 = ~"/usr/lib/whatever/../mylib"; let res = get_relative_to(p1, p2); - assert res == "../lib"; + assert res == ~"../lib"; } #[test] fn test_relative_to6() { - let p1 = "/1"; - let p2 = "/2/3"; + let p1 = ~"/1"; + let p2 = ~"/2/3"; let res = get_relative_to(p1, p2); - assert res == "2"; + assert res == ~"2"; } #[test] fn test_relative_to7() { - let p1 = "/1/2"; - let p2 = "/3"; + let p1 = ~"/1/2"; + let p2 = ~"/3"; let res = get_relative_to(p1, p2); - assert res == ".."; + assert res == ~".."; } #[test] fn test_relative_to8() { - let p1 = "/home/brian/Dev/rust/build/" - + "stage2/lib/rustc/i686-unknown-linux-gnu/lib/librustc.so"; - let p2 = "/home/brian/Dev/rust/build/stage2/bin/.." - + "/lib/rustc/i686-unknown-linux-gnu/lib/libstd.so"; + let p1 = ~"/home/brian/Dev/rust/build/" + + ~"stage2/lib/rustc/i686-unknown-linux-gnu/lib/librustc.so"; + let p2 = ~"/home/brian/Dev/rust/build/stage2/bin/.." + + ~"/lib/rustc/i686-unknown-linux-gnu/lib/libstd.so"; let res = get_relative_to(p1, p2); - assert res == "."; + assert res == ~"."; } #[test] @@ -317,8 +317,8 @@ fn test_rpath_relative() { let o = session::os_linux; check not_win32(o); let res = get_rpath_relative_to_output(o, - "/usr", "bin/rustc", "lib/libstd.so"); - assert res == "$ORIGIN/../lib"; + ~"/usr", ~"bin/rustc", ~"lib/libstd.so"); + assert res == ~"$ORIGIN/../lib"; } #[test] @@ -344,7 +344,7 @@ fn test_rpath_relative() { #[test] fn test_get_absolute_rpath() { - let res = get_absolute_rpath("/usr", "lib/libstd.so"); - assert res == "/usr/lib"; + let res = get_absolute_rpath(~"/usr", ~"lib/libstd.so"); + assert res == ~"/usr/lib"; } } diff --git a/src/rustc/back/target_strs.rs b/src/rustc/back/target_strs.rs index ca11e4c6d69a..798c4868a7c5 100644 --- a/src/rustc/back/target_strs.rs +++ b/src/rustc/back/target_strs.rs @@ -1,7 +1,7 @@ type t = { - module_asm: str, - meta_sect_name: str, - data_layout: str, - target_triple: str, - cc_args: ~[str] + module_asm: ~str, + meta_sect_name: ~str, + data_layout: ~str, + target_triple: ~str, + cc_args: ~[~str] }; diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index e95f7e39af46..94c69976c8c9 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -30,7 +30,7 @@ fn declare_upcalls(targ_cfg: @session::config, _tn: type_names, tydesc_type: TypeRef, llmod: ModuleRef) -> @upcalls { - fn decl(llmod: ModuleRef, prefix: str, name: str, + fn decl(llmod: ModuleRef, prefix: ~str, name: ~str, tys: ~[TypeRef], rv: TypeRef) -> ValueRef { let mut arg_tys: ~[TypeRef] = ~[]; @@ -41,63 +41,63 @@ fn decl(llmod: ModuleRef, prefix: str, name: str, fn nothrow(f: ValueRef) -> ValueRef { base::set_no_unwind(f); f } - let d = |a,b,c| decl(llmod, "upcall_", a, b, c); - let dv = |a,b| decl(llmod, "upcall_", a, b, T_void()); + let d = |a,b,c| decl(llmod, ~"upcall_", a, b, c); + let dv = |a,b| decl(llmod, ~"upcall_", a, b, T_void()); let int_t = T_int(targ_cfg); let size_t = T_size_t(targ_cfg); - ret @{_fail: dv("fail", ~[T_ptr(T_i8()), + ret @{_fail: dv(~"fail", ~[T_ptr(T_i8()), T_ptr(T_i8()), size_t]), - trace: dv("trace", ~[T_ptr(T_i8()), + trace: dv(~"trace", ~[T_ptr(T_i8()), T_ptr(T_i8()), int_t]), malloc: - nothrow(d("malloc", + nothrow(d(~"malloc", ~[T_ptr(tydesc_type), int_t], T_ptr(T_i8()))), free: - nothrow(dv("free", ~[T_ptr(T_i8())])), + nothrow(dv(~"free", ~[T_ptr(T_i8())])), exchange_malloc: - nothrow(d("exchange_malloc", + nothrow(d(~"exchange_malloc", ~[T_ptr(tydesc_type), int_t], T_ptr(T_i8()))), exchange_free: - nothrow(dv("exchange_free", ~[T_ptr(T_i8())])), + nothrow(dv(~"exchange_free", ~[T_ptr(T_i8())])), validate_box: - nothrow(dv("validate_box", ~[T_ptr(T_i8())])), + nothrow(dv(~"validate_box", ~[T_ptr(T_i8())])), mark: - d("mark", ~[T_ptr(T_i8())], int_t), + d(~"mark", ~[T_ptr(T_i8())], int_t), str_new_uniq: - nothrow(d("str_new_uniq", ~[T_ptr(T_i8()), int_t], + nothrow(d(~"str_new_uniq", ~[T_ptr(T_i8()), int_t], T_ptr(T_i8()))), str_new_shared: - nothrow(d("str_new_shared", ~[T_ptr(T_i8()), int_t], + nothrow(d(~"str_new_shared", ~[T_ptr(T_i8()), int_t], T_ptr(T_i8()))), cmp_type: - dv("cmp_type", + dv(~"cmp_type", ~[T_ptr(T_i1()), T_ptr(tydesc_type), T_ptr(T_i8()), T_ptr(T_i8()), T_i8()]), log_type: - dv("log_type", ~[T_ptr(tydesc_type), + dv(~"log_type", ~[T_ptr(tydesc_type), T_ptr(T_i8()), T_i32()]), alloc_c_stack: - d("alloc_c_stack", ~[size_t], T_ptr(T_i8())), + d(~"alloc_c_stack", ~[size_t], T_ptr(T_i8())), call_shim_on_c_stack: - d("call_shim_on_c_stack", + d(~"call_shim_on_c_stack", // arguments: void *args, void *fn_ptr ~[T_ptr(T_i8()), T_ptr(T_i8())], int_t), call_shim_on_rust_stack: - d("call_shim_on_rust_stack", + d(~"call_shim_on_rust_stack", ~[T_ptr(T_i8()), T_ptr(T_i8())], int_t), rust_personality: - nothrow(d("rust_personality", ~[], T_i32())), + nothrow(d(~"rust_personality", ~[], T_i32())), reset_stack_limit: - nothrow(dv("reset_stack_limit", ~[])) + nothrow(dv(~"reset_stack_limit", ~[])) }; } // diff --git a/src/rustc/back/x86.rs b/src/rustc/back/x86.rs index 63ca5b60e65d..a7cd20e875bc 100644 --- a/src/rustc/back/x86.rs +++ b/src/rustc/back/x86.rs @@ -4,38 +4,39 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { ret { - module_asm: "", + module_asm: ~"", meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), data_layout: alt target_os { session::os_macos { - "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + "-i32:32:32-i64:32:64" + - "-f32:32:32-f64:32:64-v64:64:64" + - "-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32" + ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + + ~"-i32:32:32-i64:32:64" + + ~"-f32:32:32-f64:32:64-v64:64:64" + + ~"-v128:128:128-a0:0:64-f80:128:128" + ~"-n8:16:32" } session::os_win32 { - "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32" + ~"e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32" } session::os_linux { - "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" + ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" } session::os_freebsd { - "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" + ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" } }, target_triple: alt target_os { - session::os_macos { "i686-apple-darwin" } - session::os_win32 { "i686-pc-mingw32" } - session::os_linux { "i686-unknown-linux-gnu" } - session::os_freebsd { "i686-unknown-freebsd" } + session::os_macos { ~"i686-apple-darwin" } + session::os_win32 { ~"i686-pc-mingw32" } + session::os_linux { ~"i686-unknown-linux-gnu" } + session::os_freebsd { ~"i686-unknown-freebsd" } }, - cc_args: ~["-m32"] + cc_args: ~[~"-m32"] }; } diff --git a/src/rustc/back/x86_64.rs b/src/rustc/back/x86_64.rs index b3e6c518dd4a..63399cd2b41c 100644 --- a/src/rustc/back/x86_64.rs +++ b/src/rustc/back/x86_64.rs @@ -4,45 +4,45 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { ret { - module_asm: "", + module_asm: ~"", meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), data_layout: alt target_os { session::os_macos { - "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - "s0:64:64-f80:128:128-n8:16:32:64" + ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ + ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + ~"s0:64:64-f80:128:128-n8:16:32:64" } session::os_win32 { // FIXME: Test this. Copied from linux (#2398) - "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - "s0:64:64-f80:128:128-n8:16:32:64-S128" + ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ + ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + ~"s0:64:64-f80:128:128-n8:16:32:64-S128" } session::os_linux { - "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - "s0:64:64-f80:128:128-n8:16:32:64-S128" + ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ + ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + ~"s0:64:64-f80:128:128-n8:16:32:64-S128" } session::os_freebsd { - "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - "s0:64:64-f80:128:128-n8:16:32:64-S128" + ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ + ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + ~"s0:64:64-f80:128:128-n8:16:32:64-S128" } }, target_triple: alt target_os { - session::os_macos { "x86_64-apple-darwin" } - session::os_win32 { "x86_64-pc-mingw32" } - session::os_linux { "x86_64-unknown-linux-gnu" } - session::os_freebsd { "x86_64-unknown-freebsd" } + session::os_macos { ~"x86_64-apple-darwin" } + session::os_win32 { ~"x86_64-pc-mingw32" } + session::os_linux { ~"x86_64-unknown-linux-gnu" } + session::os_freebsd { ~"x86_64-unknown-freebsd" } }, - cc_args: ~["-m64"] + cc_args: ~[~"-m64"] }; } diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index cec72045bcaf..47b126df3324 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -22,45 +22,45 @@ enum pp_mode {ppm_normal, ppm_expanded, ppm_typed, ppm_identified, * The name used for source code that doesn't originate in a file * (e.g. source from stdin or a string) */ -fn anon_src() -> str { "" } +fn anon_src() -> ~str { ~"" } -fn source_name(input: input) -> str { +fn source_name(input: input) -> ~str { alt input { file_input(ifile) { ifile } str_input(_) { anon_src() } } } -fn default_configuration(sess: session, argv0: str, input: input) -> +fn default_configuration(sess: session, argv0: ~str, input: input) -> ast::crate_cfg { let libc = alt sess.targ_cfg.os { - session::os_win32 { "msvcrt.dll" } - session::os_macos { "libc.dylib" } - session::os_linux { "libc.so.6" } - session::os_freebsd { "libc.so.7" } + session::os_win32 { ~"msvcrt.dll" } + session::os_macos { ~"libc.dylib" } + session::os_linux { ~"libc.so.6" } + session::os_freebsd { ~"libc.so.7" } // _ { "libc.so" } }; let mk = attr::mk_name_value_item_str; let arch = alt sess.targ_cfg.arch { - session::arch_x86 { "x86" } - session::arch_x86_64 { "x86_64" } - session::arch_arm { "arm" } + session::arch_x86 { ~"x86" } + session::arch_x86_64 { ~"x86_64" } + session::arch_arm { ~"arm" } }; ret ~[ // Target bindings. attr::mk_word_item(@os::family()), - mk(@"target_os", os::sysname()), - mk(@"target_family", os::family()), - mk(@"target_arch", arch), - mk(@"target_libc", libc), + mk(@~"target_os", os::sysname()), + mk(@~"target_family", os::family()), + mk(@~"target_arch", arch), + mk(@~"target_libc", libc), // Build bindings. - mk(@"build_compiler", argv0), - mk(@"build_input", source_name(input))]; + mk(@~"build_compiler", argv0), + mk(@~"build_input", source_name(input))]; } -fn build_configuration(sess: session, argv0: str, input: input) -> +fn build_configuration(sess: session, argv0: ~str, input: input) -> ast::crate_cfg { // Combine the configuration requested by the session (command line) with // some default and generated configuration items @@ -69,16 +69,16 @@ fn build_configuration(sess: session, argv0: str, input: input) -> // If the user wants a test runner, then add the test cfg let gen_cfg = { - if sess.opts.test && !attr::contains_name(user_cfg, "test") + if sess.opts.test && !attr::contains_name(user_cfg, ~"test") { - ~[attr::mk_word_item(@"test")] + ~[attr::mk_word_item(@~"test")] } else { ~[] } }; ret vec::append(vec::append(user_cfg, gen_cfg), default_cfg); } // Convert strings provided as --cfg [cfgspec] into a crate_cfg -fn parse_cfgspecs(cfgspecs: ~[str]) -> ast::crate_cfg { +fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg { // FIXME (#2399): It would be nice to use the parser to parse all // varieties of meta_item here. At the moment we just support the // meta_word variant. @@ -89,9 +89,9 @@ fn parse_cfgspecs(cfgspecs: ~[str]) -> ast::crate_cfg { enum input { /// Load source from file - file_input(str), + file_input(~str), /// The string is the source - str_input(str) + str_input(~str) } fn parse_input(sess: session, cfg: ast::crate_cfg, input: input) @@ -108,7 +108,7 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: input) } } -fn time(do_it: bool, what: str, thunk: fn() -> T) -> T { +fn time(do_it: bool, what: ~str, thunk: fn() -> T) -> T { if !do_it { ret thunk(); } let start = std::time::precise_time_s(); let rv = thunk(); @@ -131,93 +131,93 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, outputs: option) -> {crate: @ast::crate, tcx: option} { let time_passes = sess.time_passes(); - let mut crate = time(time_passes, "parsing", + let mut crate = time(time_passes, ~"parsing", ||parse_input(sess, cfg, input) ); if upto == cu_parse { ret {crate: crate, tcx: none}; } sess.building_library = session::building_library( sess.opts.crate_type, crate, sess.opts.test); - crate = time(time_passes, "configuration", || + crate = time(time_passes, ~"configuration", || front::config::strip_unconfigured_items(crate)); - crate = time(time_passes, "maybe building test harness", || + crate = time(time_passes, ~"maybe building test harness", || front::test::modify_for_testing(sess, crate)); - crate = time(time_passes, "expansion", || + crate = time(time_passes, ~"expansion", || syntax::ext::expand::expand_crate(sess.parse_sess, sess.opts.cfg, crate)); if upto == cu_expand { ret {crate: crate, tcx: none}; } - crate = time(time_passes, "intrinsic injection", || + crate = time(time_passes, ~"intrinsic injection", || front::intrinsic_inject::inject_intrinsic(sess, crate)); - crate = time(time_passes, "core injection", || + crate = time(time_passes, ~"core injection", || front::core_inject::maybe_inject_libcore_ref(sess, crate)); - time(time_passes, "building warning settings table", || + time(time_passes, ~"building warning settings table", || lint::build_settings_crate(sess, crate)); - let ast_map = time(time_passes, "ast indexing", || + let ast_map = time(time_passes, ~"ast indexing", || syntax::ast_map::map_crate(sess.diagnostic(), *crate)); - time(time_passes, "external crate/lib resolution", || + time(time_passes, ~"external crate/lib resolution", || creader::read_crates(sess.diagnostic(), *crate, sess.cstore, sess.filesearch, session::sess_os_to_meta_os(sess.targ_cfg.os), sess.opts.static)); let { def_map: def_map, exp_map: exp_map, impl_map: impl_map } = - time(time_passes, "resolution", || + time(time_passes, ~"resolution", || middle::resolve3::resolve_crate(sess, ast_map, crate)); - let freevars = time(time_passes, "freevar finding", || + let freevars = time(time_passes, ~"freevar finding", || freevars::annotate_freevars(def_map, crate)); - let region_map = time(time_passes, "region resolution", || + let region_map = time(time_passes, ~"region resolution", || middle::region::resolve_crate(sess, def_map, crate)); - let rp_set = time(time_passes, "region paramerization inference", || + let rp_set = time(time_passes, ~"region paramerization inference", || middle::region::determine_rp_in_crate(sess, ast_map, def_map, crate)); let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars, region_map, rp_set); - let (method_map, vtable_map) = time(time_passes, "typechecking", || + let (method_map, vtable_map) = time(time_passes, ~"typechecking", || typeck::check_crate(ty_cx, impl_map, crate)); - time(time_passes, "const checking", || + time(time_passes, ~"const checking", || middle::check_const::check_crate(sess, crate, ast_map, def_map, method_map, ty_cx)); if upto == cu_typeck { ret {crate: crate, tcx: some(ty_cx)}; } - time(time_passes, "block-use checking", || + time(time_passes, ~"block-use checking", || middle::block_use::check_crate(ty_cx, crate)); - time(time_passes, "loop checking", || + time(time_passes, ~"loop checking", || middle::check_loop::check_crate(ty_cx, crate)); - time(time_passes, "alt checking", || + time(time_passes, ~"alt checking", || middle::check_alt::check_crate(ty_cx, crate)); - let last_use_map = time(time_passes, "liveness checking", || + let last_use_map = time(time_passes, ~"liveness checking", || middle::liveness::check_crate(ty_cx, method_map, crate)); - time(time_passes, "typestate checking", || + time(time_passes, ~"typestate checking", || middle::tstate::ck::check_crate(ty_cx, crate)); - let (root_map, mutbl_map) = time(time_passes, "borrow checking", || + let (root_map, mutbl_map) = time(time_passes, ~"borrow checking", || middle::borrowck::check_crate(ty_cx, method_map, last_use_map, crate)); - time(time_passes, "kind checking", || + time(time_passes, ~"kind checking", || kind::check_crate(ty_cx, method_map, last_use_map, crate)); - time(time_passes, "lint checking", || lint::check_crate(ty_cx, crate)); + time(time_passes, ~"lint checking", || lint::check_crate(ty_cx, crate)); if upto == cu_no_trans { ret {crate: crate, tcx: some(ty_cx)}; } let outputs = option::get(outputs); @@ -227,11 +227,11 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, impl_map: impl_map, method_map: method_map, vtable_map: vtable_map}; - let (llmod, link_meta) = time(time_passes, "translation", || + let (llmod, link_meta) = time(time_passes, ~"translation", || trans::base::trans_crate(sess, crate, ty_cx, outputs.obj_filename, exp_map, maps)); - time(time_passes, "LLVM passes", || + time(time_passes, ~"LLVM passes", || link::write::run_passes(sess, llmod, outputs.obj_filename)); let stop_after_codegen = @@ -240,7 +240,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, if stop_after_codegen { ret {crate: crate, tcx: some(ty_cx)}; } - time(time_passes, "linking", || + time(time_passes, ~"linking", || link::link_binary(sess, outputs.obj_filename, outputs.out_filename, link_meta)); @@ -248,7 +248,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, } fn compile_input(sess: session, cfg: ast::crate_cfg, input: input, - outdir: option, output: option) { + outdir: option<~str>, output: option<~str>) { let upto = if sess.opts.parse_only { cu_parse } else if sess.opts.no_trans { cu_no_trans } @@ -266,7 +266,7 @@ fn ann_typed_post(tcx: ty::ctxt, node: pprust::ann_node) { alt node { pprust::node_expr(s, expr) { pp::space(s.s); - pp::word(s.s, "as"); + pp::word(s.s, ~"as"); pp::space(s.s); pp::word(s.s, ppaux::ty_to_str(tcx, ty::expr_ty(tcx, expr))); pprust::pclose(s); @@ -283,7 +283,7 @@ fn ann_identified_post(node: pprust::ann_node) { pprust::node_block(s, blk) { pp::space(s.s); pprust::synth_comment(s, - "block " + int::to_str(blk.node.id, 10u)); + ~"block " + int::to_str(blk.node.id, 10u)); } pprust::node_expr(s, expr) { pp::space(s.s); @@ -292,7 +292,7 @@ fn ann_identified_post(node: pprust::ann_node) { } pprust::node_pat(s, pat) { pp::space(s.s); - pprust::synth_comment(s, "pat " + int::to_str(pat.id, 10u)); + pprust::synth_comment(s, ~"pat " + int::to_str(pat.id, 10u)); } } } @@ -327,29 +327,29 @@ fn ann_identified_post(node: pprust::ann_node) { } } -fn get_os(triple: str) -> option { - ret if str::contains(triple, "win32") || - str::contains(triple, "mingw32") { +fn get_os(triple: ~str) -> option { + ret if str::contains(triple, ~"win32") || + str::contains(triple, ~"mingw32") { some(session::os_win32) - } else if str::contains(triple, "darwin") { + } else if str::contains(triple, ~"darwin") { some(session::os_macos) - } else if str::contains(triple, "linux") { + } else if str::contains(triple, ~"linux") { some(session::os_linux) - } else if str::contains(triple, "freebsd") { + } else if str::contains(triple, ~"freebsd") { some(session::os_freebsd) } else { none }; } -fn get_arch(triple: str) -> option { - ret if str::contains(triple, "i386") || str::contains(triple, "i486") || - str::contains(triple, "i586") || - str::contains(triple, "i686") || - str::contains(triple, "i786") { +fn get_arch(triple: ~str) -> option { + ret if str::contains(triple, ~"i386") || str::contains(triple, ~"i486") || + str::contains(triple, ~"i586") || + str::contains(triple, ~"i686") || + str::contains(triple, ~"i786") { some(session::arch_x86) - } else if str::contains(triple, "x86_64") { + } else if str::contains(triple, ~"x86_64") { some(session::arch_x86_64) - } else if str::contains(triple, "arm") || - str::contains(triple, "xscale") { + } else if str::contains(triple, ~"arm") || + str::contains(triple, ~"xscale") { some(session::arch_arm) } else { none }; } @@ -358,12 +358,12 @@ fn build_target_config(sopts: @session::options, demitter: diagnostic::emitter) -> @session::config { let os = alt get_os(sopts.target_triple) { some(os) { os } - none { early_error(demitter, "unknown operating system") } + none { early_error(demitter, ~"unknown operating system") } }; let arch = alt get_arch(sopts.target_triple) { some(arch) { arch } none { early_error(demitter, - "unknown architecture: " + sopts.target_triple) } + ~"unknown architecture: " + sopts.target_triple) } }; let (int_type, uint_type, float_type) = alt arch { session::arch_x86 {(ast::ty_i32, ast::ty_u32, ast::ty_f64)} @@ -381,7 +381,7 @@ fn build_target_config(sopts: @session::options, ret target_cfg; } -fn host_triple() -> str { +fn host_triple() -> ~str { // Get the host triple out of the build environment. This ensures that our // idea of the host triple is the same as for the set of libraries we've // actually built. We can't just take LLVM's host triple because they @@ -391,29 +391,29 @@ fn host_triple() -> str { // be grabbing (at compile time) the target triple that this rustc is // built with and calling that (at runtime) the host triple. let ht = #env("CFG_HOST_TRIPLE"); - ret if ht != "" { + ret if ht != ~"" { ht } else { - fail "rustc built without CFG_HOST_TRIPLE" + fail ~"rustc built without CFG_HOST_TRIPLE" }; } fn build_session_options(match: getopts::match, demitter: diagnostic::emitter) -> @session::options { - let crate_type = if opt_present(match, "lib") { + let crate_type = if opt_present(match, ~"lib") { session::lib_crate - } else if opt_present(match, "bin") { + } else if opt_present(match, ~"bin") { session::bin_crate } else { session::unknown_crate }; - let static = opt_present(match, "static"); + let static = opt_present(match, ~"static"); - let parse_only = opt_present(match, "parse-only"); - let no_trans = opt_present(match, "no-trans"); + let parse_only = opt_present(match, ~"parse-only"); + let no_trans = opt_present(match, ~"no-trans"); - let lint_flags = vec::append(getopts::opt_strs(match, "W"), - getopts::opt_strs(match, "warn")); + let lint_flags = vec::append(getopts::opt_strs(match, ~"W"), + getopts::opt_strs(match, ~"warn")); let lint_dict = lint::get_lint_dict(); let lint_opts = do vec::map(lint_flags) |flag| { alt lint::lookup_lint(lint_dict, flag) { @@ -425,7 +425,7 @@ fn build_session_options(match: getopts::match, }; let mut debugging_opts = 0u; - let debug_flags = getopts::opt_strs(match, "Z"); + let debug_flags = getopts::opt_strs(match, ~"Z"); let debug_map = session::debugging_opts_map(); for debug_flags.each |debug_flag| { let mut this_bit = 0u; @@ -442,40 +442,41 @@ fn build_session_options(match: getopts::match, let output_type = if parse_only || no_trans { link::output_type_none - } else if opt_present(match, "S") && opt_present(match, "emit-llvm") { + } else if opt_present(match, ~"S") && + opt_present(match, ~"emit-llvm") { link::output_type_llvm_assembly - } else if opt_present(match, "S") { + } else if opt_present(match, ~"S") { link::output_type_assembly - } else if opt_present(match, "c") { + } else if opt_present(match, ~"c") { link::output_type_object - } else if opt_present(match, "emit-llvm") { + } else if opt_present(match, ~"emit-llvm") { link::output_type_bitcode } else { link::output_type_exe }; - let extra_debuginfo = opt_present(match, "xg"); - let debuginfo = opt_present(match, "g") || extra_debuginfo; - let sysroot_opt = getopts::opt_maybe_str(match, "sysroot"); - let target_opt = getopts::opt_maybe_str(match, "target"); - let save_temps = getopts::opt_present(match, "save-temps"); + let extra_debuginfo = opt_present(match, ~"xg"); + let debuginfo = opt_present(match, ~"g") || extra_debuginfo; + let sysroot_opt = getopts::opt_maybe_str(match, ~"sysroot"); + let target_opt = getopts::opt_maybe_str(match, ~"target"); + let save_temps = getopts::opt_present(match, ~"save-temps"); alt output_type { // unless we're emitting huamn-readable assembly, omit comments. link::output_type_llvm_assembly | link::output_type_assembly {} _ { debugging_opts |= session::no_asm_comments; } } let opt_level: uint = - if opt_present(match, "O") { - if opt_present(match, "opt-level") { - early_error(demitter, "-O and --opt-level both provided"); + if opt_present(match, ~"O") { + if opt_present(match, ~"opt-level") { + early_error(demitter, ~"-O and --opt-level both provided"); } 2u - } else if opt_present(match, "opt-level") { - alt getopts::opt_str(match, "opt-level") { - "0" { 0u } - "1" { 1u } - "2" { 2u } - "3" { 3u } + } else if opt_present(match, ~"opt-level") { + alt getopts::opt_str(match, ~"opt-level") { + ~"0" { 0u } + ~"1" { 1u } + ~"2" { 2u } + ~"3" { 3u } _ { - early_error(demitter, "optimization level needs " + - "to be between 0-3") + early_error(demitter, ~"optimization level needs " + + ~"to be between 0-3") } } } else { 0u }; @@ -485,9 +486,9 @@ fn build_session_options(match: getopts::match, some(s) { s } }; - let addl_lib_search_paths = getopts::opt_strs(match, "L"); - let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg")); - let test = opt_present(match, "test"); + let addl_lib_search_paths = getopts::opt_strs(match, ~"L"); + let cfg = parse_cfgspecs(getopts::opt_strs(match, ~"cfg")); + let test = opt_present(match, ~"test"); let sopts: @session::options = @{crate_type: crate_type, static: static, @@ -545,44 +546,45 @@ fn build_session_( warning_settings: warning_settings} } -fn parse_pretty(sess: session, &&name: str) -> pp_mode { - if str::eq(name, "normal") { +fn parse_pretty(sess: session, &&name: ~str) -> pp_mode { + if str::eq(name, ~"normal") { ret ppm_normal; - } else if str::eq(name, "expanded") { + } else if str::eq(name, ~"expanded") { ret ppm_expanded; - } else if str::eq(name, "typed") { + } else if str::eq(name, ~"typed") { ret ppm_typed; - } else if str::eq(name, "expanded,identified") { + } else if str::eq(name, ~"expanded,identified") { ret ppm_expanded_identified; - } else if str::eq(name, "identified") { + } else if str::eq(name, ~"identified") { ret ppm_identified; } - sess.fatal("argument to `pretty` must be one of `normal`, `typed`, or " + - "`identified`"); + sess.fatal(~"argument to `pretty` must be one of `normal`, `typed`, or " + + ~"`identified`"); } fn opts() -> ~[getopts::opt] { - ret ~[optflag("h"), optflag("help"), optflag("v"), optflag("version"), - optflag("emit-llvm"), optflagopt("pretty"), - optflag("ls"), optflag("parse-only"), optflag("no-trans"), - optflag("O"), optopt("opt-level"), optmulti("L"), optflag("S"), - optopt("o"), optopt("out-dir"), optflag("xg"), - optflag("c"), optflag("g"), optflag("save-temps"), - optopt("sysroot"), optopt("target"), + ret ~[optflag(~"h"), optflag(~"help"), optflag(~"v"), optflag(~"version"), + optflag(~"emit-llvm"), optflagopt(~"pretty"), + optflag(~"ls"), optflag(~"parse-only"), optflag(~"no-trans"), + optflag(~"O"), optopt(~"opt-level"), optmulti(~"L"), optflag(~"S"), + optopt(~"o"), optopt(~"out-dir"), optflag(~"xg"), + optflag(~"c"), optflag(~"g"), optflag(~"save-temps"), + optopt(~"sysroot"), optopt(~"target"), - optmulti("W"), optmulti("warn"), + optmulti(~"W"), optmulti(~"warn"), - optmulti("Z"), + optmulti(~"Z"), - optmulti("cfg"), optflag("test"), - optflag("lib"), optflag("bin"), optflag("static"), optflag("gc")]; + optmulti(~"cfg"), optflag(~"test"), + optflag(~"lib"), optflag(~"bin"), + optflag(~"static"), optflag(~"gc")]; } -type output_filenames = @{out_filename: str, obj_filename:str}; +type output_filenames = @{out_filename: ~str, obj_filename:~str}; fn build_output_filenames(input: input, - odir: option, - ofile: option, + odir: option<~str>, + ofile: option<~str>, sess: session) -> output_filenames { let obj_path; @@ -595,13 +597,13 @@ fn build_output_filenames(input: input, let obj_suffix = alt sopts.output_type { - link::output_type_none { "none" } - link::output_type_bitcode { "bc" } - link::output_type_assembly { "s" } - link::output_type_llvm_assembly { "ll" } + link::output_type_none { ~"none" } + link::output_type_bitcode { ~"bc" } + link::output_type_assembly { ~"s" } + link::output_type_llvm_assembly { ~"ll" } // Object and exe output both use the '.o' extension here link::output_type_object | link::output_type_exe { - "o" + ~"o" } }; @@ -630,7 +632,7 @@ fn build_output_filenames(input: input, path::basename(path) } str_input(_) { - "rust_out" + ~"rust_out" } }; let base_path = path::connect(dirname, base_filename); @@ -640,10 +642,10 @@ fn build_output_filenames(input: input, let basename = path::basename(base_path); let dylibname = os::dll_filename(basename); out_path = path::connect(dirname, dylibname); - obj_path = path::connect(dirname, basename + "." + obj_suffix); + obj_path = path::connect(dirname, basename + ~"." + obj_suffix); } else { out_path = base_path; - obj_path = base_path + "." + obj_suffix; + obj_path = base_path + ~"." + obj_suffix; } } @@ -653,7 +655,7 @@ fn build_output_filenames(input: input, out_file } else { let (base, _) = path::splitext(out_file); - let modified = base + "." + obj_suffix; + let modified = base + ~"." + obj_suffix; modified }; @@ -665,7 +667,7 @@ fn build_output_filenames(input: input, } if odir != none { - sess.warn("ignoring --out-dir flag due to -o flag."); + sess.warn(~"ignoring --out-dir flag due to -o flag."); } } } @@ -673,12 +675,12 @@ fn build_output_filenames(input: input, obj_filename: obj_path}; } -fn early_error(emitter: diagnostic::emitter, msg: str) -> ! { +fn early_error(emitter: diagnostic::emitter, msg: ~str) -> ! { emitter(none, msg, diagnostic::fatal); fail; } -fn list_metadata(sess: session, path: str, out: io::writer) { +fn list_metadata(sess: session, path: ~str, out: io::writer) { metadata::loader::list_file_metadata( session::sess_os_to_meta_os(sess.targ_cfg.os), path, out); } @@ -690,15 +692,15 @@ mod test { #[test] fn test_switch_implies_cfg_test() { let match = - alt getopts::getopts(~["--test"], opts()) { + alt getopts::getopts(~[~"--test"], opts()) { ok(m) { m } - err(f) { fail "test_switch_implies_cfg_test: " + + err(f) { fail ~"test_switch_implies_cfg_test: " + getopts::fail_str(f); } }; let sessopts = build_session_options(match, diagnostic::emit); let sess = build_session(sessopts, diagnostic::emit); - let cfg = build_configuration(sess, "whatever", str_input("")); - assert (attr::contains_name(cfg, "test")); + let cfg = build_configuration(sess, ~"whatever", str_input(~"")); + assert (attr::contains_name(cfg, ~"test")); } // When the user supplies --test and --cfg test, don't implicitly add @@ -706,15 +708,17 @@ fn test_switch_implies_cfg_test() { #[test] fn test_switch_implies_cfg_test_unless_cfg_test() { let match = - alt getopts::getopts(~["--test", "--cfg=test"], opts()) { + alt getopts::getopts(~[~"--test", ~"--cfg=test"], opts()) { ok(m) { m } - err(f) { fail "test_switch_implies_cfg_test_unless_cfg_test: " + - getopts::fail_str(f); } + err(f) { + fail ~"test_switch_implies_cfg_test_unless_cfg_test: " + + getopts::fail_str(f); + } }; let sessopts = build_session_options(match, diagnostic::emit); let sess = build_session(sessopts, diagnostic::emit); - let cfg = build_configuration(sess, "whatever", str_input("")); - let test_items = attr::find_meta_items_by_name(cfg, "test"); + let cfg = build_configuration(sess, ~"whatever", str_input(~"")); + let test_items = attr::find_meta_items_by_name(cfg, ~"test"); assert (vec::len(test_items) == 1u); } } diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 5a9c6774db5e..e54ca83ebdce 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -20,17 +20,17 @@ import rustc::middle::lint; import io::reader_util; -fn version(argv0: str) { - let mut vers = "unknown version"; +fn version(argv0: ~str) { + let mut vers = ~"unknown version"; let env_vers = #env["CFG_VERSION"]; if str::len(env_vers) != 0u { vers = env_vers; } io::println(#fmt("%s %s", argv0, vers)); io::println(#fmt("host: %s", host_triple())); } -fn usage(argv0: str) { +fn usage(argv0: ~str) { io::println(#fmt("Usage: %s [options] \n", argv0) + - " + ~" Options: --bin Compile an executable crate (default) @@ -81,24 +81,24 @@ fn describe_warnings() { let lint_dict = lint::get_lint_dict(); let mut max_key = 0u; for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); } - fn padded(max: uint, s: str) -> str { + fn padded(max: uint, s: ~str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } io::println(#fmt("\nAvailable warnings:\n")); io::println(#fmt(" %s %7.7s %s", - padded(max_key, "name"), "default", "meaning")); + padded(max_key, ~"name"), ~"default", ~"meaning")); io::println(#fmt(" %s %7.7s %s\n", - padded(max_key, "----"), "-------", "-------")); + padded(max_key, ~"----"), ~"-------", ~"-------")); for lint_dict.each |k, v| { - let k = str::replace(k, "_", "-"); + let k = str::replace(k, ~"_", ~"-"); io::println(#fmt(" %s %7.7s %s", padded(max_key, k), - alt v.default { lint::warn { "warn" } - lint::error { "error" } - lint::ignore { "ignore" } }, + alt v.default { lint::warn { ~"warn" } + lint::error { ~"error" } + lint::ignore { ~"ignore" } }, v.desc)); } - io::println(""); + io::println(~""); } fn describe_debug_flags() { @@ -109,7 +109,7 @@ fn describe_debug_flags() { } } -fn run_compiler(args: ~[str], demitter: diagnostic::emitter) { +fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { // Don't display log spew by default. Can override with RUST_LOG. logging::console_off(); @@ -126,62 +126,62 @@ fn run_compiler(args: ~[str], demitter: diagnostic::emitter) { } }; - if opt_present(match, "h") || opt_present(match, "help") { + if opt_present(match, ~"h") || opt_present(match, ~"help") { usage(binary); ret; } - let lint_flags = vec::append(getopts::opt_strs(match, "W"), - getopts::opt_strs(match, "warn")); - if lint_flags.contains("help") { + let lint_flags = vec::append(getopts::opt_strs(match, ~"W"), + getopts::opt_strs(match, ~"warn")); + if lint_flags.contains(~"help") { describe_warnings(); ret; } - if getopts::opt_strs(match, "Z").contains("help") { + if getopts::opt_strs(match, ~"Z").contains(~"help") { describe_debug_flags(); ret; } - if opt_present(match, "v") || opt_present(match, "version") { + if opt_present(match, ~"v") || opt_present(match, ~"version") { version(binary); ret; } let input = alt vec::len(match.free) { - 0u { early_error(demitter, "no input filename given") } + 0u { early_error(demitter, ~"no input filename given") } 1u { let ifile = match.free[0]; - if ifile == "-" { + if ifile == ~"-" { let src = str::from_bytes(io::stdin().read_whole_stream()); str_input(src) } else { file_input(ifile) } } - _ { early_error(demitter, "multiple input filenames provided") } + _ { early_error(demitter, ~"multiple input filenames provided") } }; let sopts = build_session_options(match, demitter); let sess = build_session(sopts, demitter); - let odir = getopts::opt_maybe_str(match, "out-dir"); - let ofile = getopts::opt_maybe_str(match, "o"); + let odir = getopts::opt_maybe_str(match, ~"out-dir"); + let ofile = getopts::opt_maybe_str(match, ~"o"); let cfg = build_configuration(sess, binary, input); let pretty = - option::map(getopts::opt_default(match, "pretty", - "normal"), + option::map(getopts::opt_default(match, ~"pretty", + ~"normal"), |a| parse_pretty(sess, a) ); alt pretty { some::(ppm) { pretty_print_input(sess, cfg, input, ppm); ret; } none:: {/* continue */ } } - let ls = opt_present(match, "ls"); + let ls = opt_present(match, ~"ls"); if ls { alt input { file_input(ifile) { list_metadata(sess, ifile, io::stdout()); } str_input(_) { - early_error(demitter, "can not list metadata for stdin"); + early_error(demitter, ~"can not list metadata for stdin"); } } ret; @@ -216,7 +216,7 @@ enum monitor_msg { // The 'diagnostics emitter'. Every error, warning, etc. should // go through this function. let demitter = fn@(cmsp: option<(codemap::codemap, codemap::span)>, - msg: str, lvl: diagnostic::level) { + msg: ~str, lvl: diagnostic::level) { if lvl == diagnostic::fatal { comm::send(ch, fatal); } @@ -239,13 +239,13 @@ enum monitor_msg { if comm::recv(p) == done { diagnostic::emit( none, - diagnostic::ice_msg("unexpected failure"), + diagnostic::ice_msg(~"unexpected failure"), diagnostic::error); for [ - "the compiler hit an unexpected failure path. \ + ~"the compiler hit an unexpected failure path. \ this is a bug", - "try running with RUST_LOG=rustc=0,::rt::backtrace \ + ~"try running with RUST_LOG=rustc=0,::rt::backtrace \ to get further details and report the results \ to github.com/mozilla/rust/issues" ]/_.each |note| { @@ -258,7 +258,7 @@ enum monitor_msg { } } -fn main(args: ~[str]) { +fn main(args: ~[~str]) { do monitor |demitter| { run_compiler(args, demitter); } diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index be21555a1d73..3697934dbc00 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -40,23 +40,24 @@ enum crate_type { bin_crate, lib_crate, unknown_crate, } const borrowck_note_pure: uint = 2048; const borrowck_note_loan: uint = 4096; -fn debugging_opts_map() -> ~[(str, str, uint)] { - ~[("ppregions", "prettyprint regions with \ +fn debugging_opts_map() -> ~[(~str, ~str, uint)] { + ~[(~"ppregions", ~"prettyprint regions with \ internal repr details", ppregions), - ("time-passes", "measure time of each rustc pass", time_passes), - ("count-llvm-insns", "count where LLVM \ + (~"time-passes", ~"measure time of each rustc pass", time_passes), + (~"count-llvm-insns", ~"count where LLVM \ instrs originate", count_llvm_insns), - ("time-llvm-passes", "measure time of each LLVM pass", time_llvm_passes), - ("trans-stats", "gather trans statistics", trans_stats), - ("no-asm-comments", "omit comments when using -S", no_asm_comments), - ("no-verify", "skip LLVM verification", no_verify), - ("trace", "emit trace logs", trace), - ("no-rt", "do not link to the runtime", no_rt), - ("coherence", "perform coherence checking", coherence), - ("borrowck-stats", "gather borrowck statistics", borrowck_stats), - ("borrowck-note-pure", "note where purity is req'd", + (~"time-llvm-passes", ~"measure time of each LLVM pass", + time_llvm_passes), + (~"trans-stats", ~"gather trans statistics", trans_stats), + (~"no-asm-comments", ~"omit comments when using -S", no_asm_comments), + (~"no-verify", ~"skip LLVM verification", no_verify), + (~"trace", ~"emit trace logs", trace), + (~"no-rt", ~"do not link to the runtime", no_rt), + (~"coherence", ~"perform coherence checking", coherence), + (~"borrowck-stats", ~"gather borrowck statistics", borrowck_stats), + (~"borrowck-note-pure", ~"note where purity is req'd", borrowck_note_pure), - ("borrowck-note-loan", "note where loans are req'd", + (~"borrowck-note-loan", ~"note where loans are req'd", borrowck_note_loan) ] } @@ -72,9 +73,9 @@ fn debugging_opts_map() -> ~[(str, str, uint)] { lint_opts: ~[(lint::lint, lint::level)], save_temps: bool, output_type: back::link::output_type, - addl_lib_search_paths: ~[str], - maybe_sysroot: option, - target_triple: str, + addl_lib_search_paths: ~[~str], + maybe_sysroot: option<~str>, + target_triple: ~str, cfg: ast::crate_cfg, test: bool, parse_only: bool, @@ -82,7 +83,7 @@ fn debugging_opts_map() -> ~[(str, str, uint)] { debugging_opts: uint, }; -type crate_metadata = {name: str, data: ~[u8]}; +type crate_metadata = {name: ~str, data: ~[u8]}; type session = @{targ_cfg: @config, opts: @options, @@ -94,20 +95,20 @@ fn debugging_opts_map() -> ~[(str, str, uint)] { span_diagnostic: diagnostic::span_handler, filesearch: filesearch::filesearch, mut building_library: bool, - working_dir: str, + working_dir: ~str, warning_settings: lint::warning_settings}; impl session for session { - fn span_fatal(sp: span, msg: str) -> ! { + fn span_fatal(sp: span, msg: ~str) -> ! { self.span_diagnostic.span_fatal(sp, msg) } - fn fatal(msg: str) -> ! { + fn fatal(msg: ~str) -> ! { self.span_diagnostic.handler().fatal(msg) } - fn span_err(sp: span, msg: str) { + fn span_err(sp: span, msg: ~str) { self.span_diagnostic.span_err(sp, msg) } - fn err(msg: str) { + fn err(msg: ~str) { self.span_diagnostic.handler().err(msg) } fn has_errors() -> bool { @@ -116,32 +117,32 @@ fn has_errors() -> bool { fn abort_if_errors() { self.span_diagnostic.handler().abort_if_errors() } - fn span_warn(sp: span, msg: str) { + fn span_warn(sp: span, msg: ~str) { self.span_diagnostic.span_warn(sp, msg) } - fn warn(msg: str) { + fn warn(msg: ~str) { self.span_diagnostic.handler().warn(msg) } - fn span_note(sp: span, msg: str) { + fn span_note(sp: span, msg: ~str) { self.span_diagnostic.span_note(sp, msg) } - fn note(msg: str) { + fn note(msg: ~str) { self.span_diagnostic.handler().note(msg) } - fn span_bug(sp: span, msg: str) -> ! { + fn span_bug(sp: span, msg: ~str) -> ! { self.span_diagnostic.span_bug(sp, msg) } - fn bug(msg: str) -> ! { + fn bug(msg: ~str) -> ! { self.span_diagnostic.handler().bug(msg) } - fn span_unimpl(sp: span, msg: str) -> ! { + fn span_unimpl(sp: span, msg: ~str) -> ! { self.span_diagnostic.span_unimpl(sp, msg) } - fn unimpl(msg: str) -> ! { + fn unimpl(msg: ~str) -> ! { self.span_diagnostic.handler().unimpl(msg) } fn span_lint_level(level: lint::level, - sp: span, msg: str) { + sp: span, msg: ~str) { alt level { lint::ignore { } lint::warn { self.span_warn(sp, msg); } @@ -150,7 +151,7 @@ fn span_lint_level(level: lint::level, } fn span_lint(lint_mode: lint::lint, expr_id: ast::node_id, item_id: ast::node_id, - span: span, msg: str) { + span: span, msg: ~str) { let level = lint::get_warning_settings_level( self.warning_settings, lint_mode, expr_id, item_id); self.span_lint_level(level, span, msg); @@ -201,7 +202,7 @@ fn basic_options() -> @options { } // Seems out of place, but it uses session, so I'm putting it here -fn expect(sess: session, opt: option, msg: fn() -> str) -> T { +fn expect(sess: session, opt: option, msg: fn() -> ~str) -> T { diagnostic::expect(sess.diagnostic(), opt, msg) } @@ -216,8 +217,8 @@ fn building_library(req_crate_type: crate_type, crate: @ast::crate, } else { alt syntax::attr::first_attr_value_str_by_name( crate.node.attrs, - "crate_type") { - option::some(@"lib") { true } + ~"crate_type") { + option::some(@~"lib") { true } _ { false } } } @@ -240,12 +241,12 @@ fn sess_os_to_meta_os(os: os) -> metadata::loader::os { mod test { import syntax::ast_util; - fn make_crate_type_attr(t: str) -> ast::attribute { + fn make_crate_type_attr(t: ~str) -> ast::attribute { ast_util::respan(ast_util::dummy_sp(), { style: ast::attr_outer, value: ast_util::respan(ast_util::dummy_sp(), ast::meta_name_value( - @"crate_type", + @~"crate_type", ast_util::respan(ast_util::dummy_sp(), ast::lit_str(@t)))), is_sugared_doc: false @@ -254,8 +255,8 @@ fn make_crate_type_attr(t: str) -> ast::attribute { fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate { let mut attrs = ~[]; - if with_bin { attrs += ~[make_crate_type_attr("bin")]; } - if with_lib { attrs += ~[make_crate_type_attr("lib")]; } + if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; } + if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; } @ast_util::respan(ast_util::dummy_sp(), { directives: ~[], module: {view_items: ~[], items: ~[]}, diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index a044b45b3ae0..c633cf5d2afa 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -125,7 +125,7 @@ fn in_cfg(cfg: ast::crate_cfg, attrs: ~[ast::attribute]) -> bool { fn metas_in_cfg(cfg: ast::crate_cfg, metas: ~[@ast::meta_item]) -> bool { // The "cfg" attributes on the item - let cfg_metas = attr::find_meta_items_by_name(metas, "cfg"); + let cfg_metas = attr::find_meta_items_by_name(metas, ~"cfg"); // Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes, // so we can match against them. This is the list of configurations for diff --git a/src/rustc/front/core_inject.rs b/src/rustc/front/core_inject.rs index 446e0f25faee..24b1a8094e3a 100644 --- a/src/rustc/front/core_inject.rs +++ b/src/rustc/front/core_inject.rs @@ -16,7 +16,7 @@ fn maybe_inject_libcore_ref(sess: session, } fn use_core(crate: @ast::crate) -> bool { - !attr::attrs_contains_name(crate.node.attrs, "no_core") + !attr::attrs_contains_name(crate.node.attrs, ~"no_core") } fn inject_libcore_ref(sess: session, @@ -30,11 +30,11 @@ fn spanned(x: T) -> @ast::spanned { let n1 = sess.next_node_id(); let n2 = sess.next_node_id(); - let vi1 = @{node: ast::view_item_use(@"core", ~[], n1), + let vi1 = @{node: ast::view_item_use(@~"core", ~[], n1), attrs: ~[], vis: ast::public, span: dummy_sp()}; - let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), @"core"), + let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), @~"core"), n2)); let vi2 = @{node: ast::view_item_import(~[vp]), attrs: ~[], diff --git a/src/rustc/front/intrinsic.rs b/src/rustc/front/intrinsic.rs index 21d8777e22df..7f2e11ecccd7 100644 --- a/src/rustc/front/intrinsic.rs +++ b/src/rustc/front/intrinsic.rs @@ -64,14 +64,14 @@ fn visit_evec_fixed(n: uint, mtbl: uint, fn visit_enter_rec(n_fields: uint, sz: uint, align: uint) -> bool; - fn visit_rec_field(i: uint, name: str/&, + fn visit_rec_field(i: uint, name: &str, mtbl: uint, inner: *tydesc) -> bool; fn visit_leave_rec(n_fields: uint, sz: uint, align: uint) -> bool; fn visit_enter_class(n_fields: uint, sz: uint, align: uint) -> bool; - fn visit_class_field(i: uint, name: str/&, + fn visit_class_field(i: uint, name: &str, mtbl: uint, inner: *tydesc) -> bool; fn visit_leave_class(n_fields: uint, sz: uint, align: uint) -> bool; @@ -87,12 +87,12 @@ fn visit_enter_enum(n_variants: uint, fn visit_enter_enum_variant(variant: uint, disr_val: int, n_fields: uint, - name: str/&) -> bool; + name: &str) -> bool; fn visit_enum_variant_field(i: uint, inner: *tydesc) -> bool; fn visit_leave_enum_variant(variant: uint, disr_val: int, n_fields: uint, - name: str/&) -> bool; + name: &str) -> bool; fn visit_leave_enum(n_variants: uint, sz: uint, align: uint) -> bool; diff --git a/src/rustc/front/intrinsic_inject.rs b/src/rustc/front/intrinsic_inject.rs index 9f2741804bfa..ea841c0700cc 100644 --- a/src/rustc/front/intrinsic_inject.rs +++ b/src/rustc/front/intrinsic_inject.rs @@ -9,7 +9,7 @@ fn inject_intrinsic(sess: session, let intrinsic_module = @#include_str("intrinsic.rs"); - let item = parse::parse_item_from_source_str("", + let item = parse::parse_item_from_source_str(~"", intrinsic_module, sess.opts.cfg, ~[], ast::public, @@ -18,7 +18,7 @@ fn inject_intrinsic(sess: session, alt item { some(i) { i } none { - sess.fatal("no item found in intrinsic module"); + sess.fatal(~"no item found in intrinsic module"); } }; diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 44d68a3fcd96..17b92f6925e0 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -58,7 +58,7 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate { // When not compiling with --test we should not compile the // #[test] functions do config::strip_items(crate) |attrs| { - !attr::contains_name(attr::attr_metas(attrs), "test") + !attr::contains_name(attr::attr_metas(attrs), ~"test") } } @@ -72,7 +72,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { fn nomain(&&item: @ast::item) -> option<@ast::item> { alt item.node { ast::item_fn(_, _, _) { - if *item.ident == "main" { + if *item.ident == ~"main" { option::none } else { option::some(item) } } @@ -106,7 +106,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> ast::item_fn(decl, _, _) if decl.purity == ast::unsafe_fn { cx.sess.span_fatal( i.span, - "unsafe functions cannot be used for tests"); + ~"unsafe functions cannot be used for tests"); } _ { #debug("this is a test function"); @@ -126,7 +126,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> fn is_test_fn(i: @ast::item) -> bool { let has_test_attr = - vec::len(attr::find_attrs_by_name(i.attrs, "test")) > 0u; + vec::len(attr::find_attrs_by_name(i.attrs, ~"test")) > 0u; fn has_test_signature(i: @ast::item) -> bool { alt i.node { @@ -144,7 +144,7 @@ fn has_test_signature(i: @ast::item) -> bool { } fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool { - let ignoreattrs = attr::find_attrs_by_name(i.attrs, "ignore"); + let ignoreattrs = attr::find_attrs_by_name(i.attrs, ~"ignore"); let ignoreitems = attr::attr_metas(ignoreattrs); let cfg_metas = vec::concat(vec::filter_map(ignoreitems, |&&i| attr::get_meta_item_list(i) )); @@ -156,7 +156,7 @@ fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool { } fn should_fail(i: @ast::item) -> bool { - vec::len(attr::find_attrs_by_name(i.attrs, "should_fail")) > 0u + vec::len(attr::find_attrs_by_name(i.attrs, ~"should_fail")) > 0u } fn add_test_module(cx: test_ctxt, m: ast::_mod) -> ast::_mod { @@ -192,9 +192,9 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item { let item_ = ast::item_mod(testmod); // This attribute tells resolve to let us call unexported functions let resolve_unexported_attr = - attr::mk_attr(attr::mk_word_item(@"!resolve_unexported")); + attr::mk_attr(attr::mk_word_item(@~"!resolve_unexported")); let item: ast::item = - {ident: @"__test", + {ident: @~"__test", attrs: ~[resolve_unexported_attr], id: cx.sess.next_node_id(), node: item_, @@ -233,7 +233,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item { let item_ = ast::item_fn(decl, ~[], body); let item: ast::item = - {ident: @"tests", + {ident: @~"tests", attrs: ~[], id: cx.sess.next_node_id(), node: item_, @@ -247,18 +247,19 @@ fn mk_path(cx: test_ctxt, path: ~[ast::ident]) -> ~[ast::ident] { // the paths with std:: let is_std = { let items = attr::find_linkage_metas(cx.crate.node.attrs); - alt attr::last_meta_item_value_str_by_name(items, "name") { - some(@"std") { true } + alt attr::last_meta_item_value_str_by_name(items, ~"name") { + some(@~"std") { true } _ { false } } }; if is_std { path } - else { vec::append(~[@"std"], path) } + else { vec::append(~[@~"std"], path) } } // The ast::ty of ~[std::test::test_desc] fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { - let test_desc_ty_path = path_node(mk_path(cx, ~[@"test", @"test_desc"])); + let test_desc_ty_path = + path_node(mk_path(cx, ~[@~"test", @~"test_desc"])); let test_desc_ty: ast::ty = {id: cx.sess.next_node_id(), @@ -300,14 +301,20 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { let name_lit: ast::lit = nospan(ast::lit_str(@ast_util::path_name_i(path))); - let name_expr: ast::expr = - {id: cx.sess.next_node_id(), - callee_id: cx.sess.next_node_id(), - node: ast::expr_lit(@name_lit), - span: span}; + let name_expr_inner: @ast::expr = + @{id: cx.sess.next_node_id(), + callee_id: cx.sess.next_node_id(), + node: ast::expr_lit(@name_lit), + span: span}; + let name_expr = {id: cx.sess.next_node_id(), + callee_id: cx.sess.next_node_id(), + node: ast::expr_vstore(name_expr_inner, + ast::vstore_uniq), + span: dummy_sp()}; + let name_field: ast::field = - nospan({mutbl: ast::m_imm, ident: @"name", expr: @name_expr}); + nospan({mutbl: ast::m_imm, ident: @~"name", expr: @name_expr}); let fn_path = path_node(path); @@ -320,7 +327,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span); let fn_field: ast::field = - nospan({mutbl: ast::m_imm, ident: @"fn", expr: fn_wrapper_expr}); + nospan({mutbl: ast::m_imm, ident: @~"fn", expr: fn_wrapper_expr}); let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore)); @@ -331,7 +338,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { span: span}; let ignore_field: ast::field = - nospan({mutbl: ast::m_imm, ident: @"ignore", expr: @ignore_expr}); + nospan({mutbl: ast::m_imm, ident: @~"ignore", expr: @ignore_expr}); let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail)); @@ -342,7 +349,9 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { span: span}; let fail_field: ast::field = - nospan({mutbl: ast::m_imm, ident: @"should_fail", expr: @fail_expr}); + nospan({mutbl: ast::m_imm, + ident: @~"should_fail", + expr: @fail_expr}); let desc_rec_: ast::expr_ = ast::expr_rec(~[name_field, fn_field, ignore_field, fail_field], @@ -397,9 +406,12 @@ fn mk_test_wrapper(cx: test_ctxt, } fn mk_main(cx: test_ctxt) -> @ast::item { - let str_pt = path_node(~[@"str"]); + let str_pt = path_node(~[@~"str"]); + let str_ty_inner = @{id: cx.sess.next_node_id(), + node: ast::ty_path(str_pt, cx.sess.next_node_id()), + span: dummy_sp()}; let str_ty = @{id: cx.sess.next_node_id(), - node: ast::ty_path(str_pt, cx.sess.next_node_id()), + node: ast::ty_vstore(str_ty_inner, ast::vstore_uniq), span: dummy_sp()}; let args_mt = {ty: str_ty, mutbl: ast::m_imm}; let args_ty_inner = @{id: cx.sess.next_node_id(), @@ -413,7 +425,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { let args_arg: ast::arg = {mode: ast::expl(ast::by_val), ty: @args_ty, - ident: @"args", + ident: @~"args", id: cx.sess.next_node_id()}; let ret_ty = {id: cx.sess.next_node_id(), @@ -436,7 +448,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { let item_ = ast::item_fn(decl, ~[], body); let item: ast::item = - {ident: @"main", + {ident: @~"main", attrs: ~[], id: cx.sess.next_node_id(), node: item_, @@ -448,7 +460,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { // Get the args passed to main so we can pass the to test_main - let args_path = path_node(~[@"args"]); + let args_path = path_node(~[@~"args"]); let args_path_expr_: ast::expr_ = ast::expr_path(args_path); @@ -457,7 +469,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { node: args_path_expr_, span: dummy_sp()}; // Call __test::test to generate the vector of test_descs - let test_path = path_node(~[@"tests"]); + let test_path = path_node(~[@~"tests"]); let test_path_expr_: ast::expr_ = ast::expr_path(test_path); @@ -472,7 +484,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { node: test_call_expr_, span: dummy_sp()}; // Call std::test::test_main - let test_main_path = path_node(mk_path(cx, ~[@"test", @"test_main"])); + let test_main_path = path_node(mk_path(cx, ~[@~"test", @~"test_main"])); let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path); diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 1df423cdbb22..0c00a8674a52 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -987,19 +987,19 @@ fn SetLinkage(Global: ValueRef, Link: Linkage) { /* Memory-managed object interface to type handles. */ -type type_names = @{type_names: std::map::hashmap, - named_types: std::map::hashmap}; +type type_names = @{type_names: std::map::hashmap, + named_types: std::map::hashmap<~str, TypeRef>}; -fn associate_type(tn: type_names, s: str, t: TypeRef) { +fn associate_type(tn: type_names, s: ~str, t: TypeRef) { assert tn.type_names.insert(t, s); assert tn.named_types.insert(s, t); } -fn type_has_name(tn: type_names, t: TypeRef) -> option { +fn type_has_name(tn: type_names, t: TypeRef) -> option<~str> { ret tn.type_names.find(t); } -fn name_has_type(tn: type_names, s: str) -> option { +fn name_has_type(tn: type_names, s: ~str) -> option { ret tn.named_types.find(s); } @@ -1010,12 +1010,12 @@ fn mk_type_names() -> type_names { named_types: std::map::str_hash()} } -fn type_to_str(names: type_names, ty: TypeRef) -> str { +fn type_to_str(names: type_names, ty: TypeRef) -> ~str { ret type_to_str_inner(names, ~[], ty); } fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> - str { + ~str { alt type_has_name(names, ty) { option::some(n) { ret n; } _ {} @@ -1026,30 +1026,30 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> let kind = llvm::LLVMGetTypeKind(ty); fn tys_str(names: type_names, outer: ~[TypeRef], - tys: ~[TypeRef]) -> str { - let mut s: str = ""; + tys: ~[TypeRef]) -> ~str { + let mut s: ~str = ~""; let mut first: bool = true; for tys.each |t| { - if first { first = false; } else { s += ", "; } + if first { first = false; } else { s += ~", "; } s += type_to_str_inner(names, outer, t); } ret s; } alt kind { - Void { ret "Void"; } - Half { ret "Half"; } - Float { ret "Float"; } - Double { ret "Double"; } - X86_FP80 { ret "X86_FP80"; } - FP128 { ret "FP128"; } - PPC_FP128 { ret "PPC_FP128"; } - Label { ret "Label"; } + Void { ret ~"Void"; } + Half { ret ~"Half"; } + Float { ret ~"Float"; } + Double { ret ~"Double"; } + X86_FP80 { ret ~"X86_FP80"; } + FP128 { ret ~"FP128"; } + PPC_FP128 { ret ~"PPC_FP128"; } + Label { ret ~"Label"; } Integer { - ret "i" + int::str(llvm::LLVMGetIntTypeWidth(ty) as int); + ret ~"i" + int::str(llvm::LLVMGetIntTypeWidth(ty) as int); } Function { - let mut s = "fn("; + let mut s = ~"fn("; let out_ty: TypeRef = llvm::LLVMGetReturnType(ty); let n_args = llvm::LLVMCountParamTypes(ty) as uint; let args = vec::from_elem(n_args, 0 as TypeRef); @@ -1057,25 +1057,25 @@ fn tys_str(names: type_names, outer: ~[TypeRef], llvm::LLVMGetParamTypes(ty, vec::unsafe::to_ptr(args)); } s += tys_str(names, outer, args); - s += ") -> "; + s += ~") -> "; s += type_to_str_inner(names, outer, out_ty); ret s; } Struct { - let mut s: str = "{"; + let mut s: ~str = ~"{"; let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint; let elts = vec::from_elem(n_elts, 0 as TypeRef); unsafe { llvm::LLVMGetStructElementTypes(ty, vec::unsafe::to_ptr(elts)); } s += tys_str(names, outer, elts); - s += "}"; + s += ~"}"; ret s; } Array { let el_ty = llvm::LLVMGetElementType(ty); - ret "[" + type_to_str_inner(names, outer, el_ty) + " x " + - uint::str(llvm::LLVMGetArrayLength(ty) as uint) + "]"; + ret ~"[" + type_to_str_inner(names, outer, el_ty) + ~" x " + + uint::str(llvm::LLVMGetArrayLength(ty) as uint) + ~"]"; } Pointer { let mut i: uint = 0u; @@ -1083,23 +1083,23 @@ fn tys_str(names: type_names, outer: ~[TypeRef], i += 1u; if tout as int == ty as int { let n: uint = vec::len::(outer0) - i; - ret "*\\" + int::str(n as int); + ret ~"*\\" + int::str(n as int); } } let addrstr = { let addrspace = llvm::LLVMGetPointerAddressSpace(ty) as uint; if addrspace == 0u { - "" + ~"" } else { #fmt("addrspace(%u)", addrspace) } }; - ret addrstr + "*" + + ret addrstr + ~"*" + type_to_str_inner(names, outer, llvm::LLVMGetElementType(ty)); } - Vector { ret "Vector"; } - Metadata { ret "Metadata"; } - X86_MMX { ret "X86_MMAX"; } + Vector { ret ~"Vector"; } + Metadata { ret ~"Metadata"; } + X86_MMX { ret ~"X86_MMAX"; } } } @@ -1109,7 +1109,7 @@ fn float_width(llt: TypeRef) -> uint { 2 { 64u } 3 { 80u } 4 | 5 { 128u } - _ { fail "llvm_float_width called on a non-float type" } + _ { fail ~"llvm_float_width called on a non-float type" } }; } @@ -1131,7 +1131,7 @@ fn fn_ty_param_tys(fn_ty: TypeRef) -> ~[TypeRef] unsafe { type target_data = {lltd: TargetDataRef, dtor: @target_data_res}; -fn mk_target_data(string_rep: str) -> target_data { +fn mk_target_data(string_rep: ~str) -> target_data { let lltd = str::as_c_str(string_rep, |buf| llvm::LLVMCreateTargetData(buf) ); ret {lltd: lltd, dtor: @target_data_res(lltd)}; diff --git a/src/rustc/metadata/common.rs b/src/rustc/metadata/common.rs index b6883097a5b2..e7ef25a04d55 100644 --- a/src/rustc/metadata/common.rs +++ b/src/rustc/metadata/common.rs @@ -127,11 +127,11 @@ enum astencode_tag { // Reserves 0x50 -- 0x6f // djb's cdb hashes. fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); } -fn hash_path(&&s: str) -> uint { +fn hash_path(&&s: ~str) -> uint { let mut h = 5381u; for str::each(s) |ch| { h = (h << 5u) + h ^ (ch as uint); } ret h; } -type link_meta = {name: @str/~, vers: @str/~, extras_hash: str}; +type link_meta = {name: @~str, vers: @~str, extras_hash: ~str}; diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 13a1d3543c53..28022a373207 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -38,7 +38,7 @@ fn read_crates(diag: span_handler, crate: ast::crate, type cache_entry = { cnum: int, span: span, - hash: @str/~, + hash: @~str, metas: @~[@ast::meta_item] }; @@ -49,7 +49,7 @@ fn dump_crates(crate_cache: dvec) { #debug("span: %?", entry.span); #debug("hash: %?", entry.hash); let attrs = ~[ - attr::mk_attr(attr::mk_list_item(@"link", *entry.metas)) + attr::mk_attr(attr::mk_list_item(@~"link", *entry.metas)) ]; for attr::find_linkage_attrs(attrs).each |attr| { #debug("meta: %s", pprust::attr_to_str(attr)); @@ -79,9 +79,9 @@ fn warn_if_multiple_versions(diag: span_handler, diag.handler().warn( #fmt("using multiple versions of crate `%s`", *name)); for matches.each |match| { - diag.span_note(match.span, "used here"); + diag.span_note(match.span, ~"used here"); let attrs = ~[ - attr::mk_attr(attr::mk_list_item(@"link", *match.metas)) + attr::mk_attr(attr::mk_list_item(@~"link", *match.metas)) ]; loader::note_linkage_attrs(diag, attrs); } @@ -103,7 +103,7 @@ fn visit_view_item(e: env, i: @ast::view_item) { alt i.node { ast::view_item_use(ident, meta_items, id) { #debug("resolving use stmt. ident: %?, meta: %?", ident, meta_items); - let cnum = resolve_crate(e, ident, meta_items, "", i.span); + let cnum = resolve_crate(e, ident, meta_items, ~"", i.span); cstore::add_use_stmt_cnum(e.cstore, id, cnum); } _ { } @@ -123,25 +123,25 @@ fn visit_item(e: env, i: @ast::item) { let cstore = e.cstore; let foreign_name = - alt attr::first_attr_value_str_by_name(i.attrs, "link_name") { + alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { some(nn) { - if *nn == "" { + if *nn == ~"" { e.diag.span_fatal( i.span, - "empty #[link_name] not allowed; use #[nolink]."); + ~"empty #[link_name] not allowed; use #[nolink]."); } nn } none { i.ident } }; let mut already_added = false; - if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u { + if vec::len(attr::find_attrs_by_name(i.attrs, ~"nolink")) == 0u { already_added = !cstore::add_used_library(cstore, *foreign_name); } - let link_args = attr::find_attrs_by_name(i.attrs, "link_args"); + let link_args = attr::find_attrs_by_name(i.attrs, ~"link_args"); if vec::len(link_args) > 0u && already_added { - e.diag.span_fatal(i.span, "library '" + *foreign_name + - "' already added: can't specify link_args."); + e.diag.span_fatal(i.span, ~"library '" + *foreign_name + + ~"' already added: can't specify link_args."); } for link_args.each |a| { alt attr::get_meta_item_value_str(attr::attr_meta(a)) { @@ -168,10 +168,10 @@ fn metas_with(ident: ast::ident, key: ast::ident, fn metas_with_ident(ident: ast::ident, metas: ~[@ast::meta_item]) -> ~[@ast::meta_item] { - metas_with(ident, @"name", metas) + metas_with(ident, @~"name", metas) } -fn existing_match(e: env, metas: ~[@ast::meta_item], hash: str) -> +fn existing_match(e: env, metas: ~[@ast::meta_item], hash: ~str) -> option { for e.crate_cache.each |c| { @@ -184,7 +184,7 @@ fn existing_match(e: env, metas: ~[@ast::meta_item], hash: str) -> } fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], - hash: str, span: span) -> ast::crate_num { + hash: ~str, span: span) -> ast::crate_num { let metas = metas_with_ident(ident, metas); alt existing_match(e, metas, hash) { @@ -218,7 +218,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], let cnum_map = resolve_crate_deps(e, cdata); let cname = - alt attr::last_meta_item_value_str_by_name(metas, "name") { + alt attr::last_meta_item_value_str_by_name(metas, ~"name") { option::some(v) { v } option::none { ident } }; @@ -245,7 +245,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map { for decoder::get_crate_deps(cdata).each |dep| { let extrn_cnum = dep.cnum; let cname = dep.name; - let cmetas = metas_with(dep.vers, @"vers", ~[]); + let cmetas = metas_with(dep.vers, @~"vers", ~[]); #debug("resolving dep crate %s ver: %s hash: %s", *dep.name, *dep.vers, *dep.hash); alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) { diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index 16b2481edd9b..22d70f86eb8f 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -30,7 +30,7 @@ export get_item_path; export maybe_get_item_ast, found_ast, found, found_parent, not_found; -fn get_symbol(cstore: cstore::cstore, def: ast::def_id) -> str { +fn get_symbol(cstore: cstore::cstore, def: ast::def_id) -> ~str { let cdata = cstore::get_crate_data(cstore, def.crate).data; ret decoder::get_symbol(cdata, def.node); } diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index f805d8d16cd0..af9b6d57e578 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -37,9 +37,9 @@ // Multiple items may have the same def_id in crate metadata. They may be // renamed imports or reexports. This map keeps the "real" module path // and def_id. -type mod_path_map = map::hashmap; +type mod_path_map = map::hashmap; -type crate_metadata = @{name: str, +type crate_metadata = @{name: ~str, data: @~[u8], cnum_map: cnum_map, cnum: ast::crate_num}; @@ -55,9 +55,9 @@ enum cstore { private(cstore_private), } @{metas: map::hashmap, use_crate_map: use_crate_map, mod_path_map: mod_path_map, - mut used_crate_files: ~[str], - mut used_libraries: ~[str], - mut used_link_args: ~[str]}; + mut used_crate_files: ~[~str], + mut used_libraries: ~[~str], + mut used_link_args: ~[~str]}; // Map from node_id's of local use statements to crate numbers type use_crate_map = map::hashmap; @@ -83,12 +83,12 @@ fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata { ret p(cstore).metas.get(cnum); } -fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> @str/~ { +fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> @~str { let cdata = get_crate_data(cstore, cnum); ret decoder::get_crate_hash(cdata.data); } -fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @str/~ { +fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @~str { let cdata = get_crate_data(cstore, cnum); ret decoder::get_crate_vers(cdata.data); } @@ -111,33 +111,33 @@ fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) { for p(cstore).metas.each |k,v| { i(k, v);}; } -fn add_used_crate_file(cstore: cstore, lib: str) { +fn add_used_crate_file(cstore: cstore, lib: ~str) { if !vec::contains(p(cstore).used_crate_files, lib) { vec::push(p(cstore).used_crate_files, lib); } } -fn get_used_crate_files(cstore: cstore) -> ~[str] { +fn get_used_crate_files(cstore: cstore) -> ~[~str] { ret p(cstore).used_crate_files; } -fn add_used_library(cstore: cstore, lib: str) -> bool { - assert lib != ""; +fn add_used_library(cstore: cstore, lib: ~str) -> bool { + assert lib != ~""; if vec::contains(p(cstore).used_libraries, lib) { ret false; } vec::push(p(cstore).used_libraries, lib); ret true; } -fn get_used_libraries(cstore: cstore) -> ~[str] { +fn get_used_libraries(cstore: cstore) -> ~[~str] { ret p(cstore).used_libraries; } -fn add_used_link_args(cstore: cstore, args: str) { +fn add_used_link_args(cstore: cstore, args: ~str) { vec::push_all(p(cstore).used_link_args, str::split_char(args, ' ')); } -fn get_used_link_args(cstore: cstore) -> ~[str] { +fn get_used_link_args(cstore: cstore) -> ~[~str] { ret p(cstore).used_link_args; } @@ -153,8 +153,8 @@ fn find_use_stmt_cnum(cstore: cstore, // returns hashes of crates directly used by this crate. Hashes are // sorted by crate name. -fn get_dep_hashes(cstore: cstore) -> ~[@str/~] { - type crate_hash = {name: @str/~, hash: @str/~}; +fn get_dep_hashes(cstore: cstore) -> ~[@~str] { + type crate_hash = {name: @~str, hash: @~str}; let mut result = ~[]; for p(cstore).use_crate_map.each_value |cnum| { @@ -171,14 +171,14 @@ fn lteq(a: crate_hash, b: crate_hash) -> bool { for sorted.each |x| { #debug(" hash[%s]: %s", *x.name, *x.hash); } - fn mapper(ch: crate_hash) -> @str/~ { ret ch.hash; } + fn mapper(ch: crate_hash) -> @~str { ret ch.hash; } ret vec::map(sorted, mapper); } fn get_path(cstore: cstore, d: ast::def_id) -> ~[ast::ident] { // let f = bind str::split_str(_, "::"); option::map_default(p(cstore).mod_path_map.find(d), ~[], - |ds| str::split_str(*ds, "::").map(|x| @x ) ) + |ds| str::split_str(*ds, ~"::").map(|x| @x ) ) } // Local Variables: // mode: rust diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index a1c42ebc2638..45bdee06070f 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -112,7 +112,7 @@ fn item_family(item: ebml::doc) -> char { ebml::doc_as_u8(fam) as char } -fn item_symbol(item: ebml::doc) -> str { +fn item_symbol(item: ebml::doc) -> ~str { let sym = ebml::get_doc(item, tag_items_data_item_symbol); ret str::from_bytes(ebml::doc_data(sym)); } @@ -214,7 +214,7 @@ fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] { // Given a path and serialized crate metadata, returns the IDs of the // definitions the path may refer to. fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] { - fn eq_item(data: &[u8], s: str) -> bool { + fn eq_item(data: &[u8], s: ~str) -> bool { // XXX: Use string equality. let data_len = data.len(); let s_len = s.len(); @@ -385,7 +385,7 @@ fn class_dtor(cdata: cmd, id: ast::node_id) -> option { found } -fn get_symbol(data: @~[u8], id: ast::node_id) -> str { +fn get_symbol(data: @~[u8], id: ast::node_id) -> ~str { ret item_symbol(lookup_item(id, data)); } @@ -399,19 +399,19 @@ enum def_like { fn def_like_to_def(def_like: def_like) -> ast::def { alt def_like { dl_def(def) { ret def; } - dl_impl(*) { fail "found impl in def_like_to_def"; } - dl_field { fail "found field in def_like_to_def"; } + dl_impl(*) { fail ~"found impl in def_like_to_def"; } + dl_field { fail ~"found field in def_like_to_def"; } } } // A path. class path_entry { // The full path, separated by '::'. - let path_string: str; + let path_string: ~str; // The definition, implementation, or field that this path corresponds to. let def_like: def_like; - new(path_string: str, def_like: def_like) { + new(path_string: ~str, def_like: def_like) { self.path_string = path_string; self.def_like = def_like; } @@ -429,8 +429,8 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) { do ebml::tagged_docs(items_data, tag_items_data_item) |item_doc| { if !broken { let name = ast_map::path_to_str_with_sep(item_path(item_doc), - "::"); - if name != "" { + ~"::"); + if name != ~"" { // Extract the def ID. let def_id = class_member_id(item_doc, cdata); @@ -628,7 +628,7 @@ fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) let fty = alt ty::get(ty).struct { ty::ty_fn(f) { f } _ { tcx.diag.handler().bug( - "get_trait_methods: id has non-function type"); + ~"get_trait_methods: id has non-function type"); } }; vec::push(result, {ident: name, tps: bounds, fty: fty, purity: alt check item_family(mth) { @@ -684,7 +684,7 @@ fn family_names_type(fam_ch: char) -> bool { alt fam_ch { 'y' | 't' | 'I' { true } _ { false } } } -fn read_path(d: ebml::doc) -> {path: str, pos: uint} { +fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} { let desc = ebml::doc_data(d); let pos = io::u64_from_be_bytes(desc, 0u, 4u) as uint; let pathbytes = vec::slice::(desc, 4u, vec::len::(desc)); @@ -692,8 +692,8 @@ fn read_path(d: ebml::doc) -> {path: str, pos: uint} { ret {path: path, pos: pos}; } -fn describe_def(items: ebml::doc, id: ast::def_id) -> str { - if id.crate != ast::local_crate { ret "external"; } +fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str { + if id.crate != ast::local_crate { ret ~"external"; } let it = alt maybe_find_item(id.node, items) { some(it) { it } none { fail (#fmt("describe_def: item not found %?", id)); } @@ -701,26 +701,26 @@ fn describe_def(items: ebml::doc, id: ast::def_id) -> str { ret item_family_to_str(item_family(it)); } -fn item_family_to_str(fam: char) -> str { +fn item_family_to_str(fam: char) -> ~str { alt check fam { - 'c' { ret "const"; } - 'f' { ret "fn"; } - 'u' { ret "unsafe fn"; } - 'p' { ret "pure fn"; } - 'F' { ret "foreign fn"; } - 'U' { ret "unsafe foreign fn"; } - 'P' { ret "pure foreign fn"; } - 'y' { ret "type"; } - 'T' { ret "foreign type"; } - 't' { ret "type"; } - 'm' { ret "mod"; } - 'n' { ret "foreign mod"; } - 'v' { ret "enum"; } - 'i' { ret "impl"; } - 'I' { ret "trait"; } - 'C' { ret "class"; } - 'g' { ret "public field"; } - 'j' { ret "private field"; } + 'c' { ret ~"const"; } + 'f' { ret ~"fn"; } + 'u' { ret ~"unsafe fn"; } + 'p' { ret ~"pure fn"; } + 'F' { ret ~"foreign fn"; } + 'U' { ret ~"unsafe foreign fn"; } + 'P' { ret ~"pure foreign fn"; } + 'y' { ret ~"type"; } + 'T' { ret ~"foreign type"; } + 't' { ret ~"type"; } + 'm' { ret ~"mod"; } + 'n' { ret ~"foreign mod"; } + 'v' { ret ~"enum"; } + 'i' { ret ~"impl"; } + 'I' { ret ~"trait"; } + 'C' { ret ~"class"; } + 'g' { ret ~"public field"; } + 'j' { ret ~"private field"; } } } @@ -776,14 +776,14 @@ fn list_meta_items(meta_items: ebml::doc, out: io::writer) { } } -fn list_crate_attributes(md: ebml::doc, hash: @str/~, out: io::writer) { +fn list_crate_attributes(md: ebml::doc, hash: @~str, out: io::writer) { out.write_str(#fmt("=Crate Attributes (%s)=\n", *hash)); for get_attributes(md).each |attr| { out.write_str(#fmt["%s\n", pprust::attribute_to_str(attr)]); } - out.write_str("\n\n"); + out.write_str(~"\n\n"); } fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] { @@ -791,14 +791,14 @@ fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] { } type crate_dep = {cnum: ast::crate_num, name: ast::ident, - vers: @str/~, hash: @str/~}; + vers: @~str, hash: @~str}; fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] { let mut deps: ~[crate_dep] = ~[]; let cratedoc = ebml::doc(data); let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps); let mut crate_num = 1; - fn docstr(doc: ebml::doc, tag_: uint) -> str { + fn docstr(doc: ebml::doc, tag_: uint) -> ~str { str::from_bytes(ebml::doc_data(ebml::get_doc(doc, tag_))) } do ebml::tagged_docs(depsdoc, tag_crate_dep) |depdoc| { @@ -812,33 +812,33 @@ fn docstr(doc: ebml::doc, tag_: uint) -> str { } fn list_crate_deps(data: @~[u8], out: io::writer) { - out.write_str("=External Dependencies=\n"); + out.write_str(~"=External Dependencies=\n"); for get_crate_deps(data).each |dep| { out.write_str(#fmt["%d %s-%s-%s\n", dep.cnum, *dep.name, *dep.hash, *dep.vers]); } - out.write_str("\n"); + out.write_str(~"\n"); } -fn get_crate_hash(data: @~[u8]) -> @str/~ { +fn get_crate_hash(data: @~[u8]) -> @~str { let cratedoc = ebml::doc(data); let hashdoc = ebml::get_doc(cratedoc, tag_crate_hash); ret @str::from_bytes(ebml::doc_data(hashdoc)); } -fn get_crate_vers(data: @~[u8]) -> @str/~ { +fn get_crate_vers(data: @~[u8]) -> @~str { let attrs = decoder::get_crate_attributes(data); ret alt attr::last_meta_item_value_str_by_name( - attr::find_linkage_metas(attrs), "vers") { + attr::find_linkage_metas(attrs), ~"vers") { some(ver) { ver } - none { @"0.0" } + none { @~"0.0" } }; } fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) { - out.write_str("=Items=\n"); + out.write_str(~"=Items=\n"); let items = ebml::get_doc(md, tag_items); do iter_crate_items(bytes) |tag, path, did| { // Don't print out any metadata info about intrinsics @@ -847,10 +847,10 @@ fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) { describe_def(items, did)]); } } - out.write_str("\n"); + out.write_str(~"\n"); } -fn iter_crate_items(bytes: @~[u8], proc: fn(uint, str, ast::def_id)) { +fn iter_crate_items(bytes: @~[u8], proc: fn(uint, ~str, ast::def_id)) { let md = ebml::doc(bytes); let paths = ebml::get_doc(md, tag_paths); let index = ebml::get_doc(paths, tag_index); @@ -867,9 +867,9 @@ fn iter_crate_items(bytes: @~[u8], proc: fn(uint, str, ast::def_id)) { }; } -fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, str)] { - fn mod_of_path(p: str) -> str { - str::connect(vec::init(str::split_str(p, "::")), "::") +fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, ~str)] { + fn mod_of_path(p: ~str) -> ~str { + str::connect(vec::init(str::split_str(p, ~"::")), ~"::") } // find all module (path, def_ids), which are not @@ -913,7 +913,7 @@ fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { alt cdata.cnum_map.find(did.crate) { option::some(n) { ret {crate: n, node: did.node}; } - option::none { fail "didn't find a crate in the cnum_map"; } + option::none { fail ~"didn't find a crate in the cnum_map"; } } } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 12106e5bc451..d1ecf88b3fe2 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -43,10 +43,10 @@ diag: span_handler, tcx: ty::ctxt, reachable: hashmap, - reexports: ~[(str, def_id)], + reexports: ~[(~str, def_id)], impl_map: fn@(ast::node_id) -> ~[(ident, def_id)], - item_symbols: hashmap, - discrim_symbols: hashmap, + item_symbols: hashmap, + discrim_symbols: hashmap, link_meta: link_meta, cstore: cstore::cstore, encode_inlined_item: encode_inlined_item @@ -56,10 +56,10 @@ enum encode_ctxt = { diag: span_handler, tcx: ty::ctxt, reachable: hashmap, - reexports: ~[(str, def_id)], + reexports: ~[(~str, def_id)], impl_map: fn@(ast::node_id) -> ~[(ident, def_id)], - item_symbols: hashmap, - discrim_symbols: hashmap, + item_symbols: hashmap, + discrim_symbols: hashmap, link_meta: link_meta, cstore: cstore::cstore, encode_inlined_item: encode_inlined_item, @@ -109,7 +109,7 @@ fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) { type entry = {val: T, pos: uint}; fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: ~[variant], - path: ~[ident], &index: ~[entry]) { + path: ~[ident], &index: ~[entry<~str>]) { for variants.each |variant| { add_to_index(ebml_w, path, index, variant.node.name); do ebml_w.wr_tag(tag_paths_data_item) { @@ -119,7 +119,7 @@ fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: ~[variant], } } -fn add_to_index(ebml_w: ebml::writer, path: &[ident], &index: ~[entry], +fn add_to_index(ebml_w: ebml::writer, path: &[ident], &index: ~[entry<~str>], name: ident) { let mut full_path = ~[]; vec::push_all(full_path, path); @@ -129,7 +129,7 @@ fn add_to_index(ebml_w: ebml::writer, path: &[ident], &index: ~[entry], } fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_mod, - path: ~[ident], &index: ~[entry]) { + path: ~[ident], &index: ~[entry<~str>]) { for nmod.items.each |nitem| { add_to_index(ebml_w, path, index, nitem.ident); do ebml_w.wr_tag(tag_paths_foreign_path) { @@ -140,7 +140,7 @@ fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_mod, } fn encode_class_item_paths(ebml_w: ebml::writer, - items: ~[@class_member], path: ~[ident], &index: ~[entry]) { + items: ~[@class_member], path: ~[ident], &index: ~[entry<~str>]) { for items.each |it| { alt ast_util::class_member_visibility(it) { private { again; } @@ -158,7 +158,7 @@ fn encode_class_item_paths(ebml_w: ebml::writer, fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, module: _mod, path: ~[ident], - &index: ~[entry]) { + &index: ~[entry<~str>]) { for module.items.each |it| { if !reachable(ecx, it.id) || !ast_util::is_exported(it.ident, module) { again; } @@ -220,7 +220,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, } } item_impl(*) {} - item_mac(*) { fail "item macros unimplemented" } + item_mac(*) { fail ~"item macros unimplemented" } } } } @@ -232,8 +232,8 @@ fn encode_trait_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @trait_ref) { } fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate) - -> ~[entry] { - let mut index: ~[entry] = ~[]; + -> ~[entry<~str>] { + let mut index: ~[entry<~str>] = ~[]; let mut path: ~[ident] = ~[]; ebml_w.start_tag(tag_paths); encode_module_item_paths(ebml_w, ecx, crate.node.module, path, index); @@ -243,7 +243,7 @@ fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate) } fn encode_reexport_paths(ebml_w: ebml::writer, - ecx: @encode_ctxt, &index: ~[entry]) { + ecx: @encode_ctxt, &index: ~[entry<~str>]) { for ecx.reexports.each |reexport| { let (path, def_id) = reexport; vec::push(index, {val: path, pos: ebml_w.writer.tell()}); @@ -264,7 +264,7 @@ fn encode_family(ebml_w: ebml::writer, c: char) { ebml_w.end_tag(); } -fn def_to_str(did: def_id) -> str { ret #fmt["%d:%d", did.crate, did.node]; } +fn def_to_str(did: def_id) -> ~str { ret #fmt["%d:%d", did.crate, did.node]; } fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt, params: ~[ty_param]) { @@ -641,7 +641,7 @@ fn add_to_index_(item: @item, ebml_w: ebml::writer, do option::iter(m_dtor) |dtor| { vec::push(*index, {val: dtor.node.id, pos: ebml_w.writer.tell()}); encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident - + "_dtor"), path, if tps.len() > 0u { + + ~"_dtor"), path, if tps.len() > 0u { some(ii_dtor(dtor, item.ident, tps, local_def(item.id))) } else { none }, tps, ast_util::dtor_dec()); @@ -766,7 +766,7 @@ fn add_to_index_(item: @item, ebml_w: ebml::writer, encode_path(ebml_w, path, ast_map::path_name(item.ident)); ebml_w.end_tag(); } - item_mac(*) { fail "item macros unimplemented" } + item_mac(*) { fail ~"item macros unimplemented" } } } @@ -802,7 +802,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, ebml_w.start_tag(tag_items_data); vec::push(*index, {val: crate_node_id, pos: ebml_w.writer.tell()}); encode_info_for_mod(ecx, ebml_w, crate.node.module, - crate_node_id, ~[], @""); + crate_node_id, ~[], @~""); visit::visit_crate(*crate, (), visit::mk_vt(@{ visit_expr: |_e, _cx, _v| { }, visit_item: |i, cx, v, copy ebml_w| { @@ -886,7 +886,7 @@ fn encode_index(ebml_w: ebml::writer, buckets: ~[@~[entry]], ebml_w.end_tag(); } -fn write_str(writer: io::writer, &&s: str) { writer.write_str(s); } +fn write_str(writer: io::writer, &&s: ~str) { writer.write_str(s); } fn write_int(writer: io::writer, &&n: int) { writer.write_be_uint(n as uint, 4u); @@ -948,22 +948,22 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { fn synthesize_link_attr(ecx: @encode_ctxt, items: ~[@meta_item]) -> attribute { - assert (*ecx.link_meta.name != ""); - assert (*ecx.link_meta.vers != ""); + assert (*ecx.link_meta.name != ~""); + assert (*ecx.link_meta.vers != ~""); let name_item = - attr::mk_name_value_item_str(@"name", *ecx.link_meta.name); + attr::mk_name_value_item_str(@~"name", *ecx.link_meta.name); let vers_item = - attr::mk_name_value_item_str(@"vers", *ecx.link_meta.vers); + attr::mk_name_value_item_str(@~"vers", *ecx.link_meta.vers); let other_items = { - let tmp = attr::remove_meta_items_by_name(items, @"name"); - attr::remove_meta_items_by_name(tmp, @"vers") + let tmp = attr::remove_meta_items_by_name(items, @~"name"); + attr::remove_meta_items_by_name(tmp, @~"vers") }; let meta_items = vec::append(~[name_item, vers_item], other_items); - let link_item = attr::mk_list_item(@"link", meta_items); + let link_item = attr::mk_list_item(@~"link", meta_items); ret attr::mk_attr(link_item); } @@ -973,7 +973,7 @@ fn synthesize_link_attr(ecx: @encode_ctxt, items: ~[@meta_item]) -> for crate.node.attrs.each |attr| { vec::push( attrs, - if *attr::get_attr_name(attr) != "link" { + if *attr::get_attr_name(attr) != ~"link" { attr } else { alt attr.node.value.node { @@ -1046,7 +1046,7 @@ fn encode_crate_dep(ebml_w: ebml::writer, dep: decoder::crate_dep) { ebml_w.end_tag(); } -fn encode_hash(ebml_w: ebml::writer, hash: str) { +fn encode_hash(ebml_w: ebml::writer, hash: ~str) { ebml_w.start_tag(tag_crate_hash); ebml_w.writer.write(str::bytes(hash)); ebml_w.end_tag(); @@ -1099,7 +1099,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] { } // Get the encoded string for a type -fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> str { +fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str { let cx = @{diag: tcx.diag, ds: def_to_str, tcx: tcx, diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index ab42afb1eddd..cb773589dcc2 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -31,11 +31,11 @@ fn pick_file(file: path, path: path) -> option { } fn mk_filesearch(maybe_sysroot: option, - target_triple: str, + target_triple: ~str, addl_lib_search_paths: ~[path]) -> filesearch { type filesearch_impl = {sysroot: path, addl_lib_search_paths: ~[path], - target_triple: str}; + target_triple: ~str}; impl of filesearch for filesearch_impl { fn sysroot() -> path { self.sysroot } fn lib_search_paths() -> ~[path] { @@ -88,12 +88,12 @@ fn search(filesearch: filesearch, pick: pick) -> option { ret rslt; } -fn relative_target_lib_path(target_triple: str) -> ~[path] { - ~[libdir(), "rustc", target_triple, libdir()] +fn relative_target_lib_path(target_triple: ~str) -> ~[path] { + ~[libdir(), ~"rustc", target_triple, libdir()] } fn make_target_lib_path(sysroot: path, - target_triple: str) -> path { + target_triple: ~str) -> path { let path = vec::append(~[sysroot], relative_target_lib_path(target_triple)); let path = path::connect_many(path); @@ -102,9 +102,9 @@ fn make_target_lib_path(sysroot: path, fn get_default_sysroot() -> path { alt os::self_exe_path() { - option::some(p) { path::normalize(path::connect(p, "..")) } + option::some(p) { path::normalize(path::connect(p, ~"..")) } option::none { - fail "can't determine value for sysroot"; + fail ~"can't determine value for sysroot"; } } } @@ -116,30 +116,30 @@ fn get_sysroot(maybe_sysroot: option) -> path { } } -fn get_cargo_sysroot() -> result { - let path = ~[get_default_sysroot(), libdir(), "cargo"]; +fn get_cargo_sysroot() -> result { + let path = ~[get_default_sysroot(), libdir(), ~"cargo"]; result::ok(path::connect_many(path)) } -fn get_cargo_root() -> result { - alt os::getenv("CARGO_ROOT") { +fn get_cargo_root() -> result { + alt os::getenv(~"CARGO_ROOT") { some(_p) { result::ok(_p) } none { alt os::homedir() { - some(_q) { result::ok(path::connect(_q, ".cargo")) } - none { result::err("no CARGO_ROOT or home directory") } + some(_q) { result::ok(path::connect(_q, ~".cargo")) } + none { result::err(~"no CARGO_ROOT or home directory") } } } } } -fn get_cargo_root_nearest() -> result { +fn get_cargo_root_nearest() -> result { do result::chain(get_cargo_root()) |p| { let cwd = os::getcwd(); let mut dirname = path::dirname(cwd); let mut dirpath = path::split(dirname); - let cwd_cargo = path::connect(cwd, ".cargo"); - let mut par_cargo = path::connect(dirname, ".cargo"); + let cwd_cargo = path::connect(cwd, ~".cargo"); + let mut par_cargo = path::connect(dirname, ~".cargo"); let mut rslt = result::ok(cwd_cargo); if !os::path_is_dir(cwd_cargo) && cwd_cargo != p { @@ -150,20 +150,20 @@ fn get_cargo_root_nearest() -> result { } vec::pop(dirpath); dirname = path::dirname(dirname); - par_cargo = path::connect(dirname, ".cargo"); + par_cargo = path::connect(dirname, ~".cargo"); } } rslt } } -fn get_cargo_lib_path() -> result { +fn get_cargo_lib_path() -> result { do result::chain(get_cargo_root()) |p| { result::ok(path::connect(p, libdir())) } } -fn get_cargo_lib_path_nearest() -> result { +fn get_cargo_lib_path_nearest() -> result { do result::chain(get_cargo_root_nearest()) |p| { result::ok(path::connect(p, libdir())) } @@ -171,10 +171,10 @@ fn get_cargo_lib_path_nearest() -> result { // The name of the directory rustc expects libraries to be located. // On Unix should be "lib", on windows "bin" -fn libdir() -> str { +fn libdir() -> ~str { let libdir = #env("CFG_LIBDIR"); if str::is_empty(libdir) { - fail "rustc compiled without CFG_LIBDIR environment variable"; + fail ~"rustc compiled without CFG_LIBDIR environment variable"; } libdir } diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index 32ed2c527bb5..862e6b90e7d3 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -31,12 +31,12 @@ enum os { span: span, ident: ast::ident, metas: ~[@ast::meta_item], - hash: str, + hash: ~str, os: os, static: bool }; -fn load_library_crate(cx: ctxt) -> {ident: str, data: @~[u8]} { +fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} { alt find_library_crate(cx) { some(t) { ret t; } none { @@ -46,33 +46,33 @@ fn load_library_crate(cx: ctxt) -> {ident: str, data: @~[u8]} { } } -fn find_library_crate(cx: ctxt) -> option<{ident: str, data: @~[u8]}> { +fn find_library_crate(cx: ctxt) -> option<{ident: ~str, data: @~[u8]}> { attr::require_unique_names(cx.diag, cx.metas); find_library_crate_aux(cx, libname(cx), cx.filesearch) } -fn libname(cx: ctxt) -> {prefix: str, suffix: str} { - if cx.static { ret {prefix: "lib", suffix: ".rlib"}; } +fn libname(cx: ctxt) -> {prefix: ~str, suffix: ~str} { + if cx.static { ret {prefix: ~"lib", suffix: ~".rlib"}; } alt cx.os { - os_win32 { ret {prefix: "", suffix: ".dll"}; } - os_macos { ret {prefix: "lib", suffix: ".dylib"}; } - os_linux { ret {prefix: "lib", suffix: ".so"}; } - os_freebsd { ret {prefix: "lib", suffix: ".so"}; } + os_win32 { ret {prefix: ~"", suffix: ~".dll"}; } + os_macos { ret {prefix: ~"lib", suffix: ~".dylib"}; } + os_linux { ret {prefix: ~"lib", suffix: ~".so"}; } + os_freebsd { ret {prefix: ~"lib", suffix: ~".so"}; } } } fn find_library_crate_aux(cx: ctxt, - nn: {prefix: str, suffix: str}, + nn: {prefix: ~str, suffix: ~str}, filesearch: filesearch::filesearch) -> - option<{ident: str, data: @~[u8]}> { + option<{ident: ~str, data: @~[u8]}> { let crate_name = crate_name_from_metas(cx.metas); - let prefix: str = nn.prefix + *crate_name + "-"; - let suffix: str = nn.suffix; + let prefix: ~str = nn.prefix + *crate_name + ~"-"; + let suffix: ~str = nn.suffix; let mut matches = ~[]; filesearch::search(filesearch, |path| { #debug("inspecting file %s", path); - let f: str = path::basename(path); + let f: ~str = path::basename(path); if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) { #debug("skipping %s, doesn't look like %s*%s", path, prefix, suffix); @@ -105,7 +105,7 @@ fn find_library_crate_aux(cx: ctxt, } else { cx.diag.span_err( cx.span, #fmt("multiple matching crates for `%s`", *crate_name)); - cx.diag.handler().note("candidates:"); + cx.diag.handler().note(~"candidates:"); for matches.each |match| { cx.diag.handler().note(#fmt("path: %s", match.ident)); let attrs = decoder::get_crate_attributes(match.data); @@ -116,8 +116,8 @@ fn find_library_crate_aux(cx: ctxt, } } -fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @str/~ { - let name_items = attr::find_meta_items_by_name(metas, "name"); +fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @~str { + let name_items = attr::find_meta_items_by_name(metas, ~"name"); alt vec::last_opt(name_items) { some(i) { alt attr::get_meta_item_value_str(i) { @@ -127,7 +127,7 @@ fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @str/~ { _ { fail } } } - none { fail "expected to find the crate name" } + none { fail ~"expected to find the crate name" } } } @@ -138,7 +138,7 @@ fn note_linkage_attrs(diag: span_handler, attrs: ~[ast::attribute]) { } fn crate_matches(crate_data: @~[u8], metas: ~[@ast::meta_item], - hash: str) -> bool { + hash: ~str) -> bool { let attrs = decoder::get_crate_attributes(crate_data); let linkage_metas = attr::find_linkage_metas(attrs); if hash.is_not_empty() { @@ -170,7 +170,7 @@ fn metadata_matches(extern_metas: ~[@ast::meta_item], } fn get_metadata_section(os: os, - filename: str) -> option<@~[u8]> unsafe { + filename: ~str) -> option<@~[u8]> unsafe { let mb = str::as_c_str(filename, |buf| { llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf) }); @@ -196,21 +196,21 @@ fn get_metadata_section(os: os, ret option::none::<@~[u8]>; } -fn meta_section_name(os: os) -> str { +fn meta_section_name(os: os) -> ~str { alt os { - os_macos { "__DATA,__note.rustc" } - os_win32 { ".note.rustc" } - os_linux { ".note.rustc" } - os_freebsd { ".note.rustc" } + os_macos { ~"__DATA,__note.rustc" } + os_win32 { ~".note.rustc" } + os_linux { ~".note.rustc" } + os_freebsd { ~".note.rustc" } } } // A diagnostic function for dumping crate metadata to an output stream -fn list_file_metadata(os: os, path: str, out: io::writer) { +fn list_file_metadata(os: os, path: ~str, out: io::writer) { alt get_metadata_section(os, path) { option::some(bytes) { decoder::list_crate_metadata(bytes, out); } option::none { - out.write_str("could not find metadata in " + path + ".\n"); + out.write_str(~"could not find metadata in " + path + ~".\n"); } } } diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index 31a92b72f979..c0420f49a090 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -42,7 +42,7 @@ fn parse_ident(st: @pstate, last: char) -> ast::ident { fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) -> ast::ident { - let mut rslt = ""; + let mut rslt = ~""; while !is_last(peek(st)) { rslt += str::from_byte(next_byte(st)); } @@ -170,7 +170,7 @@ fn parse_proto(c: char) -> ast::proto { '*' { ast::proto_any } '&' { ast::proto_block } 'n' { ast::proto_bare } - _ { fail "illegal fn type kind " + str::from_char(c); } + _ { fail ~"illegal fn type kind " + str::from_char(c); } } } @@ -197,7 +197,7 @@ fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs { let self_ty = parse_opt(st, || parse_ty(st, conv) ); assert next(st) == '['; - let mut params: [ty::t]/~ = []/~; + let mut params: ~[ty::t] = ~[]; while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); } st.pos = st.pos + 1u; @@ -245,8 +245,8 @@ fn parse_opt(st: @pstate, f: fn() -> T) -> option { } } -fn parse_str(st: @pstate, term: char) -> str { - let mut result = ""; +fn parse_str(st: @pstate, term: char) -> ~str { + let mut result = ~""; while peek(st) != term { result += str::from_byte(next_byte(st)); } @@ -320,7 +320,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { } 'R' { assert (next(st) == '['); - let mut fields: [ty::field]/~ = []/~; + let mut fields: ~[ty::field] = ~[]; while peek(st) != ']' { let name = @parse_str(st, '='); vec::push(fields, {ident: name, mt: parse_mt(st, conv)}); @@ -330,7 +330,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { } 'T' { assert (next(st) == '['); - let mut params = []/~; + let mut params = ~[]; while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); } st.pos = st.pos + 1u; ret ty::mk_tup(st.tcx, params); @@ -403,7 +403,7 @@ fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt { } fn parse_def(st: @pstate, conv: conv_did) -> ast::def_id { - let mut def = []/~; + let mut def = ~[]; while peek(st) != '|' { vec::push(def, next_byte(st)); } st.pos = st.pos + 1u; ret conv(parse_def_id(def)); @@ -446,7 +446,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty { let proto = parse_proto(next(st)); let purity = parse_purity(next(st)); assert (next(st) == '['); - let mut inputs: [ty::arg]/~ = []/~; + let mut inputs: ~[ty::arg] = ~[]; while peek(st) != ']' { let mode = alt check peek(st) { '&' { ast::by_mutbl_ref } diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index 026f06bc8b0b..6cb430c519f3 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -19,7 +19,7 @@ type ctxt = { diag: span_handler, // Def -> str Callback: - ds: fn@(def_id) -> str, + ds: fn@(def_id) -> ~str, // The type context. tcx: ty::ctxt, reachable: fn@(node_id) -> bool, @@ -29,7 +29,7 @@ // Compact string representation for ty.t values. API ty_str & parse_from_str. // Extra parameters are for converting to/from def_ids in the string rep. // Whatever format you choose should not contain pipe characters. -type ty_abbrev = {pos: uint, len: uint, s: @str/~}; +type ty_abbrev = {pos: uint, len: uint, s: @~str}; enum abbrev_ctxt { ac_no_abbrevs, ac_use_abbrevs(hashmap), } @@ -84,8 +84,8 @@ fn estimate_sz(u: uint) -> uint { let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len); if abbrev_len < len { // I.e. it's actually an abbreviation. - let s = "#" + uint::to_str(pos, 16u) + ":" + - uint::to_str(len, 16u) + "#"; + let s = ~"#" + uint::to_str(pos, 16u) + ~":" + + uint::to_str(len, 16u) + ~"#"; let a = {pos: pos, len: len, s: @s}; abbrevs.insert(t, a); } @@ -146,7 +146,7 @@ fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) { } ty::re_var(_) { // these should not crop up after typeck - cx.diag.handler().bug("Cannot encode region variables"); + cx.diag.handler().bug(~"Cannot encode region variables"); } } } @@ -192,45 +192,45 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { alt t { ty_i { w.write_char('i'); } ty_char { w.write_char('c'); } - ty_i8 { w.write_str("MB"/&); } - ty_i16 { w.write_str("MW"/&); } - ty_i32 { w.write_str("ML"/&); } - ty_i64 { w.write_str("MD"/&); } + ty_i8 { w.write_str(&"MB"); } + ty_i16 { w.write_str(&"MW"); } + ty_i32 { w.write_str(&"ML"); } + ty_i64 { w.write_str(&"MD"); } } } ty::ty_uint(t) { alt t { ty_u { w.write_char('u'); } - ty_u8 { w.write_str("Mb"/&); } - ty_u16 { w.write_str("Mw"/&); } - ty_u32 { w.write_str("Ml"/&); } - ty_u64 { w.write_str("Md"/&); } + ty_u8 { w.write_str(&"Mb"); } + ty_u16 { w.write_str(&"Mw"); } + ty_u32 { w.write_str(&"Ml"); } + ty_u64 { w.write_str(&"Md"); } } } ty::ty_float(t) { alt t { ty_f { w.write_char('l'); } - ty_f32 { w.write_str("Mf"/&); } - ty_f64 { w.write_str("MF"/&); } + ty_f32 { w.write_str(&"Mf"); } + ty_f64 { w.write_str(&"MF"); } } } ty::ty_str { w.write_char('S'); } ty::ty_enum(def, substs) { - w.write_str("t["/&); + w.write_str(&"t["); w.write_str(cx.ds(def)); w.write_char('|'); enc_substs(w, cx, substs); w.write_char(']'); } ty::ty_trait(def, substs) { - w.write_str("x["/&); + w.write_str(&"x["); w.write_str(cx.ds(def)); w.write_char('|'); enc_substs(w, cx, substs); w.write_char(']'); } ty::ty_tup(ts) { - w.write_str("T["/&); + w.write_str(&"T["); for ts.each |t| { enc_ty(w, cx, t); } w.write_char(']'); } @@ -254,7 +254,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { ty::ty_vec(mt) { w.write_char('I'); enc_mt(w, cx, mt); } ty::ty_unboxed_vec(mt) { w.write_char('U'); enc_mt(w, cx, mt); } ty::ty_rec(fields) { - w.write_str("R["/&); + w.write_str(&"R["); for fields.each |field| { w.write_str(*field.ident); w.write_char('='); @@ -284,37 +284,37 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { w.write_char('s'); } ty::ty_type { w.write_char('Y'); } - ty::ty_opaque_closure_ptr(ty::ck_block) { w.write_str("C&"/&); } - ty::ty_opaque_closure_ptr(ty::ck_box) { w.write_str("C@"/&); } - ty::ty_opaque_closure_ptr(ty::ck_uniq) { w.write_str("C~"/&); } + ty::ty_opaque_closure_ptr(ty::ck_block) { w.write_str(&"C&"); } + ty::ty_opaque_closure_ptr(ty::ck_box) { w.write_str(&"C@"); } + ty::ty_opaque_closure_ptr(ty::ck_uniq) { w.write_str(&"C~"); } ty::ty_constr(ty, cs) { - w.write_str("A["/&); + w.write_str(&"A["); enc_ty(w, cx, ty); for cs.each |tc| { enc_ty_constr(w, cx, tc); } w.write_char(']'); } ty::ty_opaque_box { w.write_char('B'); } ty::ty_class(def, substs) { - #debug("~~~~ %s", "a["); - w.write_str("a["/&); + #debug("~~~~ %s", ~"a["); + w.write_str(&"a["); let s = cx.ds(def); #debug("~~~~ %s", s); w.write_str(s); - #debug("~~~~ %s", "|"); + #debug("~~~~ %s", ~"|"); w.write_char('|'); enc_substs(w, cx, substs); - #debug("~~~~ %s", "]"); + #debug("~~~~ %s", ~"]"); w.write_char(']'); } } } fn enc_proto(w: io::writer, proto: proto) { alt proto { - proto_uniq { w.write_str("f~"/&); } - proto_box { w.write_str("f@"/&); } - proto_block { w.write_str("f&"); } - proto_any { w.write_str("f*"/&); } - proto_bare { w.write_str("fn"/&); } + proto_uniq { w.write_str(&"f~"); } + proto_box { w.write_str(&"f@"); } + proto_block { w.write_str(~"f&"); } + proto_any { w.write_str(&"f*"); } + proto_bare { w.write_str(&"fn"); } } } diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index a4810e77b56d..2211f62f2357 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -433,10 +433,10 @@ fn encode_vtable_res(ecx: @e::encode_ctxt, fn encode_vtable_origin(ecx: @e::encode_ctxt, ebml_w: ebml::writer, vtable_origin: typeck::vtable_origin) { - do ebml_w.emit_enum("vtable_origin") { + do ebml_w.emit_enum(~"vtable_origin") { alt vtable_origin { typeck::vtable_static(def_id, tys, vtable_res) { - do ebml_w.emit_enum_variant("vtable_static", 0u, 3u) { + do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) { do ebml_w.emit_enum_variant_arg(0u) { ebml_w.emit_def_id(def_id) } @@ -449,7 +449,7 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, } } typeck::vtable_param(pn, bn) { - do ebml_w.emit_enum_variant("vtable_param", 1u, 2u) { + do ebml_w.emit_enum_variant(~"vtable_param", 1u, 2u) { do ebml_w.emit_enum_variant_arg(0u) { ebml_w.emit_uint(pn); } @@ -459,7 +459,7 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, } } typeck::vtable_trait(def_id, tys) { - do ebml_w.emit_enum_variant("vtable_trait", 1u, 3u) { + do ebml_w.emit_enum_variant(~"vtable_trait", 1u, 3u) { do ebml_w.emit_enum_variant_arg(0u) { ebml_w.emit_def_id(def_id) } @@ -480,7 +480,7 @@ fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res { fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin { - do self.read_enum("vtable_origin") { + do self.read_enum(~"vtable_origin") { do self.read_enum_variant |i| { alt check i { 0u { @@ -552,15 +552,15 @@ fn emit_bounds(ecx: @e::encode_ctxt, bs: ty::param_bounds) { fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty) { do self.emit_rec { - do self.emit_rec_field("bounds", 0u) { + do self.emit_rec_field(~"bounds", 0u) { do self.emit_from_vec(*tpbt.bounds) |bs| { self.emit_bounds(ecx, bs); } } - do self.emit_rec_field("rp", 1u) { + do self.emit_rec_field(~"rp", 1u) { self.emit_bool(tpbt.rp); } - do self.emit_rec_field("ty", 2u) { + do self.emit_rec_field(~"ty", 2u) { self.emit_ty(ecx, tpbt.ty); } } @@ -755,13 +755,13 @@ fn read_ty_param_bounds_and_ty(xcx: extended_decode_ctxt) -> ty::ty_param_bounds_and_ty { do self.read_rec { { - bounds: self.read_rec_field("bounds", 0u, || { + bounds: self.read_rec_field(~"bounds", 0u, || { @self.read_to_vec(|| self.read_bounds(xcx) ) }), - rp: self.read_rec_field("rp", 1u, || { + rp: self.read_rec_field(~"rp", 1u, || { self.read_bool() }), - ty: self.read_rec_field("ty", 2u, || { + ty: self.read_rec_field(~"ty", 2u, || { self.read_ty(xcx) }) } diff --git a/src/rustc/middle/block_use.rs b/src/rustc/middle/block_use.rs index e6bafb4c48a7..6c103915aaf1 100644 --- a/src/rustc/middle/block_use.rs +++ b/src/rustc/middle/block_use.rs @@ -16,7 +16,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt) { alt ty::get(ty::expr_ty(cx.tcx, ex)).struct { ty::ty_fn({proto: p, _}) if is_blockish(p) { cx.tcx.sess.span_err(ex.span, - "expressions with stack closure type \ + ~"expressions with stack closure type \ can only appear in callee or (by-ref) argument position"); } _ {} diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 01d04fa167af..4db8ae6705dc 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -185,7 +185,7 @@ fn check_crate(tcx: ty::ctxt, check_loans::check_loans(bccx, req_maps, crate); if tcx.sess.borrowck_stats() { - io::println("--- borrowck stats ---"); + io::println(~"--- borrowck stats ---"); io::println(#fmt["paths requiring guarantees: %u", bccx.guaranteed_paths]); io::println(#fmt["paths requiring loans : %s", @@ -200,7 +200,7 @@ fn check_crate(tcx: ty::ctxt, ret (bccx.root_map, bccx.mutbl_map); - fn make_stat(bccx: borrowck_ctxt, stat: uint) -> str { + fn make_stat(bccx: borrowck_ctxt, stat: uint) -> ~str { let stat_f = stat as float; let total = bccx.guaranteed_paths as float; #fmt["%u (%.0f%%)", stat , stat_f * 100f / total] @@ -386,11 +386,11 @@ fn report(err: bckerr) { self.bckerr_code_to_str(err.code)]); } - fn span_err(s: span, m: str) { + fn span_err(s: span, m: ~str) { self.tcx.sess.span_err(s, m); } - fn span_note(s: span, m: str) { + fn span_note(s: span, m: ~str) { self.tcx.sess.span_note(s, m); } @@ -408,14 +408,14 @@ fn add_to_mutbl_map(cmt: cmt) { } impl to_str_methods for borrowck_ctxt { - fn cat_to_repr(cat: categorization) -> str { + fn cat_to_repr(cat: categorization) -> ~str { alt cat { - cat_special(sk_method) { "method" } - cat_special(sk_static_item) { "static_item" } - cat_special(sk_self) { "self" } - cat_special(sk_heap_upvar) { "heap-upvar" } - cat_stack_upvar(_) { "stack-upvar" } - cat_rvalue { "rvalue" } + cat_special(sk_method) { ~"method" } + cat_special(sk_static_item) { ~"static_item" } + cat_special(sk_self) { ~"self" } + cat_special(sk_heap_upvar) { ~"heap-upvar" } + cat_stack_upvar(_) { ~"stack-upvar" } + cat_rvalue { ~"rvalue" } cat_local(node_id) { #fmt["local(%d)", node_id] } cat_binding(node_id) { #fmt["binding(%d)", node_id] } cat_arg(node_id) { #fmt["arg(%d)", node_id] } @@ -430,33 +430,33 @@ fn cat_to_repr(cat: categorization) -> str { } } - fn mut_to_str(mutbl: ast::mutability) -> str { + fn mut_to_str(mutbl: ast::mutability) -> ~str { alt mutbl { - m_mutbl { "mutable" } - m_const { "const" } - m_imm { "immutable" } + m_mutbl { ~"mutable" } + m_const { ~"const" } + m_imm { ~"immutable" } } } - fn ptr_sigil(ptr: ptr_kind) -> str { + fn ptr_sigil(ptr: ptr_kind) -> ~str { alt ptr { - uniq_ptr { "~" } - gc_ptr { "@" } - region_ptr { "&" } - unsafe_ptr { "*" } + uniq_ptr { ~"~" } + gc_ptr { ~"@" } + region_ptr { ~"&" } + unsafe_ptr { ~"*" } } } - fn comp_to_repr(comp: comp_kind) -> str { + fn comp_to_repr(comp: comp_kind) -> ~str { alt comp { comp_field(fld, _) { *fld } - comp_index(*) { "[]" } - comp_tuple { "()" } - comp_variant(_) { "" } + comp_index(*) { ~"[]" } + comp_tuple { ~"()" } + comp_variant(_) { ~"" } } } - fn lp_to_str(lp: @loan_path) -> str { + fn lp_to_str(lp: @loan_path) -> ~str { alt *lp { lp_local(node_id) { #fmt["local(%d)", node_id] @@ -475,56 +475,56 @@ fn lp_to_str(lp: @loan_path) -> str { } } - fn cmt_to_repr(cmt: cmt) -> str { + fn cmt_to_repr(cmt: cmt) -> ~str { #fmt["{%s id:%d m:%s lp:%s ty:%s}", self.cat_to_repr(cmt.cat), cmt.id, self.mut_to_str(cmt.mutbl), - cmt.lp.map_default("none", |p| self.lp_to_str(p) ), + cmt.lp.map_default(~"none", |p| self.lp_to_str(p) ), ty_to_str(self.tcx, cmt.ty)] } - fn pk_to_sigil(pk: ptr_kind) -> str { + fn pk_to_sigil(pk: ptr_kind) -> ~str { alt pk { - uniq_ptr {"~"} - gc_ptr {"@"} - region_ptr {"&"} - unsafe_ptr {"*"} + uniq_ptr {~"~"} + gc_ptr {~"@"} + region_ptr {~"&"} + unsafe_ptr {~"*"} } } - fn cmt_to_str(cmt: cmt) -> str { + fn cmt_to_str(cmt: cmt) -> ~str { let mut_str = self.mut_to_str(cmt.mutbl); alt cmt.cat { - cat_special(sk_method) { "method" } - cat_special(sk_static_item) { "static item" } - cat_special(sk_self) { "self reference" } + cat_special(sk_method) { ~"method" } + cat_special(sk_static_item) { ~"static item" } + cat_special(sk_self) { ~"self reference" } cat_special(sk_heap_upvar) { - "captured outer variable in a heap closure" + ~"captured outer variable in a heap closure" } - cat_rvalue { "non-lvalue" } - cat_local(_) { mut_str + " local variable" } - cat_binding(_) { "pattern binding" } - cat_arg(_) { "argument" } + cat_rvalue { ~"non-lvalue" } + cat_local(_) { mut_str + ~" local variable" } + cat_binding(_) { ~"pattern binding" } + cat_arg(_) { ~"argument" } cat_deref(_, _, pk) { #fmt["dereference of %s %s pointer", mut_str, self.pk_to_sigil(pk)] } cat_stack_upvar(_) { - "captured outer " + mut_str + " variable in a stack closure" + ~"captured outer " + mut_str + ~" variable in a stack closure" } - cat_comp(_, comp_field(*)) { mut_str + " field" } - cat_comp(_, comp_tuple) { "tuple content" } - cat_comp(_, comp_variant(_)) { "enum content" } + cat_comp(_, comp_field(*)) { mut_str + ~" field" } + cat_comp(_, comp_tuple) { ~"tuple content" } + cat_comp(_, comp_variant(_)) { ~"enum content" } cat_comp(_, comp_index(t, _)) { alt ty::get(t).struct { ty::ty_vec(*) | ty::ty_evec(*) { - mut_str + " vec content" + mut_str + ~" vec content" } ty::ty_str | ty::ty_estr(*) { - mut_str + " str content" + mut_str + ~" str content" } - _ { mut_str + " indexed content" } + _ { mut_str + ~" indexed content" } } } cat_discr(cmt, _) { @@ -533,20 +533,20 @@ fn cmt_to_str(cmt: cmt) -> str { } } - fn bckerr_code_to_str(code: bckerr_code) -> str { + fn bckerr_code_to_str(code: bckerr_code) -> ~str { alt code { err_mutbl(req, act) { #fmt["creating %s alias to aliasable, %s memory", self.mut_to_str(req), self.mut_to_str(act)] } err_mut_uniq { - "unique value in aliasable, mutable location" + ~"unique value in aliasable, mutable location" } err_mut_variant { - "enum variant in aliasable, mutable location" + ~"enum variant in aliasable, mutable location" } err_preserve_gc { - "GC'd value would have to be preserved for longer \ + ~"GC'd value would have to be preserved for longer \ than the scope of the function" } } diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index 4977af45b7eb..d32d5dfd4a9b 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -70,11 +70,11 @@ fn checked_by_liveness() -> bool { at_mutbl_ref {false} } } - fn ing_form(desc: str) -> str { + fn ing_form(desc: ~str) -> ~str { alt self { - at_straight_up { "assigning to " + desc } - at_swap { "swapping to and from " + desc } - at_mutbl_ref { "taking mut reference to " + desc } + at_straight_up { ~"assigning to " + desc } + at_swap { ~"swapping to and from " + desc } + at_mutbl_ref { ~"taking mut reference to " + desc } } } } @@ -381,7 +381,7 @@ fn check_for_loan_conflicting_with_assignment( } } - fn report_purity_error(pc: purity_cause, sp: span, msg: str) { + fn report_purity_error(pc: purity_cause, sp: span, msg: ~str) { alt pc { pc_pure_fn { self.tcx().sess.span_err( diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index ddbd78b631c5..3c21c6d0c0ff 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -426,7 +426,7 @@ fn gather_pat(cmt: cmt, pat: @ast::pat, self.gather_pat(subcmt, subpat, arm_id, alt_id); } none { - tcx.sess.span_bug(pat.span, "Non derefable type"); + tcx.sess.span_bug(pat.span, ~"Non derefable type"); } } } diff --git a/src/rustc/middle/borrowck/loan.rs b/src/rustc/middle/borrowck/loan.rs index 84f7f5a9d159..5549ca53eb2f 100644 --- a/src/rustc/middle/borrowck/loan.rs +++ b/src/rustc/middle/borrowck/loan.rs @@ -39,7 +39,7 @@ fn loan(cmt: cmt, req_mutbl: ast::mutability) { if cmt.lp.is_none() { self.bccx.tcx.sess.span_bug( cmt.span, - "loan() called with non-lendable value"); + ~"loan() called with non-lendable value"); } alt cmt.cat { @@ -47,7 +47,7 @@ fn loan(cmt: cmt, req_mutbl: ast::mutability) { // should never be loanable self.bccx.tcx.sess.span_bug( cmt.span, - "rvalue with a non-none lp"); + ~"rvalue with a non-none lp"); } cat_local(_) | cat_arg(_) | cat_stack_upvar(_) { self.ok_with_loan_of(cmt, req_mutbl) @@ -88,7 +88,7 @@ fn loan(cmt: cmt, req_mutbl: ast::mutability) { // Aliased data is simply not lendable. self.bccx.tcx.sess.span_bug( cmt.span, - "aliased ptr with a non-none lp"); + ~"aliased ptr with a non-none lp"); } } } diff --git a/src/rustc/middle/borrowck/preserve.rs b/src/rustc/middle/borrowck/preserve.rs index 7ec2520cd59d..08d7227557b8 100644 --- a/src/rustc/middle/borrowck/preserve.rs +++ b/src/rustc/middle/borrowck/preserve.rs @@ -25,7 +25,8 @@ fn preserve(cmt: cmt, opt_scope_id: option) -> bckres<()> { if opt_scope_id.is_some() { self.tcx.sess.span_bug( cmt.span, - "preserve() called with local and non-none opt_scope_id"); + ~"preserve() called with local and \ + non-none opt_scope_id"); } ok(()) } diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index 1d72e3e95d5f..9b2bcc315724 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -43,7 +43,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) { let v = ~[pat]; alt is_useful(tcx, seen, v) { not_useful { - tcx.sess.span_err(pat.span, "unreachable pattern"); + tcx.sess.span_err(pat.span, ~"unreachable pattern"); } _ {} } @@ -67,8 +67,8 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { alt ty::get(ty).struct { ty::ty_bool { alt check ctor { - val(const_int(1i64)) { some(@"true") } - val(const_int(0i64)) { some(@"false") } + val(const_int(1i64)) { some(@~"true") } + val(const_int(0i64)) { some(@~"false") } } } ty::ty_enum(id, _) { @@ -82,9 +82,9 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { } } }; - let msg = "non-exhaustive patterns" + alt ext { - some(s) { ": " + *s + " not covered" } - none { "" } + let msg = ~"non-exhaustive patterns" + alt ext { + some(s) { ~": " + *s + ~" not covered" } + none { ~"" } }; tcx.sess.span_err(sp, msg); } @@ -344,7 +344,7 @@ fn check_local(tcx: ty::ctxt, loc: @local, &&s: (), v: visit::vt<()>) { visit::visit_local(loc, s, v); if is_refutable(tcx, loc.node.pat) { tcx.sess.span_err(loc.node.pat.span, - "refutable pattern in local binding"); + ~"refutable pattern in local binding"); } } diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index 5ac7834c348a..287c701d7d03 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -63,16 +63,16 @@ fn check_expr(sess: session, def_map: resolve::def_map, expr_unary(box(_), _) | expr_unary(uniq(_), _) | expr_unary(deref, _){ sess.span_err(e.span, - "disallowed operator in constant expression"); + ~"disallowed operator in constant expression"); ret; } expr_lit(@{node: lit_str(_), _}) { sess.span_err(e.span, - "string constants are not supported"); + ~"string constants are not supported"); } expr_binary(_, _, _) | expr_unary(_, _) { if method_map.contains_key(e.id) { - sess.span_err(e.span, "user-defined operators are not \ + sess.span_err(e.span, ~"user-defined operators are not \ allowed in constant expressions"); } } @@ -80,9 +80,9 @@ fn check_expr(sess: session, def_map: resolve::def_map, expr_cast(_, _) { let ety = ty::expr_ty(tcx, e); if !ty::type_is_numeric(ety) { - sess.span_err(e.span, "can not cast to `" + + sess.span_err(e.span, ~"can not cast to `" + util::ppaux::ty_to_str(tcx, ety) + - "` in a constant expression"); + ~"` in a constant expression"); } } expr_path(_) { @@ -90,19 +90,20 @@ fn check_expr(sess: session, def_map: resolve::def_map, some(def_const(def_id)) { if !ast_util::is_local(def_id) { sess.span_err( - e.span, "paths in constants may only refer to \ + e.span, ~"paths in constants may only refer to \ crate-local constants"); } } _ { sess.span_err( - e.span, "paths in constants may only refer to constants"); + e.span, + ~"paths in constants may only refer to constants"); } } } _ { sess.span_err(e.span, - "constant contains unimplemented expression type"); + ~"constant contains unimplemented expression type"); ret; } } @@ -112,14 +113,14 @@ fn check_expr(sess: session, def_map: resolve::def_map, if t != ty_char { if (v as u64) > ast_util::int_ty_max( if t == ty_i { sess.targ_cfg.int_type } else { t }) { - sess.span_err(e.span, "literal out of range for its type"); + sess.span_err(e.span, ~"literal out of range for its type"); } } } expr_lit(@{node: lit_uint(v, t), _}) { if v > ast_util::uint_ty_max( if t == ty_u { sess.targ_cfg.uint_type } else { t }) { - sess.span_err(e.span, "literal out of range for its type"); + sess.span_err(e.span, ~"literal out of range for its type"); } } _ {} @@ -157,7 +158,7 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map, fn visit_item(it: @item, &&env: env, v: visit::vt) { if (*env.idstack).contains(it.id) { - env.sess.span_fatal(env.root_it.span, "recursive constant"); + env.sess.span_fatal(env.root_it.span, ~"recursive constant"); } (*env.idstack).push(it.id); visit::visit_item(it, env, v); diff --git a/src/rustc/middle/check_loop.rs b/src/rustc/middle/check_loop.rs index 524e88fc49ec..69bb7220a4c4 100644 --- a/src/rustc/middle/check_loop.rs +++ b/src/rustc/middle/check_loop.rs @@ -30,17 +30,17 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) { } expr_break { if !cx.in_loop { - tcx.sess.span_err(e.span, "`break` outside of loop"); + tcx.sess.span_err(e.span, ~"`break` outside of loop"); } } expr_again { if !cx.in_loop { - tcx.sess.span_err(e.span, "`again` outside of loop"); + tcx.sess.span_err(e.span, ~"`again` outside of loop"); } } expr_ret(oe) { if !cx.can_ret { - tcx.sess.span_err(e.span, "`ret` in block function"); + tcx.sess.span_err(e.span, ~"`ret` in block function"); } visit::visit_expr_opt(oe, cx, v); } diff --git a/src/rustc/middle/const_eval.rs b/src/rustc/middle/const_eval.rs index cc36455da068..cdb1a3b10d01 100644 --- a/src/rustc/middle/const_eval.rs +++ b/src/rustc/middle/const_eval.rs @@ -6,7 +6,7 @@ enum const_val { const_float(f64), const_int(i64), const_uint(u64), - const_str(str), + const_str(~str), } // FIXME: issue #1417 @@ -159,7 +159,7 @@ fn compare_const_vals(a: const_val, b: const_val) -> int { } } _ { - fail "compare_const_vals: ill-typed comparison"; + fail ~"compare_const_vals: ill-typed comparison"; } } } diff --git a/src/rustc/middle/freevars.rs b/src/rustc/middle/freevars.rs index ae581290ab48..7bbc2db06651 100644 --- a/src/rustc/middle/freevars.rs +++ b/src/rustc/middle/freevars.rs @@ -51,7 +51,7 @@ fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt) { } ast::expr_path(path) { let mut i = 0; alt def_map.find(expr.id) { - none { fail ("Not found: " + path_to_str(path)) } + none { fail (~"Not found: " + path_to_str(path)) } some(df) { let mut def = df; while i < depth { @@ -106,7 +106,7 @@ fn annotate_freevars(def_map: resolve::def_map, crate: @ast::crate) -> fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { alt tcx.freevars.find(fid) { - none { fail "get_freevars: " + int::str(fid) + " has no freevars"; } + none { fail ~"get_freevars: " + int::str(fid) + ~" has no freevars"; } some(d) { ret d; } } } diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index b47098202767..7d89b4c701a8 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -39,18 +39,18 @@ // primitives in the stdlib are explicitly annotated to only take sendable // types. -fn kind_to_str(k: kind) -> str { +fn kind_to_str(k: kind) -> ~str { let mut kinds = ~[]; if ty::kind_lteq(kind_const(), k) { - vec::push(kinds, "const"); + vec::push(kinds, ~"const"); } if ty::kind_can_be_copied(k) { - vec::push(kinds, "copy"); + vec::push(kinds, ~"copy"); } if ty::kind_can_be_sent(k) { - vec::push(kinds, "send"); + vec::push(kinds, ~"send"); } - str::connect(kinds, " ") + str::connect(kinds, ~" ") } type rval_map = std::map::hashmap; @@ -125,13 +125,13 @@ fn check_for_block(cx: ctx, _id: node_id, fv: option<@freevar_entry>, if fv.is_none() { cx.tcx.sess.span_err( sp, - "cannot capture values explicitly with a block closure"); + ~"cannot capture values explicitly with a block closure"); } } fn check_for_bare(cx: ctx, _id: node_id, _fv: option<@freevar_entry>, _is_move: bool,_var_t: ty::t, sp: span) { - cx.tcx.sess.span_err(sp, "attempted dynamic environment capture"); + cx.tcx.sess.span_err(sp, ~"attempted dynamic environment capture"); } let fty = ty::node_id_to_type(cx.tcx, id); @@ -224,13 +224,13 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt) { let t = ty::expr_ty(cx.tcx, ex); let ty_fields = alt ty::get(t).struct { ty::ty_rec(f) { f } - _ { cx.tcx.sess.span_bug(ex.span, "bad expr type in record"); } + _ { cx.tcx.sess.span_bug(ex.span, ~"bad expr type in record"); } }; for ty_fields.each |tf| { if !vec::any(fields, |f| f.node.ident == tf.ident ) && !ty::kind_can_be_copied(ty::type_kind(cx.tcx, tf.mt.ty)) { cx.tcx.sess.span_err(ex.span, - "copying a noncopyable value"); + ~"copying a noncopyable value"); } } } @@ -340,15 +340,15 @@ fn check_bounds(cx: ctx, id: node_id, sp: span, cx.tcx.sess.span_lint( non_implicitly_copyable_typarams, id, cx.current_item, sp, - "instantiating copy type parameter with a \ + ~"instantiating copy type parameter with a \ not implicitly copyable type"); } else { cx.tcx.sess.span_err( sp, - "instantiating a type parameter with an incompatible type " + - "(needs `" + kind_to_str(p_kind) + - "`, got `" + kind_to_str(kind) + - "`, missing `" + kind_to_str(p_kind - kind) + "`)"); + ~"instantiating a type parameter with an incompatible type " + + ~"(needs `" + kind_to_str(p_kind) + + ~"`, got `" + kind_to_str(kind) + + ~"`, missing `" + kind_to_str(p_kind - kind) + ~"`)"); } } } @@ -381,7 +381,7 @@ fn check_copy_ex(cx: ctx, ex: @expr, implicit_copy: bool) { } fn check_imm_free_var(cx: ctx, def: def, sp: span) { - let msg = "mutable variables cannot be implicitly captured; \ + let msg = ~"mutable variables cannot be implicitly captured; \ use a capture clause"; alt def { def_local(_, is_mutbl) { @@ -413,18 +413,18 @@ fn check_copy(cx: ctx, id: node_id, ty: ty::t, sp: span, implicit_copy: bool) { let k = ty::type_kind(cx.tcx, ty); if !ty::kind_can_be_copied(k) { - cx.tcx.sess.span_err(sp, "copying a noncopyable value"); + cx.tcx.sess.span_err(sp, ~"copying a noncopyable value"); } else if implicit_copy && !ty::kind_can_be_implicitly_copied(k) { cx.tcx.sess.span_lint( implicit_copies, id, cx.current_item, sp, - "implicitly copying a non-implicitly-copyable value"); + ~"implicitly copying a non-implicitly-copyable value"); } } fn check_send(cx: ctx, ty: ty::t, sp: span) { if !ty::kind_can_be_sent(ty::type_kind(cx.tcx, ty)) { - cx.tcx.sess.span_err(sp, "not a sendable value"); + cx.tcx.sess.span_err(sp, ~"not a sendable value"); } } diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index 8c47fe1aaf15..0d2de5e8899a 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -73,10 +73,10 @@ enum level { } type lint_spec = @{lint: lint, - desc: str, + desc: ~str, default: level}; -type lint_dict = hashmap; +type lint_dict = hashmap<~str,lint_spec>; /* Pass names should not contain a '-', as the compiler normalizes @@ -84,55 +84,55 @@ enum level { */ fn get_lint_dict() -> lint_dict { let v = ~[ - ("ctypes", + (~"ctypes", @{lint: ctypes, - desc: "proper use of core::libc types in foreign modules", + desc: ~"proper use of core::libc types in foreign modules", default: warn}), - ("unused_imports", + (~"unused_imports", @{lint: unused_imports, - desc: "imports that are never used", + desc: ~"imports that are never used", default: ignore}), - ("while_true", + (~"while_true", @{lint: while_true, - desc: "suggest using loop { } instead of while(true) { }", + desc: ~"suggest using loop { } instead of while(true) { }", default: warn}), - ("path_statement", + (~"path_statement", @{lint: path_statement, - desc: "path statements with no effect", + desc: ~"path statements with no effect", default: warn}), - ("old_vecs", + (~"old_vecs", @{lint: old_vecs, - desc: "old (deprecated) vectors", + desc: ~"old (deprecated) vectors", default: error}), - ("old_strs", + (~"old_strs", @{lint: old_strs, - desc: "old (deprecated) strings", - default: ignore}), + desc: ~"old (deprecated) strings", + default: error}), - ("unrecognized_warning", + (~"unrecognized_warning", @{lint: unrecognized_warning, - desc: "unrecognized warning attribute", + desc: ~"unrecognized warning attribute", default: warn}), - ("non_implicitly_copyable_typarams", + (~"non_implicitly_copyable_typarams", @{lint: non_implicitly_copyable_typarams, - desc: "passing non implicitly copyable types as copy type params", + desc: ~"passing non implicitly copyable types as copy type params", default: warn}), - ("vecs_not_implicitly_copyable", + (~"vecs_not_implicitly_copyable", @{lint: vecs_not_implicitly_copyable, - desc: "make vecs and strs not implicitly copyable\ + desc: ~"make vecs and strs not implicitly copyable\ (`err` is ignored; only checked at top level", default: warn}), - ("implicit_copies", + (~"implicit_copies", @{lint: implicit_copies, - desc: "implicit copies of non implicitly copyable data", + desc: ~"implicit copies of non implicitly copyable data", default: warn}) ]; @@ -198,7 +198,7 @@ fn set_level(lint: lint, level: level) { } } - fn span_lint(level: level, span: span, msg: str) { + fn span_lint(level: level, span: span, msg: ~str) { self.sess.span_lint_level(level, span, msg); } @@ -211,7 +211,8 @@ fn with_warn_attrs(attrs: ~[ast::attribute], f: fn(ctxt)) { let mut new_ctxt = self; - let metas = attr::attr_metas(attr::find_attrs_by_name(attrs, "warn")); + let metas = attr::attr_metas( + attr::find_attrs_by_name(attrs, ~"warn")); for metas.each |meta| { alt meta.node { ast::meta_list(_, metas) { @@ -239,14 +240,14 @@ fn with_warn_attrs(attrs: ~[ast::attribute], f: fn(ctxt)) { _ { self.sess.span_err( meta.span, - "malformed warning attribute"); + ~"malformed warning attribute"); } } } } _ { self.sess.span_err(meta.span, - "malformed warning attribute"); + ~"malformed warning attribute"); } } } @@ -256,12 +257,12 @@ fn with_warn_attrs(attrs: ~[ast::attribute], f: fn(ctxt)) { } -fn lookup_lint(dict: lint_dict, s: str) - -> (str, option<(lint, level)>) { - let s = str::replace(s, "-", "_"); - let (name, level) = if s.starts_with("no_") { +fn lookup_lint(dict: lint_dict, s: ~str) + -> (~str, option<(lint, level)>) { + let s = str::replace(s, ~"-", ~"_"); + let (name, level) = if s.starts_with(~"no_") { (s.substr(3u, s.len() - 3u), ignore) - } else if s.starts_with("err_") { + } else if s.starts_with(~"err_") { (s.substr(4u, s.len() - 4u), error) } else { (s, warn) @@ -341,7 +342,7 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) { cx.sess.span_lint( while_true, e.id, it.id, e.span, - "denote infinite loops with loop { ... }"); + ~"denote infinite loops with loop { ... }"); } _ {} } @@ -367,14 +368,14 @@ fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id, cx.sess.span_lint( ctypes, id, fn_id, ty.span, - "found rust type `int` in foreign module, while \ + ~"found rust type `int` in foreign module, while \ libc::c_int or libc::c_long should be used"); } ast::def_prim_ty(ast::ty_uint(ast::ty_u)) { cx.sess.span_lint( ctypes, id, fn_id, ty.span, - "found rust type `uint` in foreign module, while \ + ~"found rust type `uint` in foreign module, while \ libc::c_uint or libc::c_ulong should be used"); } _ { } @@ -411,7 +412,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) { cx.sess.span_lint( path_statement, id, it.id, s.span, - "path statement with no effect"); + ~"path statement with no effect"); } _ {} } @@ -432,13 +433,13 @@ fn check_item_old_vecs(cx: ty::ctxt, it: @ast::item) { if ! uses_vstore.contains_key(e.id) { cx.sess.span_lint( old_vecs, e.id, it.id, - e.span, "deprecated vec expr"); + e.span, ~"deprecated vec expr"); } ast::expr_lit(@{node: ast::lit_str(_), span:_}) if ! uses_vstore.contains_key(e.id) { cx.sess.span_lint( old_strs, e.id, it.id, - e.span, "deprecated str expr"); + e.span, ~"deprecated str expr"); } ast::expr_vstore(@inner, _) { @@ -454,14 +455,14 @@ fn check_item_old_vecs(cx: ty::ctxt, it: @ast::item) { if ! uses_vstore.contains_key(t.id) { cx.sess.span_lint( old_vecs, t.id, it.id, - t.span, "deprecated vec type"); + t.span, ~"deprecated vec type"); } ast::ty_path(@{span: _, global: _, idents: ids, rp: none, types: _}, _) - if ids == ~[@"str"] && (! uses_vstore.contains_key(t.id)) { + if ids == ~[@~"str"] && (! uses_vstore.contains_key(t.id)) { cx.sess.span_lint( old_strs, t.id, it.id, - t.span, "deprecated str type"); + t.span, ~"deprecated str type"); } ast::ty_vstore(inner, _) | ast::ty_box({ty: inner, _}) | diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 5a65e7862040..6bce1ab88d1a 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -153,11 +153,11 @@ fn check_crate(tcx: ty::ctxt, } impl of to_str::to_str for live_node { - fn to_str() -> str { #fmt["ln(%u)", *self] } + fn to_str() -> ~str { #fmt["ln(%u)", *self] } } impl of to_str::to_str for variable { - fn to_str() -> str { #fmt["v(%u)", *self] } + fn to_str() -> ~str { #fmt["v(%u)", *self] } } // ______________________________________________________________________ @@ -289,9 +289,9 @@ fn variable(node_id: node_id, span: span) -> variable { fn variable_name(var: variable) -> ident { alt self.var_kinds[*var] { vk_local(_, name) | vk_arg(_, name, _) {name} - vk_field(name) {@("self." + *name)} - vk_self {@"self"} - vk_implicit_ret {@""} + vk_field(name) {@(~"self." + *name)} + vk_self {@~"self"} + vk_implicit_ret {@~""} } } @@ -303,7 +303,7 @@ fn captures(expr: @expr) -> @~[capture_info] { alt self.capture_map.find(expr.id) { some(caps) {caps} none { - self.tcx.sess.span_bug(expr.span, "no registered caps"); + self.tcx.sess.span_bug(expr.span, ~"no registered caps"); } } } @@ -580,7 +580,7 @@ fn variable_from_def_map(node_id: node_id, } none { self.tcx.sess.span_bug( - span, "Not present in def map") + span, ~"Not present in def map") } } } @@ -654,26 +654,26 @@ fn write_vars(wr: io::writer, for uint::range(0u, self.ir.num_vars) |var_idx| { let idx = node_base_idx + var_idx; if test(idx).is_valid() { - wr.write_str(" "); + wr.write_str(~" "); wr.write_str(variable(var_idx).to_str()); } } } - fn ln_str(ln: live_node) -> str { + fn ln_str(ln: live_node) -> ~str { do io::with_str_writer |wr| { - wr.write_str("[ln("); + wr.write_str(~"[ln("); wr.write_uint(*ln); - wr.write_str(") of kind "); + wr.write_str(~") of kind "); wr.write_str(#fmt["%?", copy self.ir.lnks[*ln]]); - wr.write_str(" reads"); + wr.write_str(~" reads"); self.write_vars(wr, ln, |idx| self.users[idx].reader ); - wr.write_str(" writes"); + wr.write_str(~" writes"); self.write_vars(wr, ln, |idx| self.users[idx].writer ); - wr.write_str(" "); - wr.write_str(" precedes "); + wr.write_str(~" "); + wr.write_str(~" precedes "); wr.write_str((copy self.successors[*ln]).to_str()); - wr.write_str("]"); + wr.write_str(~"]"); } } @@ -1003,7 +1003,7 @@ fn propagate_through_expr(expr: @expr, succ: live_node) -> live_node { expr_break { if !self.break_ln.is_valid() { self.tcx.sess.span_bug( - expr.span, "break with invalid break_ln"); + expr.span, ~"break with invalid break_ln"); } self.break_ln @@ -1012,7 +1012,7 @@ fn propagate_through_expr(expr: @expr, succ: live_node) -> live_node { expr_again { if !self.cont_ln.is_valid() { self.tcx.sess.span_bug( - expr.span, "cont with invalid cont_ln"); + expr.span, ~"cont with invalid cont_ln"); } self.cont_ln @@ -1117,7 +1117,7 @@ fn propagate_through_expr(expr: @expr, succ: live_node) -> live_node { } expr_mac(*) { - self.tcx.sess.span_bug(expr.span, "unexpanded macro"); + self.tcx.sess.span_bug(expr.span, ~"unexpanded macro"); } } } @@ -1505,7 +1505,7 @@ fn check_ret(id: node_id, sp: span, fk: visit::fn_kind, } else if ty::type_is_bot(t_ret) { // for bot return types, not ok. Function should fail. self.tcx.sess.span_err( - sp, "some control paths may return"); + sp, ~"some control paths may return"); } else { alt fk { visit::fk_ctor(*) { @@ -1513,7 +1513,7 @@ fn check_ret(id: node_id, sp: span, fk: visit::fn_kind, } _ { self.tcx.sess.span_err( - sp, "not all control paths return a value"); + sp, ~"not all control paths return a value"); } } } @@ -1630,11 +1630,11 @@ fn check_for_reassignment(ln: live_node, var: variable, some(lnk_expr(span)) { self.tcx.sess.span_err( span, - "re-assignment of immutable variable"); + ~"re-assignment of immutable variable"); self.tcx.sess.span_note( orig_span, - "prior assignment occurs here"); + ~"prior assignment occurs here"); } some(lnk) { self.tcx.sess.span_bug( @@ -1671,7 +1671,7 @@ fn report_illegal_move(move_span: span, vk_self { self.tcx.sess.span_err( move_span, - "illegal move from self (cannot move out of a field of \ + ~"illegal move from self (cannot move out of a field of \ self)"); ret; } @@ -1686,7 +1686,7 @@ fn report_illegal_move(move_span: span, self.report_illegal_read(move_span, lnk, var, moved_variable); self.tcx.sess.span_note( - move_span, "move of variable occurred here"); + move_span, ~"move of variable occurred here"); } @@ -1695,9 +1695,9 @@ fn report_illegal_read(chk_span: span, var: variable, rk: read_kind) { let msg = alt rk { - possibly_uninitialized_variable {"possibly uninitialized variable"} - possibly_uninitialized_field {"possibly uninitialized field"} - moved_variable {"moved variable"} + possibly_uninitialized_variable {~"possibly uninitialized variable"} + possibly_uninitialized_field {~"possibly uninitialized field"} + moved_variable {~"moved variable"} }; let name = (*self.ir).variable_name(var); alt lnk { diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index 87640b5824e0..76851e4f778f 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -150,7 +150,7 @@ fn item2() { /* Records the parameter ID of a region name. */ type binding = {node_id: ast::node_id, - name: str, + name: ~str, br: ty::bound_region}; // Mapping from a block/expr/binding to the innermost scope that @@ -265,7 +265,7 @@ fn ancestors_of(region_map: region_map, scope: ast::node_id) fn parent_id(cx: ctxt, span: span) -> ast::node_id { alt cx.parent { none { - cx.sess.span_bug(span, "crate should not be parent here"); + cx.sess.span_bug(span, ~"crate should not be parent here"); } some(parent_id) { parent_id @@ -505,7 +505,7 @@ fn add_dep(from: ast::node_id, to: ast::node_id) { fn region_is_relevant(r: @ast::region) -> bool { alt r.node { ast::re_anon {self.anon_implies_rp} - ast::re_named(@"self") {true} + ast::re_named(@~"self") {true} ast::re_named(_) {false} } } diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 918d278a6f84..9d026b1cc209 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -104,7 +104,7 @@ enum mod_index_entry { glob_imports: dvec, mut globbed_exports: ~[ident], glob_imported_names: hashmap, - path: str + path: ~str }; /* foreign modules can't contain enums, and we don't store their ASTs because @@ -254,11 +254,11 @@ fn index_vi(e: @env, i: @ast::view_item, &&sc: scopes, _v: vt) { } } - fn path_from_scope(sc: scopes, n: str) -> str { - let mut path = n + "::"; + fn path_from_scope(sc: scopes, n: ~str) -> ~str { + let mut path = n + ~"::"; do list::iter(sc) |s| { alt s { - scope_item(i) { path = *i.ident + "::" + path; } + scope_item(i) { path = *i.ident + ~"::" + path; } _ {} } } @@ -316,7 +316,7 @@ fn link_glob(e: @env, vi: @ast::view_item, &&sc: scopes, _v: vt) { e.mod_map.get(ast::crate_node_id). glob_imports.push(glob); } - _ { e.sess.span_bug(vi.span, "unexpected scope in a \ + _ { e.sess.span_bug(vi.span, ~"unexpected scope in a \ glob import"); } } } @@ -343,7 +343,7 @@ fn link_glob(e: @env, vi: @ast::view_item, &&sc: scopes, _v: vt) { glob_imports: dvec(), mut globbed_exports: ~[], glob_imported_names: box_str_hash(), - path: ""}); + path: ~""}); // Next, assemble the links for globbed imports and exports. let v_link_glob = @@ -379,10 +379,10 @@ fn check_unused_imports(e: @env, level: lint::level) { if !vec::contains(e.used_imports.data, k) { alt level { lint::warn { - e.sess.span_warn(sp, "unused import " + *name); + e.sess.span_warn(sp, ~"unused import " + *name); } lint::error { - e.sess.span_err(sp, "unused import " + *name); + e.sess.span_err(sp, ~"unused import " + *name); } lint::ignore { } @@ -511,7 +511,7 @@ fn walk_pat(e: @env, pat: @ast::pat, &&sc: scopes, v: vt) { } _ { e.sess.span_err(p.span, - "not an enum variant: " + + ~"not an enum variant: " + ast_util::path_name(p)); } } @@ -525,8 +525,8 @@ fn walk_pat(e: @env, pat: @ast::pat, &&sc: scopes, v: vt) { e.def_map.insert(pat.id, fnd); } some(fnd@ast::def_const(_)) { - e.sess.span_err(p.span, "pattern variable conflicts \ - with constant '" + *path_to_ident(p) + "'"); + e.sess.span_err(p.span, ~"pattern variable conflicts \ + with constant '" + *path_to_ident(p) + ~"'"); } // Binds a var -- nothing needs to be done _ {} @@ -552,7 +552,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item, let old_resolve_unexported = e.resolve_unexported; e.resolve_unexported |= attr::contains_name(attr::attr_metas(i.attrs), - "!resolve_unexported"); + ~"!resolve_unexported"); let sc = @cons(scope_item(i), sc); alt i.node { @@ -759,8 +759,8 @@ fn follow_import(e: env, &&sc: scopes, path: ~[ident], sp: span) -> alt dcur { some(ast::def_mod(_)) | some(ast::def_foreign_mod(_)) { ret dcur; } _ { - e.sess.span_err(sp, str::connect(path.map(|x|*x), "::") + - " does not name a module."); + e.sess.span_err(sp, str::connect(path.map(|x|*x), ~"::") + + ~" does not name a module."); ret none; } } @@ -790,7 +790,7 @@ fn register(e: env, id: node_id, cx: ctxt, sp: codemap::span, md = lookup(ns_module); if is_none(val) && is_none(typ) && is_none(md) && vec::len(impls) == 0u { - unresolved_err(e, cx, sp, name, "import"); + unresolved_err(e, cx, sp, name, ~"import"); } else { e.imports.insert(id, resolved(val, typ, md, @impls, name, sp)); } @@ -834,7 +834,7 @@ fn lst(my_id: node_id, vis: ~[@view_item]) -> ~[node_id] { option::get(e.mod_map.get(ast::crate_node_id).m).view_items) } _ { - e.sess.bug("find_imports_after: nil or unexpected scope"); + e.sess.bug(~"find_imports_after: nil or unexpected scope"); } } } @@ -885,7 +885,7 @@ fn lst(my_id: node_id, vis: ~[@view_item]) -> ~[node_id] { // import alt e.imports.find(n_id) { some(resolving(sp)) { - e.imports.insert(n_id, resolved(none, none, none, @~[], @"", sp)); + e.imports.insert(n_id, resolved(none, none, none, @~[], @~"", sp)); } _ { } } @@ -893,17 +893,17 @@ fn lst(my_id: node_id, vis: ~[@view_item]) -> ~[node_id] { // Utilities -fn ns_name(ns: namespace) -> str { +fn ns_name(ns: namespace) -> ~str { alt ns { - ns_type { "typename" } - ns_val { "name" } - ns_module { "modulename" } + ns_type { ~"typename" } + ns_val { ~"name" } + ns_module { ~"modulename" } } } enum ctxt { in_mod(def), in_scope(scopes), } -fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) { +fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: ~str) { fn find_fn_or_mod_scope(sc: scopes) -> option { for list::each(sc) |cur| { alt cur { @@ -936,18 +936,18 @@ fn find_fn_or_mod_scope(sc: scopes) -> option { } else if did.node != ast::crate_node_id { let paths = e.ext_map.get(did); path = @str::connect(vec::append_one(paths, path).map(|x|*x), - "::"); + ~"::"); } } } e.sess.span_err(sp, mk_unresolved_msg(path, kind)); } -fn unresolved_fatal(e: env, sp: span, id: ident, kind: str) -> ! { +fn unresolved_fatal(e: env, sp: span, id: ident, kind: ~str) -> ! { e.sess.span_fatal(sp, mk_unresolved_msg(id, kind)); } -fn mk_unresolved_msg(id: ident, kind: str) -> str { +fn mk_unresolved_msg(id: ident, kind: ~str) -> ~str { ret #fmt["unresolved %s: %s", kind, *id]; } @@ -1037,22 +1037,22 @@ fn in_scope(e: env, sp: span, name: ident, s: scope, ns: namespace) -> scope_toplevel { if ns == ns_type { ret some(ast::def_prim_ty(alt *name { - "bool" { ast::ty_bool } - "int" { ast::ty_int(ast::ty_i) } - "uint" { ast::ty_uint(ast::ty_u) } - "float" { ast::ty_float(ast::ty_f) } - "str" { ast::ty_str } - "char" { ast::ty_int(ast::ty_char) } - "i8" { ast::ty_int(ast::ty_i8) } - "i16" { ast::ty_int(ast::ty_i16) } - "i32" { ast::ty_int(ast::ty_i32) } - "i64" { ast::ty_int(ast::ty_i64) } - "u8" { ast::ty_uint(ast::ty_u8) } - "u16" { ast::ty_uint(ast::ty_u16) } - "u32" { ast::ty_uint(ast::ty_u32) } - "u64" { ast::ty_uint(ast::ty_u64) } - "f32" { ast::ty_float(ast::ty_f32) } - "f64" { ast::ty_float(ast::ty_f64) } + ~"bool" { ast::ty_bool } + ~"int" { ast::ty_int(ast::ty_i) } + ~"uint" { ast::ty_uint(ast::ty_u) } + ~"float" { ast::ty_float(ast::ty_f) } + ~"str" { ast::ty_str } + ~"char" { ast::ty_int(ast::ty_char) } + ~"i8" { ast::ty_int(ast::ty_i8) } + ~"i16" { ast::ty_int(ast::ty_i16) } + ~"i32" { ast::ty_int(ast::ty_i32) } + ~"i64" { ast::ty_int(ast::ty_i64) } + ~"u8" { ast::ty_uint(ast::ty_u8) } + ~"u16" { ast::ty_uint(ast::ty_u16) } + ~"u32" { ast::ty_uint(ast::ty_u32) } + ~"u64" { ast::ty_uint(ast::ty_u64) } + ~"f32" { ast::ty_float(ast::ty_f32) } + ~"f64" { ast::ty_float(ast::ty_f64) } _ { ret none; } })); } @@ -1071,7 +1071,7 @@ fn in_scope(e: env, sp: span, name: ident, s: scope, ns: namespace) -> } ast::item_trait(tps, _) { if ns == ns_type { - if *name == "self" { + if *name == ~"self" { ret some(def_self(it.id)); } ret lookup_in_ty_params(e, name, tps); @@ -1096,7 +1096,7 @@ fn in_scope(e: env, sp: span, name: ident, s: scope, ns: namespace) -> } } scope_method(id, tps) { - if (*name == "self" && ns == ns_val) { + if (*name == ~"self" && ns == ns_val) { ret some(ast::def_self(id)); } else if ns == ns_type { ret lookup_in_ty_params(e, name, tps); @@ -1152,9 +1152,9 @@ fn in_scope(e: env, sp: span, name: ident, s: scope, ns: namespace) -> (left_fn && local || left_fn_level2 && self_scope || scope_is_fn(hd) && left_fn && def_is_ty_arg(df)) { let msg = if ns == ns_type { - "attempt to use a type argument out of scope" + ~"attempt to use a type argument out of scope" } else { - "attempted dynamic environment-capture" + ~"attempted dynamic environment-capture" }; e.sess.span_fatal(sp, msg); } else if local || self_scope { @@ -1331,7 +1331,7 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint, } } } - _ { e.sess.span_bug(vi.span, "unexpected view_item in block"); } + _ { e.sess.span_bug(vi.span, ~"unexpected view_item in block"); } } } ret none; @@ -1417,7 +1417,7 @@ fn lookup_in_mod(e: env, m: def, sp: span, name: ident, ns: namespace, } _ { // Precondition - e.sess.span_bug(sp, "lookup_in_mod was passed a non-mod def"); + e.sess.span_bug(sp, ~"lookup_in_mod was passed a non-mod def"); } } } @@ -1444,7 +1444,7 @@ fn lookup_import(e: env, n_id: node_id, ns: namespace) -> option { ret lookup_import(e, n_id, ns); } resolving(sp) { - e.sess.span_err(sp, "cyclic import"); + e.sess.span_err(sp, ~"cyclic import"); ret none; } resolved(val, typ, md, _, _, _) { @@ -1454,7 +1454,7 @@ fn lookup_import(e: env, n_id: node_id, ns: namespace) -> option { ret alt ns { ns_val { val } ns_type { typ } ns_module { md } }; } is_glob(_,_,_) { - e.sess.bug("lookup_import: can't handle is_glob"); + e.sess.bug(~"lookup_import: can't handle is_glob"); } } } @@ -1530,7 +1530,7 @@ fn lookup_in_mod_(e: env, def: glob_imp_def, sp: span, name: ident, } _ { - e.sess.span_bug(sp, "lookup_in_globs: not a glob"); + e.sess.span_bug(sp, ~"lookup_in_globs: not a glob"); } } alt lookup_in_mod(e, def.def, sp, name, ns, dr) { @@ -1551,8 +1551,8 @@ fn lookup_in_mod_(e: env, def: glob_imp_def, sp: span, name: ident, let sp = match.path.span; e.sess.span_note(sp, #fmt["'%s' is imported here", *id]); } - e.sess.span_fatal(sp, "'" + *id + "' is glob-imported from" + - " multiple different modules."); + e.sess.span_fatal(sp, ~"'" + *id + ~"' is glob-imported from" + + ~" multiple different modules."); } } @@ -1712,7 +1712,7 @@ fn ns_for_def(d: def) -> namespace { ast::def_ty(_) | ast::def_binding(_) | ast::def_use(_) | ast::def_ty_param(_, _) | ast::def_prim_ty(_) | ast::def_class(_) { ns_type } - ast::def_region(_) { fail "regions are not handled by this pass" } + ast::def_region(_) { fail ~"regions are not handled by this pass" } } } @@ -1750,25 +1750,25 @@ fn check_mod_name(e: env, name: ident, entries: @list) { let mut saw_type = false; let mut saw_value = false; let mut entries = entries; - fn dup(e: env, sp: span, word: str, name: ident) { - e.sess.span_fatal(sp, "duplicate definition of " + word + *name); + fn dup(e: env, sp: span, word: ~str, name: ident) { + e.sess.span_fatal(sp, ~"duplicate definition of " + word + *name); } loop { alt *entries { cons(entry, rest) { if !is_none(lookup_in_mie(e, entry, ns_val)) { if saw_value { - dup(e, mie_span(entry), "", name); + dup(e, mie_span(entry), ~"", name); } else { saw_value = true; } } if !is_none(lookup_in_mie(e, entry, ns_type)) { if saw_type { - dup(e, mie_span(entry), "type ", name); + dup(e, mie_span(entry), ~"type ", name); } else { saw_type = true; } } if !is_none(lookup_in_mie(e, entry, ns_module)) { if saw_mod { - dup(e, mie_span(entry), "module ", name); + dup(e, mie_span(entry), ~"module ", name); } else { saw_mod = true; } } entries = rest; @@ -1799,11 +1799,11 @@ fn typaram_names(tps: ~[ast::ty_param]) -> ~[ident] { ast::item_fn(decl, ty_params, _) { check_fn(*e, i.span, decl); ensure_unique(*e, i.span, ty_params, |tp| tp.ident, - "type parameter"); + ~"type parameter"); } ast::item_enum(_, ty_params) { ensure_unique(*e, i.span, ty_params, |tp| tp.ident, - "type parameter"); + ~"type parameter"); } ast::item_trait(_, methods) { ensure_unique(*e, i.span, methods, |m| { @@ -1816,11 +1816,11 @@ fn typaram_names(tps: ~[ast::ty_param]) -> ~[ident] { } } }, - "method"); + ~"method"); } ast::item_impl(_, _, _, methods) { ensure_unique(*e, i.span, methods, |m| m.ident, - "method"); + ~"method"); } _ { } } @@ -1834,28 +1834,28 @@ fn check_pat(e: @env, ch: checker, p: @ast::pat) { fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) { visit::visit_arm(a, x, v); - let ch0 = checker(*e, "binding"); + let ch0 = checker(*e, ~"binding"); check_pat(e, ch0, a.pats[0]); let seen0 = ch0.seen.get(); let mut i = vec::len(a.pats); while i > 1u { i -= 1u; - let ch = checker(*e, "binding"); + let ch = checker(*e, ~"binding"); check_pat(e, ch, a.pats[i]); // Ensure the bindings introduced in this pattern are the same as in // the first pattern. if ch.seen.len() != seen0.len() { e.sess.span_err(a.pats[i].span, - "inconsistent number of bindings"); + ~"inconsistent number of bindings"); } else { for ch.seen.each |name| { if is_none(vec::find(seen0, |x| str::eq(*name, *x))) { // Fight the alias checker let name_ = name; e.sess.span_err(a.pats[i].span, - "binding " + *name_ + - " does not occur in first pattern"); + ~"binding " + *name_ + + ~" does not occur in first pattern"); } } } @@ -1864,15 +1864,15 @@ fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) { fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) { visit::visit_block(b, x, v); - let values = checker(*e, "value"); - let types = checker(*e, "type"); - let mods = checker(*e, "module"); + let values = checker(*e, ~"value"); + let types = checker(*e, ~"type"); + let mods = checker(*e, ~"module"); for b.node.stmts.each |st| { alt st.node { ast::stmt_decl(d, _) { alt d.node { ast::decl_local(locs) { - let local_values = checker(*e, "value"); + let local_values = checker(*e, ~"value"); for locs.each |loc| { do pat_util::pat_bindings(e.def_map, loc.node.pat) |_i, p_sp, n| { @@ -1911,14 +1911,14 @@ fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) { fn check_fn(e: env, sp: span, decl: ast::fn_decl) { fn arg_name(a: ast::arg) -> ident { ret a.ident; } - ensure_unique(e, sp, decl.inputs, arg_name, "argument"); + ensure_unique(e, sp, decl.inputs, arg_name, ~"argument"); } fn check_expr(e: @env, ex: @ast::expr, &&x: (), v: vt<()>) { alt ex.node { ast::expr_rec(fields, _) { fn field_name(f: ast::field) -> ident { ret f.node.ident; } - ensure_unique(*e, ex.span, fields, field_name, "field"); + ensure_unique(*e, ex.span, fields, field_name, ~"field"); } _ { } } @@ -1929,16 +1929,16 @@ fn check_ty(e: @env, ty: @ast::ty, &&x: (), v: vt<()>) { alt ty.node { ast::ty_rec(fields) { fn field_name(f: ast::ty_field) -> ident { ret f.node.ident; } - ensure_unique(*e, ty.span, fields, field_name, "field"); + ensure_unique(*e, ty.span, fields, field_name, ~"field"); } _ { } } visit::visit_ty(ty, x, v); } -type checker = @{seen: dvec, kind: str, sess: session}; +type checker = @{seen: dvec, kind: ~str, sess: session}; -fn checker(e: env, kind: str) -> checker { +fn checker(e: env, kind: ~str) -> checker { ret @{seen: dvec(), kind: kind, sess: e.sess}; } @@ -1946,7 +1946,7 @@ fn check_name(ch: checker, sp: span, name: ident) { for ch.seen.each |s| { if str::eq(*s, *name) { ch.sess.span_fatal( - sp, "duplicate " + ch.kind + " name: " + *name); + sp, ~"duplicate " + ch.kind + ~" name: " + *name); } } } @@ -1956,7 +1956,7 @@ fn add_name(ch: checker, sp: span, name: ident) { } fn ensure_unique(e: env, sp: span, elts: ~[T], id: fn(T) -> ident, - kind: str) { + kind: ~str) { let ch = checker(e, kind); for elts.each |elt| { add_name(ch, sp, id(elt)); } } @@ -1969,7 +1969,7 @@ fn iter_mod(e: env, m: def, sp: span, _dr: dir, if defid.crate != ast::local_crate { // FIXME: ought to support external export-globs eventually. #2527 - e.sess.span_unimpl(sp, "glob-export of items in external crate"); + e.sess.span_unimpl(sp, ~"glob-export of items in external crate"); } else { let mid = def_id_of_def(m); @@ -1994,7 +1994,7 @@ fn iter_mod(e: env, m: def, sp: span, _dr: dir, } } _ { - let s = "glob-export from mod with non-items"; + let s = ~"glob-export from mod with non-items"; e.sess.span_unimpl(sp, s); } } @@ -2047,7 +2047,7 @@ fn check_export(e: @env, ident: ident, _mod: @indexed_mod, maybe_add_reexport(e, export_id, t); maybe_add_reexport(e, export_id, m); } - _ { e.sess.span_bug(vi.span, "unresolved export"); } + _ { e.sess.span_bug(vi.span, ~"unresolved export"); } } } mie_item(@{id, _}) | mie_foreign_item(@{id, _}) | @@ -2142,7 +2142,8 @@ enum %s", let id = if vec::len(path.idents) == 1u { path.idents[0] } else { - e.sess.span_fatal(vp.span, "bad export name-list") + e.sess.span_fatal(vp.span, + ~"bad export name-list") }; check_export_enum_list(e, node_id, _mod, vp.span, id, ids); diff --git a/src/rustc/middle/resolve3.rs b/src/rustc/middle/resolve3.rs index 8581af175d9e..07af1e5538a7 100644 --- a/src/rustc/middle/resolve3.rs +++ b/src/rustc/middle/resolve3.rs @@ -203,18 +203,18 @@ fn Atom(n: uint) -> Atom { } class AtomTable { - let atoms: hashmap<@str/~,Atom>; - let strings: dvec<@str/~>; + let atoms: hashmap<@~str,Atom>; + let strings: dvec<@~str>; let mut atom_count: uint; new() { - self.atoms = hashmap::<@str/~,Atom>(|x| str::hash(*x), + self.atoms = hashmap::<@~str,Atom>(|x| str::hash(*x), |x, y| str::eq(*x, *y)); self.strings = dvec(); self.atom_count = 0u; } - fn intern(string: @str/~) -> Atom { + fn intern(string: @~str) -> Atom { alt self.atoms.find(string) { none { /* fall through */ } some(atom) { ret atom; } @@ -228,11 +228,11 @@ fn intern(string: @str/~) -> Atom { ret atom; } - fn atom_to_str(atom: Atom) -> @str/~ { + fn atom_to_str(atom: Atom) -> @~str { ret self.strings.get_elt(atom); } - fn atoms_to_strs(atoms: ~[Atom], f: fn(@str/~) -> bool) { + fn atoms_to_strs(atoms: ~[Atom], f: fn(@~str) -> bool) { for atoms.each |atom| { if !f(self.atom_to_str(atom)) { ret; @@ -240,15 +240,15 @@ fn atoms_to_strs(atoms: ~[Atom], f: fn(@str/~) -> bool) { } } - fn atoms_to_str(atoms: ~[Atom]) -> @str/~ { + fn atoms_to_str(atoms: ~[Atom]) -> @~str { // XXX: str::connect should do this. - let mut result = ""; + let mut result = ~""; let mut first = true; for self.atoms_to_strs(atoms) |string| { if first { first = false; } else { - result += "::"; + result += ~"::"; } result += *string; @@ -498,7 +498,8 @@ fn get_module_if_available() -> option<@Module> { fn get_module() -> @Module { alt self.module_def { NoModuleDef { - fail "get_module called on a node with no module definition!"; + fail + ~"get_module called on a node with no module definition!"; } ModuleDef(module) { ret module; @@ -560,25 +561,25 @@ fn def_for_namespace(namespace: Namespace) -> option { new(atom_table: @AtomTable) { self.primitive_types = atom_hashmap(); - self.intern(atom_table, @"bool", ty_bool); - self.intern(atom_table, @"char", ty_int(ty_char)); - self.intern(atom_table, @"float", ty_float(ty_f)); - self.intern(atom_table, @"f32", ty_float(ty_f32)); - self.intern(atom_table, @"f64", ty_float(ty_f64)); - self.intern(atom_table, @"int", ty_int(ty_i)); - self.intern(atom_table, @"i8", ty_int(ty_i8)); - self.intern(atom_table, @"i16", ty_int(ty_i16)); - self.intern(atom_table, @"i32", ty_int(ty_i32)); - self.intern(atom_table, @"i64", ty_int(ty_i64)); - self.intern(atom_table, @"str", ty_str); - self.intern(atom_table, @"uint", ty_uint(ty_u)); - self.intern(atom_table, @"u8", ty_uint(ty_u8)); - self.intern(atom_table, @"u16", ty_uint(ty_u16)); - self.intern(atom_table, @"u32", ty_uint(ty_u32)); - self.intern(atom_table, @"u64", ty_uint(ty_u64)); + self.intern(atom_table, @~"bool", ty_bool); + self.intern(atom_table, @~"char", ty_int(ty_char)); + self.intern(atom_table, @~"float", ty_float(ty_f)); + self.intern(atom_table, @~"f32", ty_float(ty_f32)); + self.intern(atom_table, @~"f64", ty_float(ty_f64)); + self.intern(atom_table, @~"int", ty_int(ty_i)); + self.intern(atom_table, @~"i8", ty_int(ty_i8)); + self.intern(atom_table, @~"i16", ty_int(ty_i16)); + self.intern(atom_table, @~"i32", ty_int(ty_i32)); + self.intern(atom_table, @~"i64", ty_int(ty_i64)); + self.intern(atom_table, @~"str", ty_str); + self.intern(atom_table, @~"uint", ty_uint(ty_u)); + self.intern(atom_table, @~"u8", ty_uint(ty_u8)); + self.intern(atom_table, @~"u16", ty_uint(ty_u16)); + self.intern(atom_table, @~"u32", ty_uint(ty_u32)); + self.intern(atom_table, @~"u64", ty_uint(ty_u64)); } - fn intern(atom_table: @AtomTable, string: @str/~, + fn intern(atom_table: @AtomTable, string: @~str, primitive_type: prim_ty) { let atom = (*atom_table).intern(string); self.primitive_types.insert(atom, primitive_type); @@ -651,7 +652,7 @@ fn intern(atom_table: @AtomTable, string: @str/~, self.type_ribs = @dvec(); self.xray_context = NoXray; - self.self_atom = (*self.atom_table).intern(@"self"); + self.self_atom = (*self.atom_table).intern(@~"self"); self.primitive_type_table = @PrimitiveTypeTable(self.atom_table); self.namespaces = ~[ ModuleNS, TypeNS, ValueNS, ImplNS ]; @@ -934,7 +935,7 @@ fn build_reduced_graph_for_item(item: @item, } item_mac(*) { - fail "item macros unimplemented" + fail ~"item macros unimplemented" } } } @@ -1038,14 +1039,15 @@ fn build_reduced_graph_for_view_item(view_item: @view_item, let last_ident = full_path.idents.last(); if last_ident != ident { self.session.span_err(view_item.span, - "cannot export under \ + ~"cannot export under \ a new name"); } if full_path.idents.len() != 1u { - self.session.span_err(view_item.span, - "cannot export an item \ - that is not in this \ - module"); + self.session.span_err( + view_item.span, + ~"cannot export an item \ + that is not in this \ + module"); } let atom = (*self.atom_table).intern(ident); @@ -1054,7 +1056,7 @@ fn build_reduced_graph_for_view_item(view_item: @view_item, view_path_glob(*) { self.session.span_err(view_item.span, - "export globs are \ + ~"export globs are \ unsupported"); } @@ -1063,7 +1065,7 @@ fn build_reduced_graph_for_view_item(view_item: @view_item, path_list_idents.len() == 0u { self.session.span_warn(view_item.span, - "this syntax for \ + ~"this syntax for \ exporting no \ variants is \ unsupported; export \ @@ -1072,7 +1074,7 @@ fn build_reduced_graph_for_view_item(view_item: @view_item, } else { if path.idents.len() != 0u { self.session.span_err(view_item.span, - "cannot export an \ + ~"cannot export an \ item that is not \ in this module"); } @@ -1180,7 +1182,7 @@ fn build_reduced_graph_for_external_crate(root: @Module) { path_entry.path_string, path_entry.def_like); - let mut pieces = split_str(path_entry.path_string, "::"); + let mut pieces = split_str(path_entry.path_string, ~"::"); let final_ident = pop(pieces); // Find the module we need, creating modules along the way if we @@ -1251,7 +1253,7 @@ fn build_reduced_graph_for_external_crate(root: @Module) { alt existing_module.parent_link { NoParentLink | BlockParentLink(*) { - fail "can't happen"; + fail ~"can't happen"; } ModuleParentLink (parent_module, @@ -1468,7 +1470,7 @@ fn resolve_imports() { } if self.unresolved_imports == prev_unresolved_imports { - self.session.err("failed to resolve imports"); + self.session.err(~"failed to resolve imports"); self.report_unresolved_imports(module_root); break; } @@ -1520,7 +1522,7 @@ fn resolve_imports_for_module(module: @Module) { Failed { // We presumably emitted an error. Continue. self.session.span_err(import_directive.span, - "failed to resolve import"); + ~"failed to resolve import"); } Indeterminate { // Bail out. We'll come around next time. @@ -1803,7 +1805,7 @@ fn get_import_binding(import_resolution: binding"); } UnknownResult { - fail "module result should be known at this point"; + fail ~"module result should be known at this point"; } } alt value_result { @@ -1813,7 +1815,7 @@ fn get_import_binding(import_resolution: } UnboundResult { /* Continue. */ } UnknownResult { - fail "value result should be known at this point"; + fail ~"value result should be known at this point"; } } alt type_result { @@ -1823,7 +1825,7 @@ fn get_import_binding(import_resolution: } UnboundResult { /* Continue. */ } UnknownResult { - fail "type result should be known at this point"; + fail ~"type result should be known at this point"; } } alt impl_result { @@ -1834,7 +1836,7 @@ fn get_import_binding(import_resolution: } UnboundImplResult { /* Continue. */ } UnknownImplResult { - fail "impl result should be known at this point"; + fail ~"impl result should be known at this point"; } } @@ -2025,7 +2027,7 @@ fn resolve_module_path_from_root(module: @Module, xray) { Failed { - self.session.span_err(span, "unresolved name"); + self.session.span_err(span, ~"unresolved name"); ret Failed; } Indeterminate { @@ -2082,7 +2084,7 @@ fn resolve_module_path_for_import(module: @Module, let mut search_module; alt self.resolve_module_in_lexical_scope(module, first_element) { Failed { - self.session.span_err(span, "unresolved name"); + self.session.span_err(span, ~"unresolved name"); ret Failed; } Indeterminate { @@ -2316,7 +2318,7 @@ fn resolve_one_level_renaming_import(module: @Module, source_name = source; } GlobImport { - fail "found `import *`, which is invalid"; + fail ~"found `import *`, which is invalid"; } } @@ -2443,14 +2445,15 @@ fn resolve_one_level_renaming_import(module: @Module, if is_none(module_result) && is_none(value_result) && is_none(type_result) && is_none(impl_result) { - self.session.span_err(import_directive.span, "unresolved import"); + self.session.span_err(import_directive.span, + ~"unresolved import"); ret Failed; } // Otherwise, proceed and write in the bindings. alt module.import_resolutions.find(target_name) { none { - fail "(resolving one-level renaming import) reduced graph \ + fail ~"(resolving one-level renaming import) reduced graph \ construction or glob importing should have created the \ import resolution name by now"; } @@ -2488,7 +2491,7 @@ fn report_unresolved_imports(module: @Module) { let import_count = module.imports.len(); if index != import_count { self.session.span_err(module.imports.get_elt(index).span, - "unresolved import"); + ~"unresolved import"); } // Descend into children and anonymous children. @@ -2800,15 +2803,15 @@ fn upvarify(ribs: @dvec<@Rib>, rib_index: uint, def_like: def_like, // named function item. This is not allowed, so we // report an error. - self.session.span_err(span, - "attempted dynamic environment-\ - capture"); + self.session.span_err( + span, + ~"attempted dynamic environment-capture"); } else { // This was an attempt to use a type parameter outside // its scope. self.session.span_err(span, - "attempt to use a type \ + ~"attempt to use a type \ argument out of scope"); } @@ -2881,7 +2884,7 @@ fn resolve_item(item: @item, visitor: ResolveVisitor) { // Items with the !resolve_unexported attribute are X-ray contexts. // This is used to allow the test runner to run unexported tests. let orig_xray_flag = self.xray_context; - if contains_name(attr_metas(item.attrs), "!resolve_unexported") { + if contains_name(attr_metas(item.attrs), ~"!resolve_unexported") { self.xray_context = Xray; } @@ -3014,7 +3017,7 @@ fn resolve_item(item: @item, visitor: ResolveVisitor) { if !self.session.building_library && is_none(self.session.main_fn) && - str::eq(*item.ident, "main") { + str::eq(*item.ident, ~"main") { self.session.main_fn = some((item.id, item.span)); } @@ -3037,7 +3040,7 @@ fn resolve_item(item: @item, visitor: ResolveVisitor) { } item_mac(*) { - fail "item macros unimplemented" + fail ~"item macros unimplemented" } } @@ -3102,7 +3105,7 @@ fn resolve_function(rib_kind: RibKind, capture_item.span) { none { self.session.span_err(capture_item.span, - "unresolved name in \ + ~"unresolved name in \ capture clause"); } some(def) { @@ -3231,7 +3234,7 @@ fn resolve_class(id: node_id, alt self.resolve_path(interface.path, TypeNS, true, visitor) { none { self.session.span_err(interface.path.span, - "attempt to implement a \ + ~"attempt to implement a \ nonexistent interface"); } some(def) { @@ -3345,7 +3348,7 @@ fn resolve_implementation(id: node_id, true, visitor) { none { self.session.span_err(span, - "attempt to implement an \ + ~"attempt to implement an \ unknown interface"); } some(def) { @@ -3441,7 +3444,7 @@ fn check_consistent_bindings(arm: arm) { for arm.pats.each() |p: @pat| { if self.num_bindings(p) != good { self.session.span_err(p.span, - "inconsistent number of bindings"); + ~"inconsistent number of bindings"); self.warn_var_patterns(arm); break; }; @@ -3544,7 +3547,7 @@ fn resolve_type(ty: @ty, visitor: ResolveVisitor) { // Write the result into the def map. #debug("(resolving type) writing resolution for `%s` \ (id %d)", - connect(path.idents.map(|x| *x), "::"), + connect(path.idents.map(|x| *x), ~"::"), path_id); self.record_def(path_id, def); } @@ -3552,7 +3555,7 @@ fn resolve_type(ty: @ty, visitor: ResolveVisitor) { self.session.span_err (ty.span, #fmt("use of undeclared type name `%s`", connect(path.idents.map(|x| *x), - "::"))); + ~"::"))); } } } @@ -3565,7 +3568,7 @@ fn resolve_type(ty: @ty, visitor: ResolveVisitor) { false, visitor) { none { self.session.span_err(constraint.span, - "(resolving function) \ + ~"(resolving function) \ use of undeclared \ constraint"); } @@ -3623,7 +3626,7 @@ enum variant", } FoundConst { self.session.span_err(pattern.span, - "pattern variable \ + ~"pattern variable \ conflicts with a constant \ in scope"); } @@ -3699,7 +3702,7 @@ enum variant", } none { self.session.span_err(path.span, - "unresolved enum variant"); + ~"unresolved enum variant"); } } @@ -3735,7 +3738,7 @@ fn resolve_enum_variant_or_const(name: Atom) Success(target) { alt target.bindings.value_def { none { - fail "resolved name in the value namespace to a set \ + fail ~"resolved name in the value namespace to a set \ of name bindings with no def?!"; } some(def @ def_variant(*)) { @@ -3751,7 +3754,7 @@ fn resolve_enum_variant_or_const(name: Atom) } Indeterminate { - fail "unexpected indeterminate result"; + fail ~"unexpected indeterminate result"; } Failed { @@ -3858,7 +3861,7 @@ fn resolve_definition_of_name_in_module(containing_module: @Module, ret ImportNameDefinition(def); } none { - fail "target for namespace doesn't refer to \ + fail ~"target for namespace doesn't refer to \ bindings that contain a definition for \ that namespace!"; } @@ -3910,7 +3913,7 @@ fn resolve_module_relative_path(path: @path, } Indeterminate { - fail "indeterminate unexpected"; + fail ~"indeterminate unexpected"; } Success(resulting_module) { @@ -3964,7 +3967,7 @@ fn resolve_crate_relative_path(path: @path, } Indeterminate { - fail "indeterminate unexpected"; + fail ~"indeterminate unexpected"; } Success(resulting_module) { @@ -4012,7 +4015,7 @@ fn resolve_identifier_in_local_ribs(identifier: ident, AllowCapturingSelf); } ModuleNS | ImplNS { - fail "module or impl namespaces do not have local ribs"; + fail ~"module or impl namespaces do not have local ribs"; } } @@ -4044,7 +4047,7 @@ fn resolve_item_by_identifier_in_lexical_scope(ident: ident, Success(target) { alt (*target.bindings).def_for_namespace(namespace) { none { - fail "resolved name in a namespace to a set of name \ + fail ~"resolved name in a namespace to a set of name \ bindings with no def for that namespace?!"; } some(def) { @@ -4056,7 +4059,7 @@ fn resolve_item_by_identifier_in_lexical_scope(ident: ident, } } Indeterminate { - fail "unexpected indeterminate result"; + fail ~"unexpected indeterminate result"; } Failed { ret none; @@ -4083,14 +4086,14 @@ fn resolve_expr(expr: @expr, visitor: ResolveVisitor) { some(def) { // Write the result into the def map. #debug("(resolving expr) resolved `%s`", - connect(path.idents.map(|x| *x), "::")); + connect(path.idents.map(|x| *x), ~"::")); self.record_def(expr.id, def); } none { self.session.span_err(expr.span, #fmt("unresolved name: %s", connect(path.idents.map(|x| *x), - "::"))); + ~"::"))); } } @@ -4197,15 +4200,15 @@ fn check_for_unused_imports_in_module(module: @Module) { alt self.unused_import_lint_level { warn { self.session.span_warn(import_resolution.span, - "unused import"); + ~"unused import"); } error { self.session.span_err(import_resolution.span, - "unused import"); + ~"unused import"); } ignore { self.session.span_bug(import_resolution.span, - "shouldn't be here if lint \ + ~"shouldn't be here if lint \ pass is ignored"); } } @@ -4221,7 +4224,7 @@ fn check_for_unused_imports_in_module(module: @Module) { // /// A somewhat inefficient routine to print out the name of a module. - fn module_to_str(module: @Module) -> str { + fn module_to_str(module: @Module) -> ~str { let atoms = dvec(); let mut current_module = module; loop { @@ -4234,21 +4237,21 @@ fn module_to_str(module: @Module) -> str { current_module = module; } BlockParentLink(module, node_id) { - atoms.push((*self.atom_table).intern(@"")); + atoms.push((*self.atom_table).intern(@~"")); current_module = module; } } } if atoms.len() == 0u { - ret "???"; + ret ~"???"; } - let mut string = ""; + let mut string = ~""; let mut i = atoms.len() - 1u; loop { if i < atoms.len() - 1u { - string += "::"; + string += ~"::"; } string += *(*self.atom_table).atom_to_str(atoms.get_elt(i)); @@ -4273,36 +4276,36 @@ fn dump_module(module: @Module) { for module.import_resolutions.each |name, import_resolution| { let mut module_repr; alt (*import_resolution).target_for_namespace(ModuleNS) { - none { module_repr = ""; } + none { module_repr = ~""; } some(target) { - module_repr = " module:?"; + module_repr = ~" module:?"; // XXX } } let mut value_repr; alt (*import_resolution).target_for_namespace(ValueNS) { - none { value_repr = ""; } + none { value_repr = ~""; } some(target) { - value_repr = " value:?"; + value_repr = ~" value:?"; // XXX } } let mut type_repr; alt (*import_resolution).target_for_namespace(TypeNS) { - none { type_repr = ""; } + none { type_repr = ~""; } some(target) { - type_repr = " type:?"; + type_repr = ~" type:?"; // XXX } } let mut impl_repr; alt (*import_resolution).target_for_namespace(ImplNS) { - none { impl_repr = ""; } + none { impl_repr = ~""; } some(target) { - impl_repr = " impl:?"; + impl_repr = ~" impl:?"; // XXX } } diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 2fdf8c3ff7f3..0b7053a2c2bd 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -41,7 +41,7 @@ enum opt_result { range_result(result, result), } fn trans_opt(bcx: block, o: opt) -> opt_result { - let _icx = bcx.insn_ctxt("alt::trans_opt"); + let _icx = bcx.insn_ctxt(~"alt::trans_opt"); let ccx = bcx.ccx(); let mut bcx = bcx; alt o { @@ -275,7 +275,7 @@ fn add_to_set(tcx: ty::ctxt, &&set: dvec, val: opt) { fn extract_variant_args(bcx: block, pat_id: ast::node_id, vdefs: {enm: def_id, var: def_id}, val: ValueRef) -> {vals: ~[ValueRef], bcx: block} { - let _icx = bcx.insn_ctxt("alt::extract_variant_args"); + let _icx = bcx.insn_ctxt(~"alt::extract_variant_args"); let ccx = bcx.fcx.ccx; let enum_ty_substs = alt check ty::get(node_id_type(bcx, pat_id)).struct { ty::ty_enum(id, substs) { assert id == vdefs.enm; substs.tps } @@ -389,7 +389,7 @@ fn score(p: @ast::pat) -> uint { fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], chk: option, &exits: ~[exit_node]) { - let _icx = bcx.insn_ctxt("alt::compile_submatch"); + let _icx = bcx.insn_ctxt(~"alt::compile_submatch"); let mut bcx = bcx; let tcx = bcx.tcx(), dm = tcx.def_map; if m.len() == 0u { Br(bcx, option::get(chk)()); ret; } @@ -404,7 +404,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], bcx.fcx.lllocals.insert(val, loc); }; let {bcx: guard_cx, val} = { - do with_scope_result(bcx, e.info(), "guard") |bcx| { + do with_scope_result(bcx, e.info(), ~"guard") |bcx| { trans_temp_expr(bcx, e) } }; @@ -460,7 +460,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], let tup_ty = node_id_type(bcx, pat_id); let n_tup_elts = alt ty::get(tup_ty).struct { ty::ty_tup(elts) { elts.len() } - _ { ccx.sess.bug("non-tuple type in tuple pattern"); } + _ { ccx.sess.bug(~"non-tuple type in tuple pattern"); } }; let mut tup_vals = ~[], i = 0u; while i < n_tup_elts { @@ -531,7 +531,7 @@ enum branch_kind { no_branch, single, switch, compare, } } let else_cx = alt kind { no_branch | single { bcx } - _ { sub_block(bcx, "match_else") } + _ { sub_block(bcx, ~"match_else") } }; let sw = if kind == switch { Switch(bcx, test_val, else_cx.llbb, opts.len()) @@ -546,7 +546,7 @@ enum branch_kind { no_branch, single, switch, compare, } i += 1u; let mut opt_cx = else_cx; if !exhaustive || i < len { - opt_cx = sub_block(bcx, "match_case"); + opt_cx = sub_block(bcx, ~"match_case"); alt kind { single { Br(bcx, opt_cx.llbb); } switch { @@ -560,7 +560,7 @@ enum branch_kind { no_branch, single, switch, compare, } compare { let t = node_id_type(bcx, pat_id); let {bcx: after_cx, val: matches} = { - do with_scope_result(bcx, none, "compare_scope") |bcx| { + do with_scope_result(bcx, none, ~"compare_scope") |bcx| { alt trans_opt(bcx, opt) { single_result({bcx, val}) { trans_compare(bcx, ast::eq, test_val, t, val, t) @@ -575,7 +575,7 @@ enum branch_kind { no_branch, single, switch, compare, } } } }; - bcx = sub_block(after_cx, "compare_next"); + bcx = sub_block(after_cx, ~"compare_next"); CondBr(after_cx, matches, opt_cx.llbb, bcx.llbb); } _ { } @@ -608,7 +608,7 @@ enum branch_kind { no_branch, single, switch, compare, } // Returns false for unreachable blocks fn make_phi_bindings(bcx: block, map: ~[exit_node], ids: pat_util::pat_id_map) -> bool { - let _icx = bcx.insn_ctxt("alt::make_phi_bindings"); + let _icx = bcx.insn_ctxt(~"alt::make_phi_bindings"); let our_block = bcx.llbb as uint; let mut success = true, bcx = bcx; for ids.each |name, node_id| { @@ -642,15 +642,15 @@ fn trans_alt(bcx: block, arms: ~[ast::arm], mode: ast::alt_mode, dest: dest) -> block { - let _icx = bcx.insn_ctxt("alt::trans_alt"); - do with_scope(bcx, alt_expr.info(), "alt") |bcx| { + let _icx = bcx.insn_ctxt(~"alt::trans_alt"); + do with_scope(bcx, alt_expr.info(), ~"alt") |bcx| { trans_alt_inner(bcx, expr, arms, mode, dest) } } fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], mode: ast::alt_mode, dest: dest) -> block { - let _icx = scope_cx.insn_ctxt("alt::trans_alt_inner"); + let _icx = scope_cx.insn_ctxt(~"alt::trans_alt_inner"); let bcx = scope_cx, tcx = bcx.tcx(); let mut bodies = ~[], match = ~[]; @@ -658,7 +658,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], if bcx.unreachable { ret bcx; } for vec::each(arms) |a| { - let body = scope_block(bcx, a.body.info(), "case_body"); + let body = scope_block(bcx, a.body.info(), ~"case_body"); let id_map = pat_util::pat_id_map(tcx.def_map, a.pats[0]); vec::push(bodies, body); for vec::each(a.pats) |p| { @@ -676,8 +676,8 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], fn mk_fail(bcx: block, sp: span, done: @mut option) -> BasicBlockRef { alt *done { some(bb) { ret bb; } _ { } } - let fail_cx = sub_block(bcx, "case_fallthrough"); - trans_fail(fail_cx, some(sp), "non-exhaustive match failure");; + let fail_cx = sub_block(bcx, ~"case_fallthrough"); + trans_fail(fail_cx, some(sp), ~"non-exhaustive match failure");; *done = some(fail_cx.llbb); ret fail_cx.llbb; } @@ -709,7 +709,7 @@ fn mk_fail(bcx: block, sp: span, // Not alt-related, but similar to the pattern-munging code above fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, make_copy: bool) -> block { - let _icx = bcx.insn_ctxt("alt::bind_irrefutable_pat"); + let _icx = bcx.insn_ctxt(~"alt::bind_irrefutable_pat"); let ccx = bcx.fcx.ccx; let mut bcx = bcx; diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 2b4447d71ce0..9273170c65c8 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -65,11 +65,11 @@ enum dest { ignore, } -fn dest_str(ccx: @crate_ctxt, d: dest) -> str { +fn dest_str(ccx: @crate_ctxt, d: dest) -> ~str { alt d { by_val(v) { #fmt["by_val(%s)", val_str(ccx.tn, *v)] } save_in(v) { #fmt["save_in(%s)", val_str(ccx.tn, v)] } - ignore { "ignore" } + ignore { ~"ignore" } } } @@ -95,7 +95,7 @@ fn dup_for_join(dest: dest) -> dest { } impl ccx_icx for @crate_ctxt { - fn insn_ctxt(s: str) -> icx_popper { + fn insn_ctxt(s: ~str) -> icx_popper { #debug("new insn_ctxt: %s", s); if self.sess.count_llvm_insns() { vec::push(*self.stats.llvm_insn_ctxt, s); @@ -105,20 +105,20 @@ fn insn_ctxt(s: str) -> icx_popper { } impl bcx_icx for block { - fn insn_ctxt(s: str) -> icx_popper { + fn insn_ctxt(s: ~str) -> icx_popper { self.ccx().insn_ctxt(s) } } impl fcx_icx for fn_ctxt { - fn insn_ctxt(s: str) -> icx_popper { + fn insn_ctxt(s: ~str) -> icx_popper { self.ccx.insn_ctxt(s) } } fn join_returns(parent_cx: block, in_cxs: ~[block], in_ds: ~[dest], out_dest: dest) -> block { - let out = sub_block(parent_cx, "join"); + let out = sub_block(parent_cx, ~"join"); let mut reachable = false, i = 0u, phi = none; for vec::each(in_cxs) |cx| { if !cx.unreachable { @@ -160,11 +160,11 @@ fn store_in_dest(bcx: block, val: ValueRef, dest: dest) -> block { fn get_dest_addr(dest: dest) -> ValueRef { alt dest { save_in(a) { a } - _ { fail "get_dest_addr: not a save_in"; } + _ { fail ~"get_dest_addr: not a save_in"; } } } -fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timespec, +fn log_fn_time(ccx: @crate_ctxt, name: ~str, start: time::timespec, end: time::timespec) { let elapsed = 1000 * ((end.sec - start.sec) as int) + ((end.nsec as int) - (start.nsec as int)) / 1000000; @@ -172,7 +172,7 @@ fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timespec, } -fn decl_fn(llmod: ModuleRef, name: str, cc: lib::llvm::CallConv, +fn decl_fn(llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv, llty: TypeRef) -> ValueRef { let llfn: ValueRef = str::as_c_str(name, |buf| { llvm::LLVMGetOrInsertFunction(llmod, buf, llty) @@ -181,21 +181,22 @@ fn decl_fn(llmod: ModuleRef, name: str, cc: lib::llvm::CallConv, ret llfn; } -fn decl_cdecl_fn(llmod: ModuleRef, name: str, llty: TypeRef) -> ValueRef { +fn decl_cdecl_fn(llmod: ModuleRef, name: ~str, llty: TypeRef) -> ValueRef { ret decl_fn(llmod, name, lib::llvm::CCallConv, llty); } // Only use this if you are going to actually define the function. It's // not valid to simply declare a function as internal. -fn decl_internal_cdecl_fn(llmod: ModuleRef, name: str, llty: TypeRef) -> +fn decl_internal_cdecl_fn(llmod: ModuleRef, name: ~str, llty: TypeRef) -> ValueRef { let llfn = decl_cdecl_fn(llmod, name, llty); lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage); ret llfn; } -fn get_extern_fn(externs: hashmap, llmod: ModuleRef, name: str, +fn get_extern_fn(externs: hashmap<~str, ValueRef>, + llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv, ty: TypeRef) -> ValueRef { if externs.contains_key(name) { ret externs.get(name); } let f = decl_fn(llmod, name, cc, ty); @@ -203,8 +204,8 @@ fn get_extern_fn(externs: hashmap, llmod: ModuleRef, name: str, ret f; } -fn get_extern_const(externs: hashmap, llmod: ModuleRef, - name: str, ty: TypeRef) -> ValueRef { +fn get_extern_const(externs: hashmap<~str, ValueRef>, llmod: ModuleRef, + name: ~str, ty: TypeRef) -> ValueRef { if externs.contains_key(name) { ret externs.get(name); } let c = str::as_c_str(name, |buf| llvm::LLVMAddGlobal(llmod, ty, buf)); externs.insert(name, c); @@ -212,10 +213,10 @@ fn get_extern_const(externs: hashmap, llmod: ModuleRef, } fn get_simple_extern_fn(cx: block, - externs: hashmap, + externs: hashmap<~str, ValueRef>, llmod: ModuleRef, - name: str, n_args: int) -> ValueRef { - let _icx = cx.insn_ctxt("get_simple_extern_fn"); + name: ~str, n_args: int) -> ValueRef { + let _icx = cx.insn_ctxt(~"get_simple_extern_fn"); let ccx = cx.fcx.ccx; let inputs = vec::from_elem(n_args as uint, ccx.int_type); let output = ccx.int_type; @@ -223,10 +224,10 @@ fn get_simple_extern_fn(cx: block, ret get_extern_fn(externs, llmod, name, lib::llvm::CCallConv, t); } -fn trans_foreign_call(cx: block, externs: hashmap, - llmod: ModuleRef, name: str, args: ~[ValueRef]) -> +fn trans_foreign_call(cx: block, externs: hashmap<~str, ValueRef>, + llmod: ModuleRef, name: ~str, args: ~[ValueRef]) -> ValueRef { - let _icx = cx.insn_ctxt("trans_foreign_call"); + let _icx = cx.insn_ctxt(~"trans_foreign_call"); let n = args.len() as int; let llforeign: ValueRef = get_simple_extern_fn(cx, externs, llmod, name, n); @@ -238,26 +239,26 @@ fn trans_foreign_call(cx: block, externs: hashmap, } fn trans_free(cx: block, v: ValueRef) -> block { - let _icx = cx.insn_ctxt("trans_free"); + let _icx = cx.insn_ctxt(~"trans_free"); Call(cx, cx.ccx().upcalls.free, ~[PointerCast(cx, v, T_ptr(T_i8()))]); cx } fn trans_unique_free(cx: block, v: ValueRef) -> block { - let _icx = cx.insn_ctxt("trans_unique_free"); + let _icx = cx.insn_ctxt(~"trans_unique_free"); Call(cx, cx.ccx().upcalls.exchange_free, ~[PointerCast(cx, v, T_ptr(T_i8()))]); ret cx; } fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { - let _icx = cx.insn_ctxt("umax"); + let _icx = cx.insn_ctxt(~"umax"); let cond = ICmp(cx, lib::llvm::IntULT, a, b); ret Select(cx, cond, b, a); } fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { - let _icx = cx.insn_ctxt("umin"); + let _icx = cx.insn_ctxt(~"umin"); let cond = ICmp(cx, lib::llvm::IntULT, a, b); ret Select(cx, cond, a, b); } @@ -271,7 +272,7 @@ fn alloca_zeroed(cx: block, t: TypeRef) -> ValueRef { } fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef { - let _icx = cx.insn_ctxt("alloca"); + let _icx = cx.insn_ctxt(~"alloca"); if cx.unreachable { ret llvm::LLVMGetUndef(t); } let initcx = raw_block(cx.fcx, cx.fcx.llstaticallocas); let p = Alloca(initcx, t); @@ -280,7 +281,7 @@ fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef { } fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("zero_mem"); + let _icx = cx.insn_ctxt(~"zero_mem"); let bcx = cx; let ccx = cx.ccx(); let llty = type_of(ccx, t); @@ -289,7 +290,7 @@ fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) -> block { } fn arrayalloca(cx: block, t: TypeRef, v: ValueRef) -> ValueRef { - let _icx = cx.insn_ctxt("arrayalloca"); + let _icx = cx.insn_ctxt(~"arrayalloca"); if cx.unreachable { ret llvm::LLVMGetUndef(t); } ret ArrayAlloca(raw_block(cx.fcx, cx.fcx.llstaticallocas), t, v); } @@ -298,7 +299,7 @@ fn arrayalloca(cx: block, t: TypeRef, v: ValueRef) -> ValueRef { // The type of the returned pointer is always i8*. If you care about the // return type, use bump_ptr(). fn ptr_offs(bcx: block, base: ValueRef, sz: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("ptr_offs"); + let _icx = bcx.insn_ctxt(~"ptr_offs"); let raw = PointerCast(bcx, base, T_ptr(T_i8())); InBoundsGEP(bcx, raw, ~[sz]) } @@ -307,7 +308,7 @@ fn ptr_offs(bcx: block, base: ValueRef, sz: ValueRef) -> ValueRef { // to a given type. fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("bump_ptr"); + let _icx = bcx.insn_ctxt(~"bump_ptr"); let ccx = bcx.ccx(); let bumped = ptr_offs(bcx, base, sz); let typ = T_ptr(type_of(ccx, t)); @@ -320,7 +321,7 @@ fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) -> fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id, variant_id: ast::def_id, ty_substs: ~[ty::t], ix: uint) -> ValueRef { - let _icx = bcx.insn_ctxt("GEP_enum"); + let _icx = bcx.insn_ctxt(~"GEP_enum"); let ccx = bcx.ccx(); let variant = ty::enum_variant_with_id(ccx.tcx, enum_id, variant_id); assert ix < variant.args.len(); @@ -341,7 +342,7 @@ fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id, fn opaque_box_body(bcx: block, body_t: ty::t, boxptr: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("opaque_box_body"); + let _icx = bcx.insn_ctxt(~"opaque_box_body"); let ccx = bcx.ccx(); let boxptr = PointerCast(bcx, boxptr, T_ptr(T_box_header(ccx))); let bodyptr = GEPi(bcx, boxptr, ~[1u]); @@ -352,7 +353,7 @@ fn opaque_box_body(bcx: block, // potentially dynamic size. fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("malloc_raw"); + let _icx = bcx.insn_ctxt(~"malloc_raw"); let ccx = bcx.ccx(); let (mk_fn, upcall) = alt heap { @@ -386,7 +387,7 @@ fn malloc_raw(bcx: block, t: ty::t, heap: heap) -> ValueRef { // and pulls out the body fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) -> {box: ValueRef, body: ValueRef} { - let _icx = bcx.insn_ctxt("malloc_general"); + let _icx = bcx.insn_ctxt(~"malloc_general"); let llbox = malloc_raw_dyn(bcx, t, heap, size); let non_gc_box = non_gc_box_cast(bcx, llbox); let body = GEPi(bcx, non_gc_box, ~[0u, abi::box_field_body]); @@ -471,23 +472,23 @@ fn set_glue_inlining(f: ValueRef, t: ty::t) { // Double-check that we never ask LLVM to declare the same symbol twice. It // silently mangles such symbols, breaking our linkage model. -fn note_unique_llvm_symbol(ccx: @crate_ctxt, sym: str) { +fn note_unique_llvm_symbol(ccx: @crate_ctxt, sym: ~str) { if ccx.all_llvm_symbols.contains_key(sym) { - ccx.sess.bug("duplicate LLVM symbol: " + sym); + ccx.sess.bug(~"duplicate LLVM symbol: " + sym); } ccx.all_llvm_symbols.insert(sym, ()); } // Generates the declaration for (but doesn't emit) a type descriptor. fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { - let _icx = ccx.insn_ctxt("declare_tydesc"); + let _icx = ccx.insn_ctxt(~"declare_tydesc"); let llty = type_of(ccx, t); let llsize = llsize_of(ccx, llty); let llalign = llalign_of(ccx, llty); //XXX this triggers duplicate LLVM symbols let name = if false /*ccx.sess.opts.debuginfo*/ { - mangle_internal_name_by_type_only(ccx, t, @"tydesc") - } else { mangle_internal_name_by_seq(ccx, @"tydesc") }; + mangle_internal_name_by_type_only(ccx, t, @~"tydesc") + } else { mangle_internal_name_by_seq(ccx, @~"tydesc") }; note_unique_llvm_symbol(ccx, name); log(debug, #fmt("+++ declare_tydesc %s %s", ty_to_str(ccx.tcx, t), name)); let gvar = str::as_c_str(name, |buf| { @@ -502,22 +503,22 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { mut drop_glue: none, mut free_glue: none, mut visit_glue: none}; - log(debug, "--- declare_tydesc " + ppaux::ty_to_str(ccx.tcx, t)); + log(debug, ~"--- declare_tydesc " + ppaux::ty_to_str(ccx.tcx, t)); ret inf; } type glue_helper = fn@(block, ValueRef, ty::t); fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef, - name: str) -> ValueRef { - let _icx = ccx.insn_ctxt("declare_generic_glue"); + name: ~str) -> ValueRef { + let _icx = ccx.insn_ctxt(~"declare_generic_glue"); let name = name; let mut fn_nm; //XXX this triggers duplicate LLVM symbols if false /*ccx.sess.opts.debuginfo*/ { - fn_nm = mangle_internal_name_by_type_only(ccx, t, @("glue_" + name)); + fn_nm = mangle_internal_name_by_type_only(ccx, t, @(~"glue_" + name)); } else { - fn_nm = mangle_internal_name_by_seq(ccx, @("glue_" + name)); + fn_nm = mangle_internal_name_by_seq(ccx, @(~"glue_" + name)); } note_unique_llvm_symbol(ccx, fn_nm); let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty); @@ -527,7 +528,7 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef, fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, helper: glue_helper) -> ValueRef { - let _icx = ccx.insn_ctxt("make_generic_glue_inner"); + let _icx = ccx.insn_ctxt(~"make_generic_glue_inner"); let fcx = new_fn_ctxt(ccx, ~[], llfn, none); lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage); ccx.stats.n_glues_created += 1u; @@ -548,9 +549,9 @@ fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t, } fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, - helper: glue_helper, name: str) + helper: glue_helper, name: ~str) -> ValueRef { - let _icx = ccx.insn_ctxt("make_generic_glue"); + let _icx = ccx.insn_ctxt(~"make_generic_glue"); if !ccx.sess.trans_stats() { ret make_generic_glue_inner(ccx, t, llfn, helper); } @@ -558,13 +559,13 @@ fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, let start = time::get_time(); let llval = make_generic_glue_inner(ccx, t, llfn, helper); let end = time::get_time(); - log_fn_time(ccx, "glue " + name + " " + ty_to_short_str(ccx.tcx, t), + log_fn_time(ccx, ~"glue " + name + ~" " + ty_to_short_str(ccx.tcx, t), start, end); ret llval; } fn emit_tydescs(ccx: @crate_ctxt) { - let _icx = ccx.insn_ctxt("emit_tydescs"); + let _icx = ccx.insn_ctxt(~"emit_tydescs"); for ccx.tydescs.each |key, val| { let glue_fn_ty = T_ptr(T_glue_fn(ccx)); let ti = val; @@ -613,7 +614,7 @@ fn emit_tydescs(ccx: @crate_ctxt) { } fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { - let _icx = bcx.insn_ctxt("make_take_glue"); + let _icx = bcx.insn_ctxt(~"make_take_glue"); // NB: v is a *pointer* to type t here, not a direct value. let bcx = alt ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | @@ -655,7 +656,7 @@ fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { } fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) { - let _icx = cx.insn_ctxt("incr_refcnt_of_boxed"); + let _icx = cx.insn_ctxt(~"incr_refcnt_of_boxed"); let ccx = cx.ccx(); maybe_validate_box(cx, box_ptr); let rc_ptr = GEPi(cx, box_ptr, ~[0u, abi::box_field_refcnt]); @@ -665,10 +666,10 @@ fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) { } fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { - let _icx = bcx.insn_ctxt("make_visit_glue"); + let _icx = bcx.insn_ctxt(~"make_visit_glue"); let mut bcx = bcx; - assert bcx.ccx().tcx.intrinsic_defs.contains_key(@"ty_visitor"); - let (iid, ty) = bcx.ccx().tcx.intrinsic_defs.get(@"ty_visitor"); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(@~"ty_visitor"); + let (iid, ty) = bcx.ccx().tcx.intrinsic_defs.get(@~"ty_visitor"); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, iid); build_return(bcx); @@ -679,7 +680,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { // v is a pointer to the actual box component of the type here. The // ValueRef will have the wrong type here (make_generic_glue is casting // everything to a pointer to the type that the glue acts on). - let _icx = bcx.insn_ctxt("make_free_glue"); + let _icx = bcx.insn_ctxt(~"make_free_glue"); let ccx = bcx.ccx(); let bcx = alt ty::get(t).struct { ty::ty_box(body_mt) { @@ -761,7 +762,7 @@ fn trans_class_drop(bcx: block, v0: ValueRef, dtor_did: ast::def_id, fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { // NB: v0 is an *alias* of type t here, not a direct value. - let _icx = bcx.insn_ctxt("make_drop_glue"); + let _icx = bcx.insn_ctxt(~"make_drop_glue"); let ccx = bcx.ccx(); let bcx = alt ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | @@ -810,7 +811,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, parent_id: ast::def_id, substs: ~[ty::t]) -> ValueRef { - let _icx = ccx.insn_ctxt("trans_res_dtor"); + let _icx = ccx.insn_ctxt(~"trans_res_dtor"); if (substs.len() > 0u) { let did = if did.crate != ast::local_crate { maybe_instantiate_inline(ccx, did) @@ -842,7 +843,7 @@ fn maybe_validate_box(_cx: block, _box_ptr: ValueRef) { } fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block { - let _icx = bcx.insn_ctxt("decr_refcnt_maybe_free"); + let _icx = bcx.insn_ctxt(~"decr_refcnt_maybe_free"); let ccx = bcx.ccx(); maybe_validate_box(bcx, box_ptr); @@ -858,7 +859,7 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block { } // Structural comparison: a rather involved form of glue. -fn maybe_name_value(cx: @crate_ctxt, v: ValueRef, s: str) { +fn maybe_name_value(cx: @crate_ctxt, v: ValueRef, s: ~str) { if cx.sess.opts.save_temps { let _: () = str::as_c_str(s, |buf| llvm::LLVMSetValueName(v, buf)); } @@ -881,12 +882,12 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef, ty::ty_float(_) { ret rslt(cx, f(floating_point)); } ty::ty_type { ret rslt(trans_fail(cx, none, - "attempt to compare values of type type"), + ~"attempt to compare values of type type"), C_nil()); } _ { // Should never get here, because t is scalar. - cx.sess().bug("non-scalar type passed to \ + cx.sess().bug(~"non-scalar type passed to \ compare_scalar_types"); } } @@ -896,9 +897,9 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef, // A helper function to do the actual comparison of scalar values. fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, nt: scalar_type, op: ast::binop) -> ValueRef { - let _icx = cx.insn_ctxt("compare_scalar_values"); + let _icx = cx.insn_ctxt(~"compare_scalar_values"); fn die_(cx: block) -> ! { - cx.tcx().sess.bug("compare_scalar_values: must be a\ + cx.tcx().sess.bug(~"compare_scalar_values: must be a\ comparison operator"); } let die = fn@() -> ! { die_(cx) }; @@ -967,13 +968,13 @@ fn store_inbounds(cx: block, v: ValueRef, p: ValueRef, // Iterates through the elements of a structural type. fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, f: val_and_ty_fn) -> block { - let _icx = cx.insn_ctxt("iter_structural_ty"); + let _icx = cx.insn_ctxt(~"iter_structural_ty"); fn iter_variant(cx: block, a_tup: ValueRef, variant: ty::variant_info, tps: ~[ty::t], tid: ast::def_id, f: val_and_ty_fn) -> block { - let _icx = cx.insn_ctxt("iter_variant"); + let _icx = cx.insn_ctxt(~"iter_variant"); if variant.args.len() == 0u { ret cx; } let fn_ty = variant.ctor_ty; let ccx = cx.ccx(); @@ -989,7 +990,7 @@ fn iter_variant(cx: block, a_tup: ValueRef, j += 1u; } } - _ { cx.tcx().sess.bug("iter_variant: not a function type"); } + _ { cx.tcx().sess.bug(~"iter_variant: not a function type"); } } ret cx; } @@ -1036,14 +1037,14 @@ fn iter_variant(cx: block, a_tup: ValueRef, // NB: we must hit the discriminant first so that structural // comparison know not to proceed when the discriminants differ. cx = f(cx, lldiscrim_a_ptr, ty::mk_int(cx.tcx())); - let unr_cx = sub_block(cx, "enum-iter-unr"); + let unr_cx = sub_block(cx, ~"enum-iter-unr"); Unreachable(unr_cx); let llswitch = Switch(cx, lldiscrim_a, unr_cx.llbb, n_variants); - let next_cx = sub_block(cx, "enum-iter-next"); + let next_cx = sub_block(cx, ~"enum-iter-next"); for vec::each(*variants) |variant| { let variant_cx = sub_block(cx, - "enum-iter-variant-" + + ~"enum-iter-variant-" + int::to_str(variant.disr_val, 10u)); AddCase(llswitch, C_int(ccx, variant.disr_val), variant_cx.llbb); let variant_cx = @@ -1066,7 +1067,7 @@ fn iter_variant(cx: block, a_tup: ValueRef, cx = f(cx, llfld_a, fld.mt.ty); } } - _ { cx.sess().unimpl("type in iter_structural_ty"); } + _ { cx.sess().unimpl(~"type in iter_structural_ty"); } } ret cx; } @@ -1081,7 +1082,7 @@ fn lazily_emit_all_tydesc_glue(ccx: @crate_ctxt, fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, ti: @tydesc_info) { - let _icx = ccx.insn_ctxt("lazily_emit_tydesc_glue"); + let _icx = ccx.insn_ctxt(~"lazily_emit_tydesc_glue"); if field == abi::tydesc_field_take_glue { alt ti.take_glue { some(_) { } @@ -1089,10 +1090,10 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, #debug("+++ lazily_emit_tydesc_glue TAKE %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = declare_generic_glue - (ccx, ti.ty, T_glue_fn(ccx), "take"); + (ccx, ti.ty, T_glue_fn(ccx), ~"take"); ti.take_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, - make_take_glue, "take"); + make_take_glue, ~"take"); #debug("--- lazily_emit_tydesc_glue TAKE %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); } @@ -1104,10 +1105,10 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, #debug("+++ lazily_emit_tydesc_glue DROP %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = - declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "drop"); + declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"drop"); ti.drop_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, - make_drop_glue, "drop"); + make_drop_glue, ~"drop"); #debug("--- lazily_emit_tydesc_glue DROP %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); } @@ -1119,10 +1120,10 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, #debug("+++ lazily_emit_tydesc_glue FREE %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = - declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "free"); + declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"free"); ti.free_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, - make_free_glue, "free"); + make_free_glue, ~"free"); #debug("--- lazily_emit_tydesc_glue FREE %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); } @@ -1134,10 +1135,10 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, #debug("+++ lazily_emit_tydesc_glue VISIT %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = - declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "visit"); + declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"visit"); ti.visit_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, - make_visit_glue, "visit"); + make_visit_glue, ~"visit"); #debug("--- lazily_emit_tydesc_glue VISIT %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); } @@ -1148,7 +1149,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, // See [Note-arg-mode] fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, field: uint, static_ti: option<@tydesc_info>) { - let _icx = cx.insn_ctxt("call_tydesc_glue_full"); + let _icx = cx.insn_ctxt(~"call_tydesc_glue_full"); if cx.unreachable { ret; } let mut static_glue_fn = none; @@ -1188,7 +1189,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, // See [Note-arg-mode] fn call_tydesc_glue(++cx: block, v: ValueRef, t: ty::t, field: uint) -> block { - let _icx = cx.insn_ctxt("call_tydesc_glue"); + let _icx = cx.insn_ctxt(~"call_tydesc_glue"); let ti = get_tydesc(cx.ccx(), t); call_tydesc_glue_full(cx, v, ti.tydesc, field, some(ti)); ret cx; @@ -1198,7 +1199,7 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, llop: ValueRef) -> ValueRef { // We can't use call_tydesc_glue_full() and friends here because compare // glue has a special signature. - let _icx = bcx.insn_ctxt("call_cmp_glue"); + let _icx = bcx.insn_ctxt(~"call_cmp_glue"); let lllhs = spill_if_immediate(bcx, lhs, t); let llrhs = spill_if_immediate(bcx, rhs, t); @@ -1216,7 +1217,7 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, } fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("take_ty"); + let _icx = cx.insn_ctxt(~"take_ty"); if ty::type_needs_drop(cx.tcx(), t) { ret call_tydesc_glue(cx, v, t, abi::tydesc_field_take_glue); } @@ -1224,7 +1225,7 @@ fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block { } fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("drop_ty"); + let _icx = cx.insn_ctxt(~"drop_ty"); if ty::type_needs_drop(cx.tcx(), t) { ret call_tydesc_glue(cx, v, t, abi::tydesc_field_drop_glue); } @@ -1232,7 +1233,7 @@ fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block { } fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { - let _icx = bcx.insn_ctxt("drop_ty_immediate"); + let _icx = bcx.insn_ctxt(~"drop_ty_immediate"); alt ty::get(t).struct { ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str | ty::ty_evec(_, ty::vstore_uniq) | @@ -1244,12 +1245,12 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { ty::ty_estr(ty::vstore_box) { decr_refcnt_maybe_free(bcx, v, t) } - _ { bcx.tcx().sess.bug("drop_ty_immediate: non-box ty"); } + _ { bcx.tcx().sess.bug(~"drop_ty_immediate: non-box ty"); } } } fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result { - let _icx = bcx.insn_ctxt("take_ty_immediate"); + let _icx = bcx.insn_ctxt(~"take_ty_immediate"); alt ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_evec(_, ty::vstore_box) | @@ -1270,7 +1271,7 @@ fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result { } fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("free_ty"); + let _icx = cx.insn_ctxt(~"free_ty"); if ty::type_needs_drop(cx.tcx(), t) { ret call_tydesc_glue(cx, v, t, abi::tydesc_field_free_glue); } @@ -1283,11 +1284,11 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef, // alignment information when the alignment is statically known (it must // be nothing more than a constant int, or LLVM complains -- not even a // constant element of a tydesc works). - let _icx = cx.insn_ctxt("call_memmove"); + let _icx = cx.insn_ctxt(~"call_memmove"); let ccx = cx.ccx(); let key = alt ccx.sess.targ_cfg.arch { - session::arch_x86 | session::arch_arm { "llvm.memmove.p0i8.p0i8.i32" } - session::arch_x86_64 { "llvm.memmove.p0i8.p0i8.i64" } + session::arch_x86 | session::arch_arm { ~"llvm.memmove.p0i8.p0i8.i32" } + session::arch_x86_64 { ~"llvm.memmove.p0i8.p0i8.i64" } }; let memmove = ccx.intrinsics.get(key); let src_ptr = PointerCast(cx, src, T_ptr(T_i8())); @@ -1299,7 +1300,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef, } fn memmove_ty(bcx: block, dst: ValueRef, src: ValueRef, t: ty::t) { - let _icx = bcx.insn_ctxt("memmove_ty"); + let _icx = bcx.insn_ctxt(~"memmove_ty"); let ccx = bcx.ccx(); if ty::type_is_structural(t) { let llsz = llsize_of(ccx, type_of(ccx, t)); @@ -1322,7 +1323,7 @@ fn type_is_structural_or_param(t: ty::t) -> bool { fn copy_val(cx: block, action: copy_action, dst: ValueRef, src: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("copy_val"); + let _icx = cx.insn_ctxt(~"copy_val"); if action == DROP_EXISTING && (type_is_structural_or_param(t) || ty::type_is_unique(t)) { @@ -1339,7 +1340,7 @@ fn copy_val(cx: block, action: copy_action, dst: ValueRef, fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef, src: ValueRef, t: ty::t) -> block { - let _icx = bcx.insn_ctxt("copy_val_no_check"); + let _icx = bcx.insn_ctxt(~"copy_val_no_check"); let ccx = bcx.ccx(); let mut bcx = bcx; if ty::type_is_scalar(t) { @@ -1357,7 +1358,7 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef, memmove_ty(bcx, dst, src, t); ret take_ty(bcx, dst, t); } - ccx.sess.bug("unexpected type in trans::copy_val_no_check: " + + ccx.sess.bug(~"unexpected type in trans::copy_val_no_check: " + ppaux::ty_to_str(ccx.tcx, t)); } @@ -1370,7 +1371,7 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef, fn move_val(cx: block, action: copy_action, dst: ValueRef, src: lval_result, t: ty::t) -> block { - let _icx = cx.insn_ctxt("move_val"); + let _icx = cx.insn_ctxt(~"move_val"); let mut src_val = src.val; let tcx = cx.tcx(); let mut cx = cx; @@ -1396,14 +1397,14 @@ fn move_val(cx: block, action: copy_action, dst: ValueRef, revoke_clean(cx, src_val); ret cx; } - cx.sess().bug("unexpected type in trans::move_val: " + + cx.sess().bug(~"unexpected type in trans::move_val: " + ppaux::ty_to_str(tcx, t)); } fn store_temp_expr(cx: block, action: copy_action, dst: ValueRef, src: lval_result, t: ty::t, last_use: bool) -> block { - let _icx = cx.insn_ctxt("trans_temp_expr"); + let _icx = cx.insn_ctxt(~"trans_temp_expr"); // Lvals in memory are not temporaries. Copy them. if src.kind != temporary && !last_use { let v = if src.kind == owned { @@ -1418,7 +1419,7 @@ fn store_temp_expr(cx: block, action: copy_action, dst: ValueRef, fn trans_crate_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) -> ValueRef { - let _icx = cx.insn_ctxt("trans_crate_lit"); + let _icx = cx.insn_ctxt(~"trans_crate_lit"); alt lit.node { ast::lit_int(i, t) { C_integral(T_int_ty(cx, t), i as u64, True) } ast::lit_uint(u, t) { C_integral(T_uint_ty(cx, t), u, False) } @@ -1432,7 +1433,7 @@ fn trans_crate_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) C_integral(T_uint_ty(cx, t), i as u64, False) } _ { cx.sess.span_bug(lit.span, - "integer literal doesn't have a type"); + ~"integer literal doesn't have a type"); } } } @@ -1440,13 +1441,13 @@ fn trans_crate_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) ast::lit_bool(b) { C_bool(b) } ast::lit_nil { C_nil() } ast::lit_str(s) { - cx.sess.span_unimpl(lit.span, "unique string in this context"); + cx.sess.span_unimpl(lit.span, ~"unique string in this context"); } } } fn trans_lit(cx: block, e: @ast::expr, lit: ast::lit, dest: dest) -> block { - let _icx = cx.insn_ctxt("trans_lit"); + let _icx = cx.insn_ctxt(~"trans_lit"); if dest == ignore { ret cx; } alt lit.node { ast::lit_str(s) { tvec::trans_estr(cx, s, ast::vstore_uniq, dest) } @@ -1460,7 +1461,7 @@ fn trans_lit(cx: block, e: @ast::expr, lit: ast::lit, dest: dest) -> block { fn trans_boxed_expr(bcx: block, contents: @ast::expr, t: ty::t, heap: heap, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_boxed_expr"); + let _icx = bcx.insn_ctxt(~"trans_boxed_expr"); let {box, body} = malloc_general(bcx, t, heap); add_clean_free(bcx, box, heap); let bcx = trans_expr_save_in(bcx, contents, body); @@ -1471,7 +1472,7 @@ fn trans_boxed_expr(bcx: block, contents: @ast::expr, fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, un_expr: @ast::expr, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_unary"); + let _icx = bcx.insn_ctxt(~"trans_unary"); // Check for user-defined method call alt bcx.ccx().maps.method_map.find(un_expr.id) { some(mentry) { @@ -1507,7 +1508,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, trans_boxed_expr(bcx, e, e_ty, heap_exchange, dest) } ast::deref { - bcx.sess().bug("deref expressions should have been \ + bcx.sess().bug(~"deref expressions should have been \ translated using trans_lval(), not \ trans_unary()") } @@ -1515,7 +1516,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, } fn trans_addr_of(cx: block, e: @ast::expr, dest: dest) -> block { - let _icx = cx.insn_ctxt("trans_addr_of"); + let _icx = cx.insn_ctxt(~"trans_addr_of"); let mut {bcx, val, kind} = trans_temp_lval(cx, e); let ety = expr_ty(cx, e); let is_immediate = ty::type_is_immediate(ety); @@ -1527,7 +1528,7 @@ fn trans_addr_of(cx: block, e: @ast::expr, dest: dest) -> block { fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, _lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> result { - let _icx = cx.insn_ctxt("trans_compare"); + let _icx = cx.insn_ctxt(~"trans_compare"); if ty::type_is_scalar(rhs_t) { let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op); ret rslt(rs.bcx, rs.val); @@ -1539,7 +1540,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, ast::eq | ast::ne { C_u8(abi::cmp_glue_op_eq) } ast::lt | ast::ge { C_u8(abi::cmp_glue_op_lt) } ast::le | ast::gt { C_u8(abi::cmp_glue_op_le) } - _ { cx.tcx().sess.bug("trans_compare got non-comparison-op"); } + _ { cx.tcx().sess.bug(~"trans_compare got non-comparison-op"); } } }; @@ -1549,7 +1550,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, alt op { ast::eq | ast::lt | ast::le { rslt(cx, cmpval) } ast::ne | ast::ge | ast::gt { rslt(cx, Not(cx, cmpval)) } - _ { cx.tcx().sess.bug("trans_compare got non-comparison-op"); } + _ { cx.tcx().sess.bug(~"trans_compare got non-comparison-op"); } } } @@ -1594,9 +1595,9 @@ fn cast_shift_rhs(op: ast::binop, fn fail_if_zero(cx: block, span: span, divmod: ast::binop, rhs: ValueRef, rhs_t: ty::t) -> block { let text = if divmod == ast::div { - "divide by zero" + ~"divide by zero" } else { - "modulo zero" + ~"modulo zero" }; let is_zero = alt ty::get(rhs_t).struct { ty::ty_int(t) { @@ -1608,7 +1609,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop, ICmp(cx, lib::llvm::IntEQ, rhs, zero) } _ { - cx.tcx().sess.bug("fail-if-zero on unexpected type: " + + cx.tcx().sess.bug(~"fail-if-zero on unexpected type: " + ty_to_str(cx.ccx().tcx, rhs_t)); } }; @@ -1623,7 +1624,7 @@ fn trans_eager_binop(cx: block, span: span, op: ast::binop, lhs: ValueRef, lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t, dest: dest) -> block { let mut cx = cx; - let _icx = cx.insn_ctxt("trans_eager_binop"); + let _icx = cx.insn_ctxt(~"trans_eager_binop"); if dest == ignore { ret cx; } let intype = { if ty::type_is_bot(lhs_t) { rhs_t } @@ -1694,7 +1695,7 @@ fn trans_eager_binop(cx: block, span: span, op: ast::binop, lhs: ValueRef, fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, dst: @ast::expr, src: @ast::expr) -> block { #debug["%s", expr_to_str(ex)]; - let _icx = bcx.insn_ctxt("trans_assign_op"); + let _icx = bcx.insn_ctxt(~"trans_assign_op"); let t = expr_ty(bcx, src); let lhs_res = trans_lval(bcx, dst); assert (lhs_res.kind == owned); @@ -1735,7 +1736,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, fn root_value(bcx: block, val: ValueRef, ty: ty::t, scope_id: ast::node_id) { - let _icx = bcx.insn_ctxt("root_value"); + let _icx = bcx.insn_ctxt(~"root_value"); if bcx.sess().trace() { trans_trace( @@ -1753,7 +1754,7 @@ fn root_value(bcx: block, val: ValueRef, ty: ty::t, fn autoderef(cx: block, e_id: ast::node_id, v: ValueRef, t: ty::t, max: uint) -> result_t { - let _icx = cx.insn_ctxt("autoderef"); + let _icx = cx.insn_ctxt(~"autoderef"); let mut v1: ValueRef = v; let mut t1: ty::t = t; let ccx = cx.ccx(); @@ -1818,21 +1819,21 @@ enum lazy_binop_ty { lazy_and, lazy_or } fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, b: @ast::expr, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_lazy_binop"); + let _icx = bcx.insn_ctxt(~"trans_lazy_binop"); let {bcx: past_lhs, val: lhs} = { - do with_scope_result(bcx, a.info(), "lhs") |bcx| { + do with_scope_result(bcx, a.info(), ~"lhs") |bcx| { trans_temp_expr(bcx, a) } }; if past_lhs.unreachable { ret past_lhs; } - let join = sub_block(bcx, "join"), before_rhs = sub_block(bcx, "rhs"); + let join = sub_block(bcx, ~"join"), before_rhs = sub_block(bcx, ~"rhs"); alt op { lazy_and { CondBr(past_lhs, lhs, before_rhs.llbb, join.llbb); } lazy_or { CondBr(past_lhs, lhs, join.llbb, before_rhs.llbb); } } let {bcx: past_rhs, val: rhs} = { - do with_scope_result(before_rhs, b.info(), "rhs") |bcx| { + do with_scope_result(before_rhs, b.info(), ~"rhs") |bcx| { trans_temp_expr(bcx, b) } }; @@ -1846,7 +1847,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, rhs: @ast::expr, dest: dest, ex: @ast::expr) -> block { - let _icx = bcx.insn_ctxt("trans_binary"); + let _icx = bcx.insn_ctxt(~"trans_binary"); // User-defined operators alt bcx.ccx().maps.method_map.find(ex.id) { some(origin) { @@ -1885,13 +1886,13 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, els: option<@ast::expr>, dest: dest) -> block { - let _icx = cx.insn_ctxt("trans_if"); + let _icx = cx.insn_ctxt(~"trans_if"); let {bcx, val: cond_val} = trans_temp_expr(cx, cond); let then_dest = dup_for_join(dest); let else_dest = dup_for_join(dest); - let then_cx = scope_block(bcx, thn.info(), "then"); - let else_cx = scope_block(bcx, els.info(), "else"); + let then_cx = scope_block(bcx, thn.info(), ~"then"); + let else_cx = scope_block(bcx, els.info(), ~"else"); CondBr(bcx, cond_val, then_cx.llbb, else_cx.llbb); let then_bcx = trans_block(then_cx, thn, then_dest); let then_bcx = trans_block_cleanups(then_bcx, then_cx); @@ -1910,7 +1911,7 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, trans_block(else_cx, blk, else_dest) } // would be nice to have a constraint on ifs - _ { cx.tcx().sess.bug("strange alternative in if"); } + _ { cx.tcx().sess.bug(~"strange alternative in if"); } } } _ { else_cx } @@ -1922,11 +1923,11 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, fn trans_while(cx: block, cond: @ast::expr, body: ast::blk) -> block { - let _icx = cx.insn_ctxt("trans_while"); - let next_cx = sub_block(cx, "while next"); - let loop_cx = loop_scope_block(cx, next_cx, "`while`", body.info()); - let cond_cx = scope_block(loop_cx, cond.info(), "while loop cond"); - let body_cx = scope_block(loop_cx, body.info(), "while loop body"); + let _icx = cx.insn_ctxt(~"trans_while"); + let next_cx = sub_block(cx, ~"while next"); + let loop_cx = loop_scope_block(cx, next_cx, ~"`while`", body.info()); + let cond_cx = scope_block(loop_cx, cond.info(), ~"while loop cond"); + let body_cx = scope_block(loop_cx, body.info(), ~"while loop body"); Br(cx, loop_cx.llbb); Br(loop_cx, cond_cx.llbb); let cond_res = trans_temp_expr(cond_cx, cond); @@ -1938,9 +1939,9 @@ fn trans_while(cx: block, cond: @ast::expr, body: ast::blk) } fn trans_loop(cx:block, body: ast::blk) -> block { - let _icx = cx.insn_ctxt("trans_loop"); - let next_cx = sub_block(cx, "next"); - let body_cx = loop_scope_block(cx, next_cx, "`loop`", body.info()); + let _icx = cx.insn_ctxt(~"trans_loop"); + let next_cx = sub_block(cx, ~"next"); + let body_cx = loop_scope_block(cx, next_cx, ~"`loop`", body.info()); let body_end = trans_block(body_cx, body, ignore); cleanup_and_Br(body_end, body_cx, body_cx.llbb); Br(cx, body_cx.llbb); @@ -2078,7 +2079,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, vtables: option, ref_id: option) -> {val: ValueRef, must_cast: bool} { - let _icx = ccx.insn_ctxt("monomorphic_fn"); + let _icx = ccx.insn_ctxt(~"monomorphic_fn"); let mut must_cast = false; let substs = vec::map(real_substs, |t| { alt normalize_for_monomorphization(ccx.tcx, t) { @@ -2131,17 +2132,19 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, must_cast: true}; } ast_map::node_ctor(nm, _, ct, _, pt) { (pt, nm, ct.span) } - ast_map::node_dtor(_, dtor, _, pt) {(pt, @"drop", dtor.span)} - ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") } - ast_map::node_export(*) { - ccx.tcx.sess.bug("Can't monomorphize an export") + ast_map::node_dtor(_, dtor, _, pt) {(pt, @~"drop", dtor.span)} + ast_map::node_expr(*) { + ccx.tcx.sess.bug(~"Can't monomorphize an expr") } - ast_map::node_arg(*) { ccx.tcx.sess.bug("Can't monomorphize an arg") } + ast_map::node_export(*) { + ccx.tcx.sess.bug(~"Can't monomorphize an export") + } + ast_map::node_arg(*) { ccx.tcx.sess.bug(~"Can't monomorphize an arg") } ast_map::node_block(*) { - ccx.tcx.sess.bug("Can't monomorphize a block") + ccx.tcx.sess.bug(~"Can't monomorphize a block") } ast_map::node_local(*) { - ccx.tcx.sess.bug("Can't monomorphize a local") + ccx.tcx.sess.bug(~"Can't monomorphize a local") } }; let mono_ty = ty::subst_tps(ccx.tcx, substs, llitem_ty); @@ -2153,7 +2156,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, // causing an infinite expansion. if depth > 10u { ccx.sess.span_fatal( - span, "overly deep expansion of inlined function"); + span, ~"overly deep expansion of inlined function"); } ccx.monomorphizing.insert(fn_id, depth + 1u); @@ -2175,7 +2178,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, d } ast_map::node_item(*) { - ccx.tcx.sess.bug("Can't monomorphize this kind of item") + ccx.tcx.sess.bug(~"Can't monomorphize this kind of item") } ast_map::node_foreign_item(i, _, _) { let d = mk_lldecl(); @@ -2216,23 +2219,25 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, let parent_id = alt ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx, dtor.node.self_id)) { some(did) { did } - none { ccx.sess.span_bug(dtor.span, "Bad self ty in \ + none { ccx.sess.span_bug(dtor.span, ~"Bad self ty in \ dtor"); } }; trans_class_dtor(ccx, *pt, dtor.node.body, dtor.node.id, psubsts, some(hash_id), parent_id) } // Ugh -- but this ensures any new variants won't be forgotten - ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") } - ast_map::node_export(*) { - ccx.tcx.sess.bug("Can't monomorphize an export") + ast_map::node_expr(*) { + ccx.tcx.sess.bug(~"Can't monomorphize an expr") } - ast_map::node_arg(*) { ccx.tcx.sess.bug("Can't monomorphize an arg") } + ast_map::node_export(*) { + ccx.tcx.sess.bug(~"Can't monomorphize an export") + } + ast_map::node_arg(*) { ccx.tcx.sess.bug(~"Can't monomorphize an arg") } ast_map::node_block(*) { - ccx.tcx.sess.bug("Can't monomorphize a block") + ccx.tcx.sess.bug(~"Can't monomorphize a block") } ast_map::node_local(*) { - ccx.tcx.sess.bug("Can't monomorphize a local") + ccx.tcx.sess.bug(~"Can't monomorphize a local") } }; ccx.monomorphizing.insert(fn_id, depth); @@ -2243,7 +2248,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) -> ast::def_id { - let _icx = ccx.insn_ctxt("maybe_instantiate_inline"); + let _icx = ccx.insn_ctxt(~"maybe_instantiate_inline"); alt ccx.external.find(fn_id) { some(some(node_id)) { // Already inline @@ -2293,7 +2298,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) local_def(my_id) } csearch::found_parent(_, _) { - ccx.sess.bug("maybe_get_item_ast returned a found_parent \ + ccx.sess.bug(~"maybe_get_item_ast returned a found_parent \ with a non-item parent"); } csearch::found(ast::ii_method(impl_did, mth)) { @@ -2321,7 +2326,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("lval_static_fn"); + let _icx = bcx.insn_ctxt(~"lval_static_fn"); let vts = option::map(bcx.ccx().maps.vtable_map.find(id), |vts| { impl::resolve_vtables_in_fn_ctxt(bcx.fcx, vts) }); @@ -2331,7 +2336,7 @@ fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id) fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, tys: ~[ty::t], vtables: option) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("lval_static_fn_inner"); + let _icx = bcx.insn_ctxt(~"lval_static_fn_inner"); let ccx = bcx.ccx(), tcx = ccx.tcx; let tpt = ty::lookup_item_type(tcx, fn_id); @@ -2381,7 +2386,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, } fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef { - let _icx = ccx.insn_ctxt("lookup_discriminant"); + let _icx = ccx.insn_ctxt(~"lookup_discriminant"); alt ccx.discrims.find(vid) { none { // It's an external discriminant that we haven't seen yet. @@ -2404,13 +2409,13 @@ fn cast_self(cx: block, slf: val_self_pair) -> ValueRef { } fn trans_local_var(cx: block, def: ast::def) -> local_var_result { - let _icx = cx.insn_ctxt("trans_local_var"); + let _icx = cx.insn_ctxt(~"trans_local_var"); fn take_local(table: hashmap, id: ast::node_id) -> local_var_result { alt table.find(id) { some(local_mem(v)) { {val: v, kind: owned} } some(local_imm(v)) { {val: v, kind: owned_imm} } - r { fail("take_local: internal error"); } + r { fail(~"take_local: internal error"); } } } alt def { @@ -2429,7 +2434,7 @@ fn take_local(table: hashmap, ast::def_self(sid) { let slf = alt copy cx.fcx.llself { some(s) { cast_self(cx, s) } - none { cx.sess().bug("trans_local_var: reference to self \ + none { cx.sess().bug(~"trans_local_var: reference to self \ out of context"); } }; ret {val: slf, kind: owned}; @@ -2443,9 +2448,9 @@ fn take_local(table: hashmap, fn trans_path(cx: block, id: ast::node_id) -> lval_maybe_callee { - let _icx = cx.insn_ctxt("trans_path"); + let _icx = cx.insn_ctxt(~"trans_path"); alt cx.tcx().def_map.find(id) { - none { cx.sess().bug("trans_path: unbound node ID"); } + none { cx.sess().bug(~"trans_path: unbound node ID"); } some(df) { ret trans_var(cx, df, id); } @@ -2453,7 +2458,7 @@ fn trans_path(cx: block, id: ast::node_id) } fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { - let _icx = cx.insn_ctxt("trans_var"); + let _icx = cx.insn_ctxt(~"trans_var"); let ccx = cx.ccx(); alt def { ast::def_fn(did, _) { @@ -2492,7 +2497,7 @@ fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { fn trans_rec_field(bcx: block, base: @ast::expr, field: ast::ident) -> lval_result { - let _icx = bcx.insn_ctxt("trans_rec_field"); + let _icx = bcx.insn_ctxt(~"trans_rec_field"); let {bcx, val} = trans_temp_expr(bcx, base); let {bcx, val, ty} = autoderef(bcx, base.id, val, expr_ty(bcx, base), @@ -2512,7 +2517,7 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, ty::class_items_as_mutable_fields(bcx.tcx(), did, substs) } // Constraint? - _ { bcx.tcx().sess.span_bug(sp, "trans_rec_field:\ + _ { bcx.tcx().sess.span_bug(sp, ~"trans_rec_field:\ base expr has non-record type"); } }; // seems wrong? Doesn't take into account the field @@ -2537,7 +2542,7 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, idx: @ast::expr) -> lval_result { - let _icx = cx.insn_ctxt("trans_index"); + let _icx = cx.insn_ctxt(~"trans_index"); let base_ty = expr_ty(cx, base); let exp = trans_temp_expr(cx, base); let lv = autoderef(exp.bcx, base.id, exp.val, base_ty, uint::max_value); @@ -2562,9 +2567,9 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, let unit_ty = node_id_type(cx, ex.id); let llunitty = type_of(ccx, unit_ty); let unit_sz = llsize_of(ccx, llunitty); - maybe_name_value(cx.ccx(), unit_sz, "unit_sz"); + maybe_name_value(cx.ccx(), unit_sz, ~"unit_sz"); let scaled_ix = Mul(bcx, ix_val, unit_sz); - maybe_name_value(cx.ccx(), scaled_ix, "scaled_ix"); + maybe_name_value(cx.ccx(), scaled_ix, ~"scaled_ix"); let mut (base, len) = tvec::get_base_and_len(bcx, v, base_ty); @@ -2578,7 +2583,7 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len); let bcx = do with_cond(bcx, bounds_check) |bcx| { // fail: bad bounds check. - trans_fail(bcx, some(ex.span), "bounds check") + trans_fail(bcx, some(ex.span), ~"bounds check") }; let elt = InBoundsGEP(bcx, base, ~[ix_val]); ret lval_owned(bcx, PointerCast(bcx, elt, T_ptr(llunitty))); @@ -2594,7 +2599,7 @@ fn expr_is_lval(bcx: block, e: @ast::expr) -> bool { } fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("trans_callee"); + let _icx = bcx.insn_ctxt(~"trans_callee"); alt e.node { ast::expr_path(path) { ret trans_path(bcx, e.id); } ast::expr_field(base, _, _) { @@ -2605,7 +2610,7 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { ret impl::trans_method_callee(bcx, e.id, base, origin); } _ { - bcx.ccx().sess.span_bug(e.span, "trans_callee: weird expr"); + bcx.ccx().sess.span_bug(e.span, ~"trans_callee: weird expr"); } } } @@ -2635,7 +2640,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { scope_id]); } - let _icx = lv.bcx.insn_ctxt("root_value_lval"); + let _icx = lv.bcx.insn_ctxt(~"root_value_lval"); let ty = expr_ty(lv.bcx, e); let root_loc = alloca_zeroed(lv.bcx, type_of(cx.ccx(), ty)); let bcx = store_temp_expr(lv.bcx, INIT, root_loc, lv, ty, false); @@ -2645,7 +2650,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { }; fn unrooted(cx: block, e: @ast::expr) -> lval_result { - let _icx = cx.insn_ctxt("trans_lval"); + let _icx = cx.insn_ctxt(~"trans_lval"); alt e.node { ast::expr_path(_) { let v = trans_path(cx, e.id); @@ -2679,7 +2684,7 @@ fn unrooted(cx: block, e: @ast::expr) -> lval_result { }; ret lval_owned(sub.bcx, val); } - _ { cx.sess().span_bug(e.span, "non-lval in trans_lval"); } + _ { cx.sess().span_bug(e.span, ~"non-lval in trans_lval"); } } } } @@ -2694,7 +2699,7 @@ fn unrooted(cx: block, e: @ast::expr) -> lval_result { */ fn non_gc_box_cast(cx: block, val: ValueRef) -> ValueRef { #debug("non_gc_box_cast"); - add_comment(cx, "non_gc_box_cast"); + add_comment(cx, ~"non_gc_box_cast"); assert(llvm::LLVMGetPointerAddressSpace(val_ty(val)) as uint == 1u); let non_gc_t = T_ptr(llvm::LLVMGetElementType(val_ty(val))); PointerCast(cx, val, non_gc_t) @@ -2703,7 +2708,7 @@ fn non_gc_box_cast(cx: block, val: ValueRef) -> ValueRef { fn lval_maybe_callee_to_lval(c: lval_maybe_callee, sp: span) -> lval_result { alt c.env { self_env(*) { - c.bcx.sess().span_bug(sp, "implicitly binding method call"); + c.bcx.sess().span_bug(sp, ~"implicitly binding method call"); } is_closure { {bcx: c.bcx, val: c.val, kind: c.kind} } null_env { @@ -2717,7 +2722,7 @@ fn lval_maybe_callee_to_lval(c: lval_maybe_callee, sp: span) -> lval_result { fn int_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, llsrc: ValueRef, signed: bool) -> ValueRef { - let _icx = bcx.insn_ctxt("int_cast"); + let _icx = bcx.insn_ctxt(~"int_cast"); let srcsz = llvm::LLVMGetIntTypeWidth(llsrctype); let dstsz = llvm::LLVMGetIntTypeWidth(lldsttype); ret if dstsz == srcsz { @@ -2731,7 +2736,7 @@ fn int_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, llsrc: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("float_cast"); + let _icx = bcx.insn_ctxt(~"float_cast"); let srcsz = lib::llvm::float_width(llsrctype); let dstsz = lib::llvm::float_width(lldsttype); ret if dstsz > srcsz { @@ -2759,7 +2764,7 @@ fn cast_type_kind(t: ty::t) -> cast_kind { fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, dest: dest) -> block { - let _icx = cx.insn_ctxt("trans_cast"); + let _icx = cx.insn_ctxt(~"trans_cast"); let ccx = cx.ccx(); let t_out = node_id_type(cx, id); alt ty::get(t_out).struct { @@ -2813,10 +2818,10 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, cast_integral {int_cast(e_res.bcx, ll_t_out, val_ty(lldiscrim_a), lldiscrim_a, true)} cast_float {SIToFP(e_res.bcx, lldiscrim_a, ll_t_out)} - _ { ccx.sess.bug("translating unsupported cast.") } + _ { ccx.sess.bug(~"translating unsupported cast.") } } } - _ { ccx.sess.bug("translating unsupported cast.") } + _ { ccx.sess.bug(~"translating unsupported cast.") } }; ret store_in_dest(e_res.bcx, newval, dest); } @@ -2843,7 +2848,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, derefs: uint) -> result { #debug("+++ trans_arg_expr on %s", expr_to_str(e)); - let _icx = cx.insn_ctxt("trans_arg_expr"); + let _icx = cx.insn_ctxt(~"trans_arg_expr"); let ccx = cx.ccx(); let e_ty = expr_ty(cx, e); let is_bot = ty::type_is_bot(e_ty); @@ -3021,7 +3026,7 @@ enum call_args { fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, dest: dest, ret_flag: option) -> {bcx: block, args: ~[ValueRef], retslot: ValueRef} { - let _icx = cx.insn_ctxt("trans_args"); + let _icx = cx.insn_ctxt(~"trans_args"); let mut temp_cleanups = ~[]; let arg_tys = ty::ty_fn_args(fn_ty); let mut llargs: ~[ValueRef] = ~[]; @@ -3083,7 +3088,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, fn trans_call(in_cx: block, call_ex: @ast::expr, f: @ast::expr, args: call_args, id: ast::node_id, dest: dest) -> block { - let _icx = in_cx.insn_ctxt("trans_call"); + let _icx = in_cx.insn_ctxt(~"trans_call"); trans_call_inner( in_cx, call_ex.info(), expr_ty(in_cx, f), node_id_type(in_cx, id), |cx| trans_callee(cx, f), args, dest) @@ -3115,7 +3120,7 @@ fn trans_call_inner( args: call_args, dest: dest) -> block { - do with_scope(in_cx, call_info, "call") |cx| { + do with_scope(in_cx, call_info, ~"call") |cx| { let ret_in_loop = alt args { arg_exprs(args) { args.len() > 0u && alt vec::last(args).node { ast::expr_loop_body(@{node: ast::expr_fn_block(_, body, _), _}) { @@ -3198,15 +3203,15 @@ fn trans_call_inner( } fn invoke(bcx: block, llfn: ValueRef, llargs: ~[ValueRef]) -> block { - let _icx = bcx.insn_ctxt("invoke_"); + let _icx = bcx.insn_ctxt(~"invoke_"); if bcx.unreachable { ret bcx; } if need_invoke(bcx) { - log(debug, "invoking"); - let normal_bcx = sub_block(bcx, "normal return"); + log(debug, ~"invoking"); + let normal_bcx = sub_block(bcx, ~"normal return"); Invoke(bcx, llfn, llargs, normal_bcx.llbb, get_landing_pad(bcx)); ret normal_bcx; } else { - log(debug, "calling"); + log(debug, ~"calling"); Call(bcx, llfn, llargs); ret bcx; } @@ -3268,7 +3273,7 @@ fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) { } fn get_landing_pad(bcx: block) -> BasicBlockRef { - let _icx = bcx.insn_ctxt("get_landing_pad"); + let _icx = bcx.insn_ctxt(~"get_landing_pad"); let mut cached = none, pad_bcx = bcx; // Guaranteed to be set below do in_lpad_scope_cx(bcx) |inf| { @@ -3276,7 +3281,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { alt copy inf.landing_pad { some(target) { cached = some(target); } none { - pad_bcx = sub_block(bcx, "unwind"); + pad_bcx = sub_block(bcx, ~"unwind"); inf.landing_pad = some(pad_bcx.llbb); } } @@ -3317,7 +3322,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { } fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_tup"); + let _icx = bcx.insn_ctxt(~"trans_tup"); let mut bcx = bcx; let addr = alt dest { ignore { @@ -3325,7 +3330,7 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { ret bcx; } save_in(pos) { pos } - _ { bcx.tcx().sess.bug("trans_tup: weird dest"); } + _ { bcx.tcx().sess.bug(~"trans_tup: weird dest"); } }; let mut temp_cleanups = ~[]; for vec::eachi(elts) |i, e| { @@ -3342,7 +3347,7 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { fn trans_rec(bcx: block, fields: ~[ast::field], base: option<@ast::expr>, id: ast::node_id, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_rec"); + let _icx = bcx.insn_ctxt(~"trans_rec"); let t = node_id_type(bcx, id); let mut bcx = bcx; let addr = alt check dest { @@ -3405,7 +3410,7 @@ fn trans_expr_save_in(bcx: block, e: @ast::expr, dest: ValueRef) // trans_expr_save_in. For intermediates where you don't care about lval-ness, // use trans_temp_expr. fn trans_temp_lval(bcx: block, e: @ast::expr) -> lval_result { - let _icx = bcx.insn_ctxt("trans_temp_lval"); + let _icx = bcx.insn_ctxt(~"trans_temp_lval"); let mut bcx = bcx; if expr_is_lval(bcx, e) { ret trans_lval(bcx, e); @@ -3431,7 +3436,7 @@ fn trans_temp_lval(bcx: block, e: @ast::expr) -> lval_result { // Use only for intermediate values. See trans_expr and trans_expr_save_in for // expressions that must 'end up somewhere' (or get ignored). fn trans_temp_expr(bcx: block, e: @ast::expr) -> result { - let _icx = bcx.insn_ctxt("trans_temp_expr"); + let _icx = bcx.insn_ctxt(~"trans_temp_expr"); lval_result_to_result(trans_temp_lval(bcx, e), expr_ty(bcx, e)) } @@ -3492,7 +3497,7 @@ fn find_bcx_for_scope(bcx: block, scope_id: ast::node_id) -> block { // - exprs returning nil or bot always get dest=ignore // - exprs with non-immediate type never get dest=by_val fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_expr"); + let _icx = bcx.insn_ctxt(~"trans_expr"); debuginfo::update_source_pos(bcx, e.span); if expr_is_lval(bcx, e) { @@ -3514,7 +3519,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { scope_id]); } - let _icx = bcx.insn_ctxt("root_value_expr"); + let _icx = bcx.insn_ctxt(~"root_value_expr"); add_root_cleanup(bcx, scope_id, root_loc, ty); let lv = {bcx: bcx, val: root_loc, kind: owned}; lval_result_to_dps(lv, ty, false, dest) @@ -3531,7 +3536,7 @@ fn unrooted(bcx: block, e: @ast::expr, dest: dest) -> block { ret alt::trans_alt(bcx, e, expr, arms, mode, dest); } ast::expr_block(blk) { - ret do with_scope(bcx, blk.info(), "block-expr body") |bcx| { + ret do with_scope(bcx, blk.info(), ~"block-expr body") |bcx| { trans_block(bcx, blk, dest) }; } @@ -3627,11 +3632,11 @@ fn unrooted(bcx: block, e: @ast::expr, dest: dest) -> block { } ast::expr_assert(a) { assert dest == ignore; - ret trans_check_expr(bcx, e, a, "Assertion"); + ret trans_check_expr(bcx, e, a, ~"Assertion"); } ast::expr_check(ast::checked_expr, a) { assert dest == ignore; - ret trans_check_expr(bcx, e, a, "Predicate"); + ret trans_check_expr(bcx, e, a, ~"Predicate"); } ast::expr_check(ast::claimed_expr, a) { assert dest == ignore; @@ -3641,9 +3646,9 @@ fn unrooted(bcx: block, e: @ast::expr, dest: dest) -> block { if it's set to false and acting like a check otherwise. */ let c = get_extern_const(bcx.ccx().externs, bcx.ccx().llmod, - "check_claims", T_bool()); + ~"check_claims", T_bool()); ret do with_cond(bcx, Load(bcx, c)) |bcx| { - trans_check_expr(bcx, e, a, "Claim") + trans_check_expr(bcx, e, a, ~"Claim") }; } ast::expr_while(cond, body) { @@ -3728,7 +3733,7 @@ fn unrooted(bcx: block, e: @ast::expr, dest: dest) -> block { store_in_dest(bcx, ptr_val, dest) } _ { - bcx.tcx().sess.span_bug(e.span, "trans_expr reached \ + bcx.tcx().sess.span_bug(e.span, ~"trans_expr reached \ fall-through case"); } } @@ -3795,20 +3800,20 @@ fn do_spill_noroot(++cx: block, v: ValueRef) -> ValueRef { } fn spill_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef { - let _icx = cx.insn_ctxt("spill_if_immediate"); + let _icx = cx.insn_ctxt(~"spill_if_immediate"); if ty::type_is_immediate(t) { ret do_spill(cx, v, t); } ret v; } fn load_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef { - let _icx = cx.insn_ctxt("load_if_immediate"); + let _icx = cx.insn_ctxt(~"load_if_immediate"); if ty::type_is_immediate(t) { ret Load(cx, v); } ret v; } fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, bcx: block, e: @ast::expr) -> block { - let _icx = bcx.insn_ctxt("trans_log"); + let _icx = bcx.insn_ctxt(~"trans_log"); let ccx = bcx.ccx(); if ty::type_is_bot(expr_ty(bcx, lvl)) { ret trans_expr(bcx, lvl, ignore); @@ -3825,7 +3830,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, ccx.module_data.get(modname) } else { let s = link::mangle_internal_name_by_path_and_seq( - ccx, modpath, @"loglevel"); + ccx, modpath, @~"loglevel"); let global = str::as_c_str(s, |buf| { llvm::LLVMAddGlobal(ccx.llmod, T_i32(), buf) }); @@ -3837,14 +3842,14 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, }; let current_level = Load(bcx, global); let {bcx, val: level} = { - do with_scope_result(bcx, lvl.info(), "level") |bcx| { + do with_scope_result(bcx, lvl.info(), ~"level") |bcx| { trans_temp_expr(bcx, lvl) } }; do with_cond(bcx, ICmp(bcx, lib::llvm::IntUGE, current_level, level)) |bcx| { - do with_scope(bcx, log_ex.info(), "log") |bcx| { + do with_scope(bcx, log_ex.info(), ~"log") |bcx| { let {bcx, val, _} = trans_temp_expr(bcx, e); let e_ty = expr_ty(bcx, e); let tydesc = get_tydesc_simple(ccx, e_ty); @@ -3858,11 +3863,11 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, } fn trans_check_expr(bcx: block, chk_expr: @ast::expr, - pred_expr: @ast::expr, s: str) -> block { - let _icx = bcx.insn_ctxt("trans_check_expr"); - let expr_str = s + " " + expr_to_str(pred_expr) + " failed"; + pred_expr: @ast::expr, s: ~str) -> block { + let _icx = bcx.insn_ctxt(~"trans_check_expr"); + let expr_str = s + ~" " + expr_to_str(pred_expr) + ~" failed"; let {bcx, val} = { - do with_scope_result(bcx, chk_expr.info(), "check") |bcx| { + do with_scope_result(bcx, chk_expr.info(), ~"check") |bcx| { trans_temp_expr(bcx, pred_expr) } }; @@ -3873,7 +3878,7 @@ fn trans_check_expr(bcx: block, chk_expr: @ast::expr, fn trans_fail_expr(bcx: block, sp_opt: option, fail_expr: option<@ast::expr>) -> block { - let _icx = bcx.insn_ctxt("trans_fail_expr"); + let _icx = bcx.insn_ctxt(~"trans_fail_expr"); let mut bcx = bcx; alt fail_expr { some(expr) { @@ -3890,17 +3895,17 @@ fn trans_fail_expr(bcx: block, sp_opt: option, ret bcx; } else { bcx.sess().span_bug( - expr.span, "fail called with unsupported type " + + expr.span, ~"fail called with unsupported type " + ppaux::ty_to_str(tcx, e_ty)); } } - _ { ret trans_fail(bcx, sp_opt, "explicit failure"); } + _ { ret trans_fail(bcx, sp_opt, ~"explicit failure"); } } } -fn trans_trace(bcx: block, sp_opt: option, trace_str: str) { +fn trans_trace(bcx: block, sp_opt: option, trace_str: ~str) { if !bcx.sess().trace() { ret; } - let _icx = bcx.insn_ctxt("trans_trace"); + let _icx = bcx.insn_ctxt(~"trans_trace"); add_comment(bcx, trace_str); let V_trace_str = C_cstr(bcx.ccx(), trace_str); let {V_filename, V_line} = alt sp_opt { @@ -3911,7 +3916,7 @@ fn trans_trace(bcx: block, sp_opt: option, trace_str: str) { V_line: loc.line as int} } none { - {V_filename: C_cstr(bcx.ccx(), ""), + {V_filename: C_cstr(bcx.ccx(), ~""), V_line: 0} } }; @@ -3922,16 +3927,16 @@ fn trans_trace(bcx: block, sp_opt: option, trace_str: str) { Call(bcx, ccx.upcalls.trace, args); } -fn trans_fail(bcx: block, sp_opt: option, fail_str: str) -> +fn trans_fail(bcx: block, sp_opt: option, fail_str: ~str) -> block { - let _icx = bcx.insn_ctxt("trans_fail"); + let _icx = bcx.insn_ctxt(~"trans_fail"); let V_fail_str = C_cstr(bcx.ccx(), fail_str); ret trans_fail_value(bcx, sp_opt, V_fail_str); } fn trans_fail_value(bcx: block, sp_opt: option, V_fail_str: ValueRef) -> block { - let _icx = bcx.insn_ctxt("trans_fail_value"); + let _icx = bcx.insn_ctxt(~"trans_fail_value"); let ccx = bcx.ccx(); let {V_filename, V_line} = alt sp_opt { some(sp) { @@ -3941,7 +3946,7 @@ fn trans_fail_value(bcx: block, sp_opt: option, V_line: loc.line as int} } none { - {V_filename: C_cstr(bcx.ccx(), ""), + {V_filename: C_cstr(bcx.ccx(), ~""), V_line: 0} } }; @@ -3955,7 +3960,7 @@ fn trans_fail_value(bcx: block, sp_opt: option, fn trans_break_cont(bcx: block, to_end: bool) -> block { - let _icx = bcx.insn_ctxt("trans_break_cont"); + let _icx = bcx.insn_ctxt(~"trans_break_cont"); // Locate closest loop block, outputting cleanup as we go. let mut unwind = bcx; let mut target; @@ -3996,7 +4001,7 @@ fn trans_cont(cx: block) -> block { } fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { - let _icx = bcx.insn_ctxt("trans_ret"); + let _icx = bcx.insn_ctxt(~"trans_ret"); let mut bcx = bcx; let retptr = alt copy bcx.fcx.loop_ret { some({flagptr, retptr}) { @@ -4025,17 +4030,17 @@ fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { } fn build_return(bcx: block) { - let _icx = bcx.insn_ctxt("build_return"); + let _icx = bcx.insn_ctxt(~"build_return"); Br(bcx, bcx.fcx.llreturn); } fn init_local(bcx: block, local: @ast::local) -> block { - let _icx = bcx.insn_ctxt("init_local"); + let _icx = bcx.insn_ctxt(~"init_local"); let ty = node_id_type(bcx, local.node.id); let llptr = alt bcx.fcx.lllocals.find(local.node.id) { some(local_mem(v)) { v } _ { bcx.tcx().sess.span_bug(local.span, - "init_local: Someone forgot to document why it's\ + ~"init_local: Someone forgot to document why it's\ safe to assume local.node.init must be local_mem!"); } }; @@ -4058,7 +4063,7 @@ fn init_local(bcx: block, local: @ast::local) -> block { } fn trans_stmt(cx: block, s: ast::stmt) -> block { - let _icx = cx.insn_ctxt("trans_stmt"); + let _icx = cx.insn_ctxt(~"trans_stmt"); #debug["trans_stmt(%s)", stmt_to_str(s)]; if !cx.sess().no_asm_comments() { @@ -4093,11 +4098,11 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block { // You probably don't want to use this one. See the // next three functions instead. fn new_block(cx: fn_ctxt, parent: option, +kind: block_kind, - name: str, opt_node_info: option) -> block { + name: ~str, opt_node_info: option) -> block { let s = if cx.ccx.sess.opts.save_temps || cx.ccx.sess.opts.debuginfo { cx.ccx.names(name) - } else { "" }; + } else { ~"" }; let llbb: BasicBlockRef = str::as_c_str(s, |buf| { llvm::LLVMAppendBasicBlock(cx.llfn, buf) }); @@ -4116,17 +4121,17 @@ fn simple_block_scope() -> block_kind { // Use this when you're at the top block of a function or the like. fn top_scope_block(fcx: fn_ctxt, opt_node_info: option) -> block { ret new_block(fcx, none, simple_block_scope(), - "function top level", opt_node_info); + ~"function top level", opt_node_info); } fn scope_block(bcx: block, opt_node_info: option, - n: str) -> block { + n: ~str) -> block { ret new_block(bcx.fcx, some(bcx), simple_block_scope(), n, opt_node_info); } -fn loop_scope_block(bcx: block, loop_break: block, n: str, +fn loop_scope_block(bcx: block, loop_break: block, n: ~str, opt_node_info: option) -> block { ret new_block(bcx.fcx, some(bcx), block_scope({ loop_break: some(loop_break), @@ -4138,7 +4143,7 @@ fn loop_scope_block(bcx: block, loop_break: block, n: str, // Use this when you're making a general CFG BB within a scope. -fn sub_block(bcx: block, n: str) -> block { +fn sub_block(bcx: block, n: ~str) -> block { new_block(bcx.fcx, some(bcx), block_non_scope, n, none) } @@ -4160,7 +4165,7 @@ fn trans_block_cleanups(bcx: block, cleanup_cx: block) -> block { fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) -> block { - let _icx = bcx.insn_ctxt("trans_block_cleanups"); + let _icx = bcx.insn_ctxt(~"trans_block_cleanups"); if bcx.unreachable { ret bcx; } let mut bcx = bcx; alt check cleanup_cx.kind { @@ -4187,7 +4192,7 @@ fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) -> // instruction. fn cleanup_and_leave(bcx: block, upto: option, leave: option) { - let _icx = bcx.insn_ctxt("cleanup_and_leave"); + let _icx = bcx.insn_ctxt(~"cleanup_and_leave"); let mut cur = bcx, bcx = bcx; let is_lpad = leave == none; loop { @@ -4206,7 +4211,7 @@ fn cleanup_and_leave(bcx: block, upto: option, Br(bcx, cp.dest); ret; } - let sub_cx = sub_block(bcx, "cleanup"); + let sub_cx = sub_block(bcx, ~"cleanup"); Br(bcx, sub_cx.llbb); vec::push(inf.cleanup_paths, {target: leave, dest: sub_cx.llbb}); bcx = trans_block_cleanups_(sub_cx, cur, is_lpad); @@ -4230,30 +4235,30 @@ fn cleanup_and_leave(bcx: block, upto: option, fn cleanup_and_Br(bcx: block, upto: block, target: BasicBlockRef) { - let _icx = bcx.insn_ctxt("cleanup_and_Br"); + let _icx = bcx.insn_ctxt(~"cleanup_and_Br"); cleanup_and_leave(bcx, some(upto.llbb), some(target)); } fn leave_block(bcx: block, out_of: block) -> block { - let _icx = bcx.insn_ctxt("leave_block"); - let next_cx = sub_block(block_parent(out_of), "next"); + let _icx = bcx.insn_ctxt(~"leave_block"); + let next_cx = sub_block(block_parent(out_of), ~"next"); if bcx.unreachable { Unreachable(next_cx); } cleanup_and_Br(bcx, out_of, next_cx.llbb); next_cx } fn with_scope(bcx: block, opt_node_info: option, - name: str, f: fn(block) -> block) -> block { - let _icx = bcx.insn_ctxt("with_scope"); + name: ~str, f: fn(block) -> block) -> block { + let _icx = bcx.insn_ctxt(~"with_scope"); let scope_cx = scope_block(bcx, opt_node_info, name); Br(bcx, scope_cx.llbb); leave_block(f(scope_cx), scope_cx) } fn with_scope_result(bcx: block, opt_node_info: option, - name: str, f: fn(block) -> result) + name: ~str, f: fn(block) -> result) -> result { - let _icx = bcx.insn_ctxt("with_scope_result"); + let _icx = bcx.insn_ctxt(~"with_scope_result"); let scope_cx = scope_block(bcx, opt_node_info, name); Br(bcx, scope_cx.llbb); let {bcx, val} = f(scope_cx); @@ -4261,8 +4266,8 @@ fn with_scope_result(bcx: block, opt_node_info: option, } fn with_cond(bcx: block, val: ValueRef, f: fn(block) -> block) -> block { - let _icx = bcx.insn_ctxt("with_cond"); - let next_cx = sub_block(bcx, "next"), cond_cx = sub_block(bcx, "cond"); + let _icx = bcx.insn_ctxt(~"with_cond"); + let next_cx = sub_block(bcx, ~"next"), cond_cx = sub_block(bcx, ~"cond"); CondBr(bcx, val, cond_cx.llbb, next_cx.llbb); let after_cx = f(cond_cx); if !after_cx.terminated { Br(after_cx, next_cx.llbb); } @@ -4286,7 +4291,7 @@ fn block_locals(b: ast::blk, it: fn(@ast::local)) { } fn alloc_ty(bcx: block, t: ty::t) -> ValueRef { - let _icx = bcx.insn_ctxt("alloc_ty"); + let _icx = bcx.insn_ctxt(~"alloc_ty"); let ccx = bcx.ccx(); let llty = type_of(ccx, t); if ty::type_has_params(t) { log(error, ppaux::ty_to_str(ccx.tcx, t)); } @@ -4296,7 +4301,7 @@ fn alloc_ty(bcx: block, t: ty::t) -> ValueRef { } fn alloc_local(cx: block, local: @ast::local) -> block { - let _icx = cx.insn_ctxt("alloc_local"); + let _icx = cx.insn_ctxt(~"alloc_local"); let t = node_id_type(cx, local.node.id); let simple_name = alt local.node.pat.node { ast::pat_ident(pth, none) { some(path_to_ident(pth)) } @@ -4316,7 +4321,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block { fn trans_block(bcx: block, b: ast::blk, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_block"); + let _icx = bcx.insn_ctxt(~"trans_block"); let mut bcx = bcx; do block_locals(b) |local| { bcx = alloc_local(bcx, local); }; for vec::each(b.node.stmts) |s| { @@ -4337,11 +4342,11 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest) // Creates the standard set of basic blocks for a function fn mk_standard_basic_blocks(llfn: ValueRef) -> {sa: BasicBlockRef, ca: BasicBlockRef, rt: BasicBlockRef} { - {sa: str::as_c_str("static_allocas", + {sa: str::as_c_str(~"static_allocas", |buf| llvm::LLVMAppendBasicBlock(llfn, buf)), - ca: str::as_c_str("load_env", + ca: str::as_c_str(~"load_env", |buf| llvm::LLVMAppendBasicBlock(llfn, buf)), - rt: str::as_c_str("return", + rt: str::as_c_str(~"return", |buf| llvm::LLVMAppendBasicBlock(llfn, buf))} } @@ -4398,7 +4403,7 @@ fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef, fn create_llargs_for_fn_args(cx: fn_ctxt, ty_self: self_arg, args: ~[ast::arg]) { - let _icx = cx.insn_ctxt("create_llargs_for_fn_args"); + let _icx = cx.insn_ctxt(~"create_llargs_for_fn_args"); // Skip the implicit arguments 0, and 1. let mut arg_n = first_real_arg; alt ty_self { @@ -4423,11 +4428,11 @@ fn create_llargs_for_fn_args(cx: fn_ctxt, fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg], arg_tys: ~[ty::arg]) -> block { - let _icx = fcx.insn_ctxt("copy_args_to_allocas"); + let _icx = fcx.insn_ctxt(~"copy_args_to_allocas"); let tcx = bcx.tcx(); let mut arg_n: uint = 0u, bcx = bcx; let epic_fail = fn@() -> ! { - tcx.sess.bug("someone forgot\ + tcx.sess.bug(~"someone forgot\ to document an invariant in copy_args_to_allocas!"); }; for vec::each(arg_tys) |arg| { @@ -4459,14 +4464,14 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg], // Ties up the llstaticallocas -> llloadenv -> lltop edges, // and builds the return block. fn finish_fn(fcx: fn_ctxt, lltop: BasicBlockRef) { - let _icx = fcx.insn_ctxt("finish_fn"); + let _icx = fcx.insn_ctxt(~"finish_fn"); tie_up_header_blocks(fcx, lltop); let ret_cx = raw_block(fcx, fcx.llreturn); RetVoid(ret_cx); } fn tie_up_header_blocks(fcx: fn_ctxt, lltop: BasicBlockRef) { - let _icx = fcx.insn_ctxt("tie_up_header_blocks"); + let _icx = fcx.insn_ctxt(~"tie_up_header_blocks"); Br(raw_block(fcx, fcx.llstaticallocas), fcx.llloadenv); Br(raw_block(fcx, fcx.llloadenv), lltop); } @@ -4483,7 +4488,7 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl, id: ast::node_id, maybe_load_env: fn(fn_ctxt), finish: fn(block)) { - let _icx = ccx.insn_ctxt("trans_closure"); + let _icx = ccx.insn_ctxt(~"trans_closure"); set_uwtable(llfndecl); // Set up arguments to the function. @@ -4539,7 +4544,7 @@ fn trans_fn(ccx: @crate_ctxt, let do_time = ccx.sess.trans_stats(); let start = if do_time { time::get_time() } else { {sec: 0i64, nsec: 0i32} }; - let _icx = ccx.insn_ctxt("trans_fn"); + let _icx = ccx.insn_ctxt(~"trans_fn"); trans_closure(ccx, path, decl, body, llfndecl, ty_self, param_substs, id, |fcx| { @@ -4558,12 +4563,12 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, variant: ast::variant, disr: int, is_degen: bool, param_substs: option, llfndecl: ValueRef) { - let _icx = ccx.insn_ctxt("trans_enum_variant"); + let _icx = ccx.insn_ctxt(~"trans_enum_variant"); // Translate variant arguments to function arguments. let fn_args = vec::map(variant.node.args, |varg| {mode: ast::expl(ast::by_copy), ty: varg.ty, - ident: @"arg", + ident: @~"arg", id: varg.id}); let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, param_substs, none); @@ -4609,7 +4614,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, // duplicate constants. I think. Maybe LLVM has a magical mode that does so // later on? fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { - let _icx = cx.insn_ctxt("trans_const_expr"); + let _icx = cx.insn_ctxt(~"trans_const_expr"); alt e.node { ast::expr_lit(lit) { trans_crate_lit(cx, e, *lit) } // If we have a vstore, just keep going; it has to be a string @@ -4649,7 +4654,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { else { llvm::LLVMConstURem(te1, te2) } } ast::and | - ast::or { cx.sess.span_unimpl(e.span, "binop logic"); } + ast::or { cx.sess.span_unimpl(e.span, ~"binop logic"); } ast::bitxor { llvm::LLVMConstXor(te1, te2) } ast::bitand { llvm::LLVMConstAnd(te1, te2) } ast::bitor { llvm::LLVMConstOr(te1, te2) } @@ -4663,7 +4668,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { ast::le | ast::ne | ast::ge | - ast::gt { cx.sess.span_unimpl(e.span, "binop comparator"); } + ast::gt { cx.sess.span_unimpl(e.span, ~"binop comparator"); } } } ast::expr_unary(u, e) { @@ -4674,7 +4679,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { ast::box(_) | ast::uniq(_) | ast::deref { cx.sess.span_bug(e.span, - "bad unop type in trans_const_expr"); } + ~"bad unop type in trans_const_expr"); } ast::not { llvm::LLVMConstNot(te) } ast::neg { if is_float { llvm::LLVMConstFNeg(te) } @@ -4717,20 +4722,20 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { trans_const_expr(cx, subexpr) } _ { - cx.sess.span_bug(e.span, "expected item"); + cx.sess.span_bug(e.span, ~"expected item"); } } } - _ { cx.sess.span_bug(e.span, "expected to find a const def") } + _ { cx.sess.span_bug(e.span, ~"expected to find a const def") } } } _ { cx.sess.span_bug(e.span, - "bad constant expression type in trans_const_expr"); } + ~"bad constant expression type in trans_const_expr"); } } } fn trans_const(ccx: @crate_ctxt, e: @ast::expr, id: ast::node_id) { - let _icx = ccx.insn_ctxt("trans_const"); + let _icx = ccx.insn_ctxt(~"trans_const"); let v = trans_const_expr(ccx, e); // The scalars come back as 1st class LLVM vals @@ -4845,7 +4850,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path, } fn trans_item(ccx: @crate_ctxt, item: ast::item) { - let _icx = ccx.insn_ctxt("trans_item"); + let _icx = ccx.insn_ctxt(~"trans_item"); let path = alt check ccx.tcx.items.get(item.id) { ast_map::node_item(_, p) { p } }; @@ -4933,7 +4938,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { // only as a convenience for humans working with the code, to organize names // and control visibility. fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) { - let _icx = ccx.insn_ctxt("trans_mod"); + let _icx = ccx.insn_ctxt(~"trans_mod"); for vec::each(m.items) |item| { trans_item(ccx, *item); } } @@ -4958,7 +4963,7 @@ fn register_fn_full(ccx: @crate_ctxt, sp: span, path: path, fn register_fn_fuller(ccx: @crate_ctxt, sp: span, path: path, node_id: ast::node_id, node_type: ty::t, cc: lib::llvm::CallConv, llfty: TypeRef) -> ValueRef { - let ps: str = mangle_exported_name(ccx, path, node_type); + let ps: ~str = mangle_exported_name(ccx, path, node_type); let llfn: ValueRef = decl_fn(ccx.llmod, ps, cc, llfty); ccx.item_symbols.insert(node_id, ps); @@ -4976,14 +4981,14 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, main_node_type: ty::t) { if ccx.main_fn != none:: { - ccx.sess.span_fatal(sp, "multiple 'main' functions"); + ccx.sess.span_fatal(sp, ~"multiple 'main' functions"); } let main_takes_argv = // invariant! alt ty::get(main_node_type).struct { ty::ty_fn({inputs, _}) { inputs.len() != 0u } - _ { ccx.sess.span_fatal(sp, "main has a non-function type"); } + _ { ccx.sess.span_fatal(sp, ~"main has a non-function type"); } }; let llfn = create_main(ccx, main_llfn, main_takes_argv); @@ -4998,7 +5003,7 @@ fn create_main(ccx: @crate_ctxt, main_llfn: ValueRef, ty: ty::mk_vec(ccx.tcx, {ty: unit_ty, mutbl: ast::m_imm})}; let nt = ty::mk_nil(ccx.tcx); let llfty = type_of_fn(ccx, ~[vecarg_ty], nt); - let llfdecl = decl_fn(ccx.llmod, "_rust_main", + let llfdecl = decl_fn(ccx.llmod, ~"_rust_main", lib::llvm::CCallConv, llfty); let fcx = new_fn_ctxt(ccx, ~[], llfdecl, none); @@ -5024,10 +5029,10 @@ fn create_entry_fn(ccx: @crate_ctxt, rust_main: ValueRef) { #[cfg(windows)] fn main_name() -> str { ret "WinMain@16"; } #[cfg(unix)] - fn main_name() -> str { ret "main"; } + fn main_name() -> ~str { ret ~"main"; } let llfty = T_fn(~[ccx.int_type, ccx.int_type], ccx.int_type); let llfn = decl_cdecl_fn(ccx.llmod, main_name(), llfty); - let llbb = str::as_c_str("top", |buf| { + let llbb = str::as_c_str(~"top", |buf| { llvm::LLVMAppendBasicBlock(llfn, buf) }); let bld = ccx.builder.B; @@ -5035,7 +5040,7 @@ fn create_entry_fn(ccx: @crate_ctxt, rust_main: ValueRef) { let crate_map = ccx.crate_map; let start_ty = T_fn(~[val_ty(rust_main), ccx.int_type, ccx.int_type, val_ty(crate_map)], ccx.int_type); - let start = decl_cdecl_fn(ccx.llmod, "rust_start", start_ty); + let start = decl_cdecl_fn(ccx.llmod, ~"rust_start", start_ty); let args = ~[rust_main, llvm::LLVMGetParam(llfn, 0 as c_uint), llvm::LLVMGetParam(llfn, 1 as c_uint), crate_map]; @@ -5078,14 +5083,14 @@ fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { /* If there's already a symbol for the dtor with and substs , return it; otherwise, create one and register it, returning it as well */ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, - substs: option) -> str { + substs: option) -> ~str { let t = ty::node_id_to_type(ccx.tcx, id); alt ccx.item_symbols.find(id) { some(s) { s } none if is_none(substs) { let s = mangle_exported_name( ccx, - vec::append(path, ~[path_name(@ccx.names("dtor"))]), + vec::append(path, ~[path_name(@ccx.names(~"dtor"))]), t); ccx.item_symbols.insert(id, s); s @@ -5099,7 +5104,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, mangle_exported_name( ccx, vec::append(path, - ~[path_name(@ccx.names("dtor"))]), + ~[path_name(@ccx.names(~"dtor"))]), mono_ty) } none { @@ -5144,7 +5149,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ast_map::node_method(m, impl_id, pth) { exprt = true; let mty = ty::node_id_to_type(ccx.tcx, id); - let pth = vec::append(*pth, ~[path_name(@ccx.names("meth")), + let pth = vec::append(*pth, ~[path_name(@ccx.names(~"meth")), path_name(m.ident)]); let llfn = register_fn_full(ccx, m.span, pth, id, mty); set_inline_hint_if_appr(m.attrs, llfn); @@ -5206,7 +5211,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { // The constant translation pass. fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { - let _icx = ccx.insn_ctxt("trans_constant"); + let _icx = ccx.insn_ctxt(~"trans_constant"); alt it.node { ast::item_enum(variants, _) { let vi = ty::enum_variants(ccx.tcx, {crate: ast::local_crate, @@ -5215,7 +5220,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { let path = item_path(ccx, it); for vec::each(variants) |variant| { let p = vec::append(path, ~[path_name(variant.node.name), - path_name(@"discrim")]); + path_name(@~"discrim")]); let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx)); let disr_val = vi[i].disr_val; note_unique_llvm_symbol(ccx, s); @@ -5250,7 +5255,7 @@ fn p2i(ccx: @crate_ctxt, v: ValueRef) -> ValueRef { ret llvm::LLVMConstPtrToInt(v, ccx.int_type); } -fn declare_intrinsics(llmod: ModuleRef) -> hashmap { +fn declare_intrinsics(llmod: ModuleRef) -> hashmap<~str, ValueRef> { let T_memmove32_args: ~[TypeRef] = ~[T_ptr(T_i8()), T_ptr(T_i8()), T_i32(), T_i32(), T_i1()]; let T_memmove64_args: ~[TypeRef] = @@ -5262,67 +5267,67 @@ fn declare_intrinsics(llmod: ModuleRef) -> hashmap { let T_trap_args: ~[TypeRef] = ~[]; let T_frameaddress_args: ~[TypeRef] = ~[T_i32()]; let gcroot = - decl_cdecl_fn(llmod, "llvm.gcroot", + decl_cdecl_fn(llmod, ~"llvm.gcroot", T_fn(~[T_ptr(T_ptr(T_i8())), T_ptr(T_i8())], T_void())); let gcread = - decl_cdecl_fn(llmod, "llvm.gcread", + decl_cdecl_fn(llmod, ~"llvm.gcread", T_fn(~[T_ptr(T_i8()), T_ptr(T_ptr(T_i8()))], T_void())); let memmove32 = - decl_cdecl_fn(llmod, "llvm.memmove.p0i8.p0i8.i32", + decl_cdecl_fn(llmod, ~"llvm.memmove.p0i8.p0i8.i32", T_fn(T_memmove32_args, T_void())); let memmove64 = - decl_cdecl_fn(llmod, "llvm.memmove.p0i8.p0i8.i64", + decl_cdecl_fn(llmod, ~"llvm.memmove.p0i8.p0i8.i64", T_fn(T_memmove64_args, T_void())); let memset32 = - decl_cdecl_fn(llmod, "llvm.memset.p0i8.i32", + decl_cdecl_fn(llmod, ~"llvm.memset.p0i8.i32", T_fn(T_memset32_args, T_void())); let memset64 = - decl_cdecl_fn(llmod, "llvm.memset.p0i8.i64", + decl_cdecl_fn(llmod, ~"llvm.memset.p0i8.i64", T_fn(T_memset64_args, T_void())); - let trap = decl_cdecl_fn(llmod, "llvm.trap", T_fn(T_trap_args, + let trap = decl_cdecl_fn(llmod, ~"llvm.trap", T_fn(T_trap_args, T_void())); - let frameaddress = decl_cdecl_fn(llmod, "llvm.frameaddress", + let frameaddress = decl_cdecl_fn(llmod, ~"llvm.frameaddress", T_fn(T_frameaddress_args, T_ptr(T_i8()))); let intrinsics = str_hash::(); - intrinsics.insert("llvm.gcroot", gcroot); - intrinsics.insert("llvm.gcread", gcread); - intrinsics.insert("llvm.memmove.p0i8.p0i8.i32", memmove32); - intrinsics.insert("llvm.memmove.p0i8.p0i8.i64", memmove64); - intrinsics.insert("llvm.memset.p0i8.i32", memset32); - intrinsics.insert("llvm.memset.p0i8.i64", memset64); - intrinsics.insert("llvm.trap", trap); - intrinsics.insert("llvm.frameaddress", frameaddress); + intrinsics.insert(~"llvm.gcroot", gcroot); + intrinsics.insert(~"llvm.gcread", gcread); + intrinsics.insert(~"llvm.memmove.p0i8.p0i8.i32", memmove32); + intrinsics.insert(~"llvm.memmove.p0i8.p0i8.i64", memmove64); + intrinsics.insert(~"llvm.memset.p0i8.i32", memset32); + intrinsics.insert(~"llvm.memset.p0i8.i64", memset64); + intrinsics.insert(~"llvm.trap", trap); + intrinsics.insert(~"llvm.frameaddress", frameaddress); ret intrinsics; } fn declare_dbg_intrinsics(llmod: ModuleRef, - intrinsics: hashmap) { + intrinsics: hashmap<~str, ValueRef>) { let declare = - decl_cdecl_fn(llmod, "llvm.dbg.declare", + decl_cdecl_fn(llmod, ~"llvm.dbg.declare", T_fn(~[T_metadata(), T_metadata()], T_void())); let value = - decl_cdecl_fn(llmod, "llvm.dbg.value", + decl_cdecl_fn(llmod, ~"llvm.dbg.value", T_fn(~[T_metadata(), T_i64(), T_metadata()], T_void())); - intrinsics.insert("llvm.dbg.declare", declare); - intrinsics.insert("llvm.dbg.value", value); + intrinsics.insert(~"llvm.dbg.declare", declare); + intrinsics.insert(~"llvm.dbg.value", value); } fn trap(bcx: block) { let v: ~[ValueRef] = ~[]; - alt bcx.ccx().intrinsics.find("llvm.trap") { + alt bcx.ccx().intrinsics.find(~"llvm.trap") { some(x) { Call(bcx, x, v); } - _ { bcx.sess().bug("unbound llvm.trap in trap"); } + _ { bcx.sess().bug(~"unbound llvm.trap in trap"); } } } fn create_module_map(ccx: @crate_ctxt) -> ValueRef { let elttype = T_struct(~[ccx.int_type, ccx.int_type]); let maptype = T_array(elttype, ccx.module_data.size() + 1u); - let map = str::as_c_str("_rust_mod_map", |buf| { + let map = str::as_c_str(~"_rust_mod_map", |buf| { llvm::LLVMAddGlobal(ccx.llmod, maptype, buf) }); lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage); @@ -5347,9 +5352,9 @@ fn decl_crate_map(sess: session::session, mapmeta: link_meta, let cstore = sess.cstore; while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; } let mapname = if sess.building_library { - *mapmeta.name + "_" + *mapmeta.vers + "_" + mapmeta.extras_hash - } else { "toplevel" }; - let sym_name = "_rust_crate_map_" + mapname; + *mapmeta.name + ~"_" + *mapmeta.vers + ~"_" + mapmeta.extras_hash + } else { ~"toplevel" }; + let sym_name = ~"_rust_crate_map_" + mapname; let arrtype = T_array(int_type, n_subcrates as uint); let maptype = T_struct(~[int_type, arrtype]); let map = str::as_c_str(sym_name, |buf| { @@ -5365,9 +5370,9 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) { let cstore = ccx.sess.cstore; while cstore::have_crate_data(cstore, i) { let cdata = cstore::get_crate_data(cstore, i); - let nm = "_rust_crate_map_" + cdata.name + - "_" + *cstore::get_crate_vers(cstore, i) + - "_" + *cstore::get_crate_hash(cstore, i); + let nm = ~"_rust_crate_map_" + cdata.name + + ~"_" + *cstore::get_crate_vers(cstore, i) + + ~"_" + *cstore::get_crate_hash(cstore, i); let cr = str::as_c_str(nm, |buf| { llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf) }); @@ -5399,7 +5404,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) encode_inlined_item: encode_inlined_item }; - fn reexports(cx: @crate_ctxt) -> ~[(str, ast::def_id)] { + fn reexports(cx: @crate_ctxt) -> ~[(~str, ast::def_id)] { let mut reexports = ~[]; for cx.exp_map.each |exp_id, defs| { for defs.each |def| { @@ -5430,7 +5435,7 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { let encode_parms = crate_ctxt_to_encode_parms(cx); let llmeta = C_bytes(encoder::encode_metadata(encode_parms, crate)); let llconst = C_struct(~[llmeta]); - let mut llglobal = str::as_c_str("rust_metadata", |buf| { + let mut llglobal = str::as_c_str(~"rust_metadata", |buf| { llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf) }); llvm::LLVMSetInitializer(llglobal, llconst); @@ -5441,7 +5446,7 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { let t_ptr_i8 = T_ptr(T_i8()); llglobal = llvm::LLVMConstBitCast(llglobal, t_ptr_i8); - let llvm_used = str::as_c_str("llvm.used", |buf| { + let llvm_used = str::as_c_str(~"llvm.used", |buf| { llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u), buf) }); lib::llvm::SetLinkage(llvm_used, lib::llvm::AppendingLinkage); @@ -5450,12 +5455,12 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { // Writes the current ABI version into the crate. fn write_abi_version(ccx: @crate_ctxt) { - mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version), + mk_global(ccx, ~"rust_abi_version", C_uint(ccx, abi::abi_version), false); } fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, - output: str, emap: resolve::exp_map, + output: ~str, emap: resolve::exp_map, maps: astencode::maps) -> (ModuleRef, link_meta) { let sha = std::sha1::sha1(); @@ -5471,7 +5476,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, // crashes if the module identifer is same as other symbols // such as a function name in the module. // 1. http://llvm.org/bugs/show_bug.cgi?id=11479 - let llmod_id = *link_meta.name + ".rc"; + let llmod_id = *link_meta.name + ~".rc"; let llmod = str::as_c_str(llmod_id, |buf| { llvm::LLVMModuleCreateWithNameInContext @@ -5496,9 +5501,9 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, let float_type = T_float(targ_cfg); let task_type = T_task(targ_cfg); let taskptr_type = T_ptr(task_type); - lib::llvm::associate_type(tn, "taskptr", taskptr_type); + lib::llvm::associate_type(tn, ~"taskptr", taskptr_type); let tydesc_type = T_tydesc(targ_cfg); - lib::llvm::associate_type(tn, "tydesc", tydesc_type); + lib::llvm::associate_type(tn, ~"tydesc", tydesc_type); let crate_map = decl_crate_map(sess, link_meta, llmod); let dbg_cx = if sess.opts.debuginfo { option::some(debuginfo::mk_ctxt(llmod_id)) @@ -5516,12 +5521,12 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, item_vals: int_hash::(), exp_map: emap, reachable: reachable, - item_symbols: int_hash::(), + item_symbols: int_hash::<~str>(), mut main_fn: none::, link_meta: link_meta, enum_sizes: ty::new_ty_hash(), discrims: ast_util::new_def_hash::(), - discrim_symbols: int_hash::(), + discrim_symbols: int_hash::<~str>(), tydescs: ty::new_ty_hash(), external: ast_util::new_def_hash(), monomorphized: map::hashmap(hash_mono_id, |a, b| a == b), @@ -5563,12 +5568,12 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, { - let _icx = ccx.insn_ctxt("data"); + let _icx = ccx.insn_ctxt(~"data"); trans_constants(ccx, crate); } { - let _icx = ccx.insn_ctxt("text"); + let _icx = ccx.insn_ctxt(~"text"); trans_mod(ccx, crate.node.module); } @@ -5580,7 +5585,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, // Translate the metadata. write_metadata(ccx, crate); if ccx.sess.trans_stats() { - io::println("--- trans stats ---"); + io::println(~"--- trans stats ---"); io::println(#fmt("n_static_tydescs: %u", ccx.stats.n_static_tydescs)); io::println(#fmt("n_glues_created: %u", diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index 8c261a402b4e..3d6746aa2eaf 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -15,7 +15,7 @@ fn B(cx: block) -> BuilderRef { ret b; } -fn count_insn(cx: block, category: str) { +fn count_insn(cx: block, category: ~str) { if cx.ccx().sess.count_llvm_insns() { let h = cx.ccx().stats.llvm_insns; @@ -36,17 +36,17 @@ fn count_insn(cx: block, category: str) { // 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 = "."; + let mut s = ~"."; i = 0u; while i < len { let e = v[i]; i = mm.get(e); - s += "/"; + s += ~"/"; s += e; i += 1u; } - s += "/"; + s += ~"/"; s += category; let n = alt h.find(s) { some(n) { n } _ { 0u } }; @@ -67,7 +67,7 @@ fn RetVoid(cx: block) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "retvoid"); + count_insn(cx, ~"retvoid"); llvm::LLVMBuildRetVoid(B(cx)); } @@ -75,7 +75,7 @@ fn Ret(cx: block, V: ValueRef) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "ret"); + count_insn(cx, ~"ret"); llvm::LLVMBuildRet(B(cx), V); } @@ -93,7 +93,7 @@ fn Br(cx: block, Dest: BasicBlockRef) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "br"); + count_insn(cx, ~"br"); llvm::LLVMBuildBr(B(cx), Dest); } @@ -102,7 +102,7 @@ fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef, if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "condbr"); + count_insn(cx, ~"condbr"); llvm::LLVMBuildCondBr(B(cx), If, Then, Else); } @@ -123,7 +123,7 @@ fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "indirectbr"); + count_insn(cx, ~"indirectbr"); llvm::LLVMBuildIndirectBr(B(cx), Addr, NumDests as c_uint); } @@ -142,9 +142,9 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], #debug["Invoke(%s with arguments (%s))", val_str(cx.ccx().tn, Fn), str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)), - ", ")]; + ~", ")]; unsafe { - count_insn(cx, "invoke"); + count_insn(cx, ~"invoke"); llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, Then, Catch, noname()); @@ -157,7 +157,7 @@ fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], assert (!cx.terminated); cx.terminated = true; unsafe { - count_insn(cx, "fastinvoke"); + count_insn(cx, ~"fastinvoke"); let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, Then, Catch, noname()); @@ -169,7 +169,7 @@ fn Unreachable(cx: block) { if cx.unreachable { ret; } cx.unreachable = true; if !cx.terminated { - count_insn(cx, "unreachable"); + count_insn(cx, ~"unreachable"); llvm::LLVMBuildUnreachable(B(cx)); } } @@ -181,218 +181,218 @@ fn _Undef(val: ValueRef) -> ValueRef { /* Arithmetic */ fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "add"); + count_insn(cx, ~"add"); ret llvm::LLVMBuildAdd(B(cx), LHS, RHS, noname()); } fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nswadd"); + count_insn(cx, ~"nswadd"); ret llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, noname()); } fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nuwadd"); + count_insn(cx, ~"nuwadd"); ret llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, noname()); } fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "fadd"); + count_insn(cx, ~"fadd"); ret llvm::LLVMBuildFAdd(B(cx), LHS, RHS, noname()); } fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "sub"); + count_insn(cx, ~"sub"); ret llvm::LLVMBuildSub(B(cx), LHS, RHS, noname()); } fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nwsub"); + count_insn(cx, ~"nwsub"); ret llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, noname()); } fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nuwsub"); + count_insn(cx, ~"nuwsub"); ret llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, noname()); } fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "sub"); + count_insn(cx, ~"sub"); ret llvm::LLVMBuildFSub(B(cx), LHS, RHS, noname()); } fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "mul"); + count_insn(cx, ~"mul"); ret llvm::LLVMBuildMul(B(cx), LHS, RHS, noname()); } fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nswmul"); + count_insn(cx, ~"nswmul"); ret llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, noname()); } fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nuwmul"); + count_insn(cx, ~"nuwmul"); ret llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, noname()); } fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "fmul"); + count_insn(cx, ~"fmul"); ret llvm::LLVMBuildFMul(B(cx), LHS, RHS, noname()); } fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "udiv"); + count_insn(cx, ~"udiv"); ret llvm::LLVMBuildUDiv(B(cx), LHS, RHS, noname()); } fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "sdiv"); + count_insn(cx, ~"sdiv"); ret llvm::LLVMBuildSDiv(B(cx), LHS, RHS, noname()); } fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "extractsdiv"); + count_insn(cx, ~"extractsdiv"); ret llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, noname()); } fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "fdiv"); + count_insn(cx, ~"fdiv"); ret llvm::LLVMBuildFDiv(B(cx), LHS, RHS, noname()); } fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "urem"); + count_insn(cx, ~"urem"); ret llvm::LLVMBuildURem(B(cx), LHS, RHS, noname()); } fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "srem"); + count_insn(cx, ~"srem"); ret llvm::LLVMBuildSRem(B(cx), LHS, RHS, noname()); } fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "frem"); + count_insn(cx, ~"frem"); ret llvm::LLVMBuildFRem(B(cx), LHS, RHS, noname()); } fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "shl"); + count_insn(cx, ~"shl"); ret llvm::LLVMBuildShl(B(cx), LHS, RHS, noname()); } fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "lshr"); + count_insn(cx, ~"lshr"); ret llvm::LLVMBuildLShr(B(cx), LHS, RHS, noname()); } fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "ashr"); + count_insn(cx, ~"ashr"); ret llvm::LLVMBuildAShr(B(cx), LHS, RHS, noname()); } fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "and"); + count_insn(cx, ~"and"); ret llvm::LLVMBuildAnd(B(cx), LHS, RHS, noname()); } fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "or"); + count_insn(cx, ~"or"); ret llvm::LLVMBuildOr(B(cx), LHS, RHS, noname()); } fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "xor"); + count_insn(cx, ~"xor"); ret llvm::LLVMBuildXor(B(cx), LHS, RHS, noname()); } fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "binop"); + count_insn(cx, ~"binop"); ret llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, noname()); } fn Neg(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "neg"); + count_insn(cx, ~"neg"); ret llvm::LLVMBuildNeg(B(cx), V, noname()); } fn NSWNeg(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "nswneg"); + count_insn(cx, ~"nswneg"); ret llvm::LLVMBuildNSWNeg(B(cx), V, noname()); } fn NUWNeg(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "nuwneg"); + count_insn(cx, ~"nuwneg"); ret llvm::LLVMBuildNUWNeg(B(cx), V, noname()); } fn FNeg(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "fneg"); + count_insn(cx, ~"fneg"); ret llvm::LLVMBuildFNeg(B(cx), V, noname()); } fn Not(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "not"); + count_insn(cx, ~"not"); ret llvm::LLVMBuildNot(B(cx), V, noname()); } /* Memory */ fn Malloc(cx: block, Ty: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } - count_insn(cx, "malloc"); + count_insn(cx, ~"malloc"); ret llvm::LLVMBuildMalloc(B(cx), Ty, noname()); } fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } - count_insn(cx, "arraymalloc"); + count_insn(cx, ~"arraymalloc"); ret llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, noname()); } fn Alloca(cx: block, Ty: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(Ty)); } - count_insn(cx, "alloca"); + count_insn(cx, ~"alloca"); ret llvm::LLVMBuildAlloca(B(cx), Ty, noname()); } fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(Ty)); } - count_insn(cx, "arrayalloca"); + count_insn(cx, ~"arrayalloca"); ret llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, noname()); } fn Free(cx: block, PointerVal: ValueRef) { if cx.unreachable { ret; } - count_insn(cx, "free"); + count_insn(cx, ~"free"); llvm::LLVMBuildFree(B(cx), PointerVal); } @@ -404,7 +404,7 @@ fn Load(cx: block, PointerVal: ValueRef) -> ValueRef { llvm::LLVMGetElementType(ty) } else { ccx.int_type }; ret llvm::LLVMGetUndef(eltty); } - count_insn(cx, "load"); + count_insn(cx, ~"load"); ret llvm::LLVMBuildLoad(B(cx), PointerVal, noname()); } @@ -413,14 +413,14 @@ fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) { #debug["Store %s -> %s", val_str(cx.ccx().tn, Val), val_str(cx.ccx().tn, Ptr)]; - count_insn(cx, "store"); + count_insn(cx, ~"store"); llvm::LLVMBuildStore(B(cx), Val, Ptr); } fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { - count_insn(cx, "gep"); + count_insn(cx, ~"gep"); ret llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices), Indices.len() as c_uint, noname()); } @@ -431,7 +431,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { fn GEPi(cx: block, base: ValueRef, ixs: ~[uint]) -> ValueRef { let mut v: ~[ValueRef] = ~[]; for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); } - count_insn(cx, "gepi"); + count_insn(cx, ~"gepi"); ret InBoundsGEP(cx, base, v); } @@ -439,7 +439,7 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { - count_insn(cx, "inboundsgep"); + count_insn(cx, ~"inboundsgep"); ret llvm::LLVMBuildInBoundsGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices), Indices.len() as c_uint, @@ -449,138 +449,138 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } - count_insn(cx, "structgep"); + count_insn(cx, ~"structgep"); ret llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname()); } fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } - count_insn(cx, "globalstring"); + count_insn(cx, ~"globalstring"); ret llvm::LLVMBuildGlobalString(B(cx), _Str, noname()); } fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } - count_insn(cx, "globalstringptr"); + count_insn(cx, ~"globalstringptr"); ret llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, noname()); } /* Casts */ fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "trunc"); + count_insn(cx, ~"trunc"); ret llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname()); } fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "zext"); + count_insn(cx, ~"zext"); ret llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname()); } fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "sext"); + count_insn(cx, ~"sext"); ret llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname()); } fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fptoui"); + count_insn(cx, ~"fptoui"); ret llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname()); } fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fptosi"); + count_insn(cx, ~"fptosi"); ret llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname()); } fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "uitofp"); + count_insn(cx, ~"uitofp"); ret llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname()); } fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "sitofp"); + count_insn(cx, ~"sitofp"); ret llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname()); } fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fptrunc"); + count_insn(cx, ~"fptrunc"); ret llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname()); } fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fpext"); + count_insn(cx, ~"fpext"); ret llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname()); } fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "ptrtoint"); + count_insn(cx, ~"ptrtoint"); ret llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname()); } fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "inttoptr"); + count_insn(cx, ~"inttoptr"); ret llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname()); } fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "bitcast"); + count_insn(cx, ~"bitcast"); ret llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname()); } fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "zextorbitcast"); + count_insn(cx, ~"zextorbitcast"); ret llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname()); } fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "sextorbitcast"); + count_insn(cx, ~"sextorbitcast"); ret llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname()); } fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "truncorbitcast"); + count_insn(cx, ~"truncorbitcast"); ret llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname()); } fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef, _Name: *u8) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "cast"); + count_insn(cx, ~"cast"); ret llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname()); } fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "pointercast"); + count_insn(cx, ~"pointercast"); ret llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname()); } fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "intcast"); + count_insn(cx, ~"intcast"); ret llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname()); } fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fpcast"); + count_insn(cx, ~"fpcast"); ret llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname()); } @@ -589,21 +589,21 @@ fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - count_insn(cx, "icmp"); + count_insn(cx, ~"icmp"); ret llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname()); } fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - count_insn(cx, "fcmp"); + count_insn(cx, ~"fcmp"); ret llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname()); } /* Miscellaneous instructions */ fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(Ty); } - count_insn(cx, "emptyphi"); + count_insn(cx, ~"emptyphi"); ret llvm::LLVMBuildPhi(B(cx), Ty, noname()); } @@ -613,7 +613,7 @@ fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef]) assert vals.len() == bbs.len(); let phi = EmptyPhi(cx, Ty); unsafe { - count_insn(cx, "addincoming"); + count_insn(cx, ~"addincoming"); llvm::LLVMAddIncoming(phi, vec::unsafe::to_ptr(vals), vec::unsafe::to_ptr(bbs), vals.len() as c_uint); @@ -635,28 +635,28 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef { let ty = val_ty(Fn); let retty = if llvm::LLVMGetTypeKind(ty) == lib::llvm::Integer { llvm::LLVMGetReturnType(ty) } else { ccx.int_type }; - count_insn(cx, ""); + count_insn(cx, ~""); ret llvm::LLVMGetUndef(retty); } -fn add_span_comment(bcx: block, sp: span, text: str) { +fn add_span_comment(bcx: block, sp: span, text: ~str) { let ccx = bcx.ccx(); if !ccx.sess.no_asm_comments() { - let s = text + " (" + codemap::span_to_str(sp, ccx.sess.codemap) - + ")"; + let s = text + ~" (" + codemap::span_to_str(sp, ccx.sess.codemap) + + ~")"; log(debug, s); add_comment(bcx, s); } } -fn add_comment(bcx: block, text: str) { +fn add_comment(bcx: block, text: ~str) { let ccx = bcx.ccx(); if !ccx.sess.no_asm_comments() { - let sanitized = str::replace(text, "$", ""); - let comment_text = "# " + sanitized; + let sanitized = str::replace(text, ~"$", ~""); + let comment_text = ~"# " + sanitized; let asm = str::as_c_str(comment_text, |c| { - str::as_c_str("", |e| { - count_insn(bcx, "inlineasm"); + str::as_c_str(~"", |e| { + count_insn(bcx, ~"inlineasm"); llvm::LLVMConstInlineAsm(T_fn(~[], T_void()), c, e, False, False) }) @@ -668,7 +668,7 @@ fn add_comment(bcx: block, text: str) { fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { - count_insn(cx, "call"); + count_insn(cx, ~"call"); #debug["Call(Fn=%s, Args=%?)", val_str(cx.ccx().tn, Fn), @@ -682,7 +682,7 @@ fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { - count_insn(cx, "fastcall"); + count_insn(cx, ~"fastcall"); let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv); @@ -694,7 +694,7 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef], Conv: CallConv) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { - count_insn(cx, "callwithconv"); + count_insn(cx, ~"callwithconv"); let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); lib::llvm::SetInstructionCallConv(v, Conv); @@ -705,67 +705,67 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef], fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(Then); } - count_insn(cx, "select"); + count_insn(cx, ~"select"); ret llvm::LLVMBuildSelect(B(cx), If, Then, Else, noname()); } fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(Ty); } - count_insn(cx, "vaarg"); + count_insn(cx, ~"vaarg"); ret llvm::LLVMBuildVAArg(B(cx), list, Ty, noname()); } fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); } - count_insn(cx, "extractelement"); + count_insn(cx, ~"extractelement"); ret llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, noname()); } fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef, Index: ValueRef) { if cx.unreachable { ret; } - count_insn(cx, "insertelement"); + count_insn(cx, ~"insertelement"); llvm::LLVMBuildInsertElement(B(cx), VecVal, EltVal, Index, noname()); } fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef, Mask: ValueRef) { if cx.unreachable { ret; } - count_insn(cx, "shufflevector"); + count_insn(cx, ~"shufflevector"); llvm::LLVMBuildShuffleVector(B(cx), V1, V2, Mask, noname()); } fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); } - count_insn(cx, "extractvalue"); + count_insn(cx, ~"extractvalue"); ret llvm::LLVMBuildExtractValue(B(cx), AggVal, Index as c_uint, noname()); } fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef, Index: uint) { if cx.unreachable { ret; } - count_insn(cx, "insertvalue"); + count_insn(cx, ~"insertvalue"); llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index as c_uint, noname()); } fn IsNull(cx: block, Val: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - count_insn(cx, "isnull"); + count_insn(cx, ~"isnull"); ret llvm::LLVMBuildIsNull(B(cx), Val, noname()); } fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - count_insn(cx, "isnotnull"); + count_insn(cx, ~"isnotnull"); ret llvm::LLVMBuildIsNotNull(B(cx), Val, noname()); } fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { let ccx = cx.fcx.ccx; if cx.unreachable { ret llvm::LLVMGetUndef(ccx.int_type); } - count_insn(cx, "ptrdiff"); + count_insn(cx, ~"ptrdiff"); ret llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, noname()); } @@ -775,13 +775,13 @@ fn Trap(cx: block) { let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(b); let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB); let M: ModuleRef = llvm::LLVMGetGlobalParent(FN); - let T: ValueRef = str::as_c_str("llvm.trap", |buf| { + let T: ValueRef = str::as_c_str(~"llvm.trap", |buf| { llvm::LLVMGetNamedFunction(M, buf) }); assert (T as int != 0); let Args: ~[ValueRef] = ~[]; unsafe { - count_insn(cx, "trap"); + count_insn(cx, ~"trap"); llvm::LLVMBuildCall(b, T, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); } @@ -790,20 +790,20 @@ fn Trap(cx: block) { fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef, NumClauses: uint) -> ValueRef { assert !cx.terminated && !cx.unreachable; - count_insn(cx, "landingpad"); + count_insn(cx, ~"landingpad"); ret llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn, NumClauses as c_uint, noname()); } fn SetCleanup(cx: block, LandingPad: ValueRef) { - count_insn(cx, "setcleanup"); + count_insn(cx, ~"setcleanup"); llvm::LLVMSetCleanup(LandingPad, lib::llvm::True); } fn Resume(cx: block, Exn: ValueRef) -> ValueRef { assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "resume"); + count_insn(cx, ~"resume"); ret llvm::LLVMBuildResume(B(cx), Exn); } diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index e04af18eec96..22d16efbae55 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -100,7 +100,7 @@ enum environment_value { env_ref(ValueRef, ty::t, lval_kind), } -fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str { +fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str { alt ev { env_copy(v, t, lk) { #fmt("copy(%s,%s)", val_str(ccx.tn, v), ty_to_str(ccx.tcx, t)) } @@ -139,11 +139,11 @@ fn allocate_cbox(bcx: block, ck: ty::closure_kind, cdata_ty: ty::t) -> ValueRef { - let _icx = bcx.insn_ctxt("closure::allocate_cbox"); + let _icx = bcx.insn_ctxt(~"closure::allocate_cbox"); let ccx = bcx.ccx(), tcx = ccx.tcx; fn nuke_ref_count(bcx: block, llbox: ValueRef) { - let _icx = bcx.insn_ctxt("closure::nuke_ref_count"); + let _icx = bcx.insn_ctxt(~"closure::nuke_ref_count"); // Initialize ref count to arbitrary value for debugging: let ccx = bcx.ccx(); let llbox = PointerCast(bcx, llbox, T_opaque_box_ptr(ccx)); @@ -184,7 +184,7 @@ fn nuke_ref_count(bcx: block, llbox: ValueRef) { fn store_environment(bcx: block, bound_values: ~[environment_value], ck: ty::closure_kind) -> closure_result { - let _icx = bcx.insn_ctxt("closure::store_environment"); + let _icx = bcx.insn_ctxt(~"closure::store_environment"); let ccx = bcx.ccx(), tcx = ccx.tcx; // compute the shape of the closure @@ -224,7 +224,7 @@ fn store_environment(bcx: block, bcx = base::copy_val(bcx, INIT, bound_data, val, ty); } env_copy(_, _, temporary) { - fail "cannot capture temporary upvar"; + fail ~"cannot capture temporary upvar"; } env_move(val, ty, kind) { let src = {bcx:bcx, val:val, kind:kind}; @@ -241,7 +241,7 @@ fn store_environment(bcx: block, Store(bcx, addr, bound_data); } env_ref(_, _, temporary) { - fail "cannot capture temporary upvar"; + fail ~"cannot capture temporary upvar"; } } } @@ -257,7 +257,7 @@ fn build_closure(bcx0: block, ck: ty::closure_kind, id: ast::node_id, include_ret_handle: option) -> closure_result { - let _icx = bcx0.insn_ctxt("closure::build_closure"); + let _icx = bcx0.insn_ctxt(~"closure::build_closure"); // If we need to, package up the iterator body to call let mut env_vals = ~[]; let mut bcx = bcx0; @@ -318,7 +318,7 @@ fn load_environment(fcx: fn_ctxt, cap_vars: ~[capture::capture_var], load_ret_handle: bool, ck: ty::closure_kind) { - let _icx = fcx.insn_ctxt("closure::load_environment"); + let _icx = fcx.insn_ctxt(~"closure::load_environment"); let bcx = raw_block(fcx, fcx.llloadenv); // Load a pointer to the closure data, skipping over the box header: @@ -360,12 +360,12 @@ fn trans_expr_fn(bcx: block, cap_clause: ast::capture_clause, is_loop_body: option>, dest: dest) -> block { - let _icx = bcx.insn_ctxt("closure::trans_expr_fn"); + let _icx = bcx.insn_ctxt(~"closure::trans_expr_fn"); if dest == ignore { ret bcx; } let ccx = bcx.ccx(), bcx = bcx; let fty = node_id_type(bcx, id); let llfnty = type_of_fn_from_ty(ccx, fty); - let sub_path = vec::append_one(bcx.fcx.path, path_name(@"anon")); + let sub_path = vec::append_one(bcx.fcx.path, path_name(@~"anon")); let s = mangle_internal_name_by_path(ccx, sub_path); let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty); @@ -407,7 +407,7 @@ fn make_fn_glue( t: ty::t, glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block) -> block { - let _icx = cx.insn_ctxt("closure::make_fn_glue"); + let _icx = cx.insn_ctxt(~"closure::make_fn_glue"); let bcx = cx; let tcx = cx.tcx(); @@ -426,7 +426,7 @@ fn make_fn_glue( ty::ty_fn({proto: ast::proto_any, _}) { bcx } ty::ty_fn({proto: ast::proto_uniq, _}) { fn_env(ty::ck_uniq) } ty::ty_fn({proto: ast::proto_box, _}) { fn_env(ty::ck_box) } - _ { fail "make_fn_glue invoked on non-function type" } + _ { fail ~"make_fn_glue invoked on non-function type" } }; } @@ -436,7 +436,7 @@ fn make_opaque_cbox_take_glue( cboxptr: ValueRef) // ptr to ptr to the opaque closure -> block { // Easy cases: - let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_take_glue"); + let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_take_glue"); alt ck { ty::ck_block { ret bcx; } ty::ck_box { incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); ret bcx; } @@ -482,7 +482,7 @@ fn make_opaque_cbox_drop_glue( ck: ty::closure_kind, cboxptr: ValueRef) // ptr to the opaque closure -> block { - let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_drop_glue"); + let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_drop_glue"); alt ck { ty::ck_block { bcx } ty::ck_box { @@ -501,7 +501,7 @@ fn make_opaque_cbox_free_glue( ck: ty::closure_kind, cbox: ValueRef) // ptr to the opaque closure -> block { - let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_free_glue"); + let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_free_glue"); alt ck { ty::ck_block { ret bcx; } ty::ck_box | ty::ck_uniq { /* hard cases: */ } @@ -523,7 +523,7 @@ fn make_opaque_cbox_free_glue( // Free the ty descr (if necc) and the box itself alt ck { - ty::ck_block { fail "Impossible"; } + ty::ck_block { fail ~"Impossible"; } ty::ck_box { trans_free(bcx, cbox) } diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 4995713fbdb9..13f5b2f84705 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -21,10 +21,10 @@ import syntax::ast_map::path; import util::ppaux::ty_to_str; -type namegen = fn@(str) -> str; +type namegen = fn@(~str) -> ~str; fn new_namegen() -> namegen { let i = @mut 0; - ret fn@(prefix: str) -> str { *i += 1; prefix + int::str(*i) }; + ret fn@(prefix: ~str) -> ~str { *i += 1; prefix + int::str(*i) }; } type tydesc_info = @@ -68,9 +68,9 @@ fn new_namegen() -> namegen { mut n_glues_created: uint, mut n_null_glues: uint, mut n_real_glues: uint, - llvm_insn_ctxt: @mut ~[str], - llvm_insns: hashmap, - fn_times: @mut ~[{ident: str, time: int}]}; + llvm_insn_ctxt: @mut ~[~str], + llvm_insns: hashmap<~str, uint>, + fn_times: @mut ~[{ident: ~str, time: int}]}; class BuilderRef_res { let B: BuilderRef; @@ -84,17 +84,17 @@ fn new_namegen() -> namegen { llmod: ModuleRef, td: target_data, tn: type_names, - externs: hashmap, - intrinsics: hashmap, + externs: hashmap<~str, ValueRef>, + intrinsics: hashmap<~str, ValueRef>, item_vals: hashmap, exp_map: resolve::exp_map, reachable: reachable::map, - item_symbols: hashmap, + item_symbols: hashmap, mut main_fn: option, link_meta: link_meta, enum_sizes: hashmap, discrims: hashmap, - discrim_symbols: hashmap, + discrim_symbols: hashmap, tydescs: hashmap, // Track mapping of external ids to local items imported for inlining external: hashmap>, @@ -106,14 +106,14 @@ fn new_namegen() -> namegen { // Cache generated vtables vtables: hashmap, // Cache of constant strings, - const_cstr_cache: hashmap, - module_data: hashmap, + const_cstr_cache: hashmap<~str, ValueRef>, + module_data: hashmap<~str, ValueRef>, lltypes: hashmap, names: namegen, sha: std::sha1::sha1, - type_sha1s: hashmap, - type_short_names: hashmap, - all_llvm_symbols: set, + type_sha1s: hashmap, + type_short_names: hashmap, + all_llvm_symbols: set<~str>, tcx: ty::ctxt, maps: astencode::maps, stats: stats, @@ -204,10 +204,10 @@ enum local_val { local_mem(ValueRef), local_imm(ValueRef), } ccx: @crate_ctxt }; -fn warn_not_to_commit(ccx: @crate_ctxt, msg: str) { +fn warn_not_to_commit(ccx: @crate_ctxt, msg: ~str) { if !ccx.do_not_commit_warning_issued { ccx.do_not_commit_warning_issued = true; - ccx.sess.warn(msg + " -- do not commit like this!"); + ccx.sess.warn(msg + ~" -- do not commit like this!"); } } @@ -421,13 +421,13 @@ fn rslt(bcx: block, val: ValueRef) -> result { {bcx: bcx, val: val} } -fn ty_str(tn: type_names, t: TypeRef) -> str { +fn ty_str(tn: type_names, t: TypeRef) -> ~str { ret lib::llvm::type_to_str(tn, t); } fn val_ty(v: ValueRef) -> TypeRef { ret llvm::LLVMTypeOf(v); } -fn val_str(tn: type_names, v: ValueRef) -> str { ret ty_str(tn, val_ty(v)); } +fn val_str(tn: type_names, v: ValueRef) -> ~str { ret ty_str(tn, val_ty(v)); } // Returns the nth element of the given LLVM structure type. fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe { @@ -464,13 +464,13 @@ impl bcx_cxs for block { pure fn tcx() -> ty::ctxt { self.fcx.ccx.tcx } pure fn sess() -> session { self.fcx.ccx.sess } - fn val_str(val: ValueRef) -> str { + fn val_str(val: ValueRef) -> ~str { val_str(self.ccx().tn, val) } - fn ty_to_str(t: ty::t) -> str { + fn ty_to_str(t: ty::t) -> ~str { ty_to_str(self.tcx(), t) } - fn to_str() -> str { + fn to_str() -> ~str { alt self.node_info { some(node_info) { #fmt["[block %d]", node_info.id] @@ -591,7 +591,7 @@ fn T_struct(elts: ~[TypeRef]) -> TypeRef unsafe { ret llvm::LLVMStructType(to_ptr(elts), elts.len() as c_uint, False); } -fn T_named_struct(name: str) -> TypeRef { +fn T_named_struct(name: ~str) -> TypeRef { let c = llvm::LLVMGetGlobalContext(); ret str::as_c_str(name, |buf| llvm::LLVMStructCreateNamed(c, buf)); } @@ -610,7 +610,7 @@ fn set_struct_body(t: TypeRef, elts: ~[TypeRef]) unsafe { fn T_vtable() -> TypeRef { T_array(T_ptr(T_i8()), 1u) } fn T_task(targ_cfg: @session::config) -> TypeRef { - let t = T_named_struct("task"); + let t = T_named_struct(~"task"); // Refcount // Delegate pointer @@ -644,7 +644,7 @@ fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe { } fn T_glue_fn(cx: @crate_ctxt) -> TypeRef { - let s = "glue_fn"; + let s = ~"glue_fn"; alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} } let t = T_tydesc_field(cx, abi::tydesc_field_drop_glue); associate_type(cx.tn, s, t); @@ -652,7 +652,7 @@ fn T_glue_fn(cx: @crate_ctxt) -> TypeRef { } fn T_tydesc(targ_cfg: @session::config) -> TypeRef { - let tydesc = T_named_struct("tydesc"); + let tydesc = T_named_struct(~"tydesc"); let tydescpp = T_ptr(T_ptr(tydesc)); let pvoid = T_ptr(T_i8()); let glue_fn_ty = @@ -748,7 +748,7 @@ fn T_chan(cx: @crate_ctxt, _t: TypeRef) -> TypeRef { // This type must never be used directly; it must always be cast away. fn T_typaram(tn: type_names) -> TypeRef { - let s = "typaram"; + let s = ~"typaram"; alt name_has_type(tn, s) { some(t) { ret t; } _ {} } let t = T_i8(); associate_type(tn, s, t); @@ -768,7 +768,7 @@ fn T_enum_discrim(cx: @crate_ctxt) -> TypeRef { } fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef { - let s = "opaque_enum"; + let s = ~"opaque_enum"; alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} } let t = T_struct(~[T_enum_discrim(cx), T_i8()]); associate_type(cx.tn, s, t); @@ -799,7 +799,7 @@ fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef { ret llvm::LLVMConstInt(t, u, sign_extend); } -fn C_floating(s: str, t: TypeRef) -> ValueRef { +fn C_floating(s: ~str, t: TypeRef) -> ValueRef { ret str::as_c_str(s, |buf| llvm::LLVMConstRealOfString(t, buf)); } @@ -834,7 +834,7 @@ fn C_uint(cx: @crate_ctxt, i: uint) -> ValueRef { // This is a 'c-like' raw string, which differs from // our boxed-and-length-annotated strings. -fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { +fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef { alt cx.const_cstr_cache.find(s) { some(llval) { ret llval; } none { } @@ -844,7 +844,7 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { llvm::LLVMConstString(buf, str::len(s) as c_uint, False) }; let g = - str::as_c_str(cx.names("str"), + str::as_c_str(cx.names(~"str"), |buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf)); llvm::LLVMSetInitializer(g, sc); llvm::LLVMSetGlobalConstant(g, True); @@ -855,13 +855,13 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { ret g; } -fn C_estr_slice(cx: @crate_ctxt, s: str) -> ValueRef { +fn C_estr_slice(cx: @crate_ctxt, s: ~str) -> ValueRef { let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s), T_ptr(T_i8())); C_struct(~[cs, C_uint(cx, str::len(s) + 1u /* +1 for null */)]) } // Returns a Plain Old LLVM String: -fn C_postr(s: str) -> ValueRef { +fn C_postr(s: ~str) -> ValueRef { ret do str::as_c_str(s) |buf| { llvm::LLVMConstString(buf, str::len(s) as c_uint, False) }; @@ -898,7 +898,7 @@ fn C_bytes(bytes: ~[u8]) -> ValueRef unsafe { fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef { let llshape = C_bytes(bytes); - let llglobal = str::as_c_str(ccx.names("shape"), |buf| { + let llglobal = str::as_c_str(ccx.names(~"shape"), |buf| { llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf) }); llvm::LLVMSetInitializer(llglobal, llshape); @@ -952,12 +952,12 @@ fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef { ret build::And(cx, bumped, build::Not(cx, mask)); } -fn path_str(p: path) -> str { - let mut r = "", first = true; +fn path_str(p: path) -> ~str { + let mut r = ~"", first = true; for vec::each(p) |e| { alt e { ast_map::path_name(s) | ast_map::path_mod(s) { if first { first = false; } - else { r += "::"; } + else { r += ~"::"; } r += *s; } } } diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index bbef68aaad67..b18569a093b9 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -47,7 +47,7 @@ const DW_ATE_unsigned: int = 0x07; const DW_ATE_unsigned_char: int = 0x08; -fn llstr(s: str) -> ValueRef { +fn llstr(s: ~str) -> ValueRef { str::as_c_str(s, |sbuf| { llvm::LLVMMDString(sbuf, str::len(s) as libc::c_uint) }) @@ -75,7 +75,7 @@ fn llnull() -> ValueRef unsafe { unsafe::reinterpret_cast(ptr::null::()) } -fn add_named_metadata(cx: @crate_ctxt, name: str, val: ValueRef) { +fn add_named_metadata(cx: @crate_ctxt, name: ~str, val: ValueRef) { str::as_c_str(name, |sbuf| { llvm::LLVMAddNamedMetadataOperand(cx.llmod, sbuf, val) }) @@ -86,10 +86,10 @@ fn add_named_metadata(cx: @crate_ctxt, name: str, val: ValueRef) { type debug_ctxt = { llmetadata: metadata_cache, names: namegen, - crate_file: str + crate_file: ~str }; -fn mk_ctxt(crate: str) -> debug_ctxt { +fn mk_ctxt(crate: ~str) -> debug_ctxt { {llmetadata: map::int_hash(), names: new_namegen(), crate_file: crate} @@ -106,8 +106,8 @@ fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) { type metadata = {node: ValueRef, data: T}; -type file_md = {path: str}; -type compile_unit_md = {name: str}; +type file_md = {path: ~str}; +type compile_unit_md = {name: ~str}; type subprogram_md = {id: ast::node_id}; type local_var_md = {id: ast::node_id}; type tydesc_md = {hash: uint}; @@ -181,11 +181,11 @@ fn create_compile_unit(cx: @crate_ctxt) llstr(#env["CFG_VERSION"]), lli1(true), // deprecated: main compile unit lli1(cx.sess.opts.optimize != 0u), - llstr(""), // flags (???) + llstr(~""), // flags (???) lli32(0) // runtime version (???) ]; let unit_node = llmdnode(unit_metadata); - add_named_metadata(cx, "llvm.dbg.cu", unit_node); + add_named_metadata(cx, ~"llvm.dbg.cu", unit_node); let mdval = @{node: unit_node, data: {name: crate_name}}; update_cache(cache, tg, compile_unit_metadata(mdval)); @@ -196,7 +196,7 @@ fn get_cache(cx: @crate_ctxt) -> metadata_cache { option::get(cx.dbg_cx).llmetadata } -fn get_file_path_and_dir(work_dir: str, full_path: str) -> (str, str) { +fn get_file_path_and_dir(work_dir: ~str, full_path: ~str) -> (~str, ~str) { (if str::starts_with(full_path, work_dir) { str::slice(full_path, str::len(work_dir) + 1u, str::len(full_path)) @@ -205,7 +205,7 @@ fn get_file_path_and_dir(work_dir: str, full_path: str) -> (str, str) { }, work_dir) } -fn create_file(cx: @crate_ctxt, full_path: str) -> @metadata { +fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata { let cache = get_cache(cx);; let tg = FileDescriptorTag; alt cached_metadata::<@metadata>( @@ -292,26 +292,26 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) } let (name, encoding) = alt check ty { - ast::ty_bool {("bool", DW_ATE_boolean)} + ast::ty_bool {(~"bool", DW_ATE_boolean)} ast::ty_int(m) { alt m { - ast::ty_char {("char", DW_ATE_unsigned)} - ast::ty_i {("int", DW_ATE_signed)} - ast::ty_i8 {("i8", DW_ATE_signed_char)} - ast::ty_i16 {("i16", DW_ATE_signed)} - ast::ty_i32 {("i32", DW_ATE_signed)} - ast::ty_i64 {("i64", DW_ATE_signed)} + ast::ty_char {(~"char", DW_ATE_unsigned)} + ast::ty_i {(~"int", DW_ATE_signed)} + ast::ty_i8 {(~"i8", DW_ATE_signed_char)} + ast::ty_i16 {(~"i16", DW_ATE_signed)} + ast::ty_i32 {(~"i32", DW_ATE_signed)} + ast::ty_i64 {(~"i64", DW_ATE_signed)} }} ast::ty_uint(m) { alt m { - ast::ty_u {("uint", DW_ATE_unsigned)} - ast::ty_u8 {("u8", DW_ATE_unsigned_char)} - ast::ty_u16 {("u16", DW_ATE_unsigned)} - ast::ty_u32 {("u32", DW_ATE_unsigned)} - ast::ty_u64 {("u64", DW_ATE_unsigned)} + ast::ty_u {(~"uint", DW_ATE_unsigned)} + ast::ty_u8 {(~"u8", DW_ATE_unsigned_char)} + ast::ty_u16 {(~"u16", DW_ATE_unsigned)} + ast::ty_u32 {(~"u32", DW_ATE_unsigned)} + ast::ty_u64 {(~"u64", DW_ATE_unsigned)} }} ast::ty_float(m) { alt m { - ast::ty_f {("float", DW_ATE_float)} - ast::ty_f32 {("f32", DW_ATE_float)} - ast::ty_f64 {("f64", DW_ATE_float)} + ast::ty_f {(~"float", DW_ATE_float)} + ast::ty_f32 {(~"f32", DW_ATE_float)} + ast::ty_f64 {(~"f64", DW_ATE_float)} }} }; @@ -332,7 +332,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) let llnode = llmdnode(lldata); let mdval = @{node: llnode, data: {hash: ty::type_id(t)}}; update_cache(cache, tg, tydesc_metadata(mdval)); - add_named_metadata(cx, "llvm.dbg.ty", llnode); + add_named_metadata(cx, ~"llvm.dbg.ty", llnode); ret mdval; } @@ -350,17 +350,17 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span, let fname = filename_from_span(cx, span); let file_node = create_file(cx, fname); //let cu_node = create_compile_unit(cx, fname); - let llnode = create_derived_type(tg, file_node.node, "", 0, size * 8, + let llnode = create_derived_type(tg, file_node.node, ~"", 0, size * 8, align * 8, 0, pointee.node); let mdval = @{node: llnode, data: {hash: ty::type_id(t)}}; //update_cache(cache, tg, tydesc_metadata(mdval)); - add_named_metadata(cx, "llvm.dbg.ty", llnode); + add_named_metadata(cx, ~"llvm.dbg.ty", llnode); ret mdval; } type struct_ctxt = { file: ValueRef, - name: str, + name: ~str, line: int, mut members: ~[ValueRef], mut total_size: int, @@ -373,7 +373,7 @@ fn finish_structure(cx: @struct_ctxt) -> ValueRef { option::some(cx.members)); } -fn create_structure(file: @metadata, name: str, line: int) +fn create_structure(file: @metadata, name: ~str, line: int) -> @struct_ctxt { let cx = @{file: file.node, name: name, @@ -385,7 +385,7 @@ fn create_structure(file: @metadata, name: str, line: int) ret cx; } -fn create_derived_type(type_tag: int, file: ValueRef, name: str, line: int, +fn create_derived_type(type_tag: int, file: ValueRef, name: ~str, line: int, size: int, align: int, offset: int, ty: ValueRef) -> ValueRef { let lldata = ~[lltag(type_tag), @@ -401,7 +401,7 @@ fn create_derived_type(type_tag: int, file: ValueRef, name: str, line: int, ret llmdnode(lldata); } -fn add_member(cx: @struct_ctxt, name: str, line: int, size: int, align: int, +fn add_member(cx: @struct_ctxt, name: ~str, line: int, size: int, align: int, ty: ValueRef) { vec::push(cx.members, create_derived_type(MemberTag, cx.file, name, line, size * 8, align * 8, cx.total_size, @@ -414,7 +414,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: ~[ast::ty_field], let fname = filename_from_span(cx, span); let file_node = create_file(cx, fname); let scx = create_structure(file_node, - option::get(cx.dbg_cx).names("rec"), + option::get(cx.dbg_cx).names(~"rec"), line_from_span(cx.sess.codemap, span) as int); for fields.each |field| { @@ -446,19 +446,19 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t, let refcount_type = create_basic_type(cx, uint_t, ast::ty_uint(ast::ty_u), span); let scx = create_structure(file_node, ty_to_str(cx.tcx, outer), 0); - add_member(scx, "refcnt", 0, sys::size_of::() as int, + add_member(scx, ~"refcnt", 0, sys::size_of::() as int, sys::min_align_of::() as int, refcount_type.node); - add_member(scx, "boxed", 0, 8, //XXX member_size_and_align(??) + add_member(scx, ~"boxed", 0, 8, //XXX member_size_and_align(??) 8, //XXX just a guess boxed.node); let llnode = finish_structure(scx); let mdval = @{node: llnode, data: {hash: ty::type_id(outer)}}; //update_cache(cache, tg, tydesc_metadata(mdval)); - add_named_metadata(cx, "llvm.dbg.ty", llnode); + add_named_metadata(cx, ~"llvm.dbg.ty", llnode); ret mdval; } -fn create_composite_type(type_tag: int, name: str, file: ValueRef, line: int, +fn create_composite_type(type_tag: int, name: ~str, file: ValueRef, line: int, size: int, align: int, offset: int, derived: option, members: option<~[ValueRef]>) @@ -497,17 +497,17 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t, let scx = create_structure(file_node, ty_to_str(cx.tcx, vec_t), 0); let size_t_type = create_basic_type(cx, ty::mk_uint(cx.tcx), ast::ty_uint(ast::ty_u), vec_ty_span); - add_member(scx, "fill", 0, sys::size_of::() as int, + add_member(scx, ~"fill", 0, sys::size_of::() as int, sys::min_align_of::() as int, size_t_type.node); - add_member(scx, "alloc", 0, sys::size_of::() as int, + add_member(scx, ~"alloc", 0, sys::size_of::() as int, sys::min_align_of::() as int, size_t_type.node); let subrange = llmdnode(~[lltag(SubrangeTag), lli64(0), lli64(0)]); let (arr_size, arr_align) = size_and_align_of(cx, elem_t); - let data_ptr = create_composite_type(ArrayTypeTag, "", file_node.node, 0, + let data_ptr = create_composite_type(ArrayTypeTag, ~"", file_node.node, 0, arr_size, arr_align, 0, option::some(elem_ty_md.node), option::some(~[subrange])); - add_member(scx, "data", 0, 0, // clang says the size should be 0 + add_member(scx, ~"data", 0, 0, // clang says the size should be 0 sys::min_align_of::() as int, data_ptr); let llnode = finish_structure(scx); ret @{node: llnode, data: {hash: ty::type_id(vec_t)}}; @@ -617,11 +617,11 @@ fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty { */ } -fn filename_from_span(cx: @crate_ctxt, sp: codemap::span) -> str { +fn filename_from_span(cx: @crate_ctxt, sp: codemap::span) -> ~str { codemap::lookup_char_pos(cx.sess.codemap, sp.lo).file.name } -fn create_var(type_tag: int, context: ValueRef, name: str, file: ValueRef, +fn create_var(type_tag: int, context: ValueRef, name: ~str, file: ValueRef, line: int, ret_ty: ValueRef) -> ValueRef { let lldata = ~[lltag(type_tag), context, @@ -648,7 +648,7 @@ fn create_local_var(bcx: block, local: @ast::local) let name = alt local.node.pat.node { ast::pat_ident(pth, _) { ast_util::path_to_ident(pth) } // FIXME this should be handled (#2533) - _ { fail "no single variable name for local"; } + _ { fail ~"no single variable name for local"; } }; let loc = codemap::lookup_char_pos(cx.sess.codemap, local.span.lo); @@ -667,19 +667,19 @@ fn create_local_var(bcx: block, local: @ast::local) let llptr = alt bcx.fcx.lllocals.find(local.node.id) { option::some(local_mem(v)) { v } option::some(_) { - bcx.tcx().sess.span_bug(local.span, "local is bound to \ + bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ something weird"); } option::none { alt bcx.fcx.lllocals.get(local.node.pat.id) { local_imm(v) { v } - _ { bcx.tcx().sess.span_bug(local.span, "local is bound to \ + _ { bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ something weird"); } } } }; let declargs = ~[llmdnode(~[llptr]), mdnode]; - trans::build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"), + trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"), declargs); ret mdval; } @@ -710,7 +710,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) local_mem(v) | local_imm(v) { v } }; let declargs = ~[llmdnode(~[llptr]), mdnode]; - trans::build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"), + trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"), declargs); ret mdval; } @@ -746,7 +746,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata { ast::item_fn(decl, _, _) { (item.ident, decl.output, item.id) } - _ { fcx.ccx.sess.span_bug(item.span, "create_function: item \ + _ { fcx.ccx.sess.span_bug(item.span, ~"create_function: item \ bound to non-function"); } } } @@ -760,16 +760,16 @@ fn create_function(fcx: fn_ctxt) -> @metadata { ast_map::node_expr(expr) { alt expr.node { ast::expr_fn(_, decl, _, _) { - (@dbg_cx.names("fn"), decl.output, expr.id) + (@dbg_cx.names(~"fn"), decl.output, expr.id) } ast::expr_fn_block(decl, _, _) { - (@dbg_cx.names("fn"), decl.output, expr.id) + (@dbg_cx.names(~"fn"), decl.output, expr.id) } - _ { fcx.ccx.sess.span_bug(expr.span, "create_function: \ + _ { fcx.ccx.sess.span_bug(expr.span, ~"create_function: \ expected an expr_fn or fn_block here"); } } } - _ { fcx.ccx.sess.bug("create_function: unexpected \ + _ { fcx.ccx.sess.bug(~"create_function: unexpected \ sort of node"); } }; @@ -794,7 +794,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata { } else { llnull() }; - let sub_node = create_composite_type(SubroutineTag, "", file_node, 0, 0, + let sub_node = create_composite_type(SubroutineTag, ~"", file_node, 0, 0, 0, 0, option::none, option::some(~[ty_node])); @@ -803,7 +803,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata { file_node, llstr(*ident), llstr(*ident), //XXX fully-qualified C++ name - llstr(""), //XXX MIPS name????? + llstr(~""), //XXX MIPS name????? file_node, lli32(loc.line as int), sub_node, @@ -820,7 +820,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata { //list of func vars ]; let val = llmdnode(fn_metadata); - add_named_metadata(cx, "llvm.dbg.sp", val); + add_named_metadata(cx, ~"llvm.dbg.sp", val); let mdval = @{node: val, data: {id: id}}; update_cache(cache, SubprogramTag, subprogram_metadata(mdval)); diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 859dd5b2d69d..847aca0db2c4 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -90,7 +90,7 @@ fn ty_align(ty: TypeRef) -> uint { ty_align(elt) } _ { - fail "ty_size: unhandled type" + fail ~"ty_size: unhandled type" } }; } @@ -115,7 +115,7 @@ fn ty_size(ty: TypeRef) -> uint { len * eltsz } _ { - fail "ty_size: unhandled type" + fail ~"ty_size: unhandled type" } }; } @@ -212,7 +212,7 @@ fn classify(ty: TypeRef, } } _ { - fail "classify: unhandled type"; + fail ~"classify: unhandled type"; } } } @@ -310,7 +310,7 @@ fn llvec_len(cls: ~[x86_64_reg_class]) -> uint { vec::push(tys, T_f64()); } _ { - fail "llregtype: unhandled class"; + fail ~"llregtype: unhandled class"; } } i += 1u; @@ -420,8 +420,8 @@ fn decl_x86_64_fn(tys: x86_64_tys, ret llfn; } -fn link_name(i: @ast::foreign_item) -> str { - alt attr::first_attr_value_str_by_name(i.attrs, "link_name") { +fn link_name(i: @ast::foreign_item) -> ~str { + alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { none { ret *i.ident; } option::some(ln) { ret *ln; } } @@ -444,7 +444,7 @@ fn c_arg_and_ret_lltys(ccx: @crate_ctxt, let llretty = type_of::type_of(ccx, ret_ty); (llargtys, llretty, ret_ty) } - _ { ccx.sess.bug("c_arg_and_ret_lltys called on non-function type"); } + _ { ccx.sess.bug(~"c_arg_and_ret_lltys called on non-function type"); } } } @@ -475,7 +475,7 @@ fn c_stack_tys(ccx: @crate_ctxt, llargbundle: ValueRef, llretval: ValueRef); fn build_shim_fn_(ccx: @crate_ctxt, - shim_name: str, + shim_name: ~str, llbasefn: ValueRef, tys: @c_stack_tys, cc: lib::llvm::CallConv, @@ -519,7 +519,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt, arg_builder: wrap_arg_builder, ret_builder: wrap_ret_builder) { - let _icx = ccx.insn_ctxt("foreign::build_wrap_fn_"); + let _icx = ccx.insn_ctxt(~"foreign::build_wrap_fn_"); let fcx = new_fn_ctxt(ccx, ~[], llwrapfn, none); let bcx = top_scope_block(fcx, none); let lltop = bcx.llbb; @@ -579,18 +579,18 @@ fn build_wrap_fn_(ccx: @crate_ctxt, fn trans_foreign_mod(ccx: @crate_ctxt, foreign_mod: ast::foreign_mod, abi: ast::foreign_abi) { - let _icx = ccx.insn_ctxt("foreign::trans_foreign_mod"); + let _icx = ccx.insn_ctxt(~"foreign::trans_foreign_mod"); fn build_shim_fn(ccx: @crate_ctxt, foreign_item: @ast::foreign_item, tys: @c_stack_tys, cc: lib::llvm::CallConv) -> ValueRef { - let _icx = ccx.insn_ctxt("foreign::build_shim_fn"); + let _icx = ccx.insn_ctxt(~"foreign::build_shim_fn"); fn build_args(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef) -> ~[ValueRef] { - let _icx = bcx.insn_ctxt("foreign::shim::build_args"); + let _icx = bcx.insn_ctxt(~"foreign::shim::build_args"); let mut llargvals = ~[]; let mut i = 0u; let n = vec::len(tys.arg_tys); @@ -636,7 +636,7 @@ fn build_args(bcx: block, tys: @c_stack_tys, fn build_ret(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef, llretval: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::shim::build_ret"); + let _icx = bcx.insn_ctxt(~"foreign::shim::build_ret"); alt tys.x86_64_tys { some(x86_64) { do vec::iteri(x86_64.attrs) |i, a| { @@ -680,12 +680,12 @@ fn build_ret(bcx: block, tys: @c_stack_tys, let lname = link_name(foreign_item); let llbasefn = base_fn(ccx, lname, tys, cc); // Name the shim function - let shim_name = lname + "__c_stack_shim"; + let shim_name = lname + ~"__c_stack_shim"; ret build_shim_fn_(ccx, shim_name, llbasefn, tys, cc, build_args, build_ret); } - fn base_fn(ccx: @crate_ctxt, lname: str, tys: @c_stack_tys, + fn base_fn(ccx: @crate_ctxt, lname: ~str, tys: @c_stack_tys, cc: lib::llvm::CallConv) -> ValueRef { // Declare the "prototype" for the base function F: alt tys.x86_64_tys { @@ -727,11 +727,11 @@ fn build_wrap_fn(ccx: @crate_ctxt, llshimfn: ValueRef, llwrapfn: ValueRef) { - let _icx = ccx.insn_ctxt("foreign::build_wrap_fn"); + let _icx = ccx.insn_ctxt(~"foreign::build_wrap_fn"); fn build_args(bcx: block, tys: @c_stack_tys, llwrapfn: ValueRef, llargbundle: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::wrap::build_args"); + let _icx = bcx.insn_ctxt(~"foreign::wrap::build_args"); let mut i = 0u; let n = vec::len(tys.arg_tys); let implicit_args = first_real_arg; // ret + env @@ -746,7 +746,7 @@ fn build_args(bcx: block, tys: @c_stack_tys, fn build_ret(bcx: block, _tys: @c_stack_tys, _llargbundle: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::wrap::build_ret"); + let _icx = bcx.insn_ctxt(~"foreign::wrap::build_ret"); RetVoid(bcx); } @@ -768,7 +768,8 @@ fn build_ret(bcx: block, _tys: @c_stack_tys, if abi != ast::foreign_abi_rust_intrinsic { let llwrapfn = get_item_val(ccx, id); let tys = c_stack_tys(ccx, id); - if attr::attrs_contains_name(foreign_item.attrs, "rust_stack") { + if attr::attrs_contains_name(foreign_item.attrs, + ~"rust_stack") { build_direct_fn(ccx, llwrapfn, foreign_item, tys, cc); } else { let llshimfn = build_shim_fn(ccx, foreign_item, tys, cc); @@ -783,7 +784,7 @@ fn build_ret(bcx: block, _tys: @c_stack_tys, some(ast_map::node_foreign_item(_, _, pt)) { pt } _ { ccx.sess.span_bug(foreign_item.span, - "can't find intrinsic path") + ~"can't find intrinsic path") } }; let psubsts = { @@ -807,76 +808,76 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, some(substs), some(item.span)); let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb; alt check *item.ident { - "atomic_xchng" { + ~"atomic_xchng" { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - "atomic_xchng_acq" { + ~"atomic_xchng_acq" { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - "atomic_xchng_rel" { + ~"atomic_xchng_rel" { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Release); Store(bcx, old, fcx.llretptr); } - "atomic_add" { + ~"atomic_add" { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - "atomic_add_acq" { + ~"atomic_add_acq" { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - "atomic_add_rel" { + ~"atomic_add_rel" { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Release); Store(bcx, old, fcx.llretptr); } - "atomic_sub" { + ~"atomic_sub" { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - "atomic_sub_acq" { + ~"atomic_sub_acq" { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - "atomic_sub_rel" { + ~"atomic_sub_rel" { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Release); Store(bcx, old, fcx.llretptr); } - "size_of" { + ~"size_of" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); Store(bcx, C_uint(ccx, shape::llsize_of_real(ccx, lltp_ty)), fcx.llretptr); } - "move_val" { + ~"move_val" { let tp_ty = substs.tys[0]; let src = {bcx: bcx, val: get_param(decl, first_real_arg + 1u), @@ -886,7 +887,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, src, tp_ty); } - "move_val_init" { + ~"move_val_init" { let tp_ty = substs.tys[0]; let src = {bcx: bcx, val: get_param(decl, first_real_arg + 1u), @@ -896,19 +897,19 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, src, tp_ty); } - "min_align_of" { + ~"min_align_of" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); Store(bcx, C_uint(ccx, shape::llalign_of_min(ccx, lltp_ty)), fcx.llretptr); } - "pref_align_of" { + ~"pref_align_of" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); Store(bcx, C_uint(ccx, shape::llalign_of_pref(ccx, lltp_ty)), fcx.llretptr); } - "get_tydesc" { + ~"get_tydesc" { let tp_ty = substs.tys[0]; let static_ti = get_tydesc(ccx, tp_ty); lazily_emit_all_tydesc_glue(ccx, static_ti); @@ -917,15 +918,15 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, let td = PointerCast(bcx, static_ti.tydesc, T_ptr(T_nil())); Store(bcx, td, fcx.llretptr); } - "init" { + ~"init" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); if !ty::type_is_nil(tp_ty) { Store(bcx, C_null(lltp_ty), fcx.llretptr); } } - "forget" {} - "reinterpret_cast" { + ~"forget" {} + ~"reinterpret_cast" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); let llout_ty = type_of::type_of(ccx, substs.tys[1]); @@ -947,23 +948,23 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, Store(bcx, Load(bcx, cast), fcx.llretptr); } } - "addr_of" { + ~"addr_of" { Store(bcx, get_param(decl, first_real_arg), fcx.llretptr); } - "needs_drop" { + ~"needs_drop" { let tp_ty = substs.tys[0]; Store(bcx, C_bool(ty::type_needs_drop(ccx.tcx, tp_ty)), fcx.llretptr); } - "visit_tydesc" { + ~"visit_tydesc" { let td = get_param(decl, first_real_arg); let visitor = get_param(decl, first_real_arg + 1u); let td = PointerCast(bcx, td, T_ptr(ccx.tydesc_type)); call_tydesc_glue_full(bcx, visitor, td, abi::tydesc_field_visit_glue, none); } - "frame_address" { - let frameaddress = ccx.intrinsics.get("llvm.frameaddress"); + ~"frame_address" { + let frameaddress = ccx.intrinsics.get(~"llvm.frameaddress"); let frameaddress_val = Call(bcx, frameaddress, ~[C_i32(0i32)]); let fty = ty::mk_fn(bcx.tcx(), { purity: ast::impure_fn, @@ -993,15 +994,15 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, body: ast::blk, llwrapfn: ValueRef, id: ast::node_id) { - let _icx = ccx.insn_ctxt("foreign::build_foreign_fn"); + let _icx = ccx.insn_ctxt(~"foreign::build_foreign_fn"); fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, body: ast::blk, id: ast::node_id) -> ValueRef { - let _icx = ccx.insn_ctxt("foreign::foreign::build_rust_fn"); + let _icx = ccx.insn_ctxt(~"foreign::foreign::build_rust_fn"); let t = ty::node_id_to_type(ccx.tcx, id); let ps = link::mangle_internal_name_by_path( - ccx, vec::append_one(path, ast_map::path_name(@"__rust_abi"))); + ccx, vec::append_one(path, ast_map::path_name(@~"__rust_abi"))); let llty = type_of_fn_from_ty(ccx, t); let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty); trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id); @@ -1011,11 +1012,11 @@ fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path, fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path, llrustfn: ValueRef, tys: @c_stack_tys) -> ValueRef { - let _icx = ccx.insn_ctxt("foreign::foreign::build_shim_fn"); + let _icx = ccx.insn_ctxt(~"foreign::foreign::build_shim_fn"); fn build_args(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef) -> ~[ValueRef] { - let _icx = bcx.insn_ctxt("foreign::extern::shim::build_args"); + let _icx = bcx.insn_ctxt(~"foreign::extern::shim::build_args"); let mut llargvals = ~[]; let mut i = 0u; let n = vec::len(tys.arg_tys); @@ -1039,7 +1040,7 @@ fn build_ret(_bcx: block, _tys: @c_stack_tys, let shim_name = link::mangle_internal_name_by_path( ccx, vec::append_one(path, - ast_map::path_name(@"__rust_stack_shim"))); + ast_map::path_name(@~"__rust_stack_shim"))); ret build_shim_fn_(ccx, shim_name, llrustfn, tys, lib::llvm::CCallConv, build_args, build_ret); @@ -1048,11 +1049,11 @@ fn build_ret(_bcx: block, _tys: @c_stack_tys, fn build_wrap_fn(ccx: @crate_ctxt, llshimfn: ValueRef, llwrapfn: ValueRef, tys: @c_stack_tys) { - let _icx = ccx.insn_ctxt("foreign::foreign::build_wrap_fn"); + let _icx = ccx.insn_ctxt(~"foreign::foreign::build_wrap_fn"); fn build_args(bcx: block, tys: @c_stack_tys, llwrapfn: ValueRef, llargbundle: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_args"); + let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_args"); alt tys.x86_64_tys { option::some(x86_64) { let mut atys = x86_64.arg_tys; @@ -1106,7 +1107,7 @@ fn build_args(bcx: block, tys: @c_stack_tys, fn build_ret(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_ret"); + let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_ret"); alt tys.x86_64_tys { option::some(x86_64) { if x86_64.sret || !tys.ret_def { @@ -1150,7 +1151,7 @@ fn build_ret(bcx: block, tys: @c_stack_tys, fn register_foreign_fn(ccx: @crate_ctxt, sp: span, path: ast_map::path, node_id: ast::node_id) -> ValueRef { - let _icx = ccx.insn_ctxt("foreign::register_foreign_fn"); + let _icx = ccx.insn_ctxt(~"foreign::register_foreign_fn"); let t = ty::node_id_to_type(ccx.tcx, node_id); let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id); ret if ccx.sess.targ_cfg.arch == arch_x86_64 { @@ -1169,7 +1170,7 @@ fn register_foreign_fn(ccx: @crate_ctxt, sp: span, fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item) -> ast::foreign_abi { - alt attr::first_attr_value_str_by_name(i.attrs, "abi") { + alt attr::first_attr_value_str_by_name(i.attrs, ~"abi") { none { alt check ccx.tcx.items.get(i.id) { ast_map::node_foreign_item(_, abi, _) { abi } diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index 2ebddb0038f7..8ea0583b81b4 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -17,7 +17,7 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, methods: ~[@ast::method], tps: ~[ast::ty_param]) { - let _icx = ccx.insn_ctxt("impl::trans_impl"); + let _icx = ccx.insn_ctxt(~"impl::trans_impl"); if tps.len() > 0u { ret; } let sub_path = vec::append_one(path, path_name(name)); for vec::each(methods) |m| { @@ -33,7 +33,7 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, } fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result { - let _icx = bcx.insn_ctxt("impl::trans_self_arg"); + let _icx = bcx.insn_ctxt(~"impl::trans_self_arg"); let basety = expr_ty(bcx, base); let m_by_ref = ast::expl(ast::by_ref); let mut temp_cleanups = ~[]; @@ -51,7 +51,7 @@ fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result { fn trans_method_callee(bcx: block, callee_id: ast::node_id, self: @ast::expr, mentry: typeck::method_map_entry) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("impl::trans_method_callee"); + let _icx = bcx.insn_ctxt(~"impl::trans_method_callee"); alt mentry.origin { typeck::method_static(did) { let {bcx, val} = trans_self_arg(bcx, self, mentry.derefs); @@ -115,7 +115,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, trait_id: ast::def_id, n_method: uint, n_param: uint, n_bound: uint, substs: param_substs) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("impl::trans_monomorphized_callee"); + let _icx = bcx.insn_ctxt(~"impl::trans_monomorphized_callee"); alt find_vtable_in_fn_ctxt(substs, n_param, n_bound) { typeck::vtable_static(impl_did, impl_substs, sub_origins) { let ccx = bcx.ccx(); @@ -141,7 +141,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, trans_trait_callee(bcx, val, fty, n_method) } typeck::vtable_param(n_param, n_bound) { - fail "vtable_param left in monomorphized function's vtable substs"; + fail ~"vtable_param left in monomorphized function's vtable substs"; } } } @@ -150,7 +150,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, fn trans_trait_callee(bcx: block, val: ValueRef, callee_ty: ty::t, n_method: uint) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("impl::trans_trait_callee"); + let _icx = bcx.insn_ctxt(~"impl::trans_trait_callee"); let ccx = bcx.ccx(); let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, ~[0u, 0u]), T_ptr(T_ptr(T_vtable())))); @@ -238,9 +238,9 @@ fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin) } fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef { - let _icx = ccx.insn_ctxt("impl::make_vtable"); + let _icx = ccx.insn_ctxt(~"impl::make_vtable"); let tbl = C_struct(ptrs); - let vt_gvar = str::as_c_str(ccx.names("vtable"), |buf| { + let vt_gvar = str::as_c_str(ccx.names(~"vtable"), |buf| { llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl), buf) }); llvm::LLVMSetInitializer(vt_gvar, tbl); @@ -251,12 +251,12 @@ fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef { fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t], vtables: typeck::vtable_res) -> ValueRef { - let _icx = ccx.insn_ctxt("impl::make_impl_vtable"); + let _icx = ccx.insn_ctxt(~"impl::make_impl_vtable"); let tcx = ccx.tcx; let ifce_id = expect(ccx.sess, ty::ty_to_def_id(option::get(ty::impl_trait(tcx, impl_id))), - || "make_impl_vtable: non-trait-type implemented"); + || ~"make_impl_vtable: non-trait-type implemented"); let has_tps = (*ty::lookup_item_type(ccx.tcx, impl_id).bounds).len() > 0u; make_vtable(ccx, vec::map(*ty::trait_methods(tcx, ifce_id), |im| { let fty = ty::subst_tps(tcx, substs, ty::mk_fn(tcx, im.fty)); @@ -282,7 +282,7 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t], fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest) -> block { - let _icx = bcx.insn_ctxt("impl::trans_cast"); + let _icx = bcx.insn_ctxt(~"impl::trans_cast"); if dest == ignore { ret trans_expr(bcx, val, ignore); } let ccx = bcx.ccx(); let v_ty = expr_ty(bcx, val); diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index 39e0461dee6b..7a371e7a5fde 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -136,7 +136,7 @@ fn traverse_public_item(cx: ctx, item: @item) { } item_const(*) | item_enum(*) | item_trait(*) {} - item_mac(*) { fail "item macros unimplemented" } + item_mac(*) { fail ~"item macros unimplemented" } } } diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index 06adbf68dacf..56ad6f136327 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -28,7 +28,7 @@ fn c_int(i: int) -> ValueRef { C_int(self.bcx.ccx(), i) } - fn c_slice(s: str) -> ValueRef { + fn c_slice(s: ~str) -> ValueRef { let ss = C_estr_slice(self.bcx.ccx(), s); do_spill_noroot(self.bcx, ss) } @@ -53,9 +53,9 @@ fn c_mt(mt: ty::mt) -> ~[ValueRef] { self.c_tydesc(mt.ty)] } - fn visit(ty_name: str, args: ~[ValueRef]) { + fn visit(ty_name: ~str, args: ~[ValueRef]) { let tcx = self.bcx.tcx(); - let mth_idx = option::get(ty::method_idx(@("visit_" + ty_name), + let mth_idx = option::get(ty::method_idx(@(~"visit_" + ty_name), *self.visitor_methods)); let mth_ty = ty::mk_fn(tcx, self.visitor_methods[mth_idx].fty); let v = self.visitor_val; @@ -76,34 +76,34 @@ fn visit(ty_name: str, args: ~[ValueRef]) { let bcx = trans_call_inner(self.bcx, none, mth_ty, ty::mk_bool(tcx), get_lval, arg_vals(args), by_val(d)); - let next_bcx = sub_block(bcx, "next"); + let next_bcx = sub_block(bcx, ~"next"); CondBr(bcx, *d, next_bcx.llbb, self.final_bcx.llbb); self.bcx = next_bcx } - fn bracketed(bracket_name: str, extra: ~[ValueRef], + fn bracketed(bracket_name: ~str, extra: ~[ValueRef], inner: fn()) { - self.visit("enter_" + bracket_name, extra); + self.visit(~"enter_" + bracket_name, extra); inner(); - self.visit("leave_" + bracket_name, extra); + self.visit(~"leave_" + bracket_name, extra); } fn vstore_name_and_extra(t: ty::t, vstore: ty::vstore, - f: fn(str,~[ValueRef])) { + f: fn(~str,~[ValueRef])) { alt vstore { ty::vstore_fixed(n) { let extra = vec::append(~[self.c_uint(n)], self.c_size_and_align(t)); - f("fixed", extra) + f(~"fixed", extra) } - ty::vstore_slice(_) { f("slice", ~[]) } - ty::vstore_uniq { f("uniq", ~[]);} - ty::vstore_box { f("box", ~[]); } + ty::vstore_slice(_) { f(~"slice", ~[]) } + ty::vstore_uniq { f(~"uniq", ~[]);} + ty::vstore_box { f(~"box", ~[]); } } } - fn leaf(name: str) { + fn leaf(name: ~str) { self.visit(name, ~[]); } @@ -115,49 +115,49 @@ fn visit_ty(t: ty::t) { ty_to_str(bcx.ccx().tcx, t)); alt ty::get(t).struct { - ty::ty_bot { self.leaf("bot") } - ty::ty_nil { self.leaf("nil") } - ty::ty_bool { self.leaf("bool") } - ty::ty_int(ast::ty_i) { self.leaf("int") } - ty::ty_int(ast::ty_char) { self.leaf("char") } - ty::ty_int(ast::ty_i8) { self.leaf("i8") } - ty::ty_int(ast::ty_i16) { self.leaf("i16") } - ty::ty_int(ast::ty_i32) { self.leaf("i32") } - ty::ty_int(ast::ty_i64) { self.leaf("i64") } - ty::ty_uint(ast::ty_u) { self.leaf("uint") } - ty::ty_uint(ast::ty_u8) { self.leaf("u8") } - ty::ty_uint(ast::ty_u16) { self.leaf("u16") } - ty::ty_uint(ast::ty_u32) { self.leaf("u32") } - ty::ty_uint(ast::ty_u64) { self.leaf("u64") } - ty::ty_float(ast::ty_f) { self.leaf("float") } - ty::ty_float(ast::ty_f32) { self.leaf("f32") } - ty::ty_float(ast::ty_f64) { self.leaf("f64") } - ty::ty_str { self.leaf("str") } + ty::ty_bot { self.leaf(~"bot") } + ty::ty_nil { self.leaf(~"nil") } + ty::ty_bool { self.leaf(~"bool") } + ty::ty_int(ast::ty_i) { self.leaf(~"int") } + ty::ty_int(ast::ty_char) { self.leaf(~"char") } + ty::ty_int(ast::ty_i8) { self.leaf(~"i8") } + ty::ty_int(ast::ty_i16) { self.leaf(~"i16") } + ty::ty_int(ast::ty_i32) { self.leaf(~"i32") } + ty::ty_int(ast::ty_i64) { self.leaf(~"i64") } + ty::ty_uint(ast::ty_u) { self.leaf(~"uint") } + ty::ty_uint(ast::ty_u8) { self.leaf(~"u8") } + ty::ty_uint(ast::ty_u16) { self.leaf(~"u16") } + ty::ty_uint(ast::ty_u32) { self.leaf(~"u32") } + ty::ty_uint(ast::ty_u64) { self.leaf(~"u64") } + ty::ty_float(ast::ty_f) { self.leaf(~"float") } + ty::ty_float(ast::ty_f32) { self.leaf(~"f32") } + ty::ty_float(ast::ty_f64) { self.leaf(~"f64") } + ty::ty_str { self.leaf(~"str") } - ty::ty_vec(mt) { self.visit("vec", self.c_mt(mt)) } - ty::ty_unboxed_vec(mt) { self.visit("vec", self.c_mt(mt)) } + ty::ty_vec(mt) { self.visit(~"vec", self.c_mt(mt)) } + ty::ty_unboxed_vec(mt) { self.visit(~"vec", self.c_mt(mt)) } ty::ty_estr(vst) { do self.vstore_name_and_extra(t, vst) |name, extra| { - self.visit("estr_" + name, extra) + self.visit(~"estr_" + name, extra) } } ty::ty_evec(mt, vst) { do self.vstore_name_and_extra(t, vst) |name, extra| { - self.visit("evec_" + name, extra + + self.visit(~"evec_" + name, extra + self.c_mt(mt)) } } - ty::ty_box(mt) { self.visit("box", self.c_mt(mt)) } - ty::ty_uniq(mt) { self.visit("uniq", self.c_mt(mt)) } - ty::ty_ptr(mt) { self.visit("ptr", self.c_mt(mt)) } - ty::ty_rptr(_, mt) { self.visit("rptr", self.c_mt(mt)) } + ty::ty_box(mt) { self.visit(~"box", self.c_mt(mt)) } + ty::ty_uniq(mt) { self.visit(~"uniq", self.c_mt(mt)) } + ty::ty_ptr(mt) { self.visit(~"ptr", self.c_mt(mt)) } + ty::ty_rptr(_, mt) { self.visit(~"rptr", self.c_mt(mt)) } ty::ty_rec(fields) { - do self.bracketed("rec", + do self.bracketed(~"rec", ~[self.c_uint(vec::len(fields))] + self.c_size_and_align(t)) { for fields.eachi |i, field| { - self.visit("rec_field", + self.visit(~"rec_field", ~[self.c_uint(i), self.c_slice(*field.ident)] + self.c_mt(field.mt)); @@ -166,11 +166,11 @@ fn visit_ty(t: ty::t) { } ty::ty_tup(tys) { - do self.bracketed("tup", + do self.bracketed(~"tup", ~[self.c_uint(vec::len(tys))] + self.c_size_and_align(t)) { for tys.eachi |i, t| { - self.visit("tup_field", + self.visit(~"tup_field", ~[self.c_uint(i), self.c_tydesc(t)]); } @@ -201,7 +201,7 @@ fn visit_ty(t: ty::t) { self.c_uint(protoval), self.c_uint(vec::len(fty.inputs)), self.c_uint(retval)]; - self.visit("enter_fn", extra); + self.visit(~"enter_fn", extra); for fty.inputs.eachi |i, arg| { let modeval = alt arg.mode { ast::infer(_) { 0u } @@ -215,15 +215,15 @@ fn visit_ty(t: ty::t) { } } }; - self.visit("fn_input", + self.visit(~"fn_input", ~[self.c_uint(i), self.c_uint(modeval), self.c_tydesc(arg.ty)]); } - self.visit("fn_output", + self.visit(~"fn_output", ~[self.c_uint(retval), self.c_tydesc(fty.output)]); - self.visit("leave_fn", extra); + self.visit(~"leave_fn", extra); } ty::ty_class(did, substs) { @@ -231,10 +231,10 @@ fn visit_ty(t: ty::t) { let tcx = bcx.ccx().tcx; let fields = ty::class_items_as_fields(tcx, did, substs); - do self.bracketed("class", ~[self.c_uint(vec::len(fields))] + do self.bracketed(~"class", ~[self.c_uint(vec::len(fields))] + self.c_size_and_align(t)) { for fields.eachi |i, field| { - self.visit("class_field", + self.visit(~"class_field", ~[self.c_uint(i), self.c_slice(*field.ident)] + self.c_mt(field.mt)); @@ -251,17 +251,17 @@ fn visit_ty(t: ty::t) { let tcx = bcx.ccx().tcx; let variants = ty::substd_enum_variants(tcx, did, substs); - do self.bracketed("enum", + do self.bracketed(~"enum", ~[self.c_uint(vec::len(variants))] + self.c_size_and_align(t)) { for variants.eachi |i, v| { - do self.bracketed("enum_variant", + do self.bracketed(~"enum_variant", ~[self.c_uint(i), self.c_int(v.disr_val), self.c_uint(vec::len(v.args)), self.c_slice(*v.name)]) { for v.args.eachi |j, a| { - self.visit("enum_variant_field", + self.visit(~"enum_variant_field", ~[self.c_uint(j), self.c_tydesc(a)]); } @@ -271,21 +271,21 @@ fn visit_ty(t: ty::t) { } // Miscallaneous extra types - ty::ty_trait(_, _) { self.leaf("trait") } - ty::ty_var(_) { self.leaf("var") } - ty::ty_var_integral(_) { self.leaf("var_integral") } - ty::ty_param(n, _) { self.visit("param", ~[self.c_uint(n)]) } - ty::ty_self { self.leaf("self") } - ty::ty_type { self.leaf("type") } - ty::ty_opaque_box { self.leaf("opaque_box") } - ty::ty_constr(t, _) { self.visit("constr", ~[self.c_tydesc(t)]) } + ty::ty_trait(_, _) { self.leaf(~"trait") } + ty::ty_var(_) { self.leaf(~"var") } + ty::ty_var_integral(_) { self.leaf(~"var_integral") } + ty::ty_param(n, _) { self.visit(~"param", ~[self.c_uint(n)]) } + ty::ty_self { self.leaf(~"self") } + ty::ty_type { self.leaf(~"type") } + ty::ty_opaque_box { self.leaf(~"opaque_box") } + ty::ty_constr(t, _) { self.visit(~"constr", ~[self.c_tydesc(t)]) } ty::ty_opaque_closure_ptr(ck) { let ckval = alt ck { ty::ck_block { 0u } ty::ck_box { 1u } ty::ck_uniq { 2u } }; - self.visit("closure_ptr", ~[self.c_uint(ckval)]) + self.visit(~"closure_ptr", ~[self.c_uint(ckval)]) } } } @@ -296,9 +296,9 @@ fn emit_calls_to_trait_visit_ty(bcx: block, t: ty::t, visitor_val: ValueRef, visitor_iid: def_id) -> block { - let final = sub_block(bcx, "final"); - assert bcx.ccx().tcx.intrinsic_defs.contains_key(@"tydesc"); - let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(@"tydesc"); + let final = sub_block(bcx, ~"final"); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(@~"tydesc"); + let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(@~"tydesc"); let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty); let r = reflector({ visitor_val: visitor_val, diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index f6be67b1512b..24a1591a6c88 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -97,7 +97,7 @@ fn new_nominal_id_hash() -> hashmap { const shape_slice: u8 = 33u8; const shape_unboxed_vec: u8 = 34u8; -fn mk_global(ccx: @crate_ctxt, name: str, llval: ValueRef, internal: bool) -> +fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) -> ValueRef { let llglobal = str::as_c_str(name, @@ -184,8 +184,8 @@ fn s_send_tydesc(_tcx: ty_ctxt) -> u8 { } fn mk_ctxt(llmod: ModuleRef) -> ctxt { - let llshapetablesty = trans::common::T_named_struct("shapes"); - let llshapetables = str::as_c_str("shapes", |buf| { + let llshapetablesty = trans::common::T_named_struct(~"shapes"); + let llshapetables = str::as_c_str(~"shapes", |buf| { lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf) }); @@ -351,7 +351,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { s } ty::ty_param(*) { - ccx.tcx.sess.bug("non-monomorphized type parameter"); + ccx.tcx.sess.bug(~"non-monomorphized type parameter"); } ty::ty_fn({proto: ast::proto_box, _}) { ~[shape_box_fn] } ty::ty_fn({proto: ast::proto_uniq, _}) { ~[shape_uniq_fn] } @@ -361,7 +361,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { ty::ty_opaque_closure_ptr(_) { ~[shape_opaque_closure_ptr] } ty::ty_constr(inner_t, _) { shape_of(ccx, inner_t) } ty::ty_var(_) | ty::ty_var_integral(_) | ty::ty_self { - ccx.sess.bug("shape_of: unexpected type struct found"); + ccx.sess.bug(~"shape_of: unexpected type struct found"); } } } @@ -458,7 +458,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { header += data; header += lv_table; - ret mk_global(ccx, "tag_shapes", C_bytes(header), true); + ret mk_global(ccx, ~"tag_shapes", C_bytes(header), true); /* tjc: Not annotating FIXMEs in this module because of #1498 */ fn largest_variants(ccx: @crate_ctxt, @@ -579,7 +579,7 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef { dtors += ~[trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)]; } } - ret mk_global(ccx, "resource_shapes", C_struct(dtors), true); + ret mk_global(ccx, ~"resource_shapes", C_struct(dtors), true); } fn gen_shape_tables(ccx: @crate_ctxt) { @@ -699,7 +699,7 @@ fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { cx.enum_sizes.insert(t, max_size); ret max_size; } - _ { cx.sess.bug("static_size_of_enum called on non-enum"); } + _ { cx.sess.bug(~"static_size_of_enum called on non-enum"); } } } @@ -730,7 +730,7 @@ fn simplifier(tcx: ty::ctxt, typ: ty::t) -> ty::t { ty::ty_class(did, substs) { let simpl_fields = (if is_some(ty::ty_dtor(tcx, did)) { // remember the drop flag - ~[{ident: @"drop", mt: {ty: + ~[{ident: @~"drop", mt: {ty: ty::mk_u8(tcx), mutbl: ast::m_mutbl}}] } else { ~[] }) + diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 33aecc473b3b..0c233d2c1bc9 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -27,14 +27,14 @@ fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { ty::ty_estr(ty::vstore_box) | ty::ty_evec(_, ty::vstore_box) { ty::mk_imm_box(tcx, unboxed_vec_ty) } - _ { tcx.sess.bug("non boxed-vec type \ + _ { tcx.sess.bug(~"non boxed-vec type \ in tvec::expand_boxed_vec_ty"); } } } fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("tvec::get_fill"); + let _icx = bcx.insn_ctxt(~"tvec::get_fill"); Load(bcx, GEPi(bcx, vptr, ~[0u, abi::vec_elt_fill])) } fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) { @@ -50,12 +50,12 @@ fn get_bodyptr(bcx: block, vptr: ValueRef) -> ValueRef { fn get_dataptr(bcx: block, vptr: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("tvec::get_dataptr"); + let _icx = bcx.insn_ctxt(~"tvec::get_dataptr"); GEPi(bcx, vptr, ~[0u, abi::vec_elt_elems, 0u]) } fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("tvec::pointer_add"); + let _icx = bcx.insn_ctxt(~"tvec::pointer_add"); let old_ty = val_ty(ptr); let bptr = PointerCast(bcx, ptr, T_ptr(T_i8())); ret PointerCast(bcx, InBoundsGEP(bcx, bptr, ~[bytes]), old_ty); @@ -63,7 +63,7 @@ fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef { fn alloc_raw(bcx: block, unit_ty: ty::t, fill: ValueRef, alloc: ValueRef, heap: heap) -> result { - let _icx = bcx.insn_ctxt("tvec::alloc_uniq"); + let _icx = bcx.insn_ctxt(~"tvec::alloc_uniq"); let ccx = bcx.ccx(); let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty); @@ -80,7 +80,7 @@ fn alloc_uniq_raw(bcx: block, unit_ty: ty::t, } fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result { - let _icx = bcx.insn_ctxt("tvec::alloc_uniq"); + let _icx = bcx.insn_ctxt(~"tvec::alloc_uniq"); let ccx = bcx.ccx(); let llunitty = type_of::type_of(ccx, unit_ty); let unit_sz = llsize_of(ccx, llunitty); @@ -93,7 +93,7 @@ fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result { } fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { - let _icx = bcx.insn_ctxt("tvec::duplicate_uniq"); + let _icx = bcx.insn_ctxt(~"tvec::duplicate_uniq"); let fill = get_fill(bcx, get_bodyptr(bcx, vptr)); let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); @@ -111,7 +111,7 @@ fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> block { - let _icx = bcx.insn_ctxt("tvec::make_drop_glue_unboxed"); + let _icx = bcx.insn_ctxt(~"tvec::make_drop_glue_unboxed"); let tcx = bcx.tcx(), unit_ty = ty::sequence_element_type(tcx, vec_ty); if ty::type_needs_drop(tcx, unit_ty) { iter_vec_unboxed(bcx, vptr, vec_ty, base::drop_ty) @@ -120,7 +120,7 @@ fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> fn trans_evec(bcx: block, args: ~[@ast::expr], vst: ast::vstore, id: ast::node_id, dest: dest) -> block { - let _icx = bcx.insn_ctxt("tvec::trans_evec"); + let _icx = bcx.insn_ctxt(~"tvec::trans_evec"); let ccx = bcx.ccx(); let mut bcx = bcx; if dest == base::ignore { @@ -144,7 +144,7 @@ fn trans_evec(bcx: block, args: ~[@ast::expr], PointerCast(bcx, v, T_ptr(llunitty)) } _ { - bcx.ccx().sess.bug("bad dest for vstore_fixed \ + bcx.ccx().sess.bug(~"bad dest for vstore_fixed \ in tvec::trans_evec"); } }; @@ -226,7 +226,7 @@ fn trans_vstore(bcx: block, e: @ast::expr, ret trans_evec(bcx, es, v, e.id, dest); } _ { - bcx.sess().span_bug(e.span, "vstore on non-sequence type"); + bcx.sess().span_bug(e.span, ~"vstore on non-sequence type"); } } } @@ -266,9 +266,10 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t) } } -fn trans_estr(bcx: block, s: @str/~, vstore: ast::vstore, +fn trans_estr(bcx: block, s: @~str, vstore: ast::vstore, dest: dest) -> block { - let _icx = bcx.insn_ctxt("tvec::trans_estr"); + let _icx = bcx.insn_ctxt(~"tvec::trans_estr"); + if dest == base::ignore { ret bcx; } let ccx = bcx.ccx(); let c = alt vstore { @@ -312,7 +313,7 @@ fn trans_estr(bcx: block, s: @str/~, vstore: ast::vstore, fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, fill: ValueRef, f: iter_vec_block) -> block { - let _icx = bcx.insn_ctxt("tvec::iter_vec_raw"); + let _icx = bcx.insn_ctxt(~"tvec::iter_vec_raw"); let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); @@ -323,14 +324,14 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, let data_end_ptr = pointer_add(bcx, data_ptr, fill); // Now perform the iteration. - let header_cx = sub_block(bcx, "iter_vec_loop_header"); + let header_cx = sub_block(bcx, ~"iter_vec_loop_header"); Br(bcx, header_cx.llbb); let data_ptr = Phi(header_cx, val_ty(data_ptr), ~[data_ptr], ~[bcx.llbb]); let not_yet_at_end = ICmp(header_cx, lib::llvm::IntULT, data_ptr, data_end_ptr); - let body_cx = sub_block(header_cx, "iter_vec_loop_body"); - let next_cx = sub_block(header_cx, "iter_vec_next"); + let body_cx = sub_block(header_cx, ~"iter_vec_loop_body"); + let next_cx = sub_block(header_cx, ~"iter_vec_next"); CondBr(header_cx, not_yet_at_end, body_cx.llbb, next_cx.llbb); let body_cx = f(body_cx, data_ptr, unit_ty); AddIncomingToPhi(data_ptr, InBoundsGEP(body_cx, data_ptr, @@ -343,14 +344,14 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, fn iter_vec_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t, fill: ValueRef, f: iter_vec_block) -> block { - let _icx = bcx.insn_ctxt("tvec::iter_vec_uniq"); + let _icx = bcx.insn_ctxt(~"tvec::iter_vec_uniq"); let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr)); iter_vec_raw(bcx, data_ptr, vec_ty, fill, f) } fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t, f: iter_vec_block) -> block { - let _icx = bcx.insn_ctxt("tvec::iter_vec_unboxed"); + let _icx = bcx.insn_ctxt(~"tvec::iter_vec_unboxed"); let fill = get_fill(bcx, body_ptr); let dataptr = get_dataptr(bcx, body_ptr); ret iter_vec_raw(bcx, dataptr, vec_ty, fill, f); diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index cfc1f621efdd..aac6f2d97baf 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -59,7 +59,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef { T_ptr(T_unique(cx, type_of(cx, mt.ty))) } _ { - cx.sess.bug("non-box in type_of_non_gc_box"); + cx.sess.bug(~"non-box in type_of_non_gc_box"); } } } @@ -158,11 +158,11 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { common::T_named_struct(llvm_type_name(cx, t)) } - ty::ty_self { cx.tcx.sess.unimpl("type_of: ty_self"); } - ty::ty_var(_) { cx.tcx.sess.bug("type_of shouldn't see a ty_var"); } - ty::ty_param(*) { cx.tcx.sess.bug("type_of with ty_param"); } + ty::ty_self { cx.tcx.sess.unimpl(~"type_of: ty_self"); } + ty::ty_var(_) { cx.tcx.sess.bug(~"type_of with ty_var"); } + ty::ty_param(*) { cx.tcx.sess.bug(~"type_of with ty_param"); } ty::ty_var_integral(_) { - cx.tcx.sess.bug("type_of shouldn't see a ty_var_integral"); + cx.tcx.sess.bug(~"type_of shouldn't see a ty_var_integral"); } }; @@ -227,13 +227,13 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t) ret named_llty; } -fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> str { +fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str { let (name, did, tps) = alt check ty::get(t).struct { ty::ty_enum(did, substs) { - ("enum", did, substs.tps) + (~"enum", did, substs.tps) } ty::ty_class(did, substs) { - ("class", did, substs.tps) + (~"class", did, substs.tps) } }; ret #fmt( diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index ef2a95005da7..8d741655d353 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -76,17 +76,18 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) abi, _) { if abi == foreign_abi_rust_intrinsic { let flags = alt check *i.ident { - "size_of" | "pref_align_of" | "min_align_of" | - "init" | "reinterpret_cast" | "move_val" | "move_val_init" { + ~"size_of" | ~"pref_align_of" | ~"min_align_of" | + ~"init" | ~"reinterpret_cast" | + ~"move_val" | ~"move_val_init" { use_repr } - "get_tydesc" | "needs_drop" { use_tydesc } - "atomic_xchng" | "atomic_add" | "atomic_sub" | - "atomic_xchng_acq" | "atomic_add_acq" | "atomic_sub_acq" | - "atomic_xchng_rel" | "atomic_add_rel" | "atomic_sub_rel" { + ~"get_tydesc" | ~"needs_drop" { use_tydesc } + ~"atomic_xchng" | ~"atomic_add" | ~"atomic_sub" | + ~"atomic_xchng_acq" | ~"atomic_add_acq" | ~"atomic_sub_acq" | + ~"atomic_xchng_rel" | ~"atomic_add_rel" | ~"atomic_sub_rel" { 0u } - "visit_tydesc" | "forget" | "addr_of" { 0u } + ~"visit_tydesc" | ~"forget" | ~"addr_of" { 0u } }; for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;} } diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index 992ed26ee733..b044d0ac23c6 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -9,7 +9,7 @@ fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t) -> block { - let _icx = bcx.insn_ctxt("uniq::make_free_glue"); + let _icx = bcx.insn_ctxt(~"uniq::make_free_glue"); do with_cond(bcx, IsNotNull(bcx, vptr)) |bcx| { let content_ty = content_ty(t); let body_ptr = opaque_box_body(bcx, content_ty, vptr); @@ -32,7 +32,7 @@ fn autoderef(bcx: block, v: ValueRef, t: ty::t) -> {v: ValueRef, t: ty::t} { } fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result { - let _icx = bcx.insn_ctxt("uniq::duplicate"); + let _icx = bcx.insn_ctxt(~"uniq::duplicate"); let content_ty = content_ty(t); let {box: dst_box, body: dst_body} = malloc_unique(bcx, content_ty); diff --git a/src/rustc/middle/tstate/ann.rs b/src/rustc/middle/tstate/ann.rs index f20ad0f73dc8..d1f19ba6e1f7 100644 --- a/src/rustc/middle/tstate/ann.rs +++ b/src/rustc/middle/tstate/ann.rs @@ -239,8 +239,8 @@ fn implies(a: t, b: t) -> bool { ret tritv_doesntcare(tmp); } -fn trit_str(t: trit) -> str { - alt t { dont_care { "?" } ttrue { "1" } tfalse { "0" } } +fn trit_str(t: trit) -> ~str { + alt t { dont_care { ~"?" } ttrue { ~"1" } tfalse { ~"0" } } } // FIXME (#2538): Would be nice to have unit tests for some of these diff --git a/src/rustc/middle/tstate/annotate.rs b/src/rustc/middle/tstate/annotate.rs index e6beae9e0144..de9a4540d21b 100644 --- a/src/rustc/middle/tstate/annotate.rs +++ b/src/rustc/middle/tstate/annotate.rs @@ -40,7 +40,7 @@ fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut ~[node_id]) { fn init_vecs(ccx: crate_ctxt, node_ids: ~[node_id], len: uint) { for node_ids.each |i| { - log(debug, int::str(i) + " |-> " + uint::str(len)); + log(debug, int::str(i) + ~" |-> " + uint::str(len)); add_node(ccx, i, empty_ann(len)); } } diff --git a/src/rustc/middle/tstate/auxiliary.rs b/src/rustc/middle/tstate/auxiliary.rs index d50e445482a6..a098757175c2 100644 --- a/src/rustc/middle/tstate/auxiliary.rs +++ b/src/rustc/middle/tstate/auxiliary.rs @@ -30,17 +30,17 @@ enum oper_type { } /* logging funs */ -fn def_id_to_str(d: def_id) -> str { - ret int::str(d.crate) + "," + int::str(d.node); +fn def_id_to_str(d: def_id) -> ~str { + ret int::str(d.crate) + ~"," + int::str(d.node); } -fn comma_str(args: ~[@constr_arg_use]) -> str { - let mut rslt = ""; +fn comma_str(args: ~[@constr_arg_use]) -> ~str { + let mut rslt = ~""; let mut comma = false; for args.each |a| { - if comma { rslt += ", "; } else { comma = true; } + if comma { rslt += ~", "; } else { comma = true; } alt a.node { - carg_base { rslt += "*"; } + carg_base { rslt += ~"*"; } carg_ident(i) { rslt += *i.ident; } carg_lit(l) { rslt += lit_to_str(l); } } @@ -48,23 +48,23 @@ fn comma_str(args: ~[@constr_arg_use]) -> str { ret rslt; } -fn constraint_to_str(tcx: ty::ctxt, c: sp_constr) -> str { +fn constraint_to_str(tcx: ty::ctxt, c: sp_constr) -> ~str { ret #fmt("%s(%s) - arising from %s", path_to_str(c.node.path), comma_str(c.node.args), codemap::span_to_str(c.span, tcx.sess.codemap)); } -fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> str { - let mut s = ""; +fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> ~str { + let mut s = ~""; let mut comma = false; for constraints(fcx).each |p| { alt tritv_get(v, p.bit_num) { dont_care { } tt { s += - if comma { ", " } else { comma = true; "" } + - if tt == tfalse { "!" } else { "" } + + if comma { ~", " } else { comma = true; ~"" } + + if tt == tfalse { ~"!" } else { ~"" } + constraint_to_str(fcx.ccx.tcx, p.c); } } @@ -77,8 +77,8 @@ fn log_tritv(fcx: fn_ctxt, v: tritv::t) { } fn first_difference_string(fcx: fn_ctxt, expected: tritv::t, actual: tritv::t) - -> str { - let mut s = ""; + -> ~str { + let mut s = ~""; for constraints(fcx).each |c| { if tritv_get(expected, c.bit_num) == ttrue && tritv_get(actual, c.bit_num) != ttrue { @@ -93,12 +93,12 @@ fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) { log(error, tritv_to_str(fcx, v)); } -fn tos(v: ~[uint]) -> str { - let mut rslt = ""; +fn tos(v: ~[uint]) -> ~str { + let mut rslt = ~""; for v.each |i| { if i == 0u { - rslt += "0"; - } else if i == 1u { rslt += "1"; } else { rslt += "?"; } + rslt += ~"0"; + } else if i == 1u { rslt += ~"1"; } else { rslt += ~"?"; } } ret rslt; } @@ -143,11 +143,11 @@ fn log_states_err(pp: pre_and_post_state) { log_cond_err(p2); } -fn print_ident(i: ident) { log(debug, " " + *i + " "); } +fn print_ident(i: ident) { log(debug, ~" " + *i + ~" "); } fn print_idents(&idents: ~[ident]) { if vec::len::(idents) == 0u { ret; } - log(debug, "an ident: " + *vec::pop::(idents)); + log(debug, ~"an ident: " + *vec::pop::(idents)); print_idents(idents); } @@ -499,23 +499,23 @@ fn constraints(fcx: fn_ctxt) -> ~[norm_constraint] { fn match_args(fcx: fn_ctxt, occs: @dvec, occ: ~[@constr_arg_use]) -> uint { #debug("match_args: looking at %s", - constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, occ)); + constr_args_to_str(fn@(i: inst) -> ~str { ret *i.ident; }, occ)); for (*occs).each |pd| { log(debug, - "match_args: candidate " + pred_args_to_str(pd)); + ~"match_args: candidate " + pred_args_to_str(pd)); fn eq(p: inst, q: inst) -> bool { ret p.node == q.node; } if ty::args_eq(eq, pd.node.args, occ) { ret pd.node.bit_num; } } - fcx.ccx.tcx.sess.bug("match_args: no match for occurring args"); + fcx.ccx.tcx.sess.bug(~"match_args: no match for occurring args"); } fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id { alt tcx.def_map.find(t) { none { - tcx.sess.bug("node_id_for_constr: bad node_id " + int::str(t)); + tcx.sess.bug(~"node_id_for_constr: bad node_id " + int::str(t)); } some(def_fn(i, _)) { ret i; } - _ { tcx.sess.bug("node_id_for_constr: pred is not a function"); } + _ { tcx.sess.bug(~"node_id_for_constr: pred is not a function"); } } } @@ -535,7 +535,7 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { } none { tcx.sess.span_bug(e.span, - "exprs_to_constr_args: unbound id as pred arg"); + ~"exprs_to_constr_args: unbound id as pred arg"); } } @@ -543,8 +543,8 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { expr_lit(l) { ret @respan(e.span, carg_lit(l)); } _ { tcx.sess.span_fatal(e.span, - "arguments to constrained functions must be " + - "literals or local variables"); + ~"arguments to constrained functions must be " + + ~"literals or local variables"); } } } @@ -569,20 +569,21 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr { } _ { tcx.sess.span_bug(operator.span, - "ill-formed operator in predicate"); + ~"ill-formed operator in predicate"); } } } _ { - tcx.sess.span_bug(e.span, "ill-formed predicate"); + tcx.sess.span_bug(e.span, ~"ill-formed predicate"); } } } -fn pred_args_to_str(p: pred_args) -> str { - "<" + uint::str(p.node.bit_num) + ", " + - constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, p.node.args) - + ">" +fn pred_args_to_str(p: pred_args) -> ~str { + ~"<" + uint::str(p.node.bit_num) + ~", " + + constr_args_to_str(fn@(i: inst) -> ~str {ret *i.ident; }, + p.node.args) + + ~">" } fn substitute_constr_args(cx: ty::ctxt, actuals: ~[@expr], c: @ty::constr) -> @@ -604,7 +605,7 @@ fn substitute_arg(cx: ty::ctxt, actuals: ~[@expr], a: @constr_arg) -> if i < num_actuals { ret expr_to_constr_arg(cx, actuals[i]); } else { - cx.sess.span_fatal(a.span, "constraint argument out of bounds"); + cx.sess.span_fatal(a.span, ~"constraint argument out of bounds"); } } carg_base { ret @respan(a.span, carg_base); } @@ -689,18 +690,18 @@ fn find_in_subst_bool(s: subst, id: node_id) -> bool { is_some(find_in_subst(id, s)) } -fn insts_to_str(stuff: ~[constr_arg_general_]) -> str { - let mut rslt = "<"; +fn insts_to_str(stuff: ~[constr_arg_general_]) -> ~str { + let mut rslt = ~"<"; for stuff.each |i| { rslt += - " " + + ~" " + alt i { carg_ident(p) { *p.ident } - carg_base { "*" } - carg_lit(_) { "~[lit]" } - } + " "; + carg_base { ~"*" } + carg_lit(_) { ~"~[lit]" } + } + ~" "; } - rslt += ">"; + rslt += ~">"; rslt } @@ -741,13 +742,13 @@ fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) -> } some(_) { fcx.ccx.tcx.sess.span_fatal(sp, - "local_node_id_to_def_id: id \ + ~"local_node_id_to_def_id: id \ isn't a local"); } none { // should really be bug. span_bug()? fcx.ccx.tcx.sess.span_fatal(sp, - "local_node_id_to_def_id: id \ + ~"local_node_id_to_def_id: id \ is unbound"); } } @@ -898,7 +899,7 @@ fn args_to_constr_args(tcx: ty::ctxt, args: ~[arg], node: args[i].id}) } else { tcx.sess.span_bug(a.span, - "index out of bounds in \ + ~"index out of bounds in \ constraint arg"); } } @@ -949,7 +950,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] { } _ { // Shouldn't happen; callee should be ty_fn. - fcx.ccx.tcx.sess.bug("non-fn callee type in callee_modes: " + + fcx.ccx.tcx.sess.bug(~"non-fn callee type in callee_modes: " + util::ppaux::ty_to_str(fcx.ccx.tcx, ty)); } } diff --git a/src/rustc/middle/tstate/ck.rs b/src/rustc/middle/tstate/ck.rs index b5e9c5d32c88..d534b764c078 100644 --- a/src/rustc/middle/tstate/ck.rs +++ b/src/rustc/middle/tstate/ck.rs @@ -25,15 +25,15 @@ fn check_states_expr(e: @expr, fcx: fn_ctxt, v: visit::vt) { let pres: prestate = expr_prestate(fcx.ccx, e); if !implies(pres, prec) { - let mut s = ""; + let mut s = ~""; let diff = first_difference_string(fcx, prec, pres); s += - "unsatisfied precondition constraint (for example, " + diff + - ") for expression:\n"; + ~"unsatisfied precondition constraint (for example, " + diff + + ~") for expression:\n"; s += syntax::print::pprust::expr_to_str(e); - s += "\nprecondition:\n"; + s += ~"\nprecondition:\n"; s += tritv_to_str(fcx, prec); - s += "\nprestate:\n"; + s += ~"\nprestate:\n"; s += tritv_to_str(fcx, pres); fcx.ccx.tcx.sess.span_fatal(e.span, s); } @@ -54,15 +54,15 @@ fn check_states_stmt(s: @stmt, fcx: fn_ctxt, v: visit::vt) { log_tritv(fcx, pres); if !implies(pres, prec) { - let mut ss = ""; + let mut ss = ~""; let diff = first_difference_string(fcx, prec, pres); ss += - "unsatisfied precondition constraint (for example, " + diff + - ") for statement:\n"; + ~"unsatisfied precondition constraint (for example, " + diff + + ~") for statement:\n"; ss += syntax::print::pprust::stmt_to_str(*s); - ss += "\nprecondition:\n"; + ss += ~"\nprecondition:\n"; ss += tritv_to_str(fcx, prec); - ss += "\nprestate: \n"; + ss += ~"\nprestate: \n"; ss += tritv_to_str(fcx, pres); fcx.ccx.tcx.sess.span_fatal(s.span, ss); } diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs index 6c5eebbcb0b4..d7bfd0313077 100644 --- a/src/rustc/middle/tstate/collect_locals.rs +++ b/src/rustc/middle/tstate/collect_locals.rs @@ -55,7 +55,7 @@ fn find_locals(tcx: ty::ctxt, fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) -> uint { log(debug, - constraint_to_str(tcx, c) + " |-> " + uint::str(next)); + constraint_to_str(tcx, c) + ~" |-> " + uint::str(next)); let {path: p, def_id: d_id, args: args} = c.node; alt tbl.find(d_id) { diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index fe502e184761..591f152acb3c 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -50,12 +50,12 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) { item_foreign_mod(nm) { find_pre_post_foreign_mod(nm); } item_ty(*) | item_enum(*) | item_trait(*) { ret; } item_class(*) { - fail "find_pre_post_item: shouldn't be called on item_class"; + fail ~"find_pre_post_item: shouldn't be called on item_class"; } item_impl(_, _, _, ms) { for ms.each |m| { find_pre_post_method(ccx, m); } } - item_mac(*) { fail "item macros unimplemented" } + item_mac(*) { fail ~"item macros unimplemented" } } } @@ -303,7 +303,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { for (*cap_clause).each |cap_item| { if cap_item.is_move { - log(debug, ("forget_in_postcond: ", cap_item)); + log(debug, (~"forget_in_postcond: ", cap_item)); forget_in_postcond(fcx, e.id, cap_item.id); } } @@ -447,7 +447,7 @@ fn combine_pp(antec: pre_and_post, fcx: fn_ctxt, &&pp: pre_and_post, } expr_break { clear_pp(expr_pp(fcx.ccx, e)); } expr_again { clear_pp(expr_pp(fcx.ccx, e)); } - expr_mac(_) { fcx.ccx.tcx.sess.bug("unexpanded macro"); } + expr_mac(_) { fcx.ccx.tcx.sess.bug(~"unexpanded macro"); } } } diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index f6cf240eeca3..ebe476b3d7f9 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -20,7 +20,7 @@ fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) { alt local_node_id_to_def(fcx, rhs_id) { some(def_upvar(_, _, _)) { fcx.ccx.tcx.sess.span_err(sp, - "tried to deinitialize a variable \ + ~"tried to deinitialize a variable \ declared in a different scope"); } _ { } @@ -309,7 +309,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { expr_log(_, lvl, ex) { ret find_pre_post_state_two(fcx, pres, lvl, ex, e.id, oper_pure); } - expr_mac(_) { fcx.ccx.tcx.sess.bug("unexpanded macro"); } + expr_mac(_) { fcx.ccx.tcx.sess.bug(~"unexpanded macro"); } expr_lit(l) { ret pure_exp(fcx.ccx, e.id, pres); } expr_fn(_, _, _, cap_clause) { ret find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause); diff --git a/src/rustc/middle/tstate/tritv.rs b/src/rustc/middle/tstate/tritv.rs index c3e221ef32cd..fc158262cb6a 100644 --- a/src/rustc/middle/tstate/tritv.rs +++ b/src/rustc/middle/tstate/tritv.rs @@ -264,15 +264,15 @@ fn to_vec(v: t) -> ~[uint] { ret rslt; } -fn to_str(v: t) -> str { +fn to_str(v: t) -> ~str { let mut i: uint = 0u; - let mut rs: str = ""; + let mut rs: ~str = ~""; while i < v.nbits { rs += alt tritv_get(v, i) { - dont_care { "?" } - ttrue { "1" } - tfalse { "0" } + dont_care { ~"?" } + ttrue { ~"1" } + tfalse { ~"0" } }; i += 1u; } diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 2dd9f414677e..c3bcefb9fa55 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -253,7 +253,7 @@ enum ast_ty_to_ty_cache_entry { freevars: freevars::freevar_map, tcache: type_cache, rcache: creader_cache, - short_names_cache: hashmap, + short_names_cache: hashmap, needs_drop_cache: hashmap, needs_unwind_cleanup_cache: hashmap, kind_cache: hashmap, @@ -444,26 +444,26 @@ enum param_bound { iface vid { fn to_uint() -> uint; - fn to_str() -> str; + fn to_str() -> ~str; } impl of vid for tv_vid { fn to_uint() -> uint { *self } - fn to_str() -> str { #fmt["", self.to_uint()] } + fn to_str() -> ~str { #fmt["", self.to_uint()] } } impl of vid for tvi_vid { fn to_uint() -> uint { *self } - fn to_str() -> str { #fmt["", self.to_uint()] } + fn to_str() -> ~str { #fmt["", self.to_uint()] } } impl of vid for region_vid { fn to_uint() -> uint { *self } - fn to_str() -> str { #fmt["", self.to_uint()] } + fn to_str() -> ~str { #fmt["", self.to_uint()] } } impl of to_str::to_str for purity { - fn to_str() -> str { + fn to_str() -> ~str { purity_to_str(self) } } @@ -1020,10 +1020,10 @@ fn substs_is_noop(substs: substs) -> bool { substs.self_ty.is_none() } -fn substs_to_str(cx: ctxt, substs: substs) -> str { +fn substs_to_str(cx: ctxt, substs: substs) -> ~str { #fmt["substs(self_r=%s, self_ty=%s, tps=%?)", - substs.self_r.map_default("none", |r| region_to_str(cx, r)), - substs.self_ty.map_default("none", |t| ty_to_str(cx, t)), + substs.self_r.map_default(~"none", |r| region_to_str(cx, r)), + substs.self_ty.map_default(~"none", |t| ty_to_str(cx, t)), substs.tps.map(|t| ty_to_str(cx, t))] } @@ -1117,7 +1117,9 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t { alt get(ty).struct { ty_str | ty_estr(_) { ret mk_mach_uint(cx, ast::ty_u8); } ty_vec(mt) | ty_evec(mt, _) | ty_unboxed_vec(mt) { ret mt.ty; } - _ { cx.sess.bug("sequence_element_type called on non-sequence value"); } + _ { cx.sess.bug( + ~"sequence_element_type called on non-sequence value"); + } } } @@ -1125,7 +1127,7 @@ fn get_element_type(ty: t, i: uint) -> t { alt get(ty).struct { ty_rec(flds) { ret flds[i].mt.ty; } ty_tup(ts) { ret ts[i]; } - _ { fail "get_element_type called on invalid type"; } + _ { fail ~"get_element_type called on invalid type"; } } } @@ -1603,10 +1605,10 @@ fn type_kind(cx: ctxt, ty: t) -> kind { // FIXME (#2663): is self ever const? ty_self { kind_noncopyable() } ty_var(_) | ty_var_integral(_) { - cx.sess.bug("Asked to compute kind of a type variable"); + cx.sess.bug(~"Asked to compute kind of a type variable"); } ty_type | ty_opaque_closure_ptr(_) | ty_opaque_box | ty_unboxed_vec(_) { - cx.sess.bug("Asked to compute kind of fictitious type"); + cx.sess.bug(~"Asked to compute kind of fictitious type"); } }; @@ -1785,7 +1787,7 @@ fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool { ty_param(_, _) { true } ty_evec(_, _) | ty_estr(_) { - cx.sess.unimpl("estr/evec in type_allows_implicit_copy"); + cx.sess.unimpl(~"estr/evec in type_allows_implicit_copy"); } ty_vec(mt) { @@ -1889,7 +1891,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { } ty_var(*) | ty_var_integral(*) | ty_self(*) { - cx.sess.bug("non concrete type in type_is_pod"); + cx.sess.bug(~"non concrete type in type_is_pod"); } } @@ -2010,7 +2012,7 @@ fn hash_type_constr(id: uint, c: @type_constr) -> uint { for c.node.args.each |a| { alt a.node { carg_base { h += h << 2u; } - carg_lit(_) { fail "lit args not implemented yet"; } + carg_lit(_) { fail ~"lit args not implemented yet"; } carg_ident(p) { h += h << 2u; } } } @@ -2166,28 +2168,28 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { fn ty_fn_args(fty: t) -> ~[arg] { alt get(fty).struct { ty_fn(f) { f.inputs } - _ { fail "ty_fn_args() called on non-fn type"; } + _ { fail ~"ty_fn_args() called on non-fn type"; } } } fn ty_fn_proto(fty: t) -> ast::proto { alt get(fty).struct { ty_fn(f) { f.proto } - _ { fail "ty_fn_proto() called on non-fn type"; } + _ { fail ~"ty_fn_proto() called on non-fn type"; } } } pure fn ty_fn_ret(fty: t) -> t { alt get(fty).struct { ty_fn(f) { f.output } - _ { fail "ty_fn_ret() called on non-fn type"; } + _ { fail ~"ty_fn_ret() called on non-fn type"; } } } fn ty_fn_ret_style(fty: t) -> ast::ret_style { alt get(fty).struct { ty_fn(f) { f.ret_style } - _ { fail "ty_fn_ret_style() called on non-fn type"; } + _ { fail ~"ty_fn_ret_style() called on non-fn type"; } } } @@ -2321,11 +2323,11 @@ fn vars_in_type(ty: t) -> ~[tv_vid] { // assertion later on that the type doesn't contain // variables, so in this case we have to be sure to die. tcx.sess.span_fatal - (sp, "type inference failed because I \ + (sp, ~"type inference failed because I \ could not find a type\n that's both of the form " + ty_to_str(tcx, mk_var(tcx, vid)) + - " and of the form " + ty_to_str(tcx, rt) + - " - such a type would have to be infinitely large."); + ~" and of the form " + ty_to_str(tcx, rt) + + ~" - such a type would have to be infinitely large."); } } @@ -2400,7 +2402,7 @@ fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) { } } -fn ty_sort_str(cx: ctxt, t: t) -> str { +fn ty_sort_str(cx: ctxt, t: t) -> ~str { alt get(t).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_str | @@ -2409,41 +2411,41 @@ fn ty_sort_str(cx: ctxt, t: t) -> str { } ty_enum(id, _) { #fmt["enum %s", item_path_str(cx, id)] } - ty_box(_) { "@-ptr" } - ty_uniq(_) { "~-ptr" } - ty_evec(_, _) | ty_vec(_) { "vector" } - ty_unboxed_vec(_) { "unboxed vector" } - ty_ptr(_) { "*-ptr" } - ty_rptr(_, _) { "&-ptr" } - ty_rec(_) { "record" } - ty_fn(_) { "fn" } + ty_box(_) { ~"@-ptr" } + ty_uniq(_) { ~"~-ptr" } + ty_evec(_, _) | ty_vec(_) { ~"vector" } + ty_unboxed_vec(_) { ~"unboxed vector" } + ty_ptr(_) { ~"*-ptr" } + ty_rptr(_, _) { ~"&-ptr" } + ty_rec(_) { ~"record" } + ty_fn(_) { ~"fn" } ty_trait(id, _) { #fmt["trait %s", item_path_str(cx, id)] } ty_class(id, _) { #fmt["class %s", item_path_str(cx, id)] } - ty_tup(_) { "tuple" } - ty_var(_) { "variable" } - ty_var_integral(_) { "integral variable" } - ty_param(_, _) { "type parameter" } - ty_self { "self" } + ty_tup(_) { ~"tuple" } + ty_var(_) { ~"variable" } + ty_var_integral(_) { ~"integral variable" } + ty_param(_, _) { ~"type parameter" } + ty_self { ~"self" } ty_constr(t, _) { ty_sort_str(cx, t) } } } -fn type_err_to_str(cx: ctxt, err: type_err) -> str { - fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> str { - alt k { terr_vec { "[]" } terr_str { "str" } } +fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { + fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str { + alt k { terr_vec { ~"[]" } terr_str { ~"str" } } } alt err { - terr_mismatch { ret "types differ"; } + terr_mismatch { ret ~"types differ"; } terr_ret_style_mismatch(expect, actual) { - fn to_str(s: ast::ret_style) -> str { + fn to_str(s: ast::ret_style) -> ~str { alt s { - ast::noreturn { "non-returning" } - ast::return_val { "return-by-value" } + ast::noreturn { ~"non-returning" } + ast::return_val { ~"return-by-value" } } } - ret to_str(actual) + " function found where " + to_str(expect) + - " function was expected"; + ret to_str(actual) + ~" function found where " + to_str(expect) + + ~" function was expected"; } terr_purity_mismatch(f1, f2) { ret #fmt["expected %s fn but found %s fn", f1.to_str(), f2.to_str()]; @@ -2452,45 +2454,45 @@ fn to_str(s: ast::ret_style) -> str { ret #fmt["closure protocol mismatch (%s vs %s)", proto_to_str(e), proto_to_str(a)]; } - terr_mutability { ret "values differ in mutability"; } - terr_box_mutability { ret "boxed values differ in mutability"; } - terr_vec_mutability { ret "vectors differ in mutability"; } - terr_ptr_mutability { ret "pointers differ in mutability"; } - terr_ref_mutability { ret "references differ in mutability"; } + terr_mutability { ret ~"values differ in mutability"; } + terr_box_mutability { ret ~"boxed values differ in mutability"; } + terr_vec_mutability { ret ~"vectors differ in mutability"; } + terr_ptr_mutability { ret ~"pointers differ in mutability"; } + terr_ref_mutability { ret ~"references differ in mutability"; } terr_ty_param_size(e_sz, a_sz) { - ret "expected a type with " + uint::to_str(e_sz, 10u) + - " type params but found one with " + uint::to_str(a_sz, 10u) + - " type params"; + ret ~"expected a type with " + uint::to_str(e_sz, 10u) + + ~" type params but found one with " + uint::to_str(a_sz, 10u) + + ~" type params"; } terr_tuple_size(e_sz, a_sz) { - ret "expected a tuple with " + uint::to_str(e_sz, 10u) + - " elements but found one with " + uint::to_str(a_sz, 10u) + - " elements"; + ret ~"expected a tuple with " + uint::to_str(e_sz, 10u) + + ~" elements but found one with " + uint::to_str(a_sz, 10u) + + ~" elements"; } terr_record_size(e_sz, a_sz) { - ret "expected a record with " + uint::to_str(e_sz, 10u) + - " fields but found one with " + uint::to_str(a_sz, 10u) + - " fields"; + ret ~"expected a record with " + uint::to_str(e_sz, 10u) + + ~" fields but found one with " + uint::to_str(a_sz, 10u) + + ~" fields"; } - terr_record_mutability { ret "record elements differ in mutability"; } + terr_record_mutability { ret ~"record elements differ in mutability"; } terr_record_fields(e_fld, a_fld) { - ret "expected a record with field `" + *e_fld + - "` but found one with field `" + *a_fld + "`"; + ret ~"expected a record with field `" + *e_fld + + ~"` but found one with field `" + *a_fld + ~"`"; } - terr_arg_count { ret "incorrect number of function parameters"; } + terr_arg_count { ret ~"incorrect number of function parameters"; } terr_mode_mismatch(e_mode, a_mode) { - ret "expected argument mode " + mode_to_str(e_mode) + " but found " + - mode_to_str(a_mode); + ret ~"expected argument mode " + mode_to_str(e_mode) + + ~" but found " + mode_to_str(a_mode); } terr_constr_len(e_len, a_len) { - ret "expected a type with " + uint::str(e_len) + - " constraints, but found one with " + uint::str(a_len) + - " constraints"; + ret ~"expected a type with " + uint::str(e_len) + + ~" constraints, but found one with " + uint::str(a_len) + + ~" constraints"; } terr_constr_mismatch(e_constr, a_constr) { - ret "expected a type with constraint " + ty_constr_to_str(e_constr) + - " but found one with constraint " + - ty_constr_to_str(a_constr); + ret ~"expected a type with constraint " + ty_constr_to_str(e_constr) + + ~" but found one with constraint " + + ty_constr_to_str(a_constr); } terr_regions_differ(subregion, superregion) { ret #fmt("references with lifetime %s do not necessarily \ @@ -2511,10 +2513,10 @@ fn to_str(s: ast::ret_style) -> str { ret #fmt("%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act)); } terr_self_substs { - ret "inconsistent self substitution"; // XXX this is more of a bug + ret ~"inconsistent self substitution"; // XXX this is more of a bug } terr_no_integral_type { - ret "couldn't determine an appropriate integral type for integer \ + ret ~"couldn't determine an appropriate integral type for integer \ literal"; } } @@ -2602,7 +2604,7 @@ fn substd_enum_variants(cx: ctxt, } } -fn item_path_str(cx: ctxt, id: ast::def_id) -> str { +fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str { ast_map::path_to_str(item_path(cx, id)) } @@ -2661,7 +2663,7 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path { vec::append_one(*path, ast_map::path_name(nm)) } ast_map::node_dtor(_, _, _, path) { - vec::append_one(*path, ast_map::path_name(@"dtor")) + vec::append_one(*path, ast_map::path_name(@~"dtor")) } @@ -2707,7 +2709,7 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { // FIXME: issue #1417 disr_val = alt const_eval::eval_const_expr(cx, ex) { const_eval::const_int(val) {val as int} - _ { cx.sess.bug("tag_variants: bad disr expr"); } + _ { cx.sess.bug(~"tag_variants: bad disr expr"); } } } _ {disr_val += 1;} @@ -2720,7 +2722,7 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { } }) } - _ { cx.sess.bug("tag_variants: id not bound to an enum"); } + _ { cx.sess.bug(~"tag_variants: id not bound to an enum"); } } }; cx.enum_var_cache.insert(id, result); @@ -2738,7 +2740,7 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id, if ast_util::def_eq(variant.id, variant_id) { ret variant; } i += 1u; } - cx.sess.bug("enum_variant_with_id(): no variant exists with that ID"); + cx.sess.bug(~"enum_variant_with_id(): no variant exists with that ID"); } @@ -2789,7 +2791,7 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { ast::item_class(_, _, items, _, _) { class_field_tys(items) } - _ { cx.sess.bug("class ID bound to non-class"); } + _ { cx.sess.bug(~"class ID bound to non-class"); } } } _ { @@ -2808,7 +2810,7 @@ fn lookup_class_field(cx: ctxt, parent: ast::def_id, field_id: ast::def_id) alt vec::find(lookup_class_fields(cx, parent), |f| f.id.node == field_id.node) { some(t) { t } - none { cx.sess.bug("class ID not found in parent's fields"); } + none { cx.sess.bug(~"class ID not found in parent's fields"); } } } @@ -2834,7 +2836,7 @@ fn lookup_class_method_ids(cx: ctxt, did: ast::def_id) vis: m.vis}) } _ { - cx.sess.bug("lookup_class_method_ids: id not bound to a class"); + cx.sess.bug(~"lookup_class_method_ids: id not bound to a class"); } } } @@ -2995,8 +2997,8 @@ fn ast_constr_to_constr(tcx: ctxt, c: @ast::constr_general) -> } _ { tcx.sess.span_fatal(c.span, - "predicate " + path_to_str(c.node.path) + - " is unbound or bound to a non-function or an \ + ~"predicate " + path_to_str(c.node.path) + + ~" is unbound or bound to a non-function or an \ impure function"); } } diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 0daf663315bf..1d86c47dddb6 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -176,7 +176,7 @@ fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def { alt tcx.def_map.find(id) { some(x) { x } _ { - tcx.sess.span_fatal(sp, "internal error looking up a definition") + tcx.sess.span_fatal(sp, ~"internal error looking up a definition") } } } @@ -195,7 +195,7 @@ fn require_same_types( span: span, t1: ty::t, t2: ty::t, - msg: fn() -> str) -> bool { + msg: fn() -> ~str) -> bool { let l_tcx, l_infcx; alt maybe_infcx { @@ -212,7 +212,7 @@ fn require_same_types( alt infer::mk_eqty(l_infcx, t1, t2) { result::ok(()) { true } result::err(terr) { - l_tcx.sess.span_err(span, msg() + ": " + + l_tcx.sess.span_err(span, msg() + ~": " + ty::type_err_to_str(l_tcx, terr)); false } @@ -246,7 +246,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt, alt it.node { ast::item_fn(_,ps,_) if vec::is_not_empty(ps) { tcx.sess.span_err(main_span, - "main function is not allowed to have type parameters"); + ~"main function is not allowed to have type parameters"); ret; } _ {} @@ -269,8 +269,8 @@ fn check_main_fn_ty(ccx: @crate_ctxt, } _ { tcx.sess.span_bug(main_span, - "main has a non-function type: found `" + - ty_to_str(tcx, main_t) + "`"); + ~"main has a non-function type: found `" + + ty_to_str(tcx, main_t) + ~"`"); } } } @@ -280,7 +280,7 @@ fn check_for_main_fn(ccx: @crate_ctxt) { if !tcx.sess.building_library { alt copy tcx.sess.main_fn { some((id, sp)) { check_main_fn_ty(ccx, id, sp); } - none { tcx.sess.err("main function not found"); } + none { tcx.sess.err(~"main function not found"); } } } } diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index c785e44b80ac..7d09c57dc924 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -57,7 +57,7 @@ fn get_region_reporting_err(tcx: ty::ctxt, span: span, - res: result) -> ty::region { + res: result) -> ty::region { alt res { result::ok(r) { r } @@ -197,7 +197,7 @@ fn check_path_args(tcx: ty::ctxt, if path.types.len() > 0u { tcx.sess.span_err( path.span, - "type parameters are not allowed on this type"); + ~"type parameters are not allowed on this type"); } } @@ -205,7 +205,7 @@ fn check_path_args(tcx: ty::ctxt, if path.rp.is_some() { tcx.sess.span_err( path.span, - "region parameters are not allowed on this type"); + ~"region parameters are not allowed on this type"); } } } @@ -215,7 +215,7 @@ fn check_path_args(tcx: ty::ctxt, alt tcx.ast_ty_to_ty_cache.find(ast_ty) { some(ty::atttce_resolved(ty)) { ret ty; } some(ty::atttce_unresolved) { - tcx.sess.span_fatal(ast_ty.span, "illegal recursive type; \ + tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \ insert an enum in the cycle, \ if this is desired"); } @@ -289,7 +289,7 @@ fn check_path_args(tcx: ty::ctxt, } ast::ty_str { check_path_args(tcx, path, NO_TPS); - // This is a bit of a hack, but basically str/& needs to be + // This is a bit of a hack, but basically &str needs to be // converted into a vstore: alt path.rp { none { @@ -317,7 +317,7 @@ fn check_path_args(tcx: ty::ctxt, } _ { tcx.sess.span_fatal(ast_ty.span, - "found type name used as a variable"); + ~"found type name used as a variable"); } } } @@ -372,7 +372,7 @@ fn check_path_args(tcx: ty::ctxt, ast::ty_vstore(_, ast::vstore_fixed(none)) { tcx.sess.span_bug( ast_ty.span, - "implied fixed length for bound"); + ~"implied fixed length for bound"); } /* ast::ty_vstore(_, _) { @@ -393,11 +393,11 @@ fn check_path_args(tcx: ty::ctxt, // routine. self.tcx().sess.span_bug( ast_ty.span, - "found `ty_infer` in unexpected place"); + ~"found `ty_infer` in unexpected place"); } ast::ty_mac(_) { tcx.sess.span_bug(ast_ty.span, - "found `ty_mac` in unexpected place"); + ~"found `ty_mac` in unexpected place"); } }; diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 43dc46cd2b6b..fa43449f30ed 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -384,8 +384,9 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { // Check that there's at least one field let (fields,_) = split_class_items(members); if fields.len() < 1u { - ccx.tcx.sess.span_err(it.span, "a class must have at least one \ - field"); + ccx.tcx.sess.span_err( + it.span, + ~"a class must have at least one field"); } // Check that the class is instantiable check_instantiable(ccx.tcx, it.span, it.id); @@ -429,14 +430,14 @@ fn ty_infer(_span: span) -> ty::t { } impl of region_scope for @fn_ctxt { - fn anon_region() -> result { + fn anon_region() -> result { result::ok(self.infcx.next_region_var()) } - fn named_region(id: ast::ident) -> result { + fn named_region(id: ast::ident) -> result { do empty_rscope.named_region(id).chain_err |_e| { alt self.in_scope_regions.find(ty::br_named(id)) { some(r) { result::ok(r) } - none if *id == "blk" { self.block_region() } + none if *id == ~"blk" { self.block_region() } none { result::err(#fmt["named region `%s` not in scope here", *id]) } @@ -446,11 +447,11 @@ fn named_region(id: ast::ident) -> result { } impl methods for @fn_ctxt { - fn tag() -> str { #fmt["%x", ptr::addr_of(*self) as uint] } - fn block_region() -> result { + fn tag() -> ~str { #fmt["%x", ptr::addr_of(*self) as uint] } + fn block_region() -> result { alt vec::last_opt(self.blocks) { some(bid) { result::ok(ty::re_scope(bid)) } - none { result::err("no block is in scope here") } + none { result::err(~"no block is in scope here") } } } #[inline(always)] @@ -554,7 +555,7 @@ fn mk_subr(sub: ty::region, sup: ty::region) -> result<(), ty::type_err> { infer::mk_subr(self.infcx, sub, sup) } - fn require_unsafe(sp: span, op: str) { + fn require_unsafe(sp: span, op: ~str) { alt self.purity { ast::unsafe_fn {/*ok*/} _ { @@ -672,7 +673,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty { self_ty: none, tps: ty::ty_params_to_tys(tcx, ts)})} } - _ { tcx.sess.bug("impl_self_ty: unbound item or item that \ + _ { tcx.sess.bug(~"impl_self_ty: unbound item or item that \ doesn't have a self_ty"); } } } else { @@ -739,7 +740,7 @@ fn check_call_inner( // I would like to make this span_err, but it's // really hard due to the way that expr_bind() is // written. - fcx.ccx.tcx.sess.span_fatal(sp, "mismatched types: \ + fcx.ccx.tcx.sess.span_fatal(sp, ~"mismatched types: \ expected function or foreign \ function but found " + fcx.infcx.ty_to_str(in_fty)); @@ -762,15 +763,15 @@ fn check_call_inner( sp, #fmt["this function takes %u parameter%s but %u \ parameter%s supplied", expected_arg_count, if expected_arg_count == 1u { - "" + ~"" } else { - "s" + ~"s" }, supplied_arg_count, if supplied_arg_count == 1u { - " was" + ~" was" } else { - "s were" + ~"s were" }]); fcx.infcx.next_ty_vars(supplied_arg_count) }; @@ -839,7 +840,7 @@ fn check_call(fcx: @fn_ctxt, sp: span, call_expr_id: ast::node_id, fcx.write_ty(call_expr_id, f.output); ret bot; } - _ { fcx.ccx.tcx.sess.span_fatal(sp, "calling non-function"); } + _ { fcx.ccx.tcx.sess.span_fatal(sp, ~"calling non-function"); } } } @@ -881,7 +882,7 @@ fn check_then_else(fcx: @fn_ctxt, thn: ast::blk, ret if_bot; } - fn binop_method(op: ast::binop) -> option { + fn binop_method(op: ast::binop) -> option<~str> { alt op { ast::add | ast::subtract | ast::mul | ast::div | ast::rem | ast::bitxor | ast::bitand | ast::bitor | ast::shl | ast::shr @@ -891,7 +892,7 @@ fn binop_method(op: ast::binop) -> option { } fn lookup_op_method(fcx: @fn_ctxt, op_ex: @ast::expr, self_ex: @ast::expr, self_t: ty::t, - opname: str, args: ~[@ast::expr]) + opname: ~str, args: ~[@ast::expr]) -> option<(ty::t, bool)> { let lkup = method::lookup(fcx, op_ex, self_ex, op_ex.id, op_ex.callee_id, @opname, self_t, ~[], false); @@ -975,10 +976,10 @@ fn check_user_binop(fcx: @fn_ctxt, ex: @ast::expr, check_expr(fcx, rhs, none); tcx.sess.span_err( - ex.span, "binary operation " + ast_util::binop_to_str(op) + - " cannot be applied to type `" + + ex.span, ~"binary operation " + ast_util::binop_to_str(op) + + ~" cannot be applied to type `" + fcx.infcx.ty_to_str(lhs_resolved_t) + - "`"); + ~"`"); // If the or operator is used it might be that the user forgot to // supply the do keyword. Let's be more helpful in that situation. @@ -986,7 +987,7 @@ fn check_user_binop(fcx: @fn_ctxt, ex: @ast::expr, alt ty::get(lhs_resolved_t).struct { ty::ty_fn(f) { tcx.sess.span_note( - ex.span, "did you forget the 'do' keyword for the call?"); + ex.span, ~"did you forget the 'do' keyword for the call?"); } _ {} } @@ -994,7 +995,7 @@ fn check_user_binop(fcx: @fn_ctxt, ex: @ast::expr, (lhs_resolved_t, false) } - fn check_user_unop(fcx: @fn_ctxt, op_str: str, mname: str, + fn check_user_unop(fcx: @fn_ctxt, op_str: ~str, mname: ~str, ex: @ast::expr, rhs_expr: @ast::expr, rhs_t: ty::t) -> ty::t { alt lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, ~[]) { @@ -1074,7 +1075,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, some(ix) { if n_tys > 0u { tcx.sess.span_err(expr.span, - "can't provide type parameters \ + ~"can't provide type parameters \ to a field access"); } fcx.write_ty(expr.id, fields[ix].mt.ty); @@ -1133,7 +1134,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, if !is_callee { tcx.sess.span_err( expr.span, - "attempted to take value of method \ + ~"attempted to take value of method \ (try writing an anonymous function)"); } } @@ -1170,7 +1171,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, ty::mk_evec(tcx, {ty: t, mutbl: mutbl}, tt) } _ { - tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence") + tcx.sess.span_bug(expr.span, ~"vstore modifier on non-sequence") } }; fcx.write_ty(ev.id, typ); @@ -1245,7 +1246,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, ty::ty_ptr(*) { fcx.require_unsafe( expr.span, - "dereference of unsafe pointer"); + ~"dereference of unsafe pointer"); } _ { /*ok*/ } } @@ -1257,7 +1258,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, ty::ty_enum(*) { tcx.sess.span_err( expr.span, - "can only dereference enums \ + ~"can only dereference enums \ with a single variant which has a \ single argument"); } @@ -1275,7 +1276,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, oprnd_t = structurally_resolved_type(fcx, oprnd.span, oprnd_t); if !(ty::type_is_integral(oprnd_t) || ty::get(oprnd_t).struct == ty::ty_bool) { - oprnd_t = check_user_unop(fcx, "!", "!", expr, + oprnd_t = check_user_unop(fcx, ~"!", ~"!", expr, oprnd, oprnd_t); } } @@ -1283,7 +1284,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, oprnd_t = structurally_resolved_type(fcx, oprnd.span, oprnd_t); if !(ty::type_is_integral(oprnd_t) || ty::type_is_fp(oprnd_t)) { - oprnd_t = check_user_unop(fcx, "-", "unary-", expr, + oprnd_t = check_user_unop(fcx, ~"-", ~"unary-", expr, oprnd, oprnd_t); } } @@ -1305,7 +1306,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, let tpt = ty_param_bounds_and_ty_for_def(fcx, expr.span, defn); instantiate_path(fcx, pth, tpt, expr.span, expr.id); } - ast::expr_mac(_) { tcx.sess.bug("unexpanded macro"); } + ast::expr_mac(_) { tcx.sess.bug(~"unexpanded macro"); } ast::expr_fail(expr_opt) { bot = true; alt expr_opt { @@ -1327,7 +1328,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, result::ok(_) { /* fall through */ } result::err(_) { tcx.sess.span_err(expr.span, - "`ret;` in function returning non-nil"); } + ~"`ret;` in function returning non-nil"); } } } some(e) { check_expr_with(fcx, e, ret_ty); } @@ -1417,7 +1418,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, (ty::mk_fn(tcx, {output: ty::mk_nil(tcx) with fty}), fty.proto) } _ { - tcx.sess.span_fatal(expr.span, "a `loop` function's last \ + tcx.sess.span_fatal(expr.span, ~"a `loop` function's last \ argument should be of function \ type"); } @@ -1445,7 +1446,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, (ty::mk_fn(tcx, fty), fty.proto) } _ { - tcx.sess.span_fatal(expr.span, "a `do` function's last argument \ + tcx.sess.span_fatal(expr.span, ~"a `do` function's last argument \ should be of function type"); } }; @@ -1491,12 +1492,12 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, _ { if ty::type_is_nil(t_e) { - tcx.sess.span_err(expr.span, "cast from nil: " + - fcx.infcx.ty_to_str(t_e) + " as " + + tcx.sess.span_err(expr.span, ~"cast from nil: " + + fcx.infcx.ty_to_str(t_e) + ~" as " + fcx.infcx.ty_to_str(t_1)); } else if ty::type_is_nil(t_1) { - tcx.sess.span_err(expr.span, "cast to nil: " + - fcx.infcx.ty_to_str(t_e) + " as " + + tcx.sess.span_err(expr.span, ~"cast to nil: " + + fcx.infcx.ty_to_str(t_e) + ~" as " + fcx.infcx.ty_to_str(t_1)); } @@ -1510,8 +1511,8 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool, issue number in this comment. */ tcx.sess.span_err(expr.span, - "non-scalar cast: " + - fcx.infcx.ty_to_str(t_e) + " as " + + ~"non-scalar cast: " + + fcx.infcx.ty_to_str(t_e) + ~" as " + fcx.infcx.ty_to_str(t_1)); } } @@ -1568,7 +1569,7 @@ fn get_node(f: spanned) -> field { f.node } ty::ty_rec(flds) { flds } _ { tcx.sess.span_fatal(expr.span, - "record update has non-record base"); + ~"record update has non-record base"); } }; fcx.write_ty(id, bexpr_t); @@ -1582,7 +1583,7 @@ fn get_node(f: spanned) -> field { f.node } } if !found { tcx.sess.span_fatal(f.span, - "unknown field in record update: " + + ~"unknown field in record update: " + *f.node.ident); } } @@ -1606,13 +1607,13 @@ fn get_node(f: spanned) -> field { f.node } none { let resolved = structurally_resolved_type(fcx, expr.span, raw_base_t); - alt lookup_op_method(fcx, expr, base, resolved, "[]", + alt lookup_op_method(fcx, expr, base, resolved, ~"[]", ~[idx]) { some((ret_ty, _)) { fcx.write_ty(id, ret_ty); } _ { tcx.sess.span_fatal( - expr.span, "cannot index a value of type `" + - fcx.infcx.ty_to_str(base_t) + "`"); + expr.span, ~"cannot index a value of type `" + + fcx.infcx.ty_to_str(base_t) + ~"`"); } } } @@ -1625,7 +1626,7 @@ fn get_node(f: spanned) -> field { f.node } let p_ty = fcx.expr_ty(p); let lkup = method::lookup(fcx, p, p, expr.id, alloc_id, - @"alloc", p_ty, ~[], false); + @~"alloc", p_ty, ~[], false); alt lkup.method() { some(entry) { fcx.ccx.method_map.insert(alloc_id, entry); @@ -1672,7 +1673,7 @@ fn get_node(f: spanned) -> field { f.node } ty_to_str(tcx, fcx.expr_ty(expr)), alt expected { some(t) { ty_to_str(tcx, t) } - _ { "empty" } + _ { ~"empty" } }); unifier(); @@ -1683,9 +1684,9 @@ fn get_node(f: spanned) -> field { f.node } fn require_integral(fcx: @fn_ctxt, sp: span, t: ty::t) { if !type_is_integral(fcx, sp, t) { - fcx.ccx.tcx.sess.span_err(sp, "mismatched types: expected \ + fcx.ccx.tcx.sess.span_err(sp, ~"mismatched types: expected \ integral type but found `" - + fcx.infcx.ty_to_str(t) + "`"); + + fcx.infcx.ty_to_str(t) + ~"`"); } } @@ -1774,7 +1775,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { } _ { false } } { - fcx.ccx.tcx.sess.span_warn(s.span, "unreachable statement"); + fcx.ccx.tcx.sess.span_warn(s.span, ~"unreachable statement"); warned = true; } bot |= check_stmt(fcx, s); @@ -1783,7 +1784,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { none { fcx.write_nil(blk.node.id); } some(e) { if bot && !warned { - fcx.ccx.tcx.sess.span_warn(e.span, "unreachable expression"); + fcx.ccx.tcx.sess.span_warn(e.span, ~"unreachable expression"); } bot |= check_expr(fcx, e, none); let ety = fcx.expr_ty(e); @@ -1846,7 +1847,7 @@ fn check_enum_variants(ccx: @crate_ctxt, } _ { ccx.tcx.sess.span_err(e.span, - "expected signed integer constant"); + ~"expected signed integer constant"); } } } @@ -1854,7 +1855,7 @@ fn check_enum_variants(ccx: @crate_ctxt, } if vec::contains(disr_vals, disr_val) { ccx.tcx.sess.span_err(v.span, - "discriminator value already exists"); + ~"discriminator value already exists"); } vec::push(disr_vals, disr_val); let ctor_ty = ty::node_id_to_type(ccx.tcx, v.node.id); @@ -1881,7 +1882,7 @@ fn check_enum_variants(ccx: @crate_ctxt, _ { false } } }) { - ccx.tcx.sess.span_err(sp, "illegal recursive enum type; \ + ccx.tcx.sess.span_err(sp, ~"illegal recursive enum type; \ wrap the inner value in a box to \ make it representable"); } @@ -1902,7 +1903,7 @@ fn check_pred_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool { if !ty::is_pred_ty(fcx.expr_ty(operator)) { fcx.ccx.tcx.sess.span_err (operator.span, - "operator in constraint has non-boolean return type"); + ~"operator in constraint has non-boolean return type"); } alt operator.node { @@ -1913,26 +1914,26 @@ fn check_pred_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool { } _ { fcx.ccx.tcx.sess.span_err(operator.span, - "impure function as operator \ + ~"impure function as operator \ in constraint"); } } for operands.each |operand| { if !ast_util::is_constraint_arg(operand) { let s = - "constraint args must be slot variables or literals"; + ~"constraint args must be slot variables or literals"; fcx.ccx.tcx.sess.span_err(e.span, s); } } } _ { - let s = "in a constraint, expected the \ + let s = ~"in a constraint, expected the \ constraint name to be an explicit name"; fcx.ccx.tcx.sess.span_err(e.span, s); } } } - _ { fcx.ccx.tcx.sess.span_err(e.span, "check on non-predicate"); } + _ { fcx.ccx.tcx.sess.span_err(e.span, ~"check on non-predicate"); } } ret bot; } @@ -1957,7 +1958,7 @@ fn check_constraints(fcx: @fn_ctxt, cs: ~[@ast::constr], @alt a.node { ast::carg_base { fcx.ccx.tcx.sess.span_bug(a.span, - "check_constraints:\ + ~"check_constraints:\ unexpected carg_base"); } ast::carg_lit(l) { @@ -1982,7 +1983,7 @@ fn check_constraints(fcx: @fn_ctxt, cs: ~[@ast::constr], span: a.span} } else { fcx.ccx.tcx.sess.span_bug( - a.span, "check_constraints:\ + a.span, ~"check_constraints:\ carg_ident index out of bounds"); } } @@ -2018,7 +2019,7 @@ fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> tv_vid { some(x) { x } _ { fcx.ccx.tcx.sess.span_fatal(sp, - "internal error looking up a local var") + ~"internal error looking up a local var") } } } @@ -2048,7 +2049,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ret no_params(self_ty); } none { - fcx.ccx.tcx.sess.span_bug(sp, "def_self with no self_ty"); + fcx.ccx.tcx.sess.span_bug(sp, ~"def_self with no self_ty"); } } } @@ -2068,7 +2069,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ast::def_fn(id, ast::unsafe_fn) { // Unsafe functions can only be touched in an unsafe context - fcx.require_unsafe(sp, "access to unsafe function"); + fcx.require_unsafe(sp, ~"access to unsafe function"); ret ty::lookup_item_type(fcx.ccx.tcx, id); } @@ -2082,7 +2083,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ret no_params(typ); } ast::def_ty(_) | ast::def_prim_ty(_) { - fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found type"); + fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found type"); } ast::def_upvar(_, inner, _) { ret ty_param_bounds_and_ty_for_def(fcx, sp, *inner); @@ -2091,13 +2092,13 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ret no_params(ty::mk_param(fcx.ccx.tcx, n, did)); } ast::def_mod(*) | ast::def_foreign_mod(*) { - fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found module"); + fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found module"); } ast::def_use(*) { - fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found use"); + fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found use"); } ast::def_region(*) { - fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found region"); + fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found region"); } } } @@ -2117,7 +2118,7 @@ fn instantiate_path(fcx: @fn_ctxt, let self_r = alt pth.rp { some(r) if !tpt.rp => { fcx.ccx.tcx.sess.span_err - (sp, "this item is not region-parameterized"); + (sp, ~"this item is not region-parameterized"); none } some(r) => { @@ -2137,15 +2138,15 @@ fn instantiate_path(fcx: @fn_ctxt, fcx.infcx.next_ty_vars(ty_param_count) } else if ty_param_count == 0u { fcx.ccx.tcx.sess.span_err - (sp, "this item does not take type parameters"); + (sp, ~"this item does not take type parameters"); fcx.infcx.next_ty_vars(ty_param_count) } else if ty_substs_len > ty_param_count { fcx.ccx.tcx.sess.span_err - (sp, "too many type parameters provided for this item"); + (sp, ~"too many type parameters provided for this item"); fcx.infcx.next_ty_vars(ty_param_count) } else if ty_substs_len < ty_param_count { fcx.ccx.tcx.sess.span_err - (sp, "not enough type parameters provided for this item"); + (sp, ~"not enough type parameters provided for this item"); fcx.infcx.next_ty_vars(ty_param_count) } else { pth.types.map(|aty| fcx.to_ty(aty)) @@ -2163,7 +2164,7 @@ fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t { result::ok(t_s) if !ty::type_is_var(t_s) { ret t_s; } _ { fcx.ccx.tcx.sess.span_fatal - (sp, "the type of this value must be known in this context"); + (sp, ~"the type of this value must be known in this context"); } } } @@ -2253,45 +2254,45 @@ fn arg(m: ast::rmode, ty: ty::t) -> ty::arg { } let tcx = ccx.tcx; let (n_tps, inputs, output) = alt *it.ident { - "size_of" | - "pref_align_of" | "min_align_of" { (1u, ~[], ty::mk_uint(ccx.tcx)) } - "init" { (1u, ~[], param(ccx, 0u)) } - "forget" { (1u, ~[arg(ast::by_move, param(ccx, 0u))], + ~"size_of" | + ~"pref_align_of" | ~"min_align_of" { (1u, ~[], ty::mk_uint(ccx.tcx)) } + ~"init" { (1u, ~[], param(ccx, 0u)) } + ~"forget" { (1u, ~[arg(ast::by_move, param(ccx, 0u))], ty::mk_nil(tcx)) } - "reinterpret_cast" { (2u, ~[arg(ast::by_ref, param(ccx, 0u))], + ~"reinterpret_cast" { (2u, ~[arg(ast::by_ref, param(ccx, 0u))], param(ccx, 1u)) } - "addr_of" { (1u, ~[arg(ast::by_ref, param(ccx, 0u))], + ~"addr_of" { (1u, ~[arg(ast::by_ref, param(ccx, 0u))], ty::mk_imm_ptr(tcx, param(ccx, 0u))) } - "move_val" | "move_val_init" { + ~"move_val" | ~"move_val_init" { (1u, ~[arg(ast::by_mutbl_ref, param(ccx, 0u)), arg(ast::by_move, param(ccx, 0u))], ty::mk_nil(tcx)) } - "needs_drop" { (1u, ~[], ty::mk_bool(tcx)) } + ~"needs_drop" { (1u, ~[], ty::mk_bool(tcx)) } - "atomic_xchng" | "atomic_add" | "atomic_sub" | - "atomic_xchng_acq" | "atomic_add_acq" | "atomic_sub_acq" | - "atomic_xchng_rel" | "atomic_add_rel" | "atomic_sub_rel" { + ~"atomic_xchng" | ~"atomic_add" | ~"atomic_sub" | + ~"atomic_xchng_acq" | ~"atomic_add_acq" | ~"atomic_sub_acq" | + ~"atomic_xchng_rel" | ~"atomic_add_rel" | ~"atomic_sub_rel" { (0u, ~[arg(ast::by_mutbl_ref, ty::mk_int(tcx)), arg(ast::by_val, ty::mk_int(tcx))], ty::mk_int(tcx)) } - "get_tydesc" { + ~"get_tydesc" { // FIXME (#2712): return *intrinsic::tydesc, not *() (1u, ~[], ty::mk_nil_ptr(tcx)) } - "visit_tydesc" { - assert ccx.tcx.intrinsic_defs.contains_key(@"tydesc"); - assert ccx.tcx.intrinsic_defs.contains_key(@"ty_visitor"); - let (_, tydesc_ty) = ccx.tcx.intrinsic_defs.get(@"tydesc"); - let (_, visitor_trait) = ccx.tcx.intrinsic_defs.get(@"ty_visitor"); + ~"visit_tydesc" { + assert ccx.tcx.intrinsic_defs.contains_key(@~"tydesc"); + assert ccx.tcx.intrinsic_defs.contains_key(@~"ty_visitor"); + let (_, tydesc_ty) = ccx.tcx.intrinsic_defs.get(@~"tydesc"); + let (_, visitor_trait) = ccx.tcx.intrinsic_defs.get(@~"ty_visitor"); let td_ptr = ty::mk_ptr(ccx.tcx, {ty: tydesc_ty, mutbl: ast::m_imm}); (0u, ~[arg(ast::by_val, td_ptr), arg(ast::by_ref, visitor_trait)], ty::mk_nil(tcx)) } - "frame_address" { + ~"frame_address" { let fty = ty::mk_fn(ccx.tcx, { purity: ast::impure_fn, proto: ast::proto_any, @@ -2308,8 +2309,8 @@ fn arg(m: ast::rmode, ty: ty::t) -> ty::arg { (0u, ~[arg(ast::by_ref, fty)], ty::mk_nil(tcx)) } other { - tcx.sess.span_err(it.span, "unrecognized intrinsic function: `" + - other + "`"); + tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" + + other + ~"`"); ret; } }; diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index e45c5f308eab..158d19bb6e23 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -90,9 +90,9 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, let s = #fmt["this pattern has %u field%s, but the \ corresponding variant has %u field%s", subpats_len, - if subpats_len == 1u { "" } else { "s" }, + if subpats_len == 1u { ~"" } else { ~"s" }, arg_len, - if arg_len == 1u { "" } else { "s" }]; + if arg_len == 1u { ~"" } else { ~"s" }]; tcx.sess.span_fatal(pat.span, s); } @@ -106,8 +106,8 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, (pat.span, #fmt["this pattern has %u field%s, \ but the corresponding variant has no fields", subpats_len, - if subpats_len == 1u { "" } - else { "s" }]); + if subpats_len == 1u { ~"" } + else { ~"s" }]); } } _ { @@ -143,12 +143,12 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { #debug["pat_range ending type: %?", e_ty]; if !require_same_types( tcx, some(fcx.infcx), pat.span, b_ty, e_ty, - || "mismatched types in range") { + || ~"mismatched types in range") { // no-op } else if !ty::type_is_numeric(b_ty) { - tcx.sess.span_err(pat.span, "non-numeric type used in range"); + tcx.sess.span_err(pat.span, ~"non-numeric type used in range"); } else if !valid_range_bounds(fcx.ccx, begin, end) { - tcx.sess.span_err(begin.span, "lower range bound must be less \ + tcx.sess.span_err(begin.span, ~"lower range bound must be less \ than upper"); } fcx.write_ty(pat.id, b_ty); @@ -246,9 +246,9 @@ fn matches(name: ast::ident, f: ty::field) -> bool { _ { tcx.sess.span_fatal( pat.span, - "mismatched types: expected `" + + ~"mismatched types: expected `" + fcx.infcx.ty_to_str(expected) + - "` found box"); + ~"` found box"); } } } @@ -261,9 +261,9 @@ fn matches(name: ast::ident, f: ty::field) -> bool { _ { tcx.sess.span_fatal( pat.span, - "mismatched types: expected `" + + ~"mismatched types: expected `" + fcx.infcx.ty_to_str(expected) + - "` found uniq"); + ~"` found uniq"); } } } diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index c3829f60c40d..2dc80593e027 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -107,7 +107,7 @@ fn method() -> option { if self.candidates.len() > 1u { self.tcx().sess.span_err( self.expr.span, - "multiple applicable methods in scope"); + ~"multiple applicable methods in scope"); for self.candidates.eachi |i, candidate| { alt candidate.entry.origin { @@ -222,14 +222,14 @@ fn add_candidates_from_trait(did: ast::def_id, trait_substs: ty::substs) { if ty::type_has_self(m_fty) { self.tcx().sess.span_err( self.expr.span, - "can not call a method that contains a \ + ~"can not call a method that contains a \ self type through a boxed iface"); } if (*m.tps).len() > 0u { self.tcx().sess.span_err( self.expr.span, - "can not call a generic method through a \ + ~"can not call a generic method through a \ boxed trait"); } @@ -256,7 +256,7 @@ fn add_candidates_from_class(did: ast::def_id, class_substs: ty::substs) { if m.vis == ast::private && !self.include_private { self.tcx().sess.span_fatal( self.expr.span, - "Call to private method not allowed outside \ + ~"Call to private method not allowed outside \ its defining class"); } @@ -399,12 +399,12 @@ fn write_mty_from_candidate(cand: candidate) -> method_map_entry { } else if n_tps_m == 0u { tcx.sess.span_err( self.expr.span, - "this method does not take type parameters"); + ~"this method does not take type parameters"); self.fcx.infcx.next_ty_vars(n_tps_m) } else if n_tps_supplied != n_tps_m { tcx.sess.span_err( self.expr.span, - "incorrect number of type \ + ~"incorrect number of type \ parameters given for this method"); self.fcx.infcx.next_ty_vars(n_tps_m) } else { diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index d5401e3a4e7e..a883946252ca 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -96,11 +96,11 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, for vec::each(*ty::trait_methods(tcx, did)) |m| { if ty::type_has_self(ty::mk_fn(tcx, m.fty)) { tcx.sess.span_err( - sp, "a boxed iface with self types may not be \ + sp, ~"a boxed iface with self types may not be \ passed as a bounded type"); } else if (*m.tps).len() > 0u { tcx.sess.span_err( - sp, "a boxed iface with generic methods may not \ + sp, ~"a boxed iface with generic methods may not \ be passed as a bounded type"); } @@ -162,7 +162,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, 1u { ret found[0]; } _ { fcx.ccx.tcx.sess.span_err( - sp, "multiple applicable methods in scope"); + sp, ~"multiple applicable methods in scope"); ret found[0]; } } @@ -171,8 +171,8 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, } tcx.sess.span_fatal( - sp, "failed to find an implementation of interface " + - ty_to_str(tcx, trait_ty) + " for " + + sp, ~"failed to find an implementation of interface " + + ty_to_str(tcx, trait_ty) + ~" for " + ty_to_str(tcx, ty)); } diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index 4773788593aa..d563a4a99161 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -106,7 +106,7 @@ fn check_implementation(item: @item, none { let session = self.crate_context.tcx.sess; session.span_warn(item.span, - "no base type found for inherent \ + ~"no base type found for inherent \ implementation; implement a trait \ instead"); } @@ -194,8 +194,8 @@ fn get_base_type_def_id(original_type: t) -> option { ret some(def_id); } _ { - fail "get_base_type() returned a type that wasn't an \ - enum, class, or trait"; + fail ~"get_base_type() returned a type that \ + wasn't an enum, class, or trait"; } } } @@ -217,10 +217,11 @@ fn check_implementation_coherence(_trait_def_id: def_id, if self.polytypes_unify(polytype_a, polytype_b) { let session = self.crate_context.tcx.sess; session.span_err(implementation_b.span, - "conflicting implementations for a \ + ~"conflicting implementations for a \ trait"); - session.span_note(implementation_a.span, - "note conflicting implementation here"); + session.span_note( + implementation_a.span, + ~"note conflicting implementation here"); } } } @@ -265,8 +266,9 @@ fn get_self_type_for_implementation(implementation: @item) ret self.crate_context.tcx.tcache.get(def); } _ { - self.crate_context.tcx.sess.span_bug(implementation.span, - "not an implementation"); + self.crate_context.tcx.sess.span_bug( + implementation.span, + ~"not an implementation"); } } } @@ -328,7 +330,7 @@ fn check_privileged_scopes(crate: @crate) { let session = self.crate_context.tcx.sess; session.span_warn(item.span, - "cannot \ + ~"cannot \ implement \ inherent \ methods for a \ @@ -356,7 +358,7 @@ trait \ let session = self .crate_context.tcx.sess; session.span_warn(item.span, - "cannot \ + ~"cannot \ provide \ an \ extension \ diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index 7e4a98fdc38f..64d477ae63fa 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -29,7 +29,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { // There ought to be a better approach. Attributes? for crate.node.module.items.each |crate_item| { - if *crate_item.ident == "intrinsic" { + if *crate_item.ident == ~"intrinsic" { alt crate_item.node { ast::item_mod(m) { for m.items.each |intrinsic_item| { @@ -99,7 +99,7 @@ fn get_item_ty(id: ast::def_id) -> ty::ty_param_bounds_and_ty { fn ty_infer(span: span) -> ty::t { self.tcx.sess.span_bug(span, - "found `ty_infer` in unexpected place"); + ~"found `ty_infer` in unexpected place"); } } @@ -187,8 +187,8 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, self_ty: ty::t) { if impl_m.tps != if_m.tps { - tcx.sess.span_err(sp, "method `" + *if_m.ident + - "` has an incompatible set of type parameters"); + tcx.sess.span_err(sp, ~"method `" + *if_m.ident + + ~"` has an incompatible set of type parameters"); ret; } @@ -228,7 +228,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, }; require_same_types( tcx, none, sp, impl_fty, if_fty, - || "method `" + *if_m.ident + "` has an incompatible type"); + || ~"method `" + *if_m.ident + ~"` has an incompatible type"); ret; // Replaces bound references to the self region with `with_r`. @@ -452,7 +452,7 @@ fn ty_of_ty_method(self: @crate_ctxt, fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref, rp: bool) -> (ast::def_id, ty_param_substs_and_ty) { - let sp = t.path.span, err = "can only implement interface types", + let sp = t.path.span, err = ~"can only implement interface types", sess = ccx.tcx.sess; let rscope = type_rscope(rp); @@ -551,7 +551,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) } ast::item_impl(*) | ast::item_mod(_) | ast::item_foreign_mod(_) { fail; } - ast::item_mac(*) { fail "item macros unimplemented" } + ast::item_mac(*) { fail ~"item macros unimplemented" } } } @@ -582,7 +582,7 @@ fn compute_bounds(ccx: @crate_ctxt, } _ { ccx.tcx.sess.span_err( - t.span, "type parameter bounds must be \ + t.span, ~"type parameter bounds must be \ interface types"); ~[] } diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index ab72c5637ff1..da28e657758d 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -257,7 +257,7 @@ fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) ast::ty_i64 { int_ty_set(INT_TY_SET_i64) } ast::ty_i { int_ty_set(INT_TY_SET_i) } ast::ty_char { tcx.sess.bug( - "char type passed to convert_integral_ty_to_int_ty_set()"); } + ~"char type passed to convert_integral_ty_to_int_ty_set()"); } } } ty_uint(uint_ty) { @@ -269,7 +269,7 @@ fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) ast::ty_u { int_ty_set(INT_TY_SET_u) } } } - _ { tcx.sess.bug("non-integral type passed to \ + _ { tcx.sess.bug(~"non-integral type passed to \ convert_integral_ty_to_int_ty_set()"); } } } @@ -331,13 +331,13 @@ enum fixup_err { cyclic_region(region_vid) } -fn fixup_err_to_str(f: fixup_err) -> str { +fn fixup_err_to_str(f: fixup_err) -> ~str { alt f { - unresolved_int_ty(_) { "unconstrained integral type" } - unresolved_ty(_) { "unconstrained type" } - cyclic_ty(_) { "cyclic type of infinite size" } - unresolved_region(_) { "unconstrained region" } - cyclic_region(_) { "cyclic region" } + unresolved_int_ty(_) { ~"unconstrained integral type" } + unresolved_ty(_) { ~"unconstrained type" } + cyclic_ty(_) { ~"cyclic type of infinite size" } + unresolved_region(_) { ~"unconstrained region" } + cyclic_region(_) { ~"cyclic region" } } } @@ -442,38 +442,38 @@ fn compare(t: T, f: fn() -> ty::type_err) -> cres { } iface to_str { - fn to_str(cx: infer_ctxt) -> str; + fn to_str(cx: infer_ctxt) -> ~str; } impl of to_str for ty::t { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { ty_to_str(cx.tcx, self) } } impl of to_str for ty::mt { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { mt_to_str(cx.tcx, self) } } impl of to_str for ty::region { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { util::ppaux::region_to_str(cx.tcx, self) } } impl of to_str for bound { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { alt self { some(v) { v.to_str(cx) } - none { "none" } + none { ~"none" } } } } impl of to_str for bounds { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { #fmt["{%s <: %s}", self.lb.to_str(cx), self.ub.to_str(cx)] @@ -481,7 +481,7 @@ fn to_str(cx: infer_ctxt) -> str { } impl of to_str for int_ty_set { - fn to_str(_cx: infer_ctxt) -> str { + fn to_str(_cx: infer_ctxt) -> ~str { alt self { int_ty_set(v) { uint::to_str(v, 10u) } } @@ -489,7 +489,7 @@ fn to_str(_cx: infer_ctxt) -> str { } impl of to_str for var_value { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { alt self { redirect(vid) { #fmt("redirect(%s)", vid.to_str()) } root(pt, rk) { #fmt("root(%s, %s)", pt.to_str(cx), @@ -633,7 +633,7 @@ fn next_region_var() -> ty::region { ty::re_var(self.next_region_var_id()) } - fn ty_to_str(t: ty::t) -> str { + fn ty_to_str(t: ty::t) -> ~str { ty_to_str(self.tcx, self.resolve_type_vars_if_possible(t)) } @@ -1523,7 +1523,7 @@ fn crosspollinate(anmnt: assignment, iface combine { fn infcx() -> infer_ctxt; - fn tag() -> str; + fn tag() -> ~str; fn mts(a: ty::mt, b: ty::mt) -> cres; fn contratys(a: ty::t, b: ty::t) -> cres; @@ -1880,7 +1880,7 @@ fn super_tys( impl of combine for sub { fn infcx() -> infer_ctxt { *self } - fn tag() -> str { "sub" } + fn tag() -> ~str { ~"sub" } fn lub() -> lub { lub(*self) } @@ -2059,7 +2059,7 @@ fn self_tys(a: option, b: option) -> cres> { impl of combine for lub { fn infcx() -> infer_ctxt { *self } - fn tag() -> str { "lub" } + fn tag() -> ~str { ~"lub" } fn bot_ty(b: ty::t) -> cres { ok(b) } fn ty_bot(b: ty::t) -> cres { self.bot_ty(b) } // commutative @@ -2243,7 +2243,7 @@ fn self_tys(a: option, b: option) -> cres> { impl of combine for glb { fn infcx() -> infer_ctxt { *self } - fn tag() -> str { "glb" } + fn tag() -> ~str { ~"glb" } fn mts(a: ty::mt, b: ty::mt) -> cres { let tcx = self.infcx().tcx; diff --git a/src/rustc/middle/typeck/rscope.rs b/src/rustc/middle/typeck/rscope.rs index ec0dbe7ea8e0..759ec5496b1d 100644 --- a/src/rustc/middle/typeck/rscope.rs +++ b/src/rustc/middle/typeck/rscope.rs @@ -1,36 +1,36 @@ import result::result; iface region_scope { - fn anon_region() -> result; - fn named_region(id: ast::ident) -> result; + fn anon_region() -> result; + fn named_region(id: ast::ident) -> result; } enum empty_rscope { empty_rscope } impl of region_scope for empty_rscope { - fn anon_region() -> result { - result::err("region types are not allowed here") + fn anon_region() -> result { + result::err(~"region types are not allowed here") } - fn named_region(id: ast::ident) -> result { - if *id == "static" { result::ok(ty::re_static) } - else { result::err("only the static region is allowed here") } + fn named_region(id: ast::ident) -> result { + if *id == ~"static" { result::ok(ty::re_static) } + else { result::err(~"only the static region is allowed here") } } } enum type_rscope = bool; impl of region_scope for type_rscope { - fn anon_region() -> result { + fn anon_region() -> result { if *self { result::ok(ty::re_bound(ty::br_self)) } else { - result::err("to use region types here, the containing type \ + result::err(~"to use region types here, the containing type \ must be declared with a region bound") } } - fn named_region(id: ast::ident) -> result { + fn named_region(id: ast::ident) -> result { do empty_rscope.named_region(id).chain_err |_e| { - if *id == "self" { self.anon_region() } + if *id == ~"self" { self.anon_region() } else { - result::err("named regions other than `self` are not \ + result::err(~"named regions other than `self` are not \ allowed as part of a type declaration") } } @@ -43,10 +43,10 @@ fn in_anon_rscope(self: RS, r: ty::region) @anon_rscope({anon: r, base: self as region_scope}) } impl of region_scope for @anon_rscope { - fn anon_region() -> result { + fn anon_region() -> result { result::ok(self.anon) } - fn named_region(id: ast::ident) -> result { + fn named_region(id: ast::ident) -> result { self.base.named_region(id) } } @@ -57,10 +57,10 @@ fn in_binding_rscope(self: RS) -> @binding_rscope { @binding_rscope({base: base}) } impl of region_scope for @binding_rscope { - fn anon_region() -> result { + fn anon_region() -> result { result::ok(ty::re_bound(ty::br_anon)) } - fn named_region(id: ast::ident) -> result { + fn named_region(id: ast::ident) -> result { do self.base.named_region(id).chain_err |_e| { result::ok(ty::re_bound(ty::br_named(id))) } diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index 26b307721051..011b482f577d 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -25,7 +25,7 @@ fn indenter() -> _indenter { _indenter(()) } -type flag = hashmap; +type flag = hashmap<~str, ()>; fn field_expr(f: ast::field) -> @ast::expr { ret f.node.expr; } @@ -74,7 +74,7 @@ fn local_rhs_span(l: @ast::local, def: span) -> span { fn is_main_name(path: syntax::ast_map::path) -> bool { // FIXME (#34): path should be a constrained type, so we know // the call to last doesn't fail. - vec::last(path) == syntax::ast_map::path_name(@"main") + vec::last(path) == syntax::ast_map::path_name(@~"main") } // diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 91edf4bb0d70..5d62bc314506 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -18,16 +18,16 @@ import syntax::ast_map; import driver::session::session; -fn bound_region_to_str(cx: ctxt, br: bound_region) -> str { +fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { alt br { - br_anon { "&" } + br_anon { ~"&" } br_named(str) { #fmt["&%s", *str] } - br_self if cx.sess.ppregions() { "&" } - br_self { "&self" } + br_self if cx.sess.ppregions() { ~"&" } + br_self { ~"&self" } } } -fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> str { +fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { alt cx.items.find(node_id) { some(ast_map::node_block(blk)) { #fmt("", @@ -62,7 +62,7 @@ fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> str { } } -fn region_to_str(cx: ctxt, region: region) -> str { +fn region_to_str(cx: ctxt, region: region) -> ~str { alt region { re_scope(node_id) { #fmt["&%s", re_scope_id_to_str(cx, node_id)] } re_bound(br) { bound_region_to_str(cx, br) } @@ -78,44 +78,53 @@ fn region_to_str(cx: ctxt, region: region) -> str { // These two should not be seen by end-users (very often, anyhow): re_var(id) { #fmt("&%s", id.to_str()) } - re_static { "&static" } + re_static { ~"&static" } } } -fn mt_to_str(cx: ctxt, m: mt) -> str { +fn mt_to_str(cx: ctxt, m: mt) -> ~str { let mstr = alt m.mutbl { - ast::m_mutbl { "mut " } - ast::m_imm { "" } - ast::m_const { "const " } + ast::m_mutbl { ~"mut " } + ast::m_imm { ~"" } + ast::m_const { ~"const " } }; ret mstr + ty_to_str(cx, m.ty); } -fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> str { +fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { alt vs { ty::vstore_fixed(n) { #fmt["%u", n] } - ty::vstore_uniq { "~" } - ty::vstore_box { "@" } + ty::vstore_uniq { ~"~" } + ty::vstore_box { ~"@" } ty::vstore_slice(r) { region_to_str(cx, r) } } } -fn tys_to_str(cx: ctxt, ts: ~[t]) -> str { - let mut rs = ""; +fn vstore_ty_to_str(cx: ctxt, ty: ~str, vs: ty::vstore) -> ~str { + alt vs { + ty::vstore_fixed(_) { + #fmt["%s/%s", ty, vstore_to_str(cx, vs)] + } + _ { #fmt["%s%s", vstore_to_str(cx, vs), ty] } + } +} + +fn tys_to_str(cx: ctxt, ts: ~[t]) -> ~str { + let mut rs = ~""; for ts.each |t| { rs += ty_to_str(cx, t); } rs } -fn ty_to_str(cx: ctxt, typ: t) -> str { +fn ty_to_str(cx: ctxt, typ: t) -> ~str { fn fn_input_to_str(cx: ctxt, input: {mode: ast::mode, ty: t}) -> - str { + ~str { let {mode, ty} = input; let modestr = alt canon_mode(cx, mode) { - ast::infer(_) { "" } + ast::infer(_) { ~"" } ast::expl(m) { if !ty::type_needs_infer(ty) && m == ty::default_arg_mode_for_ty(ty) { - "" + ~"" } else { mode_to_str(ast::expl(m)) } @@ -126,37 +135,37 @@ fn fn_input_to_str(cx: ctxt, input: {mode: ast::mode, ty: t}) -> fn fn_to_str(cx: ctxt, purity: ast::purity, proto: ast::proto, ident: option, inputs: ~[arg], output: t, cf: ast::ret_style, - constrs: ~[@constr]) -> str { + constrs: ~[@constr]) -> ~str { let mut s; s = alt purity { - ast::impure_fn {""} - _ {purity_to_str(purity) + " "} + ast::impure_fn {~""} + _ {purity_to_str(purity) + ~" "} }; s += proto_to_str(proto); - alt ident { some(i) { s += " "; s += *i; } _ { } } - s += "("; + alt ident { some(i) { s += ~" "; s += *i; } _ { } } + s += ~"("; let mut strs = ~[]; for inputs.each |a| { vec::push(strs, fn_input_to_str(cx, a)); } - s += str::connect(strs, ", "); - s += ")"; + s += str::connect(strs, ~", "); + s += ~")"; if ty::get(output).struct != ty_nil { - s += " -> "; + s += ~" -> "; alt cf { - ast::noreturn { s += "!"; } + ast::noreturn { s += ~"!"; } ast::return_val { s += ty_to_str(cx, output); } } } s += constrs_str(constrs); ret s; } - fn method_to_str(cx: ctxt, m: method) -> str { + fn method_to_str(cx: ctxt, m: method) -> ~str { ret fn_to_str( cx, m.fty.purity, m.fty.proto, some(m.ident), m.fty.inputs, - m.fty.output, m.fty.ret_style, m.fty.constraints) + ";"; + m.fty.output, m.fty.ret_style, m.fty.constraints) + ~";"; } - fn field_to_str(cx: ctxt, f: field) -> str { - ret *f.ident + ": " + mt_to_str(cx, f.mt); + fn field_to_str(cx: ctxt, f: field) -> ~str { + ret *f.ident + ~": " + mt_to_str(cx, f.mt); } // if there is an id, print that instead of the structural type: @@ -167,40 +176,40 @@ fn field_to_str(cx: ctxt, f: field) -> str { // pretty print the structural type representation: ret alt ty::get(typ).struct { - ty_nil { "()" } - ty_bot { "_|_" } - ty_bool { "bool" } - ty_int(ast::ty_i) { "int" } - ty_int(ast::ty_char) { "char" } + ty_nil { ~"()" } + ty_bot { ~"_|_" } + ty_bool { ~"bool" } + ty_int(ast::ty_i) { ~"int" } + ty_int(ast::ty_char) { ~"char" } ty_int(t) { ast_util::int_ty_to_str(t) } - ty_uint(ast::ty_u) { "uint" } + ty_uint(ast::ty_u) { ~"uint" } ty_uint(t) { ast_util::uint_ty_to_str(t) } - ty_float(ast::ty_f) { "float" } + ty_float(ast::ty_f) { ~"float" } ty_float(t) { ast_util::float_ty_to_str(t) } - ty_str { "str" } - ty_box(tm) { "@" + mt_to_str(cx, tm) } - ty_uniq(tm) { "~" + mt_to_str(cx, tm) } - ty_ptr(tm) { "*" + mt_to_str(cx, tm) } + ty_str { ~"str" } + ty_box(tm) { ~"@" + mt_to_str(cx, tm) } + ty_uniq(tm) { ~"~" + mt_to_str(cx, tm) } + ty_ptr(tm) { ~"*" + mt_to_str(cx, tm) } ty_rptr(r, tm) { let rs = region_to_str(cx, r); - if rs == "&" { + if rs == ~"&" { rs + mt_to_str(cx, tm) } else { - rs + "/" + mt_to_str(cx, tm) + rs + ~"/" + mt_to_str(cx, tm) } } - ty_vec(tm) { "[" + mt_to_str(cx, tm) + "]" } - ty_unboxed_vec(tm) { "unboxed_vec<" + mt_to_str(cx, tm) + ">" } - ty_type { "type" } + ty_vec(tm) { ~"[" + mt_to_str(cx, tm) + ~"]" } + ty_unboxed_vec(tm) { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" } + ty_type { ~"type" } ty_rec(elems) { - let mut strs: ~[str] = ~[]; + let mut strs: ~[~str] = ~[]; for elems.each |fld| { vec::push(strs, field_to_str(cx, fld)); } - "{" + str::connect(strs, ",") + "}" + ~"{" + str::connect(strs, ~",") + ~"}" } ty_tup(elems) { let mut strs = ~[]; for elems.each |elem| { vec::push(strs, ty_to_str(cx, elem)); } - "(" + str::connect(strs, ",") + ")" + ~"(" + str::connect(strs, ~",") + ~")" } ty_fn(f) { fn_to_str(cx, f.purity, f.proto, none, f.inputs, @@ -209,9 +218,9 @@ fn field_to_str(cx: ctxt, f: field) -> str { ty_var(v) { v.to_str() } ty_var_integral(v) { v.to_str() } ty_param(id, _) { - "'" + str::from_bytes(~[('a' as u8) + (id as u8)]) + ~"'" + str::from_bytes(~[('a' as u8) + (id as u8)]) } - ty_self { "self" } + ty_self { ~"self" } ty_enum(did, substs) | ty_class(did, substs) { let path = ty::item_path(cx, did); let base = ast_map::path_to_str(path); @@ -223,29 +232,24 @@ fn field_to_str(cx: ctxt, f: field) -> str { parameterized(cx, base, substs.self_r, substs.tps) } ty_evec(mt, vs) { - alt vs { - ty::vstore_fixed(_) { - #fmt["[%s]/%s", mt_to_str(cx, mt), vstore_to_str(cx, vs)] - } - _ { #fmt["%s[%s]", vstore_to_str(cx, vs), mt_to_str(cx, mt)] } - } + vstore_ty_to_str(cx, #fmt["[%s]", mt_to_str(cx, mt)], vs) } - ty_estr(vs) { #fmt["str/%s", vstore_to_str(cx, vs)] } - ty_opaque_box { "@?" } - ty_constr(t, _) { "@?" } - ty_opaque_closure_ptr(ck_block) { "closure&" } - ty_opaque_closure_ptr(ck_box) { "closure@" } - ty_opaque_closure_ptr(ck_uniq) { "closure~" } + ty_estr(vs) { vstore_ty_to_str(cx, ~"str", vs) } + ty_opaque_box { ~"@?" } + ty_constr(t, _) { ~"@?" } + ty_opaque_closure_ptr(ck_block) { ~"closure&" } + ty_opaque_closure_ptr(ck_box) { ~"closure@" } + ty_opaque_closure_ptr(ck_uniq) { ~"closure~" } } } fn parameterized(cx: ctxt, - base: str, + base: ~str, self_r: option, - tps: ~[ty::t]) -> str { + tps: ~[ty::t]) -> ~str { let r_str = alt self_r { - none { "" } + none { ~"" } some(r) { #fmt["/%s", region_to_str(cx, r)] } @@ -253,35 +257,35 @@ fn parameterized(cx: ctxt, if vec::len(tps) > 0u { let strs = vec::map(tps, |t| ty_to_str(cx, t) ); - #fmt["%s%s<%s>", base, r_str, str::connect(strs, ",")] + #fmt["%s%s<%s>", base, r_str, str::connect(strs, ~",")] } else { #fmt["%s%s", base, r_str] } } -fn ty_to_short_str(cx: ctxt, typ: t) -> str { +fn ty_to_short_str(cx: ctxt, typ: t) -> ~str { let mut s = encoder::encoded_ty(cx, typ); if str::len(s) >= 32u { s = str::slice(s, 0u, 32u); } ret s; } -fn constr_to_str(c: @constr) -> str { +fn constr_to_str(c: @constr) -> ~str { ret path_to_str(c.node.path) + pprust::constr_args_to_str(pprust::uint_to_str, c.node.args); } -fn constrs_str(constrs: ~[@constr]) -> str { - let mut s = ""; +fn constrs_str(constrs: ~[@constr]) -> ~str { + let mut s = ~""; let mut colon = true; for constrs.each |c| { - if colon { s += " : "; colon = false; } else { s += ", "; } + if colon { s += ~" : "; colon = false; } else { s += ~", "; } s += constr_to_str(c); } ret s; } fn ty_constr_to_str(c: @ast::spanned>) - -> str { + -> ~str { ret path_to_str(c.node.path) + constr_args_to_str::<@ast::path>(path_to_str, c.node.args); } diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index 91522e50a326..46884bcbe123 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -38,7 +38,7 @@ type srv_owner = fn(srv: srv) -> T; type ctxt_handler = fn~(ctxt: ctxt) -> T; -type parser = fn~(session, str) -> @ast::crate; +type parser = fn~(session, ~str) -> @ast::crate; enum msg { handle_request(fn~(ctxt)), @@ -49,15 +49,15 @@ enum srv = { ch: comm::chan }; -fn from_str(source: str, owner: srv_owner) -> T { +fn from_str(source: ~str, owner: srv_owner) -> T { run(owner, source, parse::from_str_sess) } -fn from_file(file: str, owner: srv_owner) -> T { +fn from_file(file: ~str, owner: srv_owner) -> T { run(owner, file, parse::from_file_sess) } -fn run(owner: srv_owner, source: str, +parse: parser) -> T { +fn run(owner: srv_owner, source: ~str, +parse: parser) -> T { let srv_ = srv({ ch: do task::spawn_listener |po| { @@ -70,7 +70,7 @@ fn run(owner: srv_owner, source: str, +parse: parser) -> T { ret res; } -fn act(po: comm::port, source: str, parse: parser) { +fn act(po: comm::port, source: ~str, parse: parser) { let (sess, ignore_errors) = build_session(); let ctxt = build_ctxt( @@ -155,8 +155,8 @@ fn build_error_handlers( }; impl of diagnostic::handler for diagnostic_handler { - fn fatal(msg: str) -> ! { self.inner.fatal(msg) } - fn err(msg: str) { self.inner.err(msg) } + fn fatal(msg: ~str) -> ! { self.inner.fatal(msg) } + fn err(msg: ~str) { self.inner.err(msg) } fn bump_err_count() { if !(*self.ignore_errors) { self.inner.bump_err_count(); @@ -164,19 +164,19 @@ fn bump_err_count() { } fn has_errors() -> bool { self.inner.has_errors() } fn abort_if_errors() { self.inner.abort_if_errors() } - fn warn(msg: str) { self.inner.warn(msg) } - fn note(msg: str) { self.inner.note(msg) } - fn bug(msg: str) -> ! { self.inner.bug(msg) } - fn unimpl(msg: str) -> ! { self.inner.unimpl(msg) } + fn warn(msg: ~str) { self.inner.warn(msg) } + fn note(msg: ~str) { self.inner.note(msg) } + fn bug(msg: ~str) -> ! { self.inner.bug(msg) } + fn unimpl(msg: ~str) -> ! { self.inner.unimpl(msg) } fn emit(cmsp: option<(codemap::codemap, codemap::span)>, - msg: str, lvl: diagnostic::level) { + msg: ~str, lvl: diagnostic::level) { self.inner.emit(cmsp, msg, lvl) } } let ignore_errors = @mut false; let emitter = fn@(cmsp: option<(codemap::codemap, codemap::span)>, - msg: str, lvl: diagnostic::level) { + msg: ~str, lvl: diagnostic::level) { if !(*ignore_errors) { diagnostic::emit(cmsp, msg, lvl); } @@ -198,7 +198,7 @@ fn emit(cmsp: option<(codemap::codemap, codemap::span)>, #[test] fn should_prune_unconfigured_items() { - let source = "#[cfg(shut_up_and_leave_me_alone)]fn a() { }"; + let source = ~"#[cfg(shut_up_and_leave_me_alone)]fn a() { }"; do from_str(source) |srv| { do exec(srv) |ctxt| { assert vec::is_empty(ctxt.ast.node.module.items); @@ -208,7 +208,7 @@ fn should_prune_unconfigured_items() { #[test] fn srv_should_build_ast_map() { - let source = "fn a() { }"; + let source = ~"fn a() { }"; do from_str(source) |srv| { do exec(srv) |ctxt| { assert ctxt.ast_map.size() != 0u @@ -218,7 +218,7 @@ fn srv_should_build_ast_map() { #[test] fn srv_should_build_reexport_map() { - let source = "import a::b; export b; mod a { mod b { } }"; + let source = ~"import a::b; export b; mod a { mod b { } }"; do from_str(source) |srv| { do exec(srv) |ctxt| { assert ctxt.exp_map.size() != 0u @@ -228,7 +228,7 @@ fn srv_should_build_reexport_map() { #[test] fn srv_should_resolve_external_crates() { - let source = "use std;\ + let source = ~"use std;\ fn f() -> std::sha1::sha1 {\ std::sha1::mk_sha1() }"; // Just testing that resolve doesn't crash @@ -237,7 +237,7 @@ fn f() -> std::sha1::sha1 {\ #[test] fn srv_should_resolve_core_crate() { - let source = "fn a() -> option { fail }"; + let source = ~"fn a() -> option { fail }"; // Just testing that resolve doesn't crash from_str(source, |_srv| { } ) } @@ -246,25 +246,25 @@ fn srv_should_resolve_core_crate() { fn srv_should_resolve_non_existant_imports() { // We want to ignore things we can't resolve. Shouldn't // need to be able to find external crates to create docs. - let source = "import wooboo; fn a() { }"; + let source = ~"import wooboo; fn a() { }"; from_str(source, |_srv| { } ) } #[test] fn srv_should_resolve_non_existant_uses() { - let source = "use forble; fn a() { }"; + let source = ~"use forble; fn a() { }"; from_str(source, |_srv| { } ) } #[test] fn should_ignore_external_import_paths_that_dont_exist() { - let source = "use forble; import forble::bippy;"; + let source = ~"use forble; import forble::bippy;"; from_str(source, |_srv| { } ) } #[test] fn srv_should_return_request_result() { - let source = "fn a() { }"; + let source = ~"fn a() { }"; do from_str(source) |srv| { let result = exec(srv, |_ctxt| 1000 ); assert result == 1000; diff --git a/src/rustdoc/attr_parser.rs b/src/rustdoc/attr_parser.rs index 32c5f7ccf539..931df85fa2ae 100644 --- a/src/rustdoc/attr_parser.rs +++ b/src/rustdoc/attr_parser.rs @@ -14,13 +14,13 @@ export parse_hidden; type crate_attrs = { - name: option + name: option<~str> }; #[cfg(test)] mod test { - fn parse_attributes(source: str) -> ~[ast::attribute] { + fn parse_attributes(source: ~str) -> ~[ast::attribute] { import syntax::parse; import parse::parser; import parse::attr::parser_attr; @@ -29,7 +29,7 @@ fn parse_attributes(source: str) -> ~[ast::attribute] { let parse_sess = syntax::parse::new_parse_sess(none); let parser = parse::new_parser_from_source_str( - parse_sess, ~[], "-", codemap::fss_none, @source); + parse_sess, ~[], ~"-", codemap::fss_none, @source); parser.parse_outer_attributes() } @@ -44,7 +44,7 @@ fn doc_meta( * doc attribute */ - let doc_attrs = attr::find_attrs_by_name(attrs, "doc"); + let doc_attrs = attr::find_attrs_by_name(attrs, ~"doc"); let doc_metas = do doc_attrs.map |attr| { attr::attr_meta(attr::desugar_doc_attr(attr)) }; @@ -64,21 +64,21 @@ fn parse_crate(attrs: ~[ast::attribute]) -> crate_attrs { { name: attr::last_meta_item_value_str_by_name( - link_metas, "name").map(|x| *x ) + link_metas, ~"name").map(|x| *x ) } } #[test] fn should_extract_crate_name_from_link_attribute() { - let source = "#[link(name = \"snuggles\")]"; + let source = ~"#[link(name = \"snuggles\")]"; let attrs = test::parse_attributes(source); let attrs = parse_crate(attrs); - assert attrs.name == some("snuggles"); + assert attrs.name == some(~"snuggles"); } #[test] fn should_not_extract_crate_name_if_no_link_attribute() { - let source = ""; + let source = ~""; let attrs = test::parse_attributes(source); let attrs = parse_crate(attrs); assert attrs.name == none; @@ -86,13 +86,13 @@ fn should_not_extract_crate_name_if_no_link_attribute() { #[test] fn should_not_extract_crate_name_if_no_name_value_in_link_attribute() { - let source = "#[link(whatever)]"; + let source = ~"#[link(whatever)]"; let attrs = test::parse_attributes(source); let attrs = parse_crate(attrs); assert attrs.name == none; } -fn parse_desc(attrs: ~[ast::attribute]) -> option { +fn parse_desc(attrs: ~[ast::attribute]) -> option<~str> { alt doc_meta(attrs) { some(meta) { attr::get_meta_item_value_str(meta).map(|x| *x ) @@ -103,7 +103,7 @@ fn parse_desc(attrs: ~[ast::attribute]) -> option { #[test] fn parse_desc_should_handle_undocumented_mods() { - let source = ""; + let source = ~""; let attrs = test::parse_attributes(source); let attrs = parse_desc(attrs); assert attrs == none; @@ -111,10 +111,10 @@ fn parse_desc_should_handle_undocumented_mods() { #[test] fn parse_desc_should_parse_simple_doc_attributes() { - let source = "#[doc = \"basic\"]"; + let source = ~"#[doc = \"basic\"]"; let attrs = test::parse_attributes(source); let attrs = parse_desc(attrs); - assert attrs == some("basic"); + assert attrs == some(~"basic"); } fn parse_hidden(attrs: ~[ast::attribute]) -> bool { @@ -122,7 +122,7 @@ fn parse_hidden(attrs: ~[ast::attribute]) -> bool { some(meta) { alt attr::get_meta_item_list(meta) { some(metas) { - let hiddens = attr::find_meta_items_by_name(metas, "hidden"); + let hiddens = attr::find_meta_items_by_name(metas, ~"hidden"); vec::is_not_empty(hiddens) } none { false } @@ -134,14 +134,14 @@ fn parse_hidden(attrs: ~[ast::attribute]) -> bool { #[test] fn shoulde_parse_hidden_attribute() { - let source = "#[doc(hidden)]"; + let source = ~"#[doc(hidden)]"; let attrs = test::parse_attributes(source); assert parse_hidden(attrs) == true; } #[test] fn shoulde_not_parse_non_hidden_attribute() { - let source = "#[doc = \"\"]"; + let source = ~"#[doc = \"\"]"; let attrs = test::parse_attributes(source); assert parse_hidden(attrs) == false; } diff --git a/src/rustdoc/attr_pass.rs b/src/rustdoc/attr_pass.rs index 0d950b33fe7f..c884c40e70fb 100644 --- a/src/rustdoc/attr_pass.rs +++ b/src/rustdoc/attr_pass.rs @@ -14,7 +14,7 @@ fn mk_pass() -> pass { { - name: "attr", + name: ~"attr", f: run } } @@ -60,8 +60,8 @@ fn fold_crate( #[test] fn should_replace_top_module_name_with_crate_name() { - let doc = test::mk_doc("#[link(name = \"bond\")];"); - assert doc.cratemod().name() == "bond"; + let doc = test::mk_doc(~"#[link(name = \"bond\")];"); + assert doc.cratemod().name() == ~"bond"; } fn fold_item( @@ -96,7 +96,7 @@ fn parse_item_attrs( ast_map::node_item(item, _) { item.attrs } ast_map::node_foreign_item(item, _, _) { item.attrs } _ { - fail "parse_item_attrs: not an item"; + fail ~"parse_item_attrs: not an item"; } }; parse_attrs(attrs) @@ -105,32 +105,32 @@ fn parse_item_attrs( #[test] fn should_should_extract_mod_attributes() { - let doc = test::mk_doc("#[doc = \"test\"] mod a { }"); - assert doc.cratemod().mods()[0].desc() == some("test"); + let doc = test::mk_doc(~"#[doc = \"test\"] mod a { }"); + assert doc.cratemod().mods()[0].desc() == some(~"test"); } #[test] fn should_extract_top_mod_attributes() { - let doc = test::mk_doc("#[doc = \"test\"];"); - assert doc.cratemod().desc() == some("test"); + let doc = test::mk_doc(~"#[doc = \"test\"];"); + assert doc.cratemod().desc() == some(~"test"); } #[test] fn should_extract_foreign_mod_attributes() { - let doc = test::mk_doc("#[doc = \"test\"] extern mod a { }"); - assert doc.cratemod().nmods()[0].desc() == some("test"); + let doc = test::mk_doc(~"#[doc = \"test\"] extern mod a { }"); + assert doc.cratemod().nmods()[0].desc() == some(~"test"); } #[test] fn should_extract_foreign_fn_attributes() { - let doc = test::mk_doc("extern mod a { #[doc = \"test\"] fn a(); }"); - assert doc.cratemod().nmods()[0].fns[0].desc() == some("test"); + let doc = test::mk_doc(~"extern mod a { #[doc = \"test\"] fn a(); }"); + assert doc.cratemod().nmods()[0].fns[0].desc() == some(~"test"); } #[test] fn should_extract_fn_attributes() { - let doc = test::mk_doc("#[doc = \"test\"] fn a() -> int { }"); - assert doc.cratemod().fns()[0].desc() == some("test"); + let doc = test::mk_doc(~"#[doc = \"test\"] fn a() -> int { }"); + assert doc.cratemod().fns()[0].desc() == some(~"test"); } fn fold_enum( @@ -170,15 +170,15 @@ fn fold_enum( #[test] fn should_extract_enum_docs() { - let doc = test::mk_doc("#[doc = \"b\"]\ + let doc = test::mk_doc(~"#[doc = \"b\"]\ enum a { v }"); - assert doc.cratemod().enums()[0].desc() == some("b"); + assert doc.cratemod().enums()[0].desc() == some(~"b"); } #[test] fn should_extract_variant_docs() { - let doc = test::mk_doc("enum a { #[doc = \"c\"] v }"); - assert doc.cratemod().enums()[0].variants[0].desc == some("c"); + let doc = test::mk_doc(~"enum a { #[doc = \"c\"] v }"); + assert doc.cratemod().enums()[0].variants[0].desc == some(~"c"); } fn fold_trait( @@ -201,7 +201,7 @@ fn merge_method_attrs( ) -> ~[doc::methoddoc] { // Create an assoc list from method name to attributes - let attrs: ~[(str, option)] = do astsrv::exec(srv) |ctxt| { + let attrs: ~[(~str, option<~str>)] = do astsrv::exec(srv) |ctxt| { alt ctxt.ast_map.get(item_id) { ast_map::node_item(@{ node: ast::item_trait(_, methods), _ @@ -224,7 +224,7 @@ fn merge_method_attrs( (*method.ident, attr_parser::parse_desc(method.attrs)) }) } - _ { fail "unexpected item" } + _ { fail ~"unexpected item" } } }; @@ -241,18 +241,18 @@ fn merge_method_attrs( #[test] fn should_extract_trait_docs() { - let doc = test::mk_doc("#[doc = \"whatever\"] iface i { fn a(); }"); - assert doc.cratemod().traits()[0].desc() == some("whatever"); + let doc = test::mk_doc(~"#[doc = \"whatever\"] iface i { fn a(); }"); + assert doc.cratemod().traits()[0].desc() == some(~"whatever"); } #[test] fn should_extract_trait_method_docs() { let doc = test::mk_doc( - "iface i {\ + ~"iface i {\ #[doc = \"desc\"]\ fn f(a: bool) -> bool;\ }"); - assert doc.cratemod().traits()[0].methods[0].desc == some("desc"); + assert doc.cratemod().traits()[0].methods[0].desc == some(~"desc"); } @@ -272,25 +272,25 @@ fn fold_impl( #[test] fn should_extract_impl_docs() { let doc = test::mk_doc( - "#[doc = \"whatever\"] impl i for int { fn a() { } }"); - assert doc.cratemod().impls()[0].desc() == some("whatever"); + ~"#[doc = \"whatever\"] impl i for int { fn a() { } }"); + assert doc.cratemod().impls()[0].desc() == some(~"whatever"); } #[test] fn should_extract_impl_method_docs() { let doc = test::mk_doc( - "impl i for int {\ + ~"impl i for int {\ #[doc = \"desc\"]\ fn f(a: bool) -> bool { }\ }"); - assert doc.cratemod().impls()[0].methods[0].desc == some("desc"); + assert doc.cratemod().impls()[0].methods[0].desc == some(~"desc"); } #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); run(srv, doc) } } diff --git a/src/rustdoc/config.rs b/src/rustdoc/config.rs index ea397a4398ea..10bcbdb14045 100644 --- a/src/rustdoc/config.rs +++ b/src/rustdoc/config.rs @@ -28,75 +28,76 @@ enum output_style { /// The configuration for a rustdoc session type config = { - input_crate: str, - output_dir: str, + input_crate: ~str, + output_dir: ~str, output_format: output_format, output_style: output_style, - pandoc_cmd: option + pandoc_cmd: option<~str> }; -fn opt_output_dir() -> str { "output-dir" } -fn opt_output_format() -> str { "output-format" } -fn opt_output_style() -> str { "output-style" } -fn opt_pandoc_cmd() -> str { "pandoc-cmd" } -fn opt_help() -> str { "h" } +fn opt_output_dir() -> ~str { ~"output-dir" } +fn opt_output_format() -> ~str { ~"output-format" } +fn opt_output_style() -> ~str { ~"output-style" } +fn opt_pandoc_cmd() -> ~str { ~"pandoc-cmd" } +fn opt_help() -> ~str { ~"h" } -fn opts() -> ~[(getopts::opt, str)] { +fn opts() -> ~[(getopts::opt, ~str)] { ~[ (getopts::optopt(opt_output_dir()), - "--output-dir put documents here"), + ~"--output-dir put documents here"), (getopts::optopt(opt_output_format()), - "--output-format either 'markdown' or 'html'"), + ~"--output-format either 'markdown' or 'html'"), (getopts::optopt(opt_output_style()), - "--output-style either 'doc-per-crate' or 'doc-per-mod'"), + ~"--output-style either 'doc-per-crate' or 'doc-per-mod'"), (getopts::optopt(opt_pandoc_cmd()), - "--pandoc-cmd the command for running pandoc"), + ~"--pandoc-cmd the command for running pandoc"), (getopts::optflag(opt_help()), - "-h print help") + ~"-h print help") ] } fn usage() { import io::println; - println("Usage: rustdoc ~[options] \n"); - println("Options:\n"); + println(~"Usage: rustdoc ~[options] \n"); + println(~"Options:\n"); for opts().each |opt| { println(#fmt(" %s", tuple::second(opt))); } - println(""); + println(~""); } -fn default_config(input_crate: str) -> config { +fn default_config(input_crate: ~str) -> config { { input_crate: input_crate, - output_dir: ".", + output_dir: ~".", output_format: pandoc_html, output_style: doc_per_mod, pandoc_cmd: none } } -type program_output = fn~(str, ~[str]) -> {status: int, out: str, err: str}; +type program_output = fn~(~str, ~[~str]) -> + {status: int, out: ~str, err: ~str}; -fn mock_program_output(_prog: str, _args: ~[str]) -> { - status: int, out: str, err: str +fn mock_program_output(_prog: ~str, _args: ~[~str]) -> { + status: int, out: ~str, err: ~str } { { status: 0, - out: "", - err: "" + out: ~"", + err: ~"" } } -fn parse_config(args: ~[str]) -> result { +fn parse_config(args: ~[~str]) -> result { parse_config_(args, run::program_output) } fn parse_config_( - args: ~[str], + args: ~[~str], program_output: program_output -) -> result { +) -> result { let args = vec::tail(args); let opts = tuple::first(vec::unzip(opts())); alt getopts::getopts(args, opts) { @@ -105,9 +106,9 @@ fn parse_config_( let input_crate = vec::head(match.free); config_from_opts(input_crate, match, program_output) } else if vec::is_empty(match.free) { - result::err("no crates specified") + result::err(~"no crates specified") } else { - result::err("multiple crates specified") + result::err(~"multiple crates specified") } } result::err(f) { @@ -117,10 +118,10 @@ fn parse_config_( } fn config_from_opts( - input_crate: str, + input_crate: ~str, match: getopts::match, program_output: program_output -) -> result { +) -> result { let config = default_config(input_crate); let result = result::ok(config); @@ -173,27 +174,27 @@ fn config_from_opts( ret result; } -fn parse_output_format(output_format: str) -> result { +fn parse_output_format(output_format: ~str) -> result { alt output_format { - "markdown" { result::ok(markdown) } - "html" { result::ok(pandoc_html) } + ~"markdown" { result::ok(markdown) } + ~"html" { result::ok(pandoc_html) } _ { result::err(#fmt("unknown output format '%s'", output_format)) } } } -fn parse_output_style(output_style: str) -> result { +fn parse_output_style(output_style: ~str) -> result { alt output_style { - "doc-per-crate" { result::ok(doc_per_crate) } - "doc-per-mod" { result::ok(doc_per_mod) } + ~"doc-per-crate" { result::ok(doc_per_crate) } + ~"doc-per-mod" { result::ok(doc_per_mod) } _ { result::err(#fmt("unknown output style '%s'", output_style)) } } } fn maybe_find_pandoc( config: config, - maybe_pandoc_cmd: option, + maybe_pandoc_cmd: option<~str>, program_output: program_output -) -> result, str> { +) -> result, ~str> { if config.output_format != pandoc_html { ret result::ok(maybe_pandoc_cmd); } @@ -201,9 +202,9 @@ fn maybe_find_pandoc( let possible_pandocs = alt maybe_pandoc_cmd { some(pandoc_cmd) { ~[pandoc_cmd] } none { - ~["pandoc"] + alt os::homedir() { + ~[~"pandoc"] + alt os::homedir() { some(dir) { - ~[path::connect(dir, ".cabal/bin/pandoc")] + ~[path::connect(dir, ~".cabal/bin/pandoc")] } none { ~[] } } @@ -211,7 +212,7 @@ fn maybe_find_pandoc( }; let pandoc = do vec::find(possible_pandocs) |pandoc| { - let output = program_output(pandoc, ~["--version"]); + let output = program_output(pandoc, ~[~"--version"]); #debug("testing pandoc cmd %s: %?", pandoc, output); output.status == 0 }; @@ -219,7 +220,7 @@ fn maybe_find_pandoc( if option::is_some(pandoc) { result::ok(pandoc) } else { - result::err("couldn't find pandoc") + result::err(~"couldn't find pandoc") } } @@ -227,80 +228,80 @@ fn maybe_find_pandoc( fn should_find_pandoc() { let config = { output_format: pandoc_html - with default_config("test") + with default_config(~"test") }; - let mock_program_output = fn~(_prog: str, _args: ~[str]) -> { - status: int, out: str, err: str + let mock_program_output = fn~(_prog: ~str, _args: ~[~str]) -> { + status: int, out: ~str, err: ~str } { { - status: 0, out: "pandoc 1.8.2.1", err: "" + status: 0, out: ~"pandoc 1.8.2.1", err: ~"" } }; let result = maybe_find_pandoc(config, none, mock_program_output); - assert result == result::ok(some("pandoc")); + assert result == result::ok(some(~"pandoc")); } #[test] fn should_error_with_no_pandoc() { let config = { output_format: pandoc_html - with default_config("test") + with default_config(~"test") }; - let mock_program_output = fn~(_prog: str, _args: ~[str]) -> { - status: int, out: str, err: str + let mock_program_output = fn~(_prog: ~str, _args: ~[~str]) -> { + status: int, out: ~str, err: ~str } { { - status: 1, out: "", err: "" + status: 1, out: ~"", err: ~"" } }; let result = maybe_find_pandoc(config, none, mock_program_output); - assert result == result::err("couldn't find pandoc"); + assert result == result::err(~"couldn't find pandoc"); } #[cfg(test)] mod test { - fn parse_config(args: ~[str]) -> result { + fn parse_config(args: ~[~str]) -> result { parse_config_(args, mock_program_output) } } #[test] fn should_error_with_no_crates() { - let config = test::parse_config(~["rustdoc"]); - assert result::get_err(config) == "no crates specified"; + let config = test::parse_config(~[~"rustdoc"]); + assert result::get_err(config) == ~"no crates specified"; } #[test] fn should_error_with_multiple_crates() { let config = - test::parse_config(~["rustdoc", "crate1.rc", "crate2.rc"]); - assert result::get_err(config) == "multiple crates specified"; + test::parse_config(~[~"rustdoc", ~"crate1.rc", ~"crate2.rc"]); + assert result::get_err(config) == ~"multiple crates specified"; } #[test] fn should_set_output_dir_to_cwd_if_not_provided() { - let config = test::parse_config(~["rustdoc", "crate.rc"]); - assert result::get(config).output_dir == "."; + let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]); + assert result::get(config).output_dir == ~"."; } #[test] fn should_set_output_dir_if_provided() { let config = test::parse_config(~[ - "rustdoc", "crate.rc", "--output-dir", "snuggles" + ~"rustdoc", ~"crate.rc", ~"--output-dir", ~"snuggles" ]); - assert result::get(config).output_dir == "snuggles"; + assert result::get(config).output_dir == ~"snuggles"; } #[test] fn should_set_output_format_to_pandoc_html_if_not_provided() { - let config = test::parse_config(~["rustdoc", "crate.rc"]); + let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]); assert result::get(config).output_format == pandoc_html; } #[test] fn should_set_output_format_to_markdown_if_requested() { let config = test::parse_config(~[ - "rustdoc", "crate.rc", "--output-format", "markdown" + ~"rustdoc", ~"crate.rc", ~"--output-format", ~"markdown" ]); assert result::get(config).output_format == markdown; } @@ -308,7 +309,7 @@ fn should_set_output_format_to_markdown_if_requested() { #[test] fn should_set_output_format_to_pandoc_html_if_requested() { let config = test::parse_config(~[ - "rustdoc", "crate.rc", "--output-format", "html" + ~"rustdoc", ~"crate.rc", ~"--output-format", ~"html" ]); assert result::get(config).output_format == pandoc_html; } @@ -316,21 +317,21 @@ fn should_set_output_format_to_pandoc_html_if_requested() { #[test] fn should_error_on_bogus_format() { let config = test::parse_config(~[ - "rustdoc", "crate.rc", "--output-format", "bogus" + ~"rustdoc", ~"crate.rc", ~"--output-format", ~"bogus" ]); - assert result::get_err(config) == "unknown output format 'bogus'"; + assert result::get_err(config) == ~"unknown output format 'bogus'"; } #[test] fn should_set_output_style_to_doc_per_mod_by_default() { - let config = test::parse_config(~["rustdoc", "crate.rc"]); + let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]); assert result::get(config).output_style == doc_per_mod; } #[test] fn should_set_output_style_to_one_doc_if_requested() { let config = test::parse_config(~[ - "rustdoc", "crate.rc", "--output-style", "doc-per-crate" + ~"rustdoc", ~"crate.rc", ~"--output-style", ~"doc-per-crate" ]); assert result::get(config).output_style == doc_per_crate; } @@ -338,7 +339,7 @@ fn should_set_output_style_to_one_doc_if_requested() { #[test] fn should_set_output_style_to_doc_per_mod_if_requested() { let config = test::parse_config(~[ - "rustdoc", "crate.rc", "--output-style", "doc-per-mod" + ~"rustdoc", ~"crate.rc", ~"--output-style", ~"doc-per-mod" ]); assert result::get(config).output_style == doc_per_mod; } @@ -346,21 +347,21 @@ fn should_set_output_style_to_doc_per_mod_if_requested() { #[test] fn should_error_on_bogus_output_style() { let config = test::parse_config(~[ - "rustdoc", "crate.rc", "--output-style", "bogus" + ~"rustdoc", ~"crate.rc", ~"--output-style", ~"bogus" ]); - assert result::get_err(config) == "unknown output style 'bogus'"; + assert result::get_err(config) == ~"unknown output style 'bogus'"; } #[test] fn should_set_pandoc_command_if_requested() { let config = test::parse_config(~[ - "rustdoc", "crate.rc", "--pandoc-cmd", "panda-bear-doc" + ~"rustdoc", ~"crate.rc", ~"--pandoc-cmd", ~"panda-bear-doc" ]); - assert result::get(config).pandoc_cmd == some("panda-bear-doc"); + assert result::get(config).pandoc_cmd == some(~"panda-bear-doc"); } #[test] fn should_set_pandoc_command_when_using_pandoc() { - let config = test::parse_config(~["rustdoc", "crate.rc"]); - assert result::get(config).pandoc_cmd == some("pandoc"); + let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]); + assert result::get(config).pandoc_cmd == some(~"pandoc"); } diff --git a/src/rustdoc/demo.rs b/src/rustdoc/demo.rs index e84551b6a539..bedb3605309f 100644 --- a/src/rustdoc/demo.rs +++ b/src/rustdoc/demo.rs @@ -15,7 +15,7 @@ const price_of_a_muffin: float = 70f; type waitress = { - hair_color: str + hair_color: ~str }; /// The type of things that produce omnomnom diff --git a/src/rustdoc/desc_to_brief_pass.rs b/src/rustdoc/desc_to_brief_pass.rs index e70cdb418726..449ea1b5856e 100644 --- a/src/rustdoc/desc_to_brief_pass.rs +++ b/src/rustdoc/desc_to_brief_pass.rs @@ -9,7 +9,7 @@ fn mk_pass() -> pass { { - name: "desc_to_brief", + name: ~"desc_to_brief", f: run } } @@ -62,35 +62,35 @@ fn fold_impl(fold: fold::fold<()>, doc: doc::impldoc) -> doc::impldoc { #[test] fn should_promote_desc() { - let doc = test::mk_doc("#[doc = \"desc\"] mod m { }"); - assert doc.cratemod().mods()[0].brief() == some("desc"); + let doc = test::mk_doc(~"#[doc = \"desc\"] mod m { }"); + assert doc.cratemod().mods()[0].brief() == some(~"desc"); } #[test] fn should_promote_trait_method_desc() { - let doc = test::mk_doc("iface i { #[doc = \"desc\"] fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].brief == some("desc"); + let doc = test::mk_doc(~"iface i { #[doc = \"desc\"] fn a(); }"); + assert doc.cratemod().traits()[0].methods[0].brief == some(~"desc"); } #[test] fn should_promote_impl_method_desc() { let doc = test::mk_doc( - "impl i for int { #[doc = \"desc\"] fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].brief == some("desc"); + ~"impl i for int { #[doc = \"desc\"] fn a() { } }"); + assert doc.cratemod().impls()[0].methods[0].brief == some(~"desc"); } #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = attr_pass::mk_pass().f(srv, doc); run(srv, doc) } } } -fn extract(desc: option) -> option { +fn extract(desc: option<~str>) -> option<~str> { if option::is_none(desc) { ret none } @@ -98,7 +98,7 @@ fn extract(desc: option) -> option { parse_desc(option::get(desc)) } -fn parse_desc(desc: str) -> option { +fn parse_desc(desc: ~str) -> option<~str> { const max_brief_len: uint = 120u; @@ -114,17 +114,17 @@ fn parse_desc(desc: str) -> option { } } -fn first_sentence(s: str) -> option { +fn first_sentence(s: ~str) -> option<~str> { let paras = paragraphs(s); if vec::is_not_empty(paras) { let first_para = vec::head(paras); - some(str::replace(first_sentence_(first_para), "\n", " ")) + some(str::replace(first_sentence_(first_para), ~"\n", ~" ")) } else { none } } -fn first_sentence_(s: str) -> str { +fn first_sentence_(s: ~str) -> ~str { let mut dotcount = 0; // The index of the character following a single dot. This allows // Things like [0..1) to appear in the brief description @@ -146,7 +146,7 @@ fn first_sentence_(s: str) -> str { str::slice(s, 0u, idx - 1u) } _ { - if str::ends_with(s, ".") { + if str::ends_with(s, ~".") { str::slice(s, 0u, str::len(s)) } else { s @@ -155,10 +155,10 @@ fn first_sentence_(s: str) -> str { } } -fn paragraphs(s: str) -> ~[str] { +fn paragraphs(s: ~str) -> ~[~str] { let lines = str::lines_any(s); let mut whitespace_lines = 0; - let mut accum = ""; + let mut accum = ~""; let paras = do vec::foldl(~[], lines) |paras, line| { let mut res = paras; @@ -168,7 +168,7 @@ fn paragraphs(s: str) -> ~[str] { if whitespace_lines > 0 { if str::is_not_empty(accum) { res += ~[accum]; - accum = ""; + accum = ~""; } } @@ -177,7 +177,7 @@ fn paragraphs(s: str) -> ~[str] { accum = if str::is_empty(accum) { line } else { - accum + "\n" + line + accum + ~"\n" + line } } @@ -193,26 +193,26 @@ fn paragraphs(s: str) -> ~[str] { #[test] fn test_paragraphs_1() { - let paras = paragraphs("1\n\n2"); - assert paras == ~["1", "2"]; + let paras = paragraphs(~"1\n\n2"); + assert paras == ~[~"1", ~"2"]; } #[test] fn test_paragraphs_2() { - let paras = paragraphs("\n\n1\n1\n\n2\n\n"); - assert paras == ~["1\n1", "2"]; + let paras = paragraphs(~"\n\n1\n1\n\n2\n\n"); + assert paras == ~[~"1\n1", ~"2"]; } #[test] fn should_promote_short_descs() { - let desc = some("desc"); + let desc = some(~"desc"); let brief = extract(desc); assert brief == desc; } #[test] fn should_not_promote_long_descs() { - let desc = some("Warkworth Castle is a ruined medieval building + let desc = some(~"Warkworth Castle is a ruined medieval building in the town of the same name in the English county of Northumberland, and the town and castle occupy a loop of the River Coquet, less than a mile from England's north-east coast. When the castle was founded is uncertain, @@ -226,7 +226,7 @@ fn should_not_promote_long_descs() { #[test] fn should_promote_first_sentence() { - let desc = some("Warkworth Castle is a ruined medieval building + let desc = some(~"Warkworth Castle is a ruined medieval building in the town. of the same name in the English county of Northumberland, and the town and castle occupy a loop of the River Coquet, less than a mile from England's north-east coast. When the castle was founded is uncertain, @@ -236,12 +236,12 @@ fn should_promote_first_sentence() { counties."); let brief = extract(desc); assert brief == some( - "Warkworth Castle is a ruined medieval building in the town"); + ~"Warkworth Castle is a ruined medieval building in the town"); } #[test] fn should_not_consider_double_period_to_end_sentence() { - let desc = some("Warkworth..Castle is a ruined medieval building + let desc = some(~"Warkworth..Castle is a ruined medieval building in the town. of the same name in the English county of Northumberland, and the town and castle occupy a loop of the River Coquet, less than a mile from England's north-east coast. When the castle was founded is uncertain, @@ -251,12 +251,12 @@ fn should_not_consider_double_period_to_end_sentence() { counties."); let brief = extract(desc); assert brief == some( - "Warkworth..Castle is a ruined medieval building in the town"); + ~"Warkworth..Castle is a ruined medieval building in the town"); } #[test] fn should_not_consider_triple_period_to_end_sentence() { - let desc = some("Warkworth... Castle is a ruined medieval building + let desc = some(~"Warkworth... Castle is a ruined medieval building in the town. of the same name in the English county of Northumberland, and the town and castle occupy a loop of the River Coquet, less than a mile from England's north-east coast. When the castle was founded is uncertain, @@ -266,5 +266,5 @@ fn should_not_consider_triple_period_to_end_sentence() { counties."); let brief = extract(desc); assert brief == some( - "Warkworth... Castle is a ruined medieval building in the town"); + ~"Warkworth... Castle is a ruined medieval building in the town"); } diff --git a/src/rustdoc/doc.rs b/src/rustdoc/doc.rs index 9db3f9a607e5..d6b78095a152 100644 --- a/src/rustdoc/doc.rs +++ b/src/rustdoc/doc.rs @@ -21,8 +21,8 @@ enum implementation { * headers */ type section = { - header: str, - body: str + header: ~str, + body: ~str }; // FIXME (#2596): We currently give topmod the name of the crate. There @@ -45,10 +45,10 @@ enum itemtag { type itemdoc = { id: ast_id, - name: str, - path: ~[str], - brief: option, - desc: option, + name: ~str, + path: ~[~str], + brief: option<~str>, + desc: option<~str>, sections: ~[section], // Indicates that this node is a reexport of a different item reexport: bool @@ -56,7 +56,7 @@ enum itemtag { type simpleitemdoc = { item: itemdoc, - sig: option + sig: option<~str> }; type moddoc = { @@ -81,9 +81,9 @@ enum itemtag { }; type variantdoc = { - name: str, - desc: option, - sig: option + name: ~str, + desc: option<~str>, + sig: option<~str> }; type traitdoc = { @@ -92,18 +92,18 @@ enum itemtag { }; type methoddoc = { - name: str, - brief: option, - desc: option, + name: ~str, + brief: option<~str>, + desc: option<~str>, sections: ~[section], - sig: option, + sig: option<~str>, implementation: implementation, }; type impldoc = { item: itemdoc, - trait_ty: option, - self_ty: option, + trait_ty: option<~str>, + self_ty: option<~str>, methods: ~[methoddoc] }; @@ -124,10 +124,10 @@ enum itemtag { * * link - A format-specific string representing the link target */ type index_entry = { - kind: str, - name: str, - brief: option, - link: str + kind: ~str, + name: ~str, + brief: option<~str>, + link: ~str }; impl util for doc { @@ -344,19 +344,19 @@ fn id() -> ast_id { self.item().id } - fn name() -> str { + fn name() -> ~str { self.item().name } - fn path() -> ~[str] { + fn path() -> ~[~str] { self.item().path } - fn brief() -> option { + fn brief() -> option<~str> { self.item().brief } - fn desc() -> option { + fn desc() -> option<~str> { self.item().desc } diff --git a/src/rustdoc/escape_pass.rs b/src/rustdoc/escape_pass.rs index 1cefe410e8ec..dbc8a513f336 100644 --- a/src/rustdoc/escape_pass.rs +++ b/src/rustdoc/escape_pass.rs @@ -3,16 +3,16 @@ export mk_pass; fn mk_pass() -> pass { - text_pass::mk_pass("escape", escape) + text_pass::mk_pass(~"escape", escape) } -fn escape(s: str) -> str { - str::replace(s, "\\", "\\\\") +fn escape(s: ~str) -> ~str { + str::replace(s, ~"\\", ~"\\\\") } #[test] fn should_escape_backslashes() { - let s = "\\n"; + let s = ~"\\n"; let r = escape(s); - assert r == "\\\\n"; + assert r == ~"\\\\n"; } diff --git a/src/rustdoc/extract.rs b/src/rustdoc/extract.rs index 72b7150a72ef..b3fd52574755 100644 --- a/src/rustdoc/extract.rs +++ b/src/rustdoc/extract.rs @@ -6,7 +6,7 @@ fn from_srv( srv: astsrv::srv, - default_name: str + default_name: ~str ) -> doc::doc { //! Use the AST service to create a document tree @@ -18,7 +18,7 @@ fn from_srv( fn extract( crate: @ast::crate, - default_name: str + default_name: ~str ) -> doc::doc { { pages: ~[ @@ -31,7 +31,7 @@ fn extract( fn top_moddoc_from_crate( crate: @ast::crate, - default_name: str + default_name: ~str ) -> doc::moddoc { moddoc_from_mod(mk_itemdoc(ast::crate_node_id, @default_name), crate.node.module) @@ -141,9 +141,9 @@ fn constdoc_from_const(itemdoc: doc::itemdoc) -> doc::constdoc { #[test] fn should_extract_const_name_and_id() { - let doc = test::mk_doc("const a: int = 0;"); + let doc = test::mk_doc(~"const a: int = 0;"); assert doc.cratemod().consts()[0].id() != 0; - assert doc.cratemod().consts()[0].name() == "a"; + assert doc.cratemod().consts()[0].name() == ~"a"; } fn enumdoc_from_enum( @@ -172,15 +172,15 @@ fn variantdoc_from_variant(variant: ast::variant) -> doc::variantdoc { #[test] fn should_extract_enums() { - let doc = test::mk_doc("enum e { v }"); + let doc = test::mk_doc(~"enum e { v }"); assert doc.cratemod().enums()[0].id() != 0; - assert doc.cratemod().enums()[0].name() == "e"; + assert doc.cratemod().enums()[0].name() == ~"e"; } #[test] fn should_extract_enum_variants() { - let doc = test::mk_doc("enum e { v }"); - assert doc.cratemod().enums()[0].variants[0].name == "v"; + let doc = test::mk_doc(~"enum e { v }"); + assert doc.cratemod().enums()[0].variants[0].name == ~"v"; } fn traitdoc_from_trait( @@ -218,14 +218,14 @@ fn traitdoc_from_trait( #[test] fn should_extract_traits() { - let doc = test::mk_doc("trait i { fn f(); }"); - assert doc.cratemod().traits()[0].name() == "i"; + let doc = test::mk_doc(~"trait i { fn f(); }"); + assert doc.cratemod().traits()[0].name() == ~"i"; } #[test] fn should_extract_trait_methods() { - let doc = test::mk_doc("trait i { fn f(); }"); - assert doc.cratemod().traits()[0].methods[0].name == "f"; + let doc = test::mk_doc(~"trait i { fn f(); }"); + assert doc.cratemod().traits()[0].methods[0].name == ~"f"; } fn impldoc_from_impl( @@ -251,20 +251,20 @@ fn impldoc_from_impl( #[test] fn should_extract_impls_with_names() { - let doc = test::mk_doc("impl i for int { fn a() { } }"); - assert doc.cratemod().impls()[0].name() == "i"; + let doc = test::mk_doc(~"impl i for int { fn a() { } }"); + assert doc.cratemod().impls()[0].name() == ~"i"; } #[test] fn should_extract_impls_without_names() { - let doc = test::mk_doc("impl of i for int { fn a() { } }"); - assert doc.cratemod().impls()[0].name() == "i"; + let doc = test::mk_doc(~"impl of i for int { fn a() { } }"); + assert doc.cratemod().impls()[0].name() == ~"i"; } #[test] fn should_extract_impl_methods() { - let doc = test::mk_doc("impl i for int { fn f() { } }"); - assert doc.cratemod().impls()[0].methods[0].name == "f"; + let doc = test::mk_doc(~"impl i for int { fn f() { } }"); + assert doc.cratemod().impls()[0].methods[0].name == ~"f"; } fn tydoc_from_ty( @@ -278,86 +278,86 @@ fn tydoc_from_ty( #[test] fn should_extract_tys() { - let doc = test::mk_doc("type a = int;"); - assert doc.cratemod().types()[0].name() == "a"; + let doc = test::mk_doc(~"type a = int;"); + assert doc.cratemod().types()[0].name() == ~"a"; } #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { let ast = parse::from_str(source); - extract(ast, "") + extract(ast, ~"") } #[test] fn extract_empty_crate() { - let doc = mk_doc(""); + let doc = mk_doc(~""); assert vec::is_empty(doc.cratemod().mods()); assert vec::is_empty(doc.cratemod().fns()); } #[test] fn extract_mods() { - let doc = mk_doc("mod a { mod b { } mod c { } }"); - assert doc.cratemod().mods()[0].name() == "a"; - assert doc.cratemod().mods()[0].mods()[0].name() == "b"; - assert doc.cratemod().mods()[0].mods()[1].name() == "c"; + let doc = mk_doc(~"mod a { mod b { } mod c { } }"); + assert doc.cratemod().mods()[0].name() == ~"a"; + assert doc.cratemod().mods()[0].mods()[0].name() == ~"b"; + assert doc.cratemod().mods()[0].mods()[1].name() == ~"c"; } #[test] fn extract_foreign_mods() { - let doc = mk_doc("extern mod a { }"); - assert doc.cratemod().nmods()[0].name() == "a"; + let doc = mk_doc(~"extern mod a { }"); + assert doc.cratemod().nmods()[0].name() == ~"a"; } #[test] fn extract_fns_from_foreign_mods() { - let doc = mk_doc("extern mod a { fn a(); }"); - assert doc.cratemod().nmods()[0].fns[0].name() == "a"; + let doc = mk_doc(~"extern mod a { fn a(); }"); + assert doc.cratemod().nmods()[0].fns[0].name() == ~"a"; } #[test] fn extract_mods_deep() { - let doc = mk_doc("mod a { mod b { mod c { } } }"); - assert doc.cratemod().mods()[0].mods()[0].mods()[0].name() == "c"; + let doc = mk_doc(~"mod a { mod b { mod c { } } }"); + assert doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c"; } #[test] fn extract_should_set_mod_ast_id() { - let doc = mk_doc("mod a { }"); + let doc = mk_doc(~"mod a { }"); assert doc.cratemod().mods()[0].id() != 0; } #[test] fn extract_fns() { let doc = mk_doc( - "fn a() { } \ + ~"fn a() { } \ mod b { fn c() { } }"); - assert doc.cratemod().fns()[0].name() == "a"; - assert doc.cratemod().mods()[0].fns()[0].name() == "c"; + assert doc.cratemod().fns()[0].name() == ~"a"; + assert doc.cratemod().mods()[0].fns()[0].name() == ~"c"; } #[test] fn extract_should_set_fn_ast_id() { - let doc = mk_doc("fn a() { }"); + let doc = mk_doc(~"fn a() { }"); assert doc.cratemod().fns()[0].id() != 0; } #[test] fn extract_should_use_default_crate_name() { - let source = ""; + let source = ~""; let ast = parse::from_str(source); - let doc = extract(ast, "burp"); - assert doc.cratemod().name() == "burp"; + let doc = extract(ast, ~"burp"); + assert doc.cratemod().name() == ~"burp"; } #[test] fn extract_from_seq_srv() { - let source = ""; + let source = ~""; do astsrv::from_str(source) |srv| { - let doc = from_srv(srv, "name"); - assert doc.cratemod().name() == "name"; + let doc = from_srv(srv, ~"name"); + assert doc.cratemod().name() == ~"name"; } } } diff --git a/src/rustdoc/fold.rs b/src/rustdoc/fold.rs index be24edf22b65..e9d8615d1d4b 100644 --- a/src/rustdoc/fold.rs +++ b/src/rustdoc/fold.rs @@ -332,9 +332,9 @@ fn default_seq_fold_type( #[test] fn default_fold_should_produce_same_doc() { - let source = "mod a { fn b() { } mod c { fn d() { } } }"; + let source = ~"mod a { fn b() { } mod c { fn d() { } } }"; let ast = parse::from_str(source); - let doc = extract::extract(ast, ""); + let doc = extract::extract(ast, ~""); let fld = default_seq_fold(()); let folded = fld.fold_doc(fld, doc); assert doc == folded; @@ -342,9 +342,9 @@ fn default_fold_should_produce_same_doc() { #[test] fn default_fold_should_produce_same_consts() { - let source = "const a: int = 0;"; + let source = ~"const a: int = 0;"; let ast = parse::from_str(source); - let doc = extract::extract(ast, ""); + let doc = extract::extract(ast, ~""); let fld = default_seq_fold(()); let folded = fld.fold_doc(fld, doc); assert doc == folded; @@ -352,9 +352,9 @@ fn default_fold_should_produce_same_consts() { #[test] fn default_fold_should_produce_same_enums() { - let source = "enum a { b }"; + let source = ~"enum a { b }"; let ast = parse::from_str(source); - let doc = extract::extract(ast, ""); + let doc = extract::extract(ast, ~""); let fld = default_seq_fold(()); let folded = fld.fold_doc(fld, doc); assert doc == folded; @@ -362,9 +362,9 @@ fn default_fold_should_produce_same_enums() { #[test] fn default_parallel_fold_should_produce_same_doc() { - let source = "mod a { fn b() { } mod c { fn d() { } } }"; + let source = ~"mod a { fn b() { } mod c { fn d() { } } }"; let ast = parse::from_str(source); - let doc = extract::extract(ast, ""); + let doc = extract::extract(ast, ~""); let fld = default_par_fold(()); let folded = fld.fold_doc(fld, doc); assert doc == folded; diff --git a/src/rustdoc/markdown_index_pass.rs b/src/rustdoc/markdown_index_pass.rs index 6532f572c6d6..a98fe47ec0f3 100644 --- a/src/rustdoc/markdown_index_pass.rs +++ b/src/rustdoc/markdown_index_pass.rs @@ -4,7 +4,7 @@ fn mk_pass(config: config::config) -> pass { { - name: "markdown_index", + name: ~"markdown_index", f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc { run(srv, doc, config) } @@ -82,7 +82,7 @@ fn item_to_entry( markdown_writer::make_filename(config, doc::itempage(doc)) } _ { - "#" + pandoc_header_id(markdown_pass::header_text(doc)) + ~"#" + pandoc_header_id(markdown_pass::header_text(doc)) } }; @@ -94,7 +94,7 @@ fn item_to_entry( } } -fn pandoc_header_id(header: str) -> str { +fn pandoc_header_id(header: ~str) -> ~str { // http://johnmacfarlane.net/pandoc/README.html#headers @@ -106,61 +106,61 @@ fn pandoc_header_id(header: str) -> str { let header = maybe_use_section_id(header); ret header; - fn remove_formatting(s: str) -> str { - str::replace(s, "`", "") + fn remove_formatting(s: ~str) -> ~str { + str::replace(s, ~"`", ~"") } - fn remove_punctuation(s: str) -> str { - let s = str::replace(s, "<", ""); - let s = str::replace(s, ">", ""); - let s = str::replace(s, "[", ""); - let s = str::replace(s, "]", ""); - let s = str::replace(s, "(", ""); - let s = str::replace(s, ")", ""); - let s = str::replace(s, "@", ""); - let s = str::replace(s, "~", ""); - let s = str::replace(s, "/", ""); - let s = str::replace(s, ":", ""); - let s = str::replace(s, "&", ""); - let s = str::replace(s, "^", ""); + fn remove_punctuation(s: ~str) -> ~str { + let s = str::replace(s, ~"<", ~""); + let s = str::replace(s, ~">", ~""); + let s = str::replace(s, ~"[", ~""); + let s = str::replace(s, ~"]", ~""); + let s = str::replace(s, ~"(", ~""); + let s = str::replace(s, ~")", ~""); + let s = str::replace(s, ~"@~", ~""); + let s = str::replace(s, ~"~", ~""); + let s = str::replace(s, ~"/", ~""); + let s = str::replace(s, ~":", ~""); + let s = str::replace(s, ~"&", ~""); + let s = str::replace(s, ~"^", ~""); ret s; } - fn replace_with_hyphens(s: str) -> str { - str::replace(s, " ", "-") + fn replace_with_hyphens(s: ~str) -> ~str { + str::replace(s, ~" ", ~"-") } - fn convert_to_lowercase(s: str) -> str { str::to_lower(s) } - fn remove_up_to_first_letter(s: str) -> str { s } - fn maybe_use_section_id(s: str) -> str { s } + fn convert_to_lowercase(s: ~str) -> ~str { str::to_lower(s) } + fn remove_up_to_first_letter(s: ~str) -> ~str { s } + fn maybe_use_section_id(s: ~str) -> ~str { s } } #[test] fn should_remove_punctuation_from_headers() { - assert pandoc_header_id("impl foo of bar") == "impl-foo-of-bara"; - assert pandoc_header_id("fn@(~[~A])") == "fna"; - assert pandoc_header_id("impl of num::num for int") - == "impl-of-numnum-for-int"; - assert pandoc_header_id("impl of num::num for int/&") - == "impl-of-numnum-for-int"; - assert pandoc_header_id("impl of num::num for ^int") - == "impl-of-numnum-for-int"; + assert pandoc_header_id(~"impl foo of bar") == ~"impl-foo-of-bara"; + assert pandoc_header_id(~"fn@(~[~A])") == ~"fna"; + assert pandoc_header_id(~"impl of num::num for int") + == ~"impl-of-numnum-for-int"; + assert pandoc_header_id(~"impl of num::num for int/&") + == ~"impl-of-numnum-for-int"; + assert pandoc_header_id(~"impl of num::num for ^int") + == ~"impl-of-numnum-for-int"; } #[test] fn should_index_mod_contents() { let doc = test::mk_doc( config::doc_per_crate, - "mod a { } fn b() { }" + ~"mod a { } fn b() { }" ); assert option::get(doc.cratemod().index).entries[0] == { - kind: "Module", - name: "a", + kind: ~"Module", + name: ~"a", brief: none, - link: "#module-a" + link: ~"#module-a" }; assert option::get(doc.cratemod().index).entries[1] == { - kind: "Function", - name: "b", + kind: ~"Function", + name: ~"b", brief: none, - link: "#function-b" + link: ~"#function-b" }; } @@ -168,19 +168,19 @@ fn should_index_mod_contents() { fn should_index_mod_contents_multi_page() { let doc = test::mk_doc( config::doc_per_mod, - "mod a { } fn b() { }" + ~"mod a { } fn b() { }" ); assert option::get(doc.cratemod().index).entries[0] == { - kind: "Module", - name: "a", + kind: ~"Module", + name: ~"a", brief: none, - link: "a.html" + link: ~"a.html" }; assert option::get(doc.cratemod().index).entries[1] == { - kind: "Function", - name: "b", + kind: ~"Function", + name: ~"b", brief: none, - link: "#function-b" + link: ~"#function-b" }; } @@ -188,13 +188,13 @@ fn should_index_mod_contents_multi_page() { fn should_index_foreign_mod_pages() { let doc = test::mk_doc( config::doc_per_mod, - "extern mod a { }" + ~"extern mod a { }" ); assert option::get(doc.cratemod().index).entries[0] == { - kind: "Foreign module", - name: "a", + kind: ~"Foreign module", + name: ~"a", brief: none, - link: "a.html" + link: ~"a.html" }; } @@ -202,34 +202,35 @@ fn should_index_foreign_mod_pages() { fn should_add_brief_desc_to_index() { let doc = test::mk_doc( config::doc_per_mod, - "#[doc = \"test\"] mod a { }" + ~"#[doc = \"test\"] mod a { }" ); - assert option::get(doc.cratemod().index).entries[0].brief == some("test"); + assert option::get(doc.cratemod().index).entries[0].brief + == some(~"test"); } #[test] fn should_index_foreign_mod_contents() { let doc = test::mk_doc( config::doc_per_crate, - "extern mod a { fn b(); }" + ~"extern mod a { fn b(); }" ); assert option::get(doc.cratemod().nmods()[0].index).entries[0] == { - kind: "Function", - name: "b", + kind: ~"Function", + name: ~"b", brief: none, - link: "#function-b" + link: ~"#function-b" }; } #[cfg(test)] mod test { - fn mk_doc(output_style: config::output_style, source: str) -> doc::doc { + fn mk_doc(output_style: config::output_style, source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { let config = { output_style: output_style - with config::default_config("whatever") + with config::default_config(~"whatever") }; - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = attr_pass::mk_pass().f(srv, doc); let doc = desc_to_brief_pass::mk_pass().f(srv, doc); let doc = path_pass::mk_pass().f(srv, doc); diff --git a/src/rustdoc/markdown_pass.rs b/src/rustdoc/markdown_pass.rs index 10869161e8a2..9c36af9237bf 100644 --- a/src/rustdoc/markdown_pass.rs +++ b/src/rustdoc/markdown_pass.rs @@ -13,7 +13,7 @@ fn mk_pass(+writer_factory: writer_factory) -> pass { }; { - name: "markdown", + name: ~"markdown", f: f } } @@ -40,7 +40,7 @@ fn is_mod(item: doc::itemtag) -> bool { // output at the same header level so sorting mods last // makes the headers come out nested correctly. let sorted_doc = sort_pass::mk_pass( - "mods last", mods_last + ~"mods last", mods_last ).f(srv, doc); write_markdown(sorted_doc, writer_factory); @@ -58,16 +58,16 @@ fn should_write_modules_last() { modules appearing to contain items that they do not. */ let markdown = test::render( - "mod a { }\ + ~"mod a { }\ fn b() { }\ mod c { }\ fn d() { }" ); - let idx_a = option::get(str::find_str(markdown, "# Module `a`")); - let idx_b = option::get(str::find_str(markdown, "## Function `b`")); - let idx_c = option::get(str::find_str(markdown, "# Module `c`")); - let idx_d = option::get(str::find_str(markdown, "## Function `d`")); + let idx_a = option::get(str::find_str(markdown, ~"# Module `a`")); + let idx_b = option::get(str::find_str(markdown, ~"## Function `b`")); + let idx_c = option::get(str::find_str(markdown, ~"# Module `c`")); + let idx_d = option::get(str::find_str(markdown, ~"## Function `d`")); assert idx_b < idx_d; assert idx_d < idx_a; @@ -110,7 +110,7 @@ fn should_request_new_writer_for_each_page() { // This port will send us a (page, str) pair for every writer // that was created let (writer_factory, po) = markdown_writer::future_writer_factory(); - let (srv, doc) = test::create_doc_srv("mod a { }"); + let (srv, doc) = test::create_doc_srv(~"mod a { }"); // Split the document up into pages let doc = page_pass::mk_pass(config::doc_per_mod).f(srv, doc); write_markdown(doc, writer_factory); @@ -122,10 +122,10 @@ fn should_request_new_writer_for_each_page() { fn write_title(ctxt: ctxt, page: doc::page) { ctxt.w.write_line(#fmt("%% %s", make_title(page))); - ctxt.w.write_line(""); + ctxt.w.write_line(~""); } -fn make_title(page: doc::page) -> str { +fn make_title(page: doc::page) -> ~str { let item = alt page { doc::cratepage(cratedoc) { doc::modtag(cratedoc.topmod) @@ -135,7 +135,7 @@ fn make_title(page: doc::page) -> str { } }; let title = markdown_pass::header_text(item); - let title = str::replace(title, "`", ""); + let title = str::replace(title, ~"`", ~""); ret title; } @@ -143,17 +143,17 @@ fn make_title(page: doc::page) -> str { fn should_write_title_for_each_page() { let (writer_factory, po) = markdown_writer::future_writer_factory(); let (srv, doc) = test::create_doc_srv( - "#[link(name = \"core\")]; mod a { }"); + ~"#[link(name = \"core\")]; mod a { }"); let doc = page_pass::mk_pass(config::doc_per_mod).f(srv, doc); write_markdown(doc, writer_factory); for iter::repeat(2u) { let (page, markdown) = comm::recv(po); alt page { doc::cratepage(_) { - assert str::contains(markdown, "% Crate core"); + assert str::contains(markdown, ~"% Crate core"); } doc::itempage(_) { - assert str::contains(markdown, "% Module a"); + assert str::contains(markdown, ~"% Module a"); } } } @@ -171,47 +171,47 @@ fn write_header(ctxt: ctxt, lvl: hlvl, doc: doc::itemtag) { write_header_(ctxt, lvl, text); } -fn write_header_(ctxt: ctxt, lvl: hlvl, title: str) { +fn write_header_(ctxt: ctxt, lvl: hlvl, title: ~str) { let hashes = str::from_chars(vec::from_elem(lvl as uint, '#')); ctxt.w.write_line(#fmt("%s %s", hashes, title)); - ctxt.w.write_line(""); + ctxt.w.write_line(~""); } -fn header_kind(doc: doc::itemtag) -> str { +fn header_kind(doc: doc::itemtag) -> ~str { alt doc { doc::modtag(_) { if doc.id() == syntax::ast::crate_node_id { - "Crate" + ~"Crate" } else { - "Module" + ~"Module" } } doc::nmodtag(_) { - "Foreign module" + ~"Foreign module" } doc::fntag(_) { - "Function" + ~"Function" } doc::consttag(_) { - "Const" + ~"Const" } doc::enumtag(_) { - "Enum" + ~"Enum" } doc::traittag(_) { - "Interface" + ~"Interface" } doc::impltag(doc) { - "Implementation" + ~"Implementation" } doc::tytag(_) { - "Type" + ~"Type" } } } -fn header_name(doc: doc::itemtag) -> str { - let fullpath = str::connect(doc.path() + ~[doc.name()], "::"); +fn header_name(doc: doc::itemtag) -> ~str { + let fullpath = str::connect(doc.path() + ~[doc.name()], ~"::"); alt doc { doc::modtag(_) if doc.id() != syntax::ast::crate_node_id { fullpath @@ -237,11 +237,11 @@ fn header_name(doc: doc::itemtag) -> str { } } -fn header_text(doc: doc::itemtag) -> str { +fn header_text(doc: doc::itemtag) -> ~str { header_text_(header_kind(doc), header_name(doc)) } -fn header_text_(kind: str, name: str) -> str { +fn header_text_(kind: ~str, name: ~str) -> ~str { #fmt("%s `%s`", kind, name) } @@ -268,13 +268,13 @@ fn write_mod( #[test] fn should_write_full_path_to_mod() { - let markdown = test::render("mod a { mod b { mod c { } } }"); - assert str::contains(markdown, "# Module `a::b::c`"); + let markdown = test::render(~"mod a { mod b { mod c { } } }"); + assert str::contains(markdown, ~"# Module `a::b::c`"); } fn write_common( ctxt: ctxt, - desc: option, + desc: option<~str>, sections: ~[doc::section] ) { write_desc(ctxt, desc); @@ -283,12 +283,12 @@ fn write_common( fn write_desc( ctxt: ctxt, - desc: option + desc: option<~str> ) { alt desc { some(desc) { ctxt.w.write_line(desc); - ctxt.w.write_line(""); + ctxt.w.write_line(~""); } none { } } @@ -303,17 +303,17 @@ fn write_sections(ctxt: ctxt, sections: ~[doc::section]) { fn write_section(ctxt: ctxt, section: doc::section) { write_header_(ctxt, h4, section.header); ctxt.w.write_line(section.body); - ctxt.w.write_line(""); + ctxt.w.write_line(~""); } #[test] fn should_write_sections() { let markdown = test::render( - "#[doc = \"\ + ~"#[doc = \"\ # Header\n\ Body\"]\ mod a { }"); - assert str::contains(markdown, "#### Header\n\nBody\n\n"); + assert str::contains(markdown, ~"#### Header\n\nBody\n\n"); } fn write_mod_contents( @@ -368,8 +368,8 @@ fn item_header_lvl(doc: doc::itemtag) -> hlvl { #[test] fn should_write_crate_description() { - let markdown = test::render("#[doc = \"this is the crate\"];"); - assert str::contains(markdown, "this is the crate"); + let markdown = test::render(~"#[doc = \"this is the crate\"];"); + assert str::contains(markdown, ~"this is the crate"); } fn write_index(ctxt: ctxt, index: doc::index) { @@ -387,37 +387,37 @@ fn write_index(ctxt: ctxt, index: doc::index) { ctxt.w.write_line(#fmt("* [%s](%s)", header, id)); } } - ctxt.w.write_line(""); + ctxt.w.write_line(~""); } #[test] fn should_write_index() { - let markdown = test::render("mod a { } mod b { }"); + let markdown = test::render(~"mod a { } mod b { }"); assert str::contains( markdown, - "\n\n* [Module `a`](#module-a)\n\ + ~"\n\n* [Module `a`](#module-a)\n\ * [Module `b`](#module-b)\n\n" ); } #[test] fn should_write_index_brief() { - let markdown = test::render("#[doc = \"test\"] mod a { }"); - assert str::contains(markdown, "(#module-a) - test\n"); + let markdown = test::render(~"#[doc = \"test\"] mod a { }"); + assert str::contains(markdown, ~"(#module-a) - test\n"); } #[test] fn should_not_write_index_if_no_entries() { - let markdown = test::render(""); - assert !str::contains(markdown, "\n\n\n"); + let markdown = test::render(~""); + assert !str::contains(markdown, ~"\n\n\n"); } #[test] fn should_write_index_for_foreign_mods() { - let markdown = test::render("extern mod a { fn a(); }"); + let markdown = test::render(~"extern mod a { fn a(); }"); assert str::contains( markdown, - "\n\n* [Function `a`](#function-a)\n\n" + ~"\n\n* [Function `a`](#function-a)\n\n" ); } @@ -435,21 +435,23 @@ fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) { #[test] fn should_write_foreign_mods() { - let markdown = test::render("#[doc = \"test\"] extern mod a { }"); - assert str::contains(markdown, "Foreign module `a`"); - assert str::contains(markdown, "test"); + let markdown = test::render(~"#[doc = \"test\"] extern mod a { }"); + assert str::contains(markdown, ~"Foreign module `a`"); + assert str::contains(markdown, ~"test"); } #[test] fn should_write_foreign_fns() { - let markdown = test::render("extern mod a { #[doc = \"test\"] fn a(); }"); - assert str::contains(markdown, "test"); + let markdown = test::render( + ~"extern mod a { #[doc = \"test\"] fn a(); }"); + assert str::contains(markdown, ~"test"); } #[test] fn should_write_foreign_fn_headers() { - let markdown = test::render("extern mod a { #[doc = \"test\"] fn a(); }"); - assert str::contains(markdown, "## Function `a`"); + let markdown = test::render( + ~"extern mod a { #[doc = \"test\"] fn a(); }"); + assert str::contains(markdown, ~"## Function `a`"); } fn write_fn( @@ -466,57 +468,57 @@ fn write_fn( fn write_fnlike( ctxt: ctxt, - sig: option, - desc: option, + sig: option<~str>, + desc: option<~str>, sections: ~[doc::section] ) { write_sig(ctxt, sig); write_common(ctxt, desc, sections); } -fn write_sig(ctxt: ctxt, sig: option) { +fn write_sig(ctxt: ctxt, sig: option<~str>) { alt sig { some(sig) { ctxt.w.write_line(code_block_indent(sig)); - ctxt.w.write_line(""); + ctxt.w.write_line(~""); } - none { fail "unimplemented" } + none { fail ~"unimplemented" } } } -fn code_block_indent(s: str) -> str { +fn code_block_indent(s: ~str) -> ~str { let lines = str::lines_any(s); let indented = par::seqmap(lines, |line| #fmt(" %s", line) ); - str::connect(indented, "\n") + str::connect(indented, ~"\n") } #[test] fn write_markdown_should_write_function_header() { - let markdown = test::render("fn func() { }"); - assert str::contains(markdown, "## Function `func`"); + let markdown = test::render(~"fn func() { }"); + assert str::contains(markdown, ~"## Function `func`"); } #[test] fn should_write_the_function_signature() { - let markdown = test::render("#[doc = \"f\"] fn a() { }"); - assert str::contains(markdown, "\n fn a()\n"); + let markdown = test::render(~"#[doc = \"f\"] fn a() { }"); + assert str::contains(markdown, ~"\n fn a()\n"); } #[test] fn should_insert_blank_line_after_fn_signature() { - let markdown = test::render("#[doc = \"f\"] fn a() { }"); - assert str::contains(markdown, "fn a()\n\n"); + let markdown = test::render(~"#[doc = \"f\"] fn a() { }"); + assert str::contains(markdown, ~"fn a()\n\n"); } #[test] fn should_correctly_indent_fn_signature() { - let doc = test::create_doc("fn a() { }"); + let doc = test::create_doc(~"fn a() { }"); let doc = { pages: ~[ doc::cratepage({ topmod: { items: ~[doc::fntag({ - sig: some("line 1\nline 2") + sig: some(~"line 1\nline 2") with doc.cratemod().fns()[0] })] with doc.cratemod() @@ -526,13 +528,13 @@ fn should_correctly_indent_fn_signature() { ] }; let markdown = test::write_markdown_str(doc); - assert str::contains(markdown, " line 1\n line 2"); + assert str::contains(markdown, ~" line 1\n line 2"); } #[test] fn should_leave_blank_line_between_fn_header_and_sig() { - let markdown = test::render("fn a() { }"); - assert str::contains(markdown, "Function `a`\n\n fn a()"); + let markdown = test::render(~"fn a() { }"); + assert str::contains(markdown, ~"Function `a`\n\n fn a()"); } fn write_const( @@ -545,16 +547,16 @@ fn write_const( #[test] fn should_write_const_header() { - let markdown = test::render("const a: bool = true;"); - assert str::contains(markdown, "## Const `a`\n\n"); + let markdown = test::render(~"const a: bool = true;"); + assert str::contains(markdown, ~"## Const `a`\n\n"); } #[test] fn should_write_const_description() { let markdown = test::render( - "#[doc = \"b\"]\ + ~"#[doc = \"b\"]\ const a: bool = true;"); - assert str::contains(markdown, "\n\nb\n\n"); + assert str::contains(markdown, ~"\n\nb\n\n"); } fn write_enum( @@ -567,15 +569,15 @@ fn write_enum( #[test] fn should_write_enum_header() { - let markdown = test::render("enum a { b }"); - assert str::contains(markdown, "## Enum `a`\n\n"); + let markdown = test::render(~"enum a { b }"); + assert str::contains(markdown, ~"## Enum `a`\n\n"); } #[test] fn should_write_enum_description() { let markdown = test::render( - "#[doc = \"b\"] enum a { b }"); - assert str::contains(markdown, "\n\nb\n\n"); + ~"#[doc = \"b\"] enum a { b }"); + assert str::contains(markdown, ~"\n\nb\n\n"); } fn write_variants( @@ -586,11 +588,11 @@ fn write_variants( ret; } - write_header_(ctxt, h4, "Variants"); + write_header_(ctxt, h4, ~"Variants"); vec::iter(docs, |variant| write_variant(ctxt, variant) ); - ctxt.w.write_line(""); + ctxt.w.write_line(~""); } fn write_variant(ctxt: ctxt, doc: doc::variantdoc) { @@ -609,32 +611,32 @@ fn write_variant(ctxt: ctxt, doc: doc::variantdoc) { #[test] fn should_write_variant_list() { let markdown = test::render( - "enum a { \ + ~"enum a { \ #[doc = \"test\"] b, \ #[doc = \"test\"] c }"); assert str::contains( markdown, - "\n\n#### Variants\n\ + ~"\n\n#### Variants\n\ \n* `b` - test\ \n* `c` - test\n\n"); } #[test] fn should_write_variant_list_without_descs() { - let markdown = test::render("enum a { b, c }"); + let markdown = test::render(~"enum a { b, c }"); assert str::contains( markdown, - "\n\n#### Variants\n\ + ~"\n\n#### Variants\n\ \n* `b`\ \n* `c`\n\n"); } #[test] fn should_write_variant_list_with_signatures() { - let markdown = test::render("enum a { b(int), #[doc = \"a\"] c(int) }"); + let markdown = test::render(~"enum a { b(int), #[doc = \"a\"] c(int) }"); assert str::contains( markdown, - "\n\n#### Variants\n\ + ~"\n\n#### Variants\n\ \n* `b(int)`\ \n* `c(int)` - a\n\n"); } @@ -649,7 +651,7 @@ fn write_methods(ctxt: ctxt, docs: ~[doc::methoddoc]) { } fn write_method(ctxt: ctxt, doc: doc::methoddoc) { - write_header_(ctxt, h3, header_text_("Method", doc.name)); + write_header_(ctxt, h3, header_text_(~"Method", doc.name)); write_fnlike( ctxt, doc.sig, @@ -660,29 +662,29 @@ fn write_method(ctxt: ctxt, doc: doc::methoddoc) { #[test] fn should_write_trait_header() { - let markdown = test::render("iface i { fn a(); }"); - assert str::contains(markdown, "## Interface `i`"); + let markdown = test::render(~"iface i { fn a(); }"); + assert str::contains(markdown, ~"## Interface `i`"); } #[test] fn should_write_trait_desc() { let markdown = test::render( - "#[doc = \"desc\"] iface i { fn a(); }"); - assert str::contains(markdown, "desc"); + ~"#[doc = \"desc\"] iface i { fn a(); }"); + assert str::contains(markdown, ~"desc"); } #[test] fn should_write_trait_method_header() { let markdown = test::render( - "iface i { fn a(); }"); - assert str::contains(markdown, "### Method `a`"); + ~"iface i { fn a(); }"); + assert str::contains(markdown, ~"### Method `a`"); } #[test] fn should_write_trait_method_signature() { let markdown = test::render( - "iface i { fn a(); }"); - assert str::contains(markdown, "\n fn a()"); + ~"iface i { fn a(); }"); + assert str::contains(markdown, ~"\n fn a()"); } fn write_impl(ctxt: ctxt, doc: doc::impldoc) { @@ -692,35 +694,35 @@ fn write_impl(ctxt: ctxt, doc: doc::impldoc) { #[test] fn should_write_impl_header() { - let markdown = test::render("impl i for int { fn a() { } }"); - assert str::contains(markdown, "## Implementation `i for int`"); + let markdown = test::render(~"impl i for int { fn a() { } }"); + assert str::contains(markdown, ~"## Implementation `i for int`"); } #[test] fn should_write_impl_header_with_trait() { - let markdown = test::render("impl i of j for int { fn a() { } }"); - assert str::contains(markdown, "## Implementation `i of j for int`"); + let markdown = test::render(~"impl i of j for int { fn a() { } }"); + assert str::contains(markdown, ~"## Implementation `i of j for int`"); } #[test] fn should_write_impl_desc() { let markdown = test::render( - "#[doc = \"desc\"] impl i for int { fn a() { } }"); - assert str::contains(markdown, "desc"); + ~"#[doc = \"desc\"] impl i for int { fn a() { } }"); + assert str::contains(markdown, ~"desc"); } #[test] fn should_write_impl_method_header() { let markdown = test::render( - "impl i for int { fn a() { } }"); - assert str::contains(markdown, "### Method `a`"); + ~"impl i for int { fn a() { } }"); + assert str::contains(markdown, ~"### Method `a`"); } #[test] fn should_write_impl_method_signature() { let markdown = test::render( - "impl i for int { fn a() { } }"); - assert str::contains(markdown, "\n fn a()"); + ~"impl i for int { fn a() { } }"); + assert str::contains(markdown, ~"\n fn a()"); } fn write_type( @@ -733,41 +735,41 @@ fn write_type( #[test] fn should_write_type_header() { - let markdown = test::render("type t = int;"); - assert str::contains(markdown, "## Type `t`"); + let markdown = test::render(~"type t = int;"); + assert str::contains(markdown, ~"## Type `t`"); } #[test] fn should_write_type_desc() { let markdown = test::render( - "#[doc = \"desc\"] type t = int;"); - assert str::contains(markdown, "\n\ndesc\n\n"); + ~"#[doc = \"desc\"] type t = int;"); + assert str::contains(markdown, ~"\n\ndesc\n\n"); } #[test] fn should_write_type_signature() { - let markdown = test::render("type t = int;"); - assert str::contains(markdown, "\n\n type t = int\n\n"); + let markdown = test::render(~"type t = int;"); + assert str::contains(markdown, ~"\n\n type t = int\n\n"); } #[cfg(test)] mod test { - fn render(source: str) -> str { + fn render(source: ~str) -> ~str { let (srv, doc) = create_doc_srv(source); let markdown = write_markdown_str_srv(srv, doc); #debug("markdown: %s", markdown); markdown } - fn create_doc_srv(source: str) -> (astsrv::srv, doc::doc) { + fn create_doc_srv(source: ~str) -> (astsrv::srv, doc::doc) { do astsrv::from_str(source) |srv| { let config = { output_style: config::doc_per_crate - with config::default_config("whatever") + with config::default_config(~"whatever") }; - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); #debug("doc (extract): %?", doc); let doc = tystr_pass::mk_pass().f(srv, doc); #debug("doc (tystr): %?", doc); @@ -789,14 +791,14 @@ fn create_doc_srv(source: str) -> (astsrv::srv, doc::doc) { } } - fn create_doc(source: str) -> doc::doc { + fn create_doc(source: ~str) -> doc::doc { let (_, doc) = create_doc_srv(source); doc } fn write_markdown_str( doc: doc::doc - ) -> str { + ) -> ~str { let (writer_factory, po) = markdown_writer::future_writer_factory(); write_markdown(doc, writer_factory); ret tuple::second(comm::recv(po)); @@ -805,7 +807,7 @@ fn write_markdown_str( fn write_markdown_str_srv( srv: astsrv::srv, doc: doc::doc - ) -> str { + ) -> ~str { let (writer_factory, po) = markdown_writer::future_writer_factory(); let pass = mk_pass(writer_factory); pass.f(srv, doc); @@ -814,13 +816,13 @@ fn write_markdown_str_srv( #[test] fn write_markdown_should_write_mod_headers() { - let markdown = render("mod moo { }"); - assert str::contains(markdown, "# Module `moo`"); + let markdown = render(~"mod moo { }"); + assert str::contains(markdown, ~"# Module `moo`"); } #[test] fn should_leave_blank_line_after_header() { - let markdown = render("mod morp { }"); - assert str::contains(markdown, "Module `morp`\n\n"); + let markdown = render(~"mod morp { }"); + assert str::contains(markdown, ~"Module `morp`\n\n"); } } diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs index 6c41f0923a57..5ac9998d9ea3 100644 --- a/src/rustdoc/markdown_writer.rs +++ b/src/rustdoc/markdown_writer.rs @@ -7,7 +7,7 @@ export make_filename; enum writeinstr { - write(str), + write(~str), done } @@ -15,12 +15,12 @@ enum writeinstr { type writer_factory = fn~(page: doc::page) -> writer; impl writer_util for writer { - fn write_str(str: str) { + fn write_str(str: ~str) { self(write(str)); } - fn write_line(str: str) { - self.write_str(str + "\n"); + fn write_line(str: ~str) { + self.write_str(str + ~"\n"); } fn write_done() { @@ -70,19 +70,19 @@ fn pandoc_writer( let filename = make_local_filename(config, page); let pandoc_args = ~[ - "--standalone", - "--section-divs", - "--from=markdown", - "--to=html", - "--css=rust.css", - "--output=" + filename + ~"--standalone", + ~"--section-divs", + ~"--from=markdown", + ~"--to=html", + ~"--css=rust.css", + ~"--output=" + filename ]; do generic_writer |markdown| { import io::writer_util; #debug("pandoc cmd: %s", pandoc_cmd); - #debug("pandoc args: %s", str::connect(pandoc_args, " ")); + #debug("pandoc args: %s", str::connect(pandoc_args, ~" ")); let pipe_in = os::pipe(); let pipe_out = os::pipe(); @@ -118,16 +118,16 @@ fn pandoc_writer( if status != 0 { #error("pandoc-out: %s", stdout); #error("pandoc-err: %s", stderr); - fail "pandoc failed"; + fail ~"pandoc failed"; } } } -fn readclose(fd: libc::c_int) -> str { +fn readclose(fd: libc::c_int) -> ~str { // Copied from run::program_output let file = os::fdopen(fd); let reader = io::FILE_reader(file, false); - let mut buf = ""; + let mut buf = ~""; while !reader.eof() { let bytes = reader.read_bytes(4096u); buf += str::from_bytes(bytes); @@ -136,9 +136,9 @@ fn readclose(fd: libc::c_int) -> str { ret buf; } -fn generic_writer(+process: fn~(markdown: str)) -> writer { +fn generic_writer(+process: fn~(markdown: ~str)) -> writer { let ch = do task::spawn_listener |po: comm::port| { - let mut markdown = ""; + let mut markdown = ~""; let mut keep_going = true; while keep_going { alt comm::recv(po) { @@ -157,7 +157,7 @@ fn generic_writer(+process: fn~(markdown: str)) -> writer { fn make_local_filename( config: config::config, page: doc::page -) -> str { +) -> ~str { let filename = make_filename(config, page); path::connect(config.output_dir, filename) } @@ -165,77 +165,77 @@ fn make_local_filename( fn make_filename( config: config::config, page: doc::page -) -> str { +) -> ~str { let filename = { alt page { doc::cratepage(doc) { if config.output_format == config::pandoc_html && config.output_style == config::doc_per_mod { - "index" + ~"index" } else { - assert doc.topmod.name() != ""; + assert doc.topmod.name() != ~""; doc.topmod.name() } } doc::itempage(doc) { - str::connect(doc.path() + ~[doc.name()], "_") + str::connect(doc.path() + ~[doc.name()], ~"_") } } }; let ext = alt config.output_format { - config::markdown { "md" } - config::pandoc_html { "html" } + config::markdown { ~"md" } + config::pandoc_html { ~"html" } }; - filename + "." + ext + filename + ~"." + ext } #[test] fn should_use_markdown_file_name_based_off_crate() { let config = { - output_dir: "output/dir", + output_dir: ~"output/dir", output_format: config::markdown, output_style: config::doc_per_crate - with config::default_config("input/test.rc") + with config::default_config(~"input/test.rc") }; - let doc = test::mk_doc("test", ""); + let doc = test::mk_doc(~"test", ~""); let page = doc::cratepage(doc.cratedoc()); let filename = make_local_filename(config, page); - assert filename == "output/dir/test.md"; + assert filename == ~"output/dir/test.md"; } #[test] fn should_name_html_crate_file_name_index_html_when_doc_per_mod() { let config = { - output_dir: "output/dir", + output_dir: ~"output/dir", output_format: config::pandoc_html, output_style: config::doc_per_mod - with config::default_config("input/test.rc") + with config::default_config(~"input/test.rc") }; - let doc = test::mk_doc("", ""); + let doc = test::mk_doc(~"", ~""); let page = doc::cratepage(doc.cratedoc()); let filename = make_local_filename(config, page); - assert filename == "output/dir/index.html"; + assert filename == ~"output/dir/index.html"; } #[test] fn should_name_mod_file_names_by_path() { let config = { - output_dir: "output/dir", + output_dir: ~"output/dir", output_format: config::pandoc_html, output_style: config::doc_per_mod - with config::default_config("input/test.rc") + with config::default_config(~"input/test.rc") }; - let doc = test::mk_doc("", "mod a { mod b { } }"); + let doc = test::mk_doc(~"", ~"mod a { mod b { } }"); let modb = doc.cratemod().mods()[0].mods()[0]; let page = doc::itempage(doc::modtag(modb)); let filename = make_local_filename(config, page); - assert filename == "output/dir/a_b.html"; + assert filename == ~"output/dir/a_b.html"; } #[cfg(test)] mod test { - fn mk_doc(name: str, source: str) -> doc::doc { + fn mk_doc(name: ~str, source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, name); let doc = path_pass::mk_pass().f(srv, doc); @@ -244,7 +244,7 @@ fn mk_doc(name: str, source: str) -> doc::doc { } } -fn write_file(path: str, s: str) { +fn write_file(path: ~str, s: ~str) { import io::writer_util; alt io::file_writer(path, ~[io::create, io::truncate]) { @@ -256,7 +256,7 @@ fn write_file(path: str, s: str) { } fn future_writer_factory( -) -> (writer_factory, comm::port<(doc::page, str)>) { +) -> (writer_factory, comm::port<(doc::page, ~str)>) { let markdown_po = comm::port(); let markdown_ch = comm::chan(markdown_po); let writer_factory = fn~(page: doc::page) -> writer { @@ -274,14 +274,14 @@ fn future_writer_factory( (writer_factory, markdown_po) } -fn future_writer() -> (writer, future::future) { +fn future_writer() -> (writer, future::future<~str>) { let port = comm::port(); let chan = comm::chan(port); let writer = fn~(+instr: writeinstr) { comm::send(chan, copy instr); }; let future = do future::from_fn { - let mut res = ""; + let mut res = ~""; loop { alt comm::recv(port) { write(s) { res += s } diff --git a/src/rustdoc/page_pass.rs b/src/rustdoc/page_pass.rs index 255854df8f03..972a697202e1 100644 --- a/src/rustdoc/page_pass.rs +++ b/src/rustdoc/page_pass.rs @@ -11,7 +11,7 @@ fn mk_pass(output_style: config::output_style) -> pass { { - name: "page", + name: ~"page", f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc { run(srv, doc, output_style) } @@ -129,32 +129,32 @@ fn fold_nmod( fn should_not_split_the_doc_into_pages_for_doc_per_crate() { let doc = test::mk_doc_( config::doc_per_crate, - "mod a { } mod b { mod c { } }" + ~"mod a { } mod b { mod c { } }" ); assert doc.pages.len() == 1u; } #[test] fn should_make_a_page_for_every_mod() { - let doc = test::mk_doc("mod a { }"); - assert doc.pages.mods()[0].name() == "a"; + let doc = test::mk_doc(~"mod a { }"); + assert doc.pages.mods()[0].name() == ~"a"; } #[test] fn should_remove_mods_from_containing_mods() { - let doc = test::mk_doc("mod a { }"); + let doc = test::mk_doc(~"mod a { }"); assert vec::is_empty(doc.cratemod().mods()); } #[test] fn should_make_a_page_for_every_foreign_mod() { - let doc = test::mk_doc("extern mod a { }"); - assert doc.pages.nmods()[0].name() == "a"; + let doc = test::mk_doc(~"extern mod a { }"); + assert doc.pages.nmods()[0].name() == ~"a"; } #[test] fn should_remove_foreign_mods_from_containing_mods() { - let doc = test::mk_doc("extern mod a { }"); + let doc = test::mk_doc(~"extern mod a { }"); assert vec::is_empty(doc.cratemod().nmods()); } @@ -162,15 +162,15 @@ fn should_remove_foreign_mods_from_containing_mods() { mod test { fn mk_doc_( output_style: config::output_style, - source: str + source: ~str ) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); run(srv, doc, output_style) } } - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { mk_doc_(config::doc_per_mod, source) } } diff --git a/src/rustdoc/parse.rs b/src/rustdoc/parse.rs index c327830f517f..ca30e8aa8a8f 100644 --- a/src/rustdoc/parse.rs +++ b/src/rustdoc/parse.rs @@ -10,26 +10,26 @@ export from_file, from_str, from_file_sess, from_str_sess; -fn from_file(file: str) -> @ast::crate { +fn from_file(file: ~str) -> @ast::crate { parse::parse_crate_from_file( file, ~[], parse::new_parse_sess(none)) } -fn from_str(source: str) -> @ast::crate { +fn from_str(source: ~str) -> @ast::crate { parse::parse_crate_from_source_str( - "-", @source, ~[], parse::new_parse_sess(none)) + ~"-", @source, ~[], parse::new_parse_sess(none)) } -fn from_file_sess(sess: session::session, file: str) -> @ast::crate { +fn from_file_sess(sess: session::session, file: ~str) -> @ast::crate { parse::parse_crate_from_file( file, cfg(sess, file_input(file)), sess.parse_sess) } -fn from_str_sess(sess: session::session, source: str) -> @ast::crate { +fn from_str_sess(sess: session::session, source: ~str) -> @ast::crate { parse::parse_crate_from_source_str( - "-", @source, cfg(sess, str_input(source)), sess.parse_sess) + ~"-", @source, cfg(sess, str_input(source)), sess.parse_sess) } fn cfg(sess: session::session, input: driver::input) -> ast::crate_cfg { - driver::default_configuration(sess, "rustdoc", input) + driver::default_configuration(sess, ~"rustdoc", input) } diff --git a/src/rustdoc/path_pass.rs b/src/rustdoc/path_pass.rs index 91330cb11928..45cd72878623 100644 --- a/src/rustdoc/path_pass.rs +++ b/src/rustdoc/path_pass.rs @@ -6,14 +6,14 @@ fn mk_pass() -> pass { { - name: "path", + name: ~"path", f: run } } type ctxt = { srv: astsrv::srv, - mut path: ~[str] + mut path: ~[~str] }; #[warn(no_non_implicitly_copyable_typarams)] @@ -65,43 +65,43 @@ fn fold_nmod(fold: fold::fold, doc: doc::nmoddoc) -> doc::nmoddoc { #[test] fn should_record_mod_paths() { - let source = "mod a { mod b { mod c { } } mod d { mod e { } } }"; + let source = ~"mod a { mod b { mod c { } } mod d { mod e { } } }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = run(srv, doc); assert doc.cratemod().mods()[0].mods()[0].mods()[0].path() - == ~["a", "b"]; + == ~[~"a", ~"b"]; assert doc.cratemod().mods()[0].mods()[1].mods()[0].path() - == ~["a", "d"]; + == ~[~"a", ~"d"]; } } #[test] fn should_record_fn_paths() { - let source = "mod a { fn b() { } }"; + let source = ~"mod a { fn b() { } }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = run(srv, doc); - assert doc.cratemod().mods()[0].fns()[0].path() == ~["a"]; + assert doc.cratemod().mods()[0].fns()[0].path() == ~[~"a"]; } } #[test] fn should_record_foreign_mod_paths() { - let source = "mod a { extern mod b { } }"; + let source = ~"mod a { extern mod b { } }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = run(srv, doc); - assert doc.cratemod().mods()[0].nmods()[0].path() == ~["a"]; + assert doc.cratemod().mods()[0].nmods()[0].path() == ~[~"a"]; } } #[test] fn should_record_foreign_fn_paths() { - let source = "extern mod a { fn b(); }"; + let source = ~"extern mod a { fn b(); }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = run(srv, doc); - assert doc.cratemod().nmods()[0].fns[0].path() == ~["a"]; + assert doc.cratemod().nmods()[0].fns[0].path() == ~[~"a"]; } } diff --git a/src/rustdoc/prune_hidden_pass.rs b/src/rustdoc/prune_hidden_pass.rs index e121cc88dd7f..f5899e29df3e 100644 --- a/src/rustdoc/prune_hidden_pass.rs +++ b/src/rustdoc/prune_hidden_pass.rs @@ -5,7 +5,7 @@ fn mk_pass() -> pass { { - name: "prune_hidden", + name: ~"prune_hidden", f: run } } @@ -47,15 +47,15 @@ fn is_hidden(srv: astsrv::srv, doc: doc::itemdoc) -> bool { #[test] fn should_prune_hidden_items() { - let doc = test::mk_doc("#[doc(hidden)] mod a { }"); + let doc = test::mk_doc(~"#[doc(hidden)] mod a { }"); assert vec::is_empty(doc.cratemod().mods()) } #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); run(srv, doc) } } diff --git a/src/rustdoc/prune_unexported_pass.rs b/src/rustdoc/prune_unexported_pass.rs index b6cafbd0adeb..00173e388505 100644 --- a/src/rustdoc/prune_unexported_pass.rs +++ b/src/rustdoc/prune_unexported_pass.rs @@ -9,7 +9,7 @@ fn mk_pass() -> pass { { - name: "prune_unexported", + name: ~"prune_unexported", f: run } } @@ -70,7 +70,7 @@ fn exported_items_from_mod( fn exported_items_from( srv: astsrv::srv, doc: doc::moddoc, - is_exported: fn(astsrv::srv, str) -> bool + is_exported: fn(astsrv::srv, ~str) -> bool ) -> ~[doc::itemtag] { do vec::filter_map(doc.items) |itemtag| { let itemtag = alt itemtag { @@ -95,7 +95,7 @@ fn exported_items_from( fn exported_variants_from( srv: astsrv::srv, doc: doc::enumdoc, - is_exported: fn(astsrv::srv, str) -> bool + is_exported: fn(astsrv::srv, ~str) -> bool ) -> ~[doc::variantdoc] { do vec::filter_map(doc.variants) |doc| { if is_exported(srv, doc.name) { @@ -109,7 +109,7 @@ fn exported_variants_from( fn is_exported_from_mod( srv: astsrv::srv, mod_id: doc::ast_id, - item_name: str + item_name: ~str ) -> bool { do astsrv::exec(srv) |ctxt| { alt ctxt.ast_map.get(mod_id) { @@ -119,18 +119,18 @@ fn is_exported_from_mod( ast_util::is_exported(@item_name, m) } _ { - fail "is_exported_from_mod: not a mod"; + fail ~"is_exported_from_mod: not a mod"; } } } - _ { fail "is_exported_from_mod: not an item"; } + _ { fail ~"is_exported_from_mod: not an item"; } } } } fn is_exported_from_crate( srv: astsrv::srv, - item_name: str + item_name: ~str ) -> bool { do astsrv::exec(srv) |ctxt| { ast_util::is_exported(@item_name, ctxt.ast.node.module) @@ -139,32 +139,32 @@ fn is_exported_from_crate( #[test] fn should_prune_unexported_fns() { - let doc = test::mk_doc("mod b { export a; fn a() { } fn b() { } }"); + let doc = test::mk_doc(~"mod b { export a; fn a() { } fn b() { } }"); assert vec::len(doc.cratemod().mods()[0].fns()) == 1u; } #[test] fn should_prune_unexported_fns_from_top_mod() { - let doc = test::mk_doc("export a; fn a() { } fn b() { }"); + let doc = test::mk_doc(~"export a; fn a() { } fn b() { }"); assert vec::len(doc.cratemod().fns()) == 1u; } #[test] fn should_prune_unexported_modules() { - let doc = test::mk_doc("mod a { export a; mod a { } mod b { } }"); + let doc = test::mk_doc(~"mod a { export a; mod a { } mod b { } }"); assert vec::len(doc.cratemod().mods()[0].mods()) == 1u; } #[test] fn should_prune_unexported_modules_from_top_mod() { - let doc = test::mk_doc("export a; mod a { } mod b { }"); + let doc = test::mk_doc(~"export a; mod a { } mod b { }"); assert vec::len(doc.cratemod().mods()) == 1u; } #[test] fn should_prune_unexported_consts() { let doc = test::mk_doc( - "mod a { export a; \ + ~"mod a { export a; \ const a: bool = true; \ const b: bool = true; }"); assert vec::len(doc.cratemod().mods()[0].consts()) == 1u; @@ -173,63 +173,63 @@ fn should_prune_unexported_consts() { #[test] fn should_prune_unexported_consts_from_top_mod() { let doc = test::mk_doc( - "export a; const a: bool = true; const b: bool = true;"); + ~"export a; const a: bool = true; const b: bool = true;"); assert vec::len(doc.cratemod().consts()) == 1u; } #[test] fn should_prune_unexported_enums_from_top_mod() { - let doc = test::mk_doc("export a; mod a { } enum b { c }"); + let doc = test::mk_doc(~"export a; mod a { } enum b { c }"); assert vec::len(doc.cratemod().enums()) == 0u; } #[test] fn should_prune_unexported_enums() { - let doc = test::mk_doc("mod a { export a; mod a { } enum b { c } }"); + let doc = test::mk_doc(~"mod a { export a; mod a { } enum b { c } }"); assert vec::len(doc.cratemod().mods()[0].enums()) == 0u; } #[test] fn should_prune_unexported_variants_from_top_mod() { - let doc = test::mk_doc("export b::{}; enum b { c }"); + let doc = test::mk_doc(~"export b::{}; enum b { c }"); assert vec::len(doc.cratemod().enums()[0].variants) == 0u; } #[test] fn should_prune_unexported_variants() { - let doc = test::mk_doc("mod a { export b::{}; enum b { c } }"); + let doc = test::mk_doc(~"mod a { export b::{}; enum b { c } }"); assert vec::len(doc.cratemod().mods()[0].enums()[0].variants) == 0u; } #[test] fn should_prune_unexported_traits_from_top_mod() { - let doc = test::mk_doc("export a; mod a { } iface b { fn c(); }"); + let doc = test::mk_doc(~"export a; mod a { } iface b { fn c(); }"); assert vec::is_empty(doc.cratemod().traits()); } #[test] fn should_prune_unexported_impls_from_top_mod() { let doc = test::mk_doc( - "export a; mod a { } impl b for int { fn c() { } }"); + ~"export a; mod a { } impl b for int { fn c() { } }"); assert vec::is_empty(doc.cratemod().impls()) } #[test] fn should_prune_unexported_types() { - let doc = test::mk_doc("export a; mod a { } type b = int;"); + let doc = test::mk_doc(~"export a; mod a { } type b = int;"); assert vec::is_empty(doc.cratemod().types()); } #[test] fn should_not_prune_reexports() { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = reexport_pass::mk_pass().f(srv, doc); run(srv, doc) } } - let doc = mk_doc("import a::b; \ + let doc = mk_doc(~"import a::b; \ export b; \ mod a { fn b() { } }"); assert vec::is_not_empty(doc.cratemod().fns()); @@ -237,9 +237,9 @@ fn mk_doc(source: str) -> doc::doc { #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); run(srv, doc) } } diff --git a/src/rustdoc/reexport_pass.rs b/src/rustdoc/reexport_pass.rs index 6a5d2b326b95..188c168d7c3e 100644 --- a/src/rustdoc/reexport_pass.rs +++ b/src/rustdoc/reexport_pass.rs @@ -14,14 +14,14 @@ fn mk_pass() -> pass { { - name: "reexport", + name: ~"reexport", f: run } } type def_set = map::set; type def_map = map::hashmap; -type path_map = map::hashmap; +type path_map = map::hashmap<~str, ~[(~str, doc::itemtag)]>; fn run(srv: astsrv::srv, doc: doc::doc) -> doc::doc { @@ -72,8 +72,8 @@ fn from_def_assoc_list( } fn from_str_assoc_list( - list: ~[(str, V)] -) -> map::hashmap { + list: ~[(~str, V)] +) -> map::hashmap<~str, V> { from_assoc_list(list, map::str_hash) } @@ -169,7 +169,7 @@ fn build_reexport_path_map(srv: astsrv::srv, -def_map: def_map) -> path_map { let assoc_list = do astsrv::exec(srv) |ctxt| { let def_map = from_def_assoc_list(def_assoc_list); - let path_map = map::str_hash::<~[(str,doc::itemtag)]>(); + let path_map = map::str_hash::<~[(~str,doc::itemtag)]>(); for ctxt.exp_map.each |exp_id, defs| { let path = alt check ctxt.ast_map.get(exp_id) { @@ -223,7 +223,7 @@ fn build_reexport_path_map(srv: astsrv::srv, -def_map: def_map) -> path_map { fn find_reexport_impl_docs( ctxt: astsrv::ctxt, def_map: def_map -) -> ~[(str, (str, doc::itemtag))] { +) -> ~[(~str, (~str, doc::itemtag))] { let docs = @mut ~[]; do for_each_reexported_impl(ctxt) |mod_id, i| { @@ -233,12 +233,12 @@ fn find_reexport_impl_docs( if str::is_empty(path) { *item.ident } else { - path + "::" + *item.ident + path + ~"::" + *item.ident } } _ { assert mod_id == ast::crate_node_id; - "" + ~"" } }; let ident = *i.ident; @@ -334,9 +334,9 @@ fn fold_mod(fold: fold::fold, doc: doc::moddoc) -> doc::moddoc { } } - fn get_new_items(path: ~[str], path_map: path_map) -> ~[doc::itemtag] { + fn get_new_items(path: ~[~str], path_map: path_map) -> ~[doc::itemtag] { #debug("looking for reexports in path %?", path); - alt path_map.find(str::connect(path, "::")) { + alt path_map.find(str::connect(path, ~"::")) { some(name_docs) { do vec::foldl(~[], name_docs) |v, name_doc| { let (name, doc) = name_doc; @@ -347,7 +347,7 @@ fn get_new_items(path: ~[str], path_map: path_map) -> ~[doc::itemtag] { } } - fn reexport_doc(doc: doc::itemtag, name: str) -> doc::itemtag { + fn reexport_doc(doc: doc::itemtag, name: ~str) -> doc::itemtag { alt doc { doc::modtag(doc @ {item, _}) { doc::modtag({ @@ -395,7 +395,7 @@ fn reexport_doc(doc: doc::itemtag, name: str) -> doc::itemtag { } } - fn reexport(doc: doc::itemdoc, name: str) -> doc::itemdoc { + fn reexport(doc: doc::itemdoc, name: ~str) -> doc::itemdoc { { name: name, reexport: true @@ -406,15 +406,15 @@ fn reexport(doc: doc::itemdoc, name: str) -> doc::itemdoc { #[test] fn should_duplicate_reexported_items() { - let source = "mod a { export b; fn b() { } } \ + let source = ~"mod a { export b; fn b() { } } \ mod c { import a::b; export b; }"; let doc = test::mk_doc(source); - assert doc.cratemod().mods()[1].fns()[0].name() == "b"; + assert doc.cratemod().mods()[1].fns()[0].name() == ~"b"; } #[test] fn should_mark_reepxorts_as_such() { - let source = "mod a { export b; fn b() { } } \ + let source = ~"mod a { export b; fn b() { } } \ mod c { import a::b; export b; }"; let doc = test::mk_doc(source); assert doc.cratemod().mods()[1].fns()[0].item.reexport == true; @@ -422,39 +422,39 @@ fn should_mark_reepxorts_as_such() { #[test] fn should_duplicate_reexported_impls() { - let source = "mod a { impl b for int { fn c() { } } } \ + let source = ~"mod a { impl b for int { fn c() { } } } \ mod d { import a::b; export b; }"; let doc = test::mk_doc(source); - assert doc.cratemod().mods()[1].impls()[0].name() == "b"; + assert doc.cratemod().mods()[1].impls()[0].name() == ~"b"; } #[test] fn should_duplicate_reexported_impls_deep() { - let source = "mod a { impl b for int { fn c() { } } } \ + let source = ~"mod a { impl b for int { fn c() { } } } \ mod d { mod e { import a::b; export b; } }"; let doc = test::mk_doc(source); - assert doc.cratemod().mods()[1].mods()[0].impls()[0].name() == "b"; + assert doc.cratemod().mods()[1].mods()[0].impls()[0].name() == ~"b"; } #[test] fn should_duplicate_reexported_impls_crate() { - let source = "import a::b; export b; \ + let source = ~"import a::b; export b; \ mod a { impl b for int { fn c() { } } }"; let doc = test::mk_doc(source); - assert doc.cratemod().impls()[0].name() == "b"; + assert doc.cratemod().impls()[0].name() == ~"b"; } #[test] fn should_duplicate_reexported_foreign_fns() { - let source = "extern mod a { fn b(); } \ + let source = ~"extern mod a { fn b(); } \ mod c { import a::b; export b; }"; let doc = test::mk_doc(source); - assert doc.cratemod().mods()[0].fns()[0].name() == "b"; + assert doc.cratemod().mods()[0].fns()[0].name() == ~"b"; } #[test] fn should_duplicate_multiple_reexported_items() { - let source = "mod a { \ + let source = ~"mod a { \ export b; export c; \ fn b() { } fn c() { } \ } \ @@ -463,46 +463,46 @@ mod d { \ export b; export c; \ }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = path_pass::mk_pass().f(srv, doc); let doc = run(srv, doc); // Reexports may not be in any specific order let doc = sort_item_name_pass::mk_pass().f(srv, doc); - assert doc.cratemod().mods()[1].fns()[0].name() == "b"; - assert doc.cratemod().mods()[1].fns()[1].name() == "c"; + assert doc.cratemod().mods()[1].fns()[0].name() == ~"b"; + assert doc.cratemod().mods()[1].fns()[1].name() == ~"c"; } } #[test] fn should_rename_items_reexported_with_different_names() { - let source = "mod a { export b; fn b() { } } \ + let source = ~"mod a { export b; fn b() { } } \ mod c { import x = a::b; export x; }"; let doc = test::mk_doc(source); - assert doc.cratemod().mods()[1].fns()[0].name() == "x"; + assert doc.cratemod().mods()[1].fns()[0].name() == ~"x"; } #[test] fn should_reexport_in_topmod() { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, "core"); + let doc = extract::from_srv(srv, ~"core"); let doc = path_pass::mk_pass().f(srv, doc); run(srv, doc) } } - let source = "import option::{some, none}; \ + let source = ~"import option::{some, none}; \ import option = option::t; \ export option, some, none; \ mod option { \ enum t { some, none } \ }"; let doc = mk_doc(source); - assert doc.cratemod().enums()[0].name() == "option"; + assert doc.cratemod().enums()[0].name() == ~"option"; } #[test] fn should_not_reexport_multiple_times() { - let source = "import option = option::t; \ + let source = ~"import option = option::t; \ export option; \ export option; \ mod option { \ @@ -514,9 +514,9 @@ enum t { none, some } \ #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = path_pass::mk_pass().f(srv, doc); run(srv, doc) } diff --git a/src/rustdoc/rustdoc.rs b/src/rustdoc/rustdoc.rs index 2b70ea4ea96e..952539376ef4 100755 --- a/src/rustdoc/rustdoc.rs +++ b/src/rustdoc/rustdoc.rs @@ -4,7 +4,7 @@ /// A single operation on the document model type pass = { - name: str, + name: ~str, f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc }; @@ -52,7 +52,7 @@ fn pass1( doc::cratepage({ topmod: { item: { - name: doc.cratemod().name() + "two" + name: doc.cratemod().name() + ~"two" with doc.cratemod().item }, items: ~[], @@ -71,7 +71,7 @@ fn pass2( doc::cratepage({ topmod: { item: { - name: doc.cratemod().name() + "three" + name: doc.cratemod().name() + ~"three" with doc.cratemod().item }, items: ~[], @@ -81,27 +81,27 @@ fn pass2( ] } } - let source = ""; + let source = ~""; do astsrv::from_str(source) |srv| { let passes = ~[ { - name: "", + name: ~"", f: pass1 }, { - name: "", + name: ~"", f: pass2 } ]; - let doc = extract::from_srv(srv, "one"); + let doc = extract::from_srv(srv, ~"one"); let doc = run_passes(srv, doc, passes); - assert doc.cratemod().name() == "onetwothree"; + assert doc.cratemod().name() == ~"onetwothree"; } } -fn main(args: ~[str]) { +fn main(args: ~[~str]) { - if vec::contains(args, "-h") { + if vec::contains(args, ~"-h") { config::usage(); ret; } @@ -117,7 +117,7 @@ fn main(args: ~[str]) { run(config); } -fn time(what: str, f: fn() -> T) -> T { +fn time(what: ~str, f: fn() -> T) -> T { let start = std::time::precise_time_s(); let rv = f(); let end = std::time::precise_time_s(); @@ -130,10 +130,10 @@ fn run(config: config::config) { let source_file = config.input_crate; do astsrv::from_file(source_file) |srv| { - do time("wait_ast") { + do time(~"wait_ast") { do astsrv::exec(srv) |_ctxt| { } }; - let doc = time("extract", || { + let doc = time(~"extract", || { let default_name = source_file; extract::from_srv(srv, default_name) }); diff --git a/src/rustdoc/sectionalize_pass.rs b/src/rustdoc/sectionalize_pass.rs index 0974e5da8505..a6bb35746875 100644 --- a/src/rustdoc/sectionalize_pass.rs +++ b/src/rustdoc/sectionalize_pass.rs @@ -4,7 +4,7 @@ fn mk_pass() -> pass { { - name: "sectionalize", + name: ~"sectionalize", f: run } } @@ -64,7 +64,7 @@ fn fold_impl(fold: fold::fold<()>, doc: doc::impldoc) -> doc::impldoc { } } -fn sectionalize(desc: option) -> (option, ~[doc::section]) { +fn sectionalize(desc: option<~str>) -> (option<~str>, ~[doc::section]) { /*! * Take a description of the form @@ -88,7 +88,7 @@ fn sectionalize(desc: option) -> (option, ~[doc::section]) { let lines = str::lines(option::get(desc)); - let mut new_desc = none::; + let mut new_desc = none::<~str>; let mut current_section = none; let mut sections = ~[]; @@ -100,21 +100,21 @@ fn sectionalize(desc: option) -> (option, ~[doc::section]) { } current_section = some({ header: header, - body: "" + body: ~"" }); } none { alt copy current_section { some(section) { current_section = some({ - body: section.body + "\n" + line + body: section.body + ~"\n" + line with section }); } none { new_desc = alt new_desc { some(desc) { - some(desc + "\n" + line) + some(desc + ~"\n" + line) } none { some(line) @@ -133,8 +133,8 @@ fn sectionalize(desc: option) -> (option, ~[doc::section]) { (new_desc, sections) } -fn parse_header(line: str) -> option { - if str::starts_with(line, "# ") { +fn parse_header(line: ~str) -> option<~str> { + if str::starts_with(line, ~"# ") { some(str::slice(line, 2u, str::len(line))) } else { none @@ -144,31 +144,31 @@ fn parse_header(line: str) -> option { #[test] fn should_create_section_headers() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ # Header\n\ Body\"]\ mod a { }"); assert str::contains( doc.cratemod().mods()[0].item.sections[0].header, - "Header"); + ~"Header"); } #[test] fn should_create_section_bodies() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ # Header\n\ Body\"]\ mod a { }"); assert str::contains( doc.cratemod().mods()[0].item.sections[0].body, - "Body"); + ~"Body"); } #[test] fn should_not_create_sections_from_indented_headers() { let doc = test::mk_doc( - "#[doc = \"\n\ + ~"#[doc = \"\n\ Text\n # Header\n\ Body\"]\ mod a { }"); @@ -178,23 +178,23 @@ fn should_not_create_sections_from_indented_headers() { #[test] fn should_remove_section_text_from_main_desc() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ Description\n\n\ # Header\n\ Body\"]\ mod a { }"); assert !str::contains( option::get(doc.cratemod().mods()[0].desc()), - "Header"); + ~"Header"); assert !str::contains( option::get(doc.cratemod().mods()[0].desc()), - "Body"); + ~"Body"); } #[test] fn should_eliminate_desc_if_it_is_just_whitespace() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ # Header\n\ Body\"]\ mod a { }"); @@ -204,7 +204,7 @@ fn should_eliminate_desc_if_it_is_just_whitespace() { #[test] fn should_sectionalize_trait_methods() { let doc = test::mk_doc( - "iface i { + ~"iface i { #[doc = \"\ # Header\n\ Body\"]\ @@ -215,7 +215,7 @@ fn should_sectionalize_trait_methods() { #[test] fn should_sectionalize_impl_methods() { let doc = test::mk_doc( - "impl i for bool { + ~"impl i for bool { #[doc = \"\ # Header\n\ Body\"]\ @@ -225,9 +225,9 @@ fn should_sectionalize_impl_methods() { #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = attr_pass::mk_pass().f(srv, doc); run(srv, doc) } diff --git a/src/rustdoc/sort_item_name_pass.rs b/src/rustdoc/sort_item_name_pass.rs index 47a69fed953b..daf7d97c2ea4 100644 --- a/src/rustdoc/sort_item_name_pass.rs +++ b/src/rustdoc/sort_item_name_pass.rs @@ -3,18 +3,18 @@ export mk_pass; fn mk_pass() -> pass { - sort_pass::mk_pass("sort_item_name", |item1, item2| { + sort_pass::mk_pass(~"sort_item_name", |item1, item2| { str::le(item1.name(), item2.name()) }) } #[test] fn test() { - let source = "mod z { } fn y() { }"; + let source = ~"mod z { } fn y() { }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = mk_pass().f(srv, doc); - assert doc.cratemod().items[0].name() == "y"; - assert doc.cratemod().items[1].name() == "z"; + assert doc.cratemod().items[0].name() == ~"y"; + assert doc.cratemod().items[1].name() == ~"z"; } } diff --git a/src/rustdoc/sort_item_type_pass.rs b/src/rustdoc/sort_item_type_pass.rs index d8e566d04003..bc2650e590a5 100644 --- a/src/rustdoc/sort_item_type_pass.rs +++ b/src/rustdoc/sort_item_type_pass.rs @@ -3,7 +3,7 @@ export mk_pass; fn mk_pass() -> pass { - do sort_pass::mk_pass("sort_item_type") |item1, item2| { + do sort_pass::mk_pass(~"sort_item_type") |item1, item2| { fn score(item: doc::itemtag) -> int { alt item { doc::consttag(_) { 0 } @@ -24,7 +24,7 @@ fn score(item: doc::itemtag) -> int { #[test] fn test() { let source = - "mod imod { } \ + ~"mod imod { } \ extern mod inmod { } \ const iconst: int = 0; \ fn ifn() { } \ @@ -33,15 +33,15 @@ enum ienum { ivar } \ impl iimpl for int { fn a() { } } \ type itype = int;"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = mk_pass().f(srv, doc); - assert doc.cratemod().items[0].name() == "iconst"; - assert doc.cratemod().items[1].name() == "itype"; - assert doc.cratemod().items[2].name() == "ienum"; - assert doc.cratemod().items[3].name() == "iiface"; - assert doc.cratemod().items[4].name() == "iimpl"; - assert doc.cratemod().items[5].name() == "ifn"; - assert doc.cratemod().items[6].name() == "imod"; - assert doc.cratemod().items[7].name() == "inmod"; + assert doc.cratemod().items[0].name() == ~"iconst"; + assert doc.cratemod().items[1].name() == ~"itype"; + assert doc.cratemod().items[2].name() == ~"ienum"; + assert doc.cratemod().items[3].name() == ~"iiface"; + assert doc.cratemod().items[4].name() == ~"iimpl"; + assert doc.cratemod().items[5].name() == ~"ifn"; + assert doc.cratemod().items[6].name() == ~"imod"; + assert doc.cratemod().items[7].name() == ~"inmod"; } } diff --git a/src/rustdoc/sort_pass.rs b/src/rustdoc/sort_pass.rs index 86dc2260e7d7..a95de20d1baa 100644 --- a/src/rustdoc/sort_pass.rs +++ b/src/rustdoc/sort_pass.rs @@ -6,7 +6,7 @@ type item_lteq = fn~(doc::itemtag, doc::itemtag) -> bool; -fn mk_pass(name: str, +lteq: item_lteq) -> pass { +fn mk_pass(name: ~str, +lteq: item_lteq) -> pass { { name: name, f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc { @@ -46,14 +46,14 @@ fn name_lteq(item1: doc::itemtag, item2: doc::itemtag) -> bool { str::le(item1.name(), item2.name()) } - let source = "mod z { mod y { } fn x() { } } mod w { }"; + let source = ~"mod z { mod y { } fn x() { } } mod w { }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); - let doc = mk_pass("", name_lteq).f(srv, doc); - assert doc.cratemod().mods()[0].name() == "w"; - assert doc.cratemod().mods()[1].items[0].name() == "x"; - assert doc.cratemod().mods()[1].items[1].name() == "y"; - assert doc.cratemod().mods()[1].name() == "z"; + let doc = extract::from_srv(srv, ~""); + let doc = mk_pass(~"", name_lteq).f(srv, doc); + assert doc.cratemod().mods()[0].name() == ~"w"; + assert doc.cratemod().mods()[1].items[0].name() == ~"x"; + assert doc.cratemod().mods()[1].items[1].name() == ~"y"; + assert doc.cratemod().mods()[1].name() == ~"z"; } } @@ -63,14 +63,14 @@ fn always_eq(_item1: doc::itemtag, _item2: doc::itemtag) -> bool { true } - let source = "mod a { mod b { } } mod c { mod d { } }"; + let source = ~"mod a { mod b { } } mod c { mod d { } }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); - let doc = mk_pass("", always_eq).f(srv, doc); - assert doc.cratemod().mods()[0].items[0].name() == "b"; - assert doc.cratemod().mods()[1].items[0].name() == "d"; - let doc = mk_pass("", always_eq).f(srv, doc); - assert doc.cratemod().mods()[0].items[0].name() == "b"; - assert doc.cratemod().mods()[1].items[0].name() == "d"; + let doc = extract::from_srv(srv, ~""); + let doc = mk_pass(~"", always_eq).f(srv, doc); + assert doc.cratemod().mods()[0].items[0].name() == ~"b"; + assert doc.cratemod().mods()[1].items[0].name() == ~"d"; + let doc = mk_pass(~"", always_eq).f(srv, doc); + assert doc.cratemod().mods()[0].items[0].name() == ~"b"; + assert doc.cratemod().mods()[1].items[0].name() == ~"d"; } } diff --git a/src/rustdoc/text_pass.rs b/src/rustdoc/text_pass.rs index cd001e69f211..ac419c557dfc 100644 --- a/src/rustdoc/text_pass.rs +++ b/src/rustdoc/text_pass.rs @@ -2,7 +2,7 @@ export mk_pass; -fn mk_pass(name: str, +op: fn~(str) -> str) -> pass { +fn mk_pass(name: ~str, +op: fn~(~str) -> ~str) -> pass { { name: name, f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc { @@ -11,7 +11,7 @@ fn mk_pass(name: str, +op: fn~(str) -> str) -> pass { } } -type op = fn~(str) -> str; +type op = fn~(~str) -> ~str; #[warn(no_non_implicitly_copyable_typarams)] fn run( @@ -29,7 +29,7 @@ fn run( fold.fold_doc(fold, doc) } -fn maybe_apply_op(op: op, s: option) -> option { +fn maybe_apply_op(op: op, s: option<~str>) -> option<~str> { option::map(s, |s| op(s) ) } @@ -96,167 +96,167 @@ fn fold_impl(fold: fold::fold, doc: doc::impldoc) -> doc::impldoc { #[test] fn should_execute_op_on_enum_brief() { - let doc = test::mk_doc("#[doc = \" a \"] enum a { b }"); - assert doc.cratemod().enums()[0].brief() == some("a"); + let doc = test::mk_doc(~"#[doc = \" a \"] enum a { b }"); + assert doc.cratemod().enums()[0].brief() == some(~"a"); } #[test] fn should_execute_op_on_enum_desc() { - let doc = test::mk_doc("#[doc = \" a \"] enum a { b }"); - assert doc.cratemod().enums()[0].desc() == some("a"); + let doc = test::mk_doc(~"#[doc = \" a \"] enum a { b }"); + assert doc.cratemod().enums()[0].desc() == some(~"a"); } #[test] fn should_execute_op_on_variant_desc() { - let doc = test::mk_doc("enum a { #[doc = \" a \"] b }"); - assert doc.cratemod().enums()[0].variants[0].desc == some("a"); + let doc = test::mk_doc(~"enum a { #[doc = \" a \"] b }"); + assert doc.cratemod().enums()[0].variants[0].desc == some(~"a"); } #[test] fn should_execute_op_on_trait_brief() { let doc = test::mk_doc( - "#[doc = \" a \"] iface i { fn a(); }"); - assert doc.cratemod().traits()[0].brief() == some("a"); + ~"#[doc = \" a \"] iface i { fn a(); }"); + assert doc.cratemod().traits()[0].brief() == some(~"a"); } #[test] fn should_execute_op_on_trait_desc() { let doc = test::mk_doc( - "#[doc = \" a \"] iface i { fn a(); }"); - assert doc.cratemod().traits()[0].desc() == some("a"); + ~"#[doc = \" a \"] iface i { fn a(); }"); + assert doc.cratemod().traits()[0].desc() == some(~"a"); } #[test] fn should_execute_op_on_trait_method_brief() { let doc = test::mk_doc( - "iface i { #[doc = \" a \"] fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].brief == some("a"); + ~"iface i { #[doc = \" a \"] fn a(); }"); + assert doc.cratemod().traits()[0].methods[0].brief == some(~"a"); } #[test] fn should_execute_op_on_trait_method_desc() { let doc = test::mk_doc( - "iface i { #[doc = \" a \"] fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].desc == some("a"); + ~"iface i { #[doc = \" a \"] fn a(); }"); + assert doc.cratemod().traits()[0].methods[0].desc == some(~"a"); } #[test] fn should_execute_op_on_impl_brief() { let doc = test::mk_doc( - "#[doc = \" a \"] impl i for int { fn a() { } }"); - assert doc.cratemod().impls()[0].brief() == some("a"); + ~"#[doc = \" a \"] impl i for int { fn a() { } }"); + assert doc.cratemod().impls()[0].brief() == some(~"a"); } #[test] fn should_execute_op_on_impl_desc() { let doc = test::mk_doc( - "#[doc = \" a \"] impl i for int { fn a() { } }"); - assert doc.cratemod().impls()[0].desc() == some("a"); + ~"#[doc = \" a \"] impl i for int { fn a() { } }"); + assert doc.cratemod().impls()[0].desc() == some(~"a"); } #[test] fn should_execute_op_on_impl_method_brief() { let doc = test::mk_doc( - "impl i for int { #[doc = \" a \"] fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].brief == some("a"); + ~"impl i for int { #[doc = \" a \"] fn a() { } }"); + assert doc.cratemod().impls()[0].methods[0].brief == some(~"a"); } #[test] fn should_execute_op_on_impl_method_desc() { let doc = test::mk_doc( - "impl i for int { #[doc = \" a \"] fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].desc == some("a"); + ~"impl i for int { #[doc = \" a \"] fn a() { } }"); + assert doc.cratemod().impls()[0].methods[0].desc == some(~"a"); } #[test] fn should_execute_op_on_type_brief() { let doc = test::mk_doc( - "#[doc = \" a \"] type t = int;"); - assert doc.cratemod().types()[0].brief() == some("a"); + ~"#[doc = \" a \"] type t = int;"); + assert doc.cratemod().types()[0].brief() == some(~"a"); } #[test] fn should_execute_op_on_type_desc() { let doc = test::mk_doc( - "#[doc = \" a \"] type t = int;"); - assert doc.cratemod().types()[0].desc() == some("a"); + ~"#[doc = \" a \"] type t = int;"); + assert doc.cratemod().types()[0].desc() == some(~"a"); } #[test] fn should_execute_on_item_section_headers() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ # Header \n\ Body\"]\ fn a() { }"); - assert doc.cratemod().fns()[0].sections()[0].header == "Header"; + assert doc.cratemod().fns()[0].sections()[0].header == ~"Header"; } #[test] fn should_execute_on_item_section_bodies() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ # Header\n\ Body \"]\ fn a() { }"); - assert doc.cratemod().fns()[0].sections()[0].body == "Body"; + assert doc.cratemod().fns()[0].sections()[0].body == ~"Body"; } #[test] fn should_execute_on_trait_method_section_headers() { let doc = test::mk_doc( - "iface i { + ~"iface i { #[doc = \"\ # Header \n\ Body\"]\ fn a(); }"); assert doc.cratemod().traits()[0].methods[0].sections[0].header - == "Header"; + == ~"Header"; } #[test] fn should_execute_on_trait_method_section_bodies() { let doc = test::mk_doc( - "iface i { + ~"iface i { #[doc = \"\ # Header\n\ Body \"]\ fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].sections[0].body == "Body"; + assert doc.cratemod().traits()[0].methods[0].sections[0].body == ~"Body"; } #[test] fn should_execute_on_impl_method_section_headers() { let doc = test::mk_doc( - "impl i for bool { + ~"impl i for bool { #[doc = \"\ # Header \n\ Body\"]\ fn a() { } }"); assert doc.cratemod().impls()[0].methods[0].sections[0].header - == "Header"; + == ~"Header"; } #[test] fn should_execute_on_impl_method_section_bodies() { let doc = test::mk_doc( - "impl i for bool { + ~"impl i for bool { #[doc = \"\ # Header\n\ Body \"]\ fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].sections[0].body == "Body"; + assert doc.cratemod().impls()[0].methods[0].sections[0].body == ~"Body"; } #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = attr_pass::mk_pass().f(srv, doc); let doc = desc_to_brief_pass::mk_pass().f(srv, doc); let doc = sectionalize_pass::mk_pass().f(srv, doc); - mk_pass("", |s| str::trim(s) ).f(srv, doc) + mk_pass(~"", |s| str::trim(s) ).f(srv, doc) } } } diff --git a/src/rustdoc/trim_pass.rs b/src/rustdoc/trim_pass.rs index 3d135d8073c0..1a5e96dbed41 100644 --- a/src/rustdoc/trim_pass.rs +++ b/src/rustdoc/trim_pass.rs @@ -8,21 +8,21 @@ export mk_pass; fn mk_pass() -> pass { - text_pass::mk_pass("trim", |s| str::trim(s) ) + text_pass::mk_pass(~"trim", |s| str::trim(s) ) } #[test] fn should_trim_text() { - let doc = test::mk_doc("#[doc = \" desc \"] \ + let doc = test::mk_doc(~"#[doc = \" desc \"] \ mod m { }"); - assert doc.cratemod().mods()[0].desc() == some("desc"); + assert doc.cratemod().mods()[0].desc() == some(~"desc"); } #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = attr_pass::mk_pass().f(srv, doc); mk_pass().f(srv, doc) } diff --git a/src/rustdoc/tystr_pass.rs b/src/rustdoc/tystr_pass.rs index 011420bdcf4b..006e8bc66dc7 100644 --- a/src/rustdoc/tystr_pass.rs +++ b/src/rustdoc/tystr_pass.rs @@ -9,7 +9,7 @@ fn mk_pass() -> pass { { - name: "tystr", + name: ~"tystr", f: run } } @@ -43,7 +43,7 @@ fn fold_fn( } } -fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> option { +fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> option<~str> { do astsrv::exec(srv) |ctxt| { alt check ctxt.ast_map.get(fn_id) { ast_map::node_item(@{ @@ -62,14 +62,14 @@ fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> option { #[test] fn should_add_fn_sig() { - let doc = test::mk_doc("fn a() -> int { }"); - assert doc.cratemod().fns()[0].sig == some("fn a() -> int"); + let doc = test::mk_doc(~"fn a() -> int { }"); + assert doc.cratemod().fns()[0].sig == some(~"fn a() -> int"); } #[test] fn should_add_foreign_fn_sig() { - let doc = test::mk_doc("extern mod a { fn a() -> int; }"); - assert doc.cratemod().nmods()[0].fns[0].sig == some("fn a() -> int"); + let doc = test::mk_doc(~"extern mod a { fn a() -> int; }"); + assert doc.cratemod().nmods()[0].fns[0].sig == some(~"fn a() -> int"); } fn fold_const( @@ -94,8 +94,8 @@ fn fold_const( #[test] fn should_add_const_types() { - let doc = test::mk_doc("const a: bool = true;"); - assert doc.cratemod().consts()[0].sig == some("bool"); + let doc = test::mk_doc(~"const a: bool = true;"); + assert doc.cratemod().consts()[0].sig == some(~"bool"); } fn fold_enum( @@ -133,8 +133,8 @@ fn fold_enum( #[test] fn should_add_variant_sigs() { - let doc = test::mk_doc("enum a { b(int) }"); - assert doc.cratemod().enums()[0].variants[0].sig == some("b(int)"); + let doc = test::mk_doc(~"enum a { b(int) }"); + assert doc.cratemod().enums()[0].variants[0].sig == some(~"b(int)"); } fn fold_trait( @@ -163,8 +163,8 @@ fn merge_methods( fn get_method_sig( srv: astsrv::srv, item_id: doc::ast_id, - method_name: str -) -> option { + method_name: ~str +) -> option<~str> { do astsrv::exec(srv) |ctxt| { alt check ctxt.ast_map.get(item_id) { ast_map::node_item(@{ @@ -217,9 +217,9 @@ fn get_method_sig( #[test] fn should_add_trait_method_sigs() { - let doc = test::mk_doc("iface i { fn a() -> int; }"); + let doc = test::mk_doc(~"iface i { fn a() -> int; }"); assert doc.cratemod().traits()[0].methods[0].sig - == some("fn a() -> int"); + == some(~"fn a() -> int"); } fn fold_impl( @@ -239,7 +239,7 @@ fn fold_impl( }); (trait_ty, some(pprust::ty_to_str(self_ty))) } - _ { fail "expected impl" } + _ { fail ~"expected impl" } } }; @@ -253,27 +253,27 @@ fn fold_impl( #[test] fn should_add_impl_trait_ty() { - let doc = test::mk_doc("impl i of j for int { fn a() { } }"); - assert doc.cratemod().impls()[0].trait_ty == some("j"); + let doc = test::mk_doc(~"impl i of j for int { fn a() { } }"); + assert doc.cratemod().impls()[0].trait_ty == some(~"j"); } #[test] fn should_not_add_impl_trait_ty_if_none() { - let doc = test::mk_doc("impl i for int { fn a() { } }"); + let doc = test::mk_doc(~"impl i for int { fn a() { } }"); assert doc.cratemod().impls()[0].trait_ty == none; } #[test] fn should_add_impl_self_ty() { - let doc = test::mk_doc("impl i for int { fn a() { } }"); - assert doc.cratemod().impls()[0].self_ty == some("int"); + let doc = test::mk_doc(~"impl i for int { fn a() { } }"); + assert doc.cratemod().impls()[0].self_ty == some(~"int"); } #[test] fn should_add_impl_method_sigs() { - let doc = test::mk_doc("impl i for int { fn a() -> int { fail } }"); + let doc = test::mk_doc(~"impl i for int { fn a() -> int { fail } }"); assert doc.cratemod().impls()[0].methods[0].sig - == some("fn a() -> int"); + == some(~"fn a() -> int"); } fn fold_type( @@ -297,7 +297,7 @@ fn fold_type( pprust::ty_to_str(ty) )) } - _ { fail "expected type" } + _ { fail ~"expected type" } } } with doc @@ -306,15 +306,15 @@ fn fold_type( #[test] fn should_add_type_signatures() { - let doc = test::mk_doc("type t = int;"); - assert doc.cratemod().types()[0].sig == some("type t = int"); + let doc = test::mk_doc(~"type t = int;"); + assert doc.cratemod().types()[0].sig == some(~"type t = int"); } #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); run(srv, doc) } } diff --git a/src/rustdoc/unindent_pass.rs b/src/rustdoc/unindent_pass.rs index 1df8d5b8f502..52d91a7994f4 100644 --- a/src/rustdoc/unindent_pass.rs +++ b/src/rustdoc/unindent_pass.rs @@ -12,10 +12,10 @@ export mk_pass; fn mk_pass() -> pass { - text_pass::mk_pass("unindent", unindent) + text_pass::mk_pass(~"unindent", unindent) } -fn unindent(s: str) -> str { +fn unindent(s: ~str) -> ~str { let lines = str::lines_any(s); let mut saw_first_line = false; let mut saw_second_line = false; @@ -70,7 +70,7 @@ fn unindent(s: str) -> str { str::slice(line, min_indent, str::len(line)) } }; - str::connect(unindented, "\n") + str::connect(unindented, ~"\n") } else { s } @@ -78,25 +78,25 @@ fn unindent(s: str) -> str { #[test] fn should_unindent() { - let s = " line1\n line2"; + let s = ~" line1\n line2"; let r = unindent(s); - assert r == "line1\nline2"; + assert r == ~"line1\nline2"; } #[test] fn should_unindent_multiple_paragraphs() { - let s = " line1\n\n line2"; + let s = ~" line1\n\n line2"; let r = unindent(s); - assert r == "line1\n\nline2"; + assert r == ~"line1\n\nline2"; } #[test] fn should_leave_multiple_indent_levels() { // Line 2 is indented another level beyond the // base indentation and should be preserved - let s = " line1\n\n line2"; + let s = ~" line1\n\n line2"; let r = unindent(s); - assert r == "line1\n\n line2"; + assert r == ~"line1\n\n line2"; } #[test] @@ -106,14 +106,14 @@ fn should_ignore_first_line_indent() { // // #[doc = "Start way over here // and continue here"] - let s = "line1\n line2"; + let s = ~"line1\n line2"; let r = unindent(s); - assert r == "line1\nline2"; + assert r == ~"line1\nline2"; } #[test] fn should_not_ignore_first_line_indent_in_a_single_line_para() { - let s = "line1\n\n line2"; + let s = ~"line1\n\n line2"; let r = unindent(s); - assert r == "line1\n\n line2"; + assert r == ~"line1\n\n line2"; } diff --git a/src/snapshots.txt b/src/snapshots.txt index a99a9f39a814..19390ca63d59 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,19 @@ +S 2012-07-13 6247a52 + macos-i386 90490415d34d0c0cdfca7edaf880f268e50f346b + macos-x86_64 2114a361fe1162d0a20671dcfa61378ba924544b + freebsd-x86_64 49a2503abfd426a010cbde2a79cbd29c3dd200db + linux-i386 a6dc9a74adb6bbe41daf1daddb792921f3d45f51 + linux-x86_64 0cb3bd25bb46d0df7ad6bc386e2ff6ed56b14170 + winnt-i386 e11e07dacd711f7832a1b63c075df76972ee4d4c + +S 2012-07-13 d7f4d8d + macos-i386 0796275306d77c0f5d376a388dc7914e28b56bf0 + macos-x86_64 0c6cae29afc39f5e9d14e44825e0ec6f799a9f76 + freebsd-x86_64 8eced1b9246d8a15c00071b414b6420fa935174a + linux-i386 def8afd6a3da27f197552a9b9875d21302b9cb77 + linux-x86_64 ecbbb565ccd702ed851f111cff8c156024af9ff2 + winnt-i386 a16f903bc613b25bd65440829e5d724b10aff385 + S 2012-07-12 8ad4e92 macos-i386 b31efba34f0af7ce527adc49cd345548da528ccf macos-x86_64 ef82309eb8ba269091fbe5f41a1e28fa3c6da90e diff --git a/src/test/auxiliary/cci_class_4.rs b/src/test/auxiliary/cci_class_4.rs index ef16b540d0cc..4bd1393a137a 100644 --- a/src/test/auxiliary/cci_class_4.rs +++ b/src/test/auxiliary/cci_class_4.rs @@ -13,9 +13,9 @@ fn meow() { } let mut how_hungry : int; - let name : str; + let name : ~str; - new(in_x : uint, in_y : int, in_name: str) + new(in_x : uint, in_y : int, in_name: ~str) { self.meows = in_x; self.how_hungry = in_y; self.name = in_name; } fn speak() { self.meow(); } diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 63b8426ac93c..d031546c9dbe 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -16,9 +16,9 @@ fn meow() { } let mut how_hungry : int; - let name : str; + let name : ~str; - new(in_x : uint, in_y : int, in_name: str) + new(in_x : uint, in_y : int, in_name: ~str) { self.meows = in_x; self.how_hungry = in_y; self.name = in_name; } fn speak() { self.meow(); } @@ -35,6 +35,6 @@ fn eat() -> bool { } } - fn to_str() -> str { self.name } + fn to_str() -> ~str { self.name } } } diff --git a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs index eae7bf8e7cbd..97787cc84066 100644 --- a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs +++ b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs @@ -9,7 +9,7 @@ mod name_pool { type name_pool = (); impl methods for name_pool { - fn add(s: str) { + fn add(s: ~str) { } } } diff --git a/src/test/auxiliary/crateresolve5-1.rs b/src/test/auxiliary/crateresolve5-1.rs index 9de656e5b9c9..d1a31246f5b0 100644 --- a/src/test/auxiliary/crateresolve5-1.rs +++ b/src/test/auxiliary/crateresolve5-1.rs @@ -3,8 +3,8 @@ #[crate_type = "lib"]; -fn structural() -> { name: str, val: int } { - { name: "crateresolve5", val: 10 } +fn structural() -> { name: ~str, val: int } { + { name: ~"crateresolve5", val: 10 } } enum e { diff --git a/src/test/auxiliary/crateresolve5-2.rs b/src/test/auxiliary/crateresolve5-2.rs index ff884a5ba685..df28b2c25b76 100644 --- a/src/test/auxiliary/crateresolve5-2.rs +++ b/src/test/auxiliary/crateresolve5-2.rs @@ -3,8 +3,8 @@ #[crate_type = "lib"]; -fn structural() -> { name: str, val: int } { - { name: "crateresolve5", val: 10 } +fn structural() -> { name: ~str, val: int } { + { name: ~"crateresolve5", val: 10 } } enum e { diff --git a/src/test/auxiliary/foreign_lib.rs b/src/test/auxiliary/foreign_lib.rs index ff4bb5266eca..c33ced59fec4 100644 --- a/src/test/auxiliary/foreign_lib.rs +++ b/src/test/auxiliary/foreign_lib.rs @@ -1,5 +1,5 @@ #[link(name="foreign_lib", vers="0.0")]; extern mod rustrt { - fn last_os_error() -> str; + fn last_os_error() -> ~str; } \ No newline at end of file diff --git a/src/test/auxiliary/issue-2414-a.rs b/src/test/auxiliary/issue-2414-a.rs index 0f4b51a8dad4..01cadc922469 100644 --- a/src/test/auxiliary/issue-2414-a.rs +++ b/src/test/auxiliary/issue-2414-a.rs @@ -2,4 +2,4 @@ #[crate_type = "lib"]; type t1 = uint; -impl t2 for str { } +impl t2 for ~str { } diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 049988863be9..dd8ace9ee742 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -7,9 +7,9 @@ import dvec::dvec; import std::map::hashmap; -type header_map = hashmap>; +type header_map = hashmap<~str, @dvec<@~str>>; // the unused ty param is necessary so this gets monomorphized fn request(req: header_map) { - let _x = *(*req.get("METHOD"))[0u]; + let _x = *(*req.get(~"METHOD"))[0u]; } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 48e2b5b6a10b..db7434a21396 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -8,7 +8,7 @@ import io::{reader, reader_util}; -fn main(argv: ~[str]) { +fn main(argv: ~[~str]) { #macro[ [#bench[id], maybe_run_test(argv, #stringify(id), id) @@ -26,12 +26,12 @@ fn main(argv: ~[str]) { #bench[vec_push_all]; } -fn maybe_run_test(argv: &[str], name: str, test: fn()) { +fn maybe_run_test(argv: &[~str], name: ~str, test: fn()) { let mut run_test = false; - if os::getenv("RUST_BENCH").is_some() { run_test = true } + if os::getenv(~"RUST_BENCH").is_some() { run_test = true } else if argv.len() > 0 { - run_test = argv.contains("all") || argv.contains(name) + run_test = argv.contains(~"all") || argv.contains(name) } if !run_test { ret } @@ -55,7 +55,7 @@ fn shift_push() { fn read_line() { let path = path::connect( #env("CFG_SRC_DIR"), - "src/test/bench/shootout-k-nucleotide.data" + ~"src/test/bench/shootout-k-nucleotide.data" ); for int::range(0, 3) |_i| { diff --git a/src/test/bench/core-uint-to-str.rs b/src/test/bench/core-uint-to-str.rs index 5dac712414d5..5a6c9b9def7f 100644 --- a/src/test/bench/core-uint-to-str.rs +++ b/src/test/bench/core-uint-to-str.rs @@ -1,8 +1,8 @@ -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "10000000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"10000000"] } else if args.len() <= 1u { - ~["", "100000"] + ~[~"", ~"100000"] } else { args }; diff --git a/src/test/bench/core-vec-append.rs b/src/test/bench/core-vec-append.rs index 7e4a327ea12e..dec0c0b9f226 100644 --- a/src/test/bench/core-vec-append.rs +++ b/src/test/bench/core-vec-append.rs @@ -20,11 +20,11 @@ fn collect_dvec(num: uint) -> ~[mut uint] { ret dvec::unwrap(result); } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "50000000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"50000000"] } else if args.len() <= 1u { - ~["", "100000"] + ~[~"", ~"100000"] } else { args }; diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 5f3946e14243..bd3f2c615bfd 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -196,7 +196,7 @@ fn is_gray(c: color) -> bool { alt c { white { -1i64 } black(parent) { parent } - _ { fail "Found remaining gray nodes in BFS" } + _ { fail ~"Found remaining gray nodes in BFS" } } } } @@ -276,7 +276,7 @@ fn is_gray(c: color) -> bool { alt c { white { -1i64 } black(parent) { parent } - _ { fail "Found remaining gray nodes in BFS" } + _ { fail ~"Found remaining gray nodes in BFS" } } } } @@ -292,7 +292,7 @@ fn validate(edges: ~[(node_id, node_id)], // parent chains back to the root. While we do this, we also // compute the levels for each node. - log(info, "Verifying tree structure..."); + log(info, ~"Verifying tree structure..."); let mut status = true; let level = do tree.map() |parent| { @@ -324,7 +324,7 @@ fn validate(edges: ~[(node_id, node_id)], // 2. Each tree edge connects vertices whose BFS levels differ by // exactly one. - log(info, "Verifying tree edges..."); + log(info, ~"Verifying tree edges..."); let status = do tree.alli() |k, parent| { if parent != root && parent != -1i64 { @@ -340,7 +340,7 @@ fn validate(edges: ~[(node_id, node_id)], // 3. Every edge in the input list has vertices with levels that // differ by at most one or that both are not in the BFS tree. - log(info, "Verifying graph edges..."); + log(info, ~"Verifying graph edges..."); let status = do edges.all() |e| { let (u, v) = e; @@ -357,7 +357,7 @@ fn validate(edges: ~[(node_id, node_id)], // 5. A node and its parent are joined by an edge of the original // graph. - log(info, "Verifying tree and graph edges..."); + log(info, ~"Verifying tree and graph edges..."); let status = do par::alli(tree) |u, v| { let u = u as node_id; @@ -375,11 +375,11 @@ fn validate(edges: ~[(node_id, node_id)], true } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "15", "48"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"15", ~"48"] } else if args.len() <= 1u { - ~["", "10", "16"] + ~[~"", ~"10", ~"16"] } else { args }; @@ -413,7 +413,7 @@ fn main(args: ~[str]) { let graph_arc = arc::arc(copy graph); do gen_search_keys(graph, num_keys).map() |root| { - io::stdout().write_line(""); + io::stdout().write_line(~""); io::stdout().write_line(#fmt("Search key: %?", root)); if do_sequential { @@ -477,7 +477,7 @@ fn main(args: ~[str]) { } }; - io::stdout().write_line(""); + io::stdout().write_line(~""); io::stdout().write_line( #fmt("Total sequential: %? \t Total Parallel: %? \t Speedup: %?x", total_seq, total_par, total_seq / total_par)); diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 6a626cff81aa..4a94083b8245 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -45,7 +45,7 @@ fn server(requests: port, responses: pipes::chan) { //#error("server exiting"); } -fn run(args: &[str]) { +fn run(args: &[~str]) { let (to_parent, from_child) = pipes::stream(); let (to_child, from_parent) = pipes::stream(); @@ -86,11 +86,11 @@ fn run(args: &[str]) { assert result == num_bytes * size; } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "1000000", "10000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"1000000", ~"10000"] } else if args.len() <= 1u { - ~["", "10000", "4"] + ~[~"", ~"10000", ~"4"] } else { copy args }; diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index faa207945866..78eaab475669 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -40,7 +40,7 @@ fn server(requests: port_set, responses: pipes::chan) { //#error("server exiting"); } -fn run(args: &[str]) { +fn run(args: &[~str]) { let (to_parent, from_child) = pipes::stream(); let (to_child, from_parent_) = pipes::stream(); let from_parent = port_set(); @@ -82,11 +82,11 @@ fn run(args: &[str]) { assert result == num_bytes * size; } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "1000000", "8"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"1000000", ~"8"] } else if args.len() <= 1u { - ~["", "10000", "4"] + ~[~"", ~"10000", ~"4"] } else { copy args }; diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index b93f3a4bc2da..3e2e955a0839 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -52,11 +52,11 @@ fn thread_ring(i: uint, }; } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "100", "10000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"100", ~"10000"] } else if args.len() <= 1u { - ~["", "100", "1000"] + ~[~"", ~"100", ~"1000"] } else { copy args }; diff --git a/src/test/bench/msgsend-ring.rs b/src/test/bench/msgsend-ring.rs index fde609b5636c..ceaed45f8f33 100644 --- a/src/test/bench/msgsend-ring.rs +++ b/src/test/bench/msgsend-ring.rs @@ -22,11 +22,11 @@ fn thread_ring(i: uint, }; } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "100", "10000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"100", ~"10000"] } else if args.len() <= 1u { - ~["", "100", "1000"] + ~[~"", ~"100", ~"1000"] } else { args }; diff --git a/src/test/bench/msgsend.rs b/src/test/bench/msgsend.rs index 85d34c41fed4..2f993d502ac9 100644 --- a/src/test/bench/msgsend.rs +++ b/src/test/bench/msgsend.rs @@ -27,7 +27,7 @@ fn server(requests: comm::port, responses: comm::chan) { comm::send(responses, count); } -fn run(args: ~[str]) { +fn run(args: ~[~str]) { let from_child = comm::port(); let to_parent = comm::chan(from_child); let to_child = do task::spawn_listener |po| { @@ -58,11 +58,11 @@ fn run(args: ~[str]) { io::stdout().write_str(#fmt("Throughput=%f per sec\n", thruput)); } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "1000000", "10000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"1000000", ~"10000"] } else if args.len() <= 1u { - ~["", "10000", "4"] + ~[~"", ~"10000", ~"4"] } else { args }; diff --git a/src/test/bench/shootout-ackermann.rs b/src/test/bench/shootout-ackermann.rs index e1fd385957b7..21d82f4daf9c 100644 --- a/src/test/bench/shootout-ackermann.rs +++ b/src/test/bench/shootout-ackermann.rs @@ -12,11 +12,11 @@ fn ack(m: int, n: int) -> int { } } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "12"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"12"] } else if args.len() <= 1u { - ~["", "8"] + ~[~"", ~"8"] } else { args }; diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 1098d30a7fc0..f80060891c31 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -22,11 +22,11 @@ fn bottom_up_tree(arena: &a.arena::arena, item: int, depth: int) -> &a.tree { ret new(*arena) nil; } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "17"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"17"] } else if args.len() <= 1u { - ~["", "8"] + ~[~"", ~"8"] } else { args }; diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index e0a7a26ef868..900df13cf3f4 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -11,8 +11,8 @@ fn print_complements() { let all = ~[Blue, Red, Yellow]; for vec::each(all) |aa| { for vec::each(all) |bb| { - io::println(show_color(aa) + " + " + show_color(bb) + - " -> " + show_color(transform(aa,bb))); + io::println(show_color(aa) + ~" + " + show_color(bb) + + ~" -> " + show_color(transform(aa,bb))); } } } @@ -21,41 +21,41 @@ enum color { Red, Yellow, Blue } type creature_info = { name: uint, color: color }; -fn show_color(cc: color) -> str { +fn show_color(cc: color) -> ~str { alt (cc) { - Red {"red"} - Yellow {"yellow"} - Blue {"blue"} + Red {~"red"} + Yellow {~"yellow"} + Blue {~"blue"} } } -fn show_color_list(set: ~[color]) -> str { - let mut out = ""; +fn show_color_list(set: ~[color]) -> ~str { + let mut out = ~""; for vec::eachi(set) |_ii, col| { - out += " "; + out += ~" "; out += show_color(col); } ret out; } -fn show_digit(nn: uint) -> str { +fn show_digit(nn: uint) -> ~str { alt (nn) { - 0 {"zero"} - 1 {"one"} - 2 {"two"} - 3 {"three"} - 4 {"four"} - 5 {"five"} - 6 {"six"} - 7 {"seven"} - 8 {"eight"} - 9 {"nine"} - _ {fail "expected digits from 0 to 9..."} + 0 {~"zero"} + 1 {~"one"} + 2 {~"two"} + 3 {~"three"} + 4 {~"four"} + 5 {~"five"} + 6 {~"six"} + 7 {~"seven"} + 8 {~"eight"} + 9 {~"nine"} + _ {fail ~"expected digits from 0 to 9..."} } } -fn show_number(nn: uint) -> str { - let mut out = ""; +fn show_number(nn: uint) -> ~str { + let mut out = ~""; let mut num = nn; let mut dig; @@ -64,7 +64,7 @@ fn show_number(nn: uint) -> str { while num != 0 { dig = num % 10; num = num / 10; - out = show_digit(dig) + " " + out; + out = show_digit(dig) + ~" " + out; } ret out; @@ -89,7 +89,7 @@ fn creature( color: color, from_rendezvous: comm::port>, to_rendezvous: comm::chan, - to_rendezvous_log: comm::chan + to_rendezvous_log: comm::chan<~str> ) { let mut color = color; let mut creatures_met = 0; @@ -113,7 +113,7 @@ fn creature( } option::none { // log creatures met and evil clones of self - let report = #fmt("%u", creatures_met) + " " + + let report = #fmt("%u", creatures_met) + ~" " + show_number(evil_clones_met); comm::send(to_rendezvous_log, report); break; @@ -125,7 +125,7 @@ fn creature( fn rendezvous(nn: uint, set: ~[color]) { // these ports will allow us to hear from the creatures let from_creatures: comm::port = comm::port(); - let from_creatures_log: comm::port = comm::port(); + let from_creatures_log: comm::port<~str> = comm::port(); // these channels will be passed to the creatures so they can talk to us let to_rendezvous = comm::chan(from_creatures); @@ -180,11 +180,11 @@ fn rendezvous(nn: uint, set: ~[color]) { io::println(show_number(creatures_met)); } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "200000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"200000"] } else if args.len() <= 1u { - ~["", "600"] + ~[~"", ~"600"] } else { args }; @@ -192,10 +192,10 @@ fn main(args: ~[str]) { let nn = uint::from_str(args[1]).get(); print_complements(); - io::println(""); + io::println(~""); rendezvous(nn, ~[Blue, Red, Yellow]); - io::println(""); + io::println(~""); rendezvous(nn, ~[Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue]); diff --git a/src/test/bench/shootout-fannkuchredux.rs b/src/test/bench/shootout-fannkuchredux.rs index a537a5adc1c6..0e0a5333c040 100644 --- a/src/test/bench/shootout-fannkuchredux.rs +++ b/src/test/bench/shootout-fannkuchredux.rs @@ -58,11 +58,11 @@ fn fannkuch(n: int) -> int { ret flips; } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "10"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"10"] } else if args.len() <= 1u { - ~["", "8"] + ~[~"", ~"8"] } else { args }; diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index 919ad52fa466..ca528764b1d9 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -43,30 +43,30 @@ fn bisect(v: ~[aminoacids], lo: uint, hi: uint, target: u32) -> char { ret bisect(genelist, 0u, vec::len::(genelist) - 1u, r); } -fn make_random_fasta(wr: io::writer, id: str, desc: str, genelist: ~[aminoacids], n: int) { - wr.write_line(">" + id + " " + desc); +fn make_random_fasta(wr: io::writer, id: ~str, desc: ~str, genelist: ~[aminoacids], n: int) { + wr.write_line(~">" + id + ~" " + desc); let rng = @{mut last: rand::rng().next()}; - let mut op: str = ""; + let mut op: ~str = ~""; for uint::range(0u, n as uint) |_i| { str::push_char(op, select_random(myrandom_next(rng, 100u32), genelist)); if str::len(op) >= LINE_LENGTH() { wr.write_line(op); - op = ""; + op = ~""; } } if str::len(op) > 0u { wr.write_line(op); } } -fn make_repeat_fasta(wr: io::writer, id: str, desc: str, s: str, n: int) unsafe { - wr.write_line(">" + id + " " + desc); - let mut op: str = ""; +fn make_repeat_fasta(wr: io::writer, id: ~str, desc: ~str, s: ~str, n: int) unsafe { + wr.write_line(~">" + id + ~" " + desc); + let mut op: ~str = ~""; let sl: uint = str::len(s); for uint::range(0u, n as uint) |i| { str::unsafe::push_byte(op, s[i % sl]); if str::len(op) >= LINE_LENGTH() { wr.write_line(op); - op = ""; + op = ~""; } } if str::len(op) > 0u { wr.write_line(op); } @@ -74,18 +74,18 @@ fn make_repeat_fasta(wr: io::writer, id: str, desc: str, s: str, n: int) unsafe fn acid(ch: char, prob: u32) -> aminoacids { ret {ch: ch, prob: prob}; } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { // alioth tests k-nucleotide with this data at 25,000,000 - ~["", "5000000"] + ~[~"", ~"5000000"] } else if args.len() <= 1u { - ~["", "1000"] + ~[~"", ~"1000"] } else { args }; - let writer = if os::getenv("RUST_BENCH").is_some() { - result::get(io::file_writer("./shootout-fasta.data", ~[io::truncate, io::create])) + let writer = if os::getenv(~"RUST_BENCH").is_some() { + result::get(io::file_writer(~"./shootout-fasta.data", ~[io::truncate, io::create])) } else { io::stdout() }; @@ -101,16 +101,16 @@ fn main(args: ~[str]) { let homosapiens: ~[aminoacids] = make_cumulative(~[acid('a', 30u32), acid('c', 20u32), acid('g', 20u32), acid('t', 30u32)]); - let alu: str = - "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" + - "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" + - "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" + - "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" + - "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" + - "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" + - "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; - make_repeat_fasta(writer, "ONE", "Homo sapiens alu", alu, n * 2); - make_random_fasta(writer, "TWO", "IUB ambiguity codes", iub, n * 3); - make_random_fasta(writer, "THREE", - "Homo sapiens frequency", homosapiens, n * 5); + let alu: ~str = + ~"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" + + ~"GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" + + ~"CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" + + ~"ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" + + ~"GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" + + ~"AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" + + ~"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; + make_repeat_fasta(writer, ~"ONE", ~"Homo sapiens alu", alu, n * 2); + make_random_fasta(writer, ~"TWO", ~"IUB ambiguity codes", iub, n * 3); + make_random_fasta(writer, ~"THREE", + ~"Homo sapiens frequency", homosapiens, n * 5); } diff --git a/src/test/bench/shootout-fibo.rs b/src/test/bench/shootout-fibo.rs index dcdc92ad943f..08932324ac25 100644 --- a/src/test/bench/shootout-fibo.rs +++ b/src/test/bench/shootout-fibo.rs @@ -8,11 +8,11 @@ fn fib(n: int) -> int { } } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "40"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"40"] } else if args.len() <= 1u { - ~["", "30"] + ~[~"", ~"30"] } else { args }; diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index d4084f43304f..fbf18ab7aa40 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -12,7 +12,7 @@ import pipes::{stream, port, chan}; // given a map, print a sorted version of it -fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> str { +fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { fn pct(xx: uint, yy: uint) -> float { ret (xx as float) * 100f / (yy as float); } @@ -44,7 +44,7 @@ fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { let pairs_sorted = sortKV(pairs); - let mut buffer = ""; + let mut buffer = ~""; pairs_sorted.each(fn&(kv: (~[u8], float)) -> bool unsafe { let (k,v) = kv; @@ -56,7 +56,7 @@ fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { } // given a map, search for the frequency of a pattern -fn find(mm: hashmap<~[u8], uint>, key: str) -> uint { +fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint { alt mm.find(str::bytes(str::to_lower(key))) { option::none { ret 0u; } option::some(num) { ret num; } @@ -90,7 +90,7 @@ fn windows_with_carry(bb: ~[const u8], nn: uint, } fn make_sequence_processor(sz: uint, from_parent: pipes::port<~[u8]>, - to_parent: pipes::chan) { + to_parent: pipes::chan<~str>) { let freqs: hashmap<~[u8], uint> = map::bytes_hash(); let mut carry: ~[u8] = ~[]; @@ -112,12 +112,12 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::port<~[u8]>, let buffer = alt sz { 1u { sort_and_fmt(freqs, total) } 2u { sort_and_fmt(freqs, total) } - 3u { #fmt["%u\t%s", find(freqs, "GGT"), "GGT"] } - 4u { #fmt["%u\t%s", find(freqs, "GGTA"), "GGTA"] } - 6u { #fmt["%u\t%s", find(freqs, "GGTATT"), "GGTATT"] } - 12u { #fmt["%u\t%s", find(freqs, "GGTATTTTAATT"), "GGTATTTTAATT"] } - 18u { #fmt["%u\t%s", find(freqs, "GGTATTTTAATTTATAGT"), "GGTATTTTAATTTATAGT"] } - _ { "" } + 3u { #fmt["%u\t%s", find(freqs, ~"GGT"), ~"GGT"] } + 4u { #fmt["%u\t%s", find(freqs, ~"GGTA"), ~"GGTA"] } + 6u { #fmt["%u\t%s", find(freqs, ~"GGTATT"), ~"GGTATT"] } + 12u { #fmt["%u\t%s", find(freqs, ~"GGTATTTTAATT"), ~"GGTATTTTAATT"] } + 18u { #fmt["%u\t%s", find(freqs, ~"GGTATTTTAATTTATAGT"), ~"GGTATTTTAATTTATAGT"] } + _ { ~"" } }; //comm::send(to_parent, #fmt["yay{%u}", sz]); @@ -125,13 +125,13 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::port<~[u8]>, } // given a FASTA file on stdin, process sequence THREE -fn main(args: ~[str]) { - let rdr = if os::getenv("RUST_BENCH").is_some() { +fn main(args: ~[~str]) { + let rdr = if os::getenv(~"RUST_BENCH").is_some() { // FIXME: Using this compile-time env variable is a crummy way to // get to this massive data set, but #include_bin chokes on it (#2598) let path = path::connect( #env("CFG_SRC_DIR"), - "src/test/bench/shootout-k-nucleotide.data" + ~"src/test/bench/shootout-k-nucleotide.data" ); result::get(io::file_reader(path)) } else { @@ -167,7 +167,7 @@ fn main(args: ~[str]) { let mut proc_mode = false; while !rdr.eof() { - let line: str = rdr.read_line(); + let line: ~str = rdr.read_line(); if str::len(line) == 0u { again; } @@ -175,7 +175,7 @@ fn main(args: ~[str]) { // start processing if this is the one ('>' as u8, false) { - alt str::find_str_from(line, "THREE", 1u) { + alt str::find_str_from(line, ~"THREE", 1u) { option::some(_) { proc_mode = true; } option::none { } } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index c19b71991971..db6c1b67174d 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -10,7 +10,7 @@ import std::sort; // given a map, print a sorted version of it -fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> str { +fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { fn pct(xx: uint, yy: uint) -> float { ret (xx as float) * 100f / (yy as float); } @@ -42,7 +42,7 @@ fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { let pairs_sorted = sortKV(pairs); - let mut buffer = ""; + let mut buffer = ~""; pairs_sorted.each(fn&(kv: (~[u8], float)) -> bool unsafe { let (k,v) = kv; @@ -54,7 +54,7 @@ fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { } // given a map, search for the frequency of a pattern -fn find(mm: hashmap<~[u8], uint>, key: str) -> uint { +fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint { alt mm.find(str::bytes(str::to_lower(key))) { option::none { ret 0u; } option::some(num) { ret num; } @@ -88,7 +88,7 @@ fn windows_with_carry(bb: ~[const u8], nn: uint, } fn make_sequence_processor(sz: uint, from_parent: comm::port<~[u8]>, - to_parent: comm::chan) { + to_parent: comm::chan<~str>) { let freqs: hashmap<~[u8], uint> = map::bytes_hash(); let mut carry: ~[u8] = ~[]; @@ -110,12 +110,12 @@ fn make_sequence_processor(sz: uint, from_parent: comm::port<~[u8]>, let buffer = alt sz { 1u { sort_and_fmt(freqs, total) } 2u { sort_and_fmt(freqs, total) } - 3u { #fmt["%u\t%s", find(freqs, "GGT"), "GGT"] } - 4u { #fmt["%u\t%s", find(freqs, "GGTA"), "GGTA"] } - 6u { #fmt["%u\t%s", find(freqs, "GGTATT"), "GGTATT"] } - 12u { #fmt["%u\t%s", find(freqs, "GGTATTTTAATT"), "GGTATTTTAATT"] } - 18u { #fmt["%u\t%s", find(freqs, "GGTATTTTAATTTATAGT"), "GGTATTTTAATTTATAGT"] } - _ { "" } + 3u { #fmt["%u\t%s", find(freqs, ~"GGT"), ~"GGT"] } + 4u { #fmt["%u\t%s", find(freqs, ~"GGTA"), ~"GGTA"] } + 6u { #fmt["%u\t%s", find(freqs, ~"GGTATT"), ~"GGTATT"] } + 12u { #fmt["%u\t%s", find(freqs, ~"GGTATTTTAATT"), ~"GGTATTTTAATT"] } + 18u { #fmt["%u\t%s", find(freqs, ~"GGTATTTTAATTTATAGT"), ~"GGTATTTTAATTTATAGT"] } + _ { ~"" } }; //comm::send(to_parent, #fmt["yay{%u}", sz]); @@ -123,13 +123,13 @@ fn make_sequence_processor(sz: uint, from_parent: comm::port<~[u8]>, } // given a FASTA file on stdin, process sequence THREE -fn main(args: ~[str]) { - let rdr = if os::getenv("RUST_BENCH").is_some() { +fn main(args: ~[~str]) { + let rdr = if os::getenv(~"RUST_BENCH").is_some() { // FIXME: Using this compile-time env variable is a crummy way to // get to this massive data set, but #include_bin chokes on it (#2598) let path = path::connect( #env("CFG_SRC_DIR"), - "src/test/bench/shootout-k-nucleotide.data" + ~"src/test/bench/shootout-k-nucleotide.data" ); result::get(io::file_reader(path)) } else { @@ -154,7 +154,7 @@ fn main(args: ~[str]) { let mut proc_mode = false; while !rdr.eof() { - let line: str = rdr.read_line(); + let line: ~str = rdr.read_line(); if str::len(line) == 0u { again; } @@ -162,7 +162,7 @@ fn main(args: ~[str]) { // start processing if this is the one ('>' as u8, false) { - alt str::find_str_from(line, "THREE", 1u) { + alt str::find_str_from(line, ~"THREE", 1u) { option::some(_) { proc_mode = true; } option::none { } } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 27a3d993cd4e..aa6377633c2f 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -85,16 +85,16 @@ fn tell() -> uint {0_u} fn flush() -> int {0} } -fn writer(path: str, writech: comm::chan>, size: uint) +fn writer(path: ~str, writech: comm::chan>, size: uint) { let p: comm::port = comm::port(); let ch = comm::chan(p); comm::send(writech, ch); let cout: io::writer = alt path { - "" { + ~"" { {dn: 0} as io::writer } - "-" { + ~"-" { io::stdout() } _ { @@ -103,7 +103,7 @@ fn writer(path: str, writech: comm::chan>, size: uint) ~[io::create, io::truncate])) } }; - cout.write_line("P4"); + cout.write_line(~"P4"); cout.write_line(#fmt("%u %u", size, size)); let lines = std::map::uint_hash(); let mut done = 0_u; @@ -139,14 +139,14 @@ fn writer(path: str, writech: comm::chan>, size: uint) } } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "4000", "10"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"4000", ~"10"] } else { args }; - let path = if vec::len(args) < 4_u { "" } + let path = if vec::len(args) < 4_u { ~"" } else { args[3] }; let yieldevery = if vec::len(args) < 3_u { 10_u } diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 56b01325b245..8c2c44269349 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -13,11 +13,11 @@ fn sqrt(n: float) -> float; } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "4000000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"4000000"] } else if args.len() <= 1u { - ~["", "100000"] + ~[~"", ~"100000"] } else { args }; diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 8ce91865b04c..41d2bdeb71b3 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -46,14 +46,14 @@ fn pfib(c: chan, n: int) { type config = {stress: bool}; -fn parse_opts(argv: ~[str]) -> config { - let opts = ~[getopts::optflag("stress")]; +fn parse_opts(argv: ~[~str]) -> config { + let opts = ~[getopts::optflag(~"stress")]; let opt_args = vec::slice(argv, 1u, vec::len(argv)); alt getopts::getopts(opt_args, opts) { - ok(m) { ret {stress: getopts::opt_present(m, "stress")} } + ok(m) { ret {stress: getopts::opt_present(m, ~"stress")} } err(_) { fail; } } } @@ -78,11 +78,11 @@ fn stress(num_tasks: int) { for results.each |r| { future::get(r); } } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "20"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"20"] } else if args.len() <= 1u { - ~["", "8"] + ~[~"", ~"8"] } else { args }; diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index c5a952aab8db..983efce1f50d 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -40,11 +40,11 @@ fn eval_AtA_times_u(u: ~[const float], AtAu: ~[mut float]) { eval_At_times_u(v, AtAu); } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "2000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"2000"] } else if args.len() <= 1u { - ~["", "1000"] + ~[~"", ~"1000"] } else { args }; diff --git a/src/test/bench/shootout-threadring.rs b/src/test/bench/shootout-threadring.rs index be2e1fc3ad88..e064c9481f2a 100644 --- a/src/test/bench/shootout-threadring.rs +++ b/src/test/bench/shootout-threadring.rs @@ -37,11 +37,11 @@ fn roundtrip(id: int, p: comm::port, ch: comm::chan) { } } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "2000000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"2000000"] } else if args.len() <= 1u { - ~["", "1000"] + ~[~"", ~"1000"] } else { args }; diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index 4a712e2d995e..865385d81b0e 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -17,11 +17,11 @@ fn check_sequential(min: uint, max: uint, map: smallintmap) { } } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "100000", "100"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"100000", ~"100"] } else if args.len() <= 1u { - ~["", "10000", "50"] + ~[~"", ~"10000", ~"50"] } else { args }; diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 61055b49c5d6..3eeb16f93796 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -29,7 +29,7 @@ enum grid_t { grid_ctor(grid), } // read a sudoku problem from file f fn read_grid(f: io::reader) -> grid_t { - assert f.read_line() == "9,9"; /* assert first line is exactly "9,9" */ + assert f.read_line() == ~"9,9"; /* assert first line is exactly "9,9" */ let g = vec::from_fn(10u, {|_i| vec::to_mut(vec::from_elem(10u, 0 as u8)) @@ -110,7 +110,7 @@ fn drop_color(g: grid, colors: bitv::bitv, row: u8, col: u8) { ptr = ptr + 1u; } else { // no: redo this field aft recoloring pred; unless there is none - if ptr == 0u { fail "No solution found for this sudoku"; } + if ptr == 0u { fail ~"No solution found for this sudoku"; } ptr = ptr - 1u; } } @@ -126,7 +126,7 @@ fn write_grid(f: io::writer, g: grid_t) { } } -fn main(args: ~[str]) { +fn main(args: ~[~str]) { let grid = if vec::len(args) == 1u { // FIXME create sudoku inline since nested vec consts dont work yet // (#571) diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 194c78e250d3..240febf8f25f 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -7,7 +7,7 @@ import std::time::precise_time_s; fn main() { - let (repeat, depth) = if os::getenv("RUST_BENCH").is_some() { + let (repeat, depth) = if os::getenv(~"RUST_BENCH").is_some() { (50, 1000) } else { (10, 10) diff --git a/src/test/bench/task-perf-one-million.rs b/src/test/bench/task-perf-one-million.rs index 6992162fc5c4..adb5e1a07990 100644 --- a/src/test/bench/task-perf-one-million.rs +++ b/src/test/bench/task-perf-one-million.rs @@ -45,11 +45,11 @@ fn calc(children: uint, parent_ch: comm::chan) { comm::send(parent_ch, done(sum + 1)); } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "100000"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"100000"] } else if args.len() <= 1u { - ~["", "100"] + ~[~"", ~"100"] } else { args }; diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs index 7cc9446250e2..32e701498b04 100644 --- a/src/test/bench/task-perf-spawnalot.rs +++ b/src/test/bench/task-perf-spawnalot.rs @@ -8,11 +8,11 @@ fn f(&&n: uint) { fn g() { } -fn main(args: ~[str]) { - let args = if os::getenv("RUST_BENCH").is_some() { - ~["", "400"] +fn main(args: ~[~str]) { + let args = if os::getenv(~"RUST_BENCH").is_some() { + ~[~"", ~"400"] } else if args.len() <= 1u { - ~["", "10"] + ~[~"", ~"10"] } else { args }; diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 85e92602dcc5..62aa4d75f20b 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -38,7 +38,7 @@ macro_rules! move { } trait word_reader { - fn read_word() -> option; + fn read_word() -> option<~str>; } trait hash_key { @@ -52,9 +52,9 @@ fn hashfn(k: K) -> uint { k.hash() } map::hashmap(hashfn::, |x, y| x.eq(y)) } -impl of hash_key for str { +impl of hash_key for ~str { fn hash() -> uint { str::hash(self) } - fn eq(&&x: str) -> bool { str::eq(self, x) } + fn eq(&&x: ~str) -> bool { str::eq(self, x) } } // These used to be in task, but they disappeard. @@ -74,17 +74,17 @@ fn join(t: joinable_task) { } impl of word_reader for io::reader { - fn read_word() -> option { read_word(self) } + fn read_word() -> option<~str> { read_word(self) } } -fn file_word_reader(filename: str) -> word_reader { +fn file_word_reader(filename: ~str) -> word_reader { alt io::file_reader(filename) { result::ok(f) { f as word_reader } result::err(e) { fail #fmt("%?", e) } } } -fn map(f: fn~() -> word_reader, emit: map_reduce::putter) { +fn map(f: fn~() -> word_reader, emit: map_reduce::putter<~str, int>) { let f = f(); loop { alt f.read_word() { @@ -94,7 +94,7 @@ fn map(f: fn~() -> word_reader, emit: map_reduce::putter) { } } -fn reduce(&&word: str, get: map_reduce::getter) { +fn reduce(&&word: ~str, get: map_reduce::getter) { let mut count = 0; loop { alt get() { some(_) { count += 1; } none { break; } } } @@ -299,8 +299,8 @@ fn map_reduce( } } -fn main(argv: ~[str]) { - if vec::len(argv) < 2u && !os::getenv("RUST_BENCH").is_some() { +fn main(argv: ~[~str]) { + if vec::len(argv) < 2u && !os::getenv(~"RUST_BENCH").is_some() { let out = io::stdout(); out.write_line(#fmt["Usage: %s ...", argv[0]]); @@ -330,19 +330,19 @@ fn main(argv: ~[str]) { let elapsed = (stop - start) / 1000000u64; - log(error, "MapReduce completed in " - + u64::str(elapsed) + "ms"); + log(error, ~"MapReduce completed in " + + u64::str(elapsed) + ~"ms"); } -fn read_word(r: io::reader) -> option { - let mut w = ""; +fn read_word(r: io::reader) -> option<~str> { + let mut w = ~""; while !r.eof() { let c = r.read_char(); if is_word_char(c) { w += str::from_char(c); - } else { if w != "" { ret some(w); } } + } else { if w != ~"" { ret some(w); } } } ret none; } @@ -359,7 +359,7 @@ fn is_word_char(c: char) -> bool { self.rng = rand::rng(); } - fn read_word() -> option { + fn read_word() -> option<~str> { if self.remaining > 0 { self.remaining -= 1; let len = self.rng.gen_uint_range(1, 4); diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs index 83c0eb53d99b..055da76b159f 100644 --- a/src/test/bench/task-perf-word-count.rs +++ b/src/test/bench/task-perf-word-count.rs @@ -21,7 +21,7 @@ import comm::recv; import comm::send; -fn map(input: str, emit: map_reduce::putter) { +fn map(input: ~str, emit: map_reduce::putter) { let f = io::str_reader(input); @@ -30,7 +30,7 @@ fn map(input: str, emit: map_reduce::putter) { } } -fn reduce(_word: str, get: map_reduce::getter) { +fn reduce(_word: ~str, get: map_reduce::getter) { let mut count = 0; loop { alt get() { some(_) { count += 1; } none { break; } } } @@ -43,22 +43,22 @@ mod map_reduce { export reducer; export map_reduce; - type putter = fn@(str, int); + type putter = fn@(~str, int); - type mapper = fn@(str, putter); + type mapper = fn@(~str, putter); type getter = fn@() -> option; - type reducer = fn@(str, getter); + type reducer = fn@(~str, getter); enum ctrl_proto { - find_reducer(str, chan>), + find_reducer(~str, chan>), mapper_done, } enum reduce_proto { emit_val(int), done, ref, release, } - fn start_mappers(ctrl: chan, -inputs: ~[str]) -> + fn start_mappers(ctrl: chan, -inputs: ~[~str]) -> ~[future::future] { let mut results = ~[]; for inputs.each |i| { @@ -69,12 +69,12 @@ fn start_mappers(ctrl: chan, -inputs: ~[str]) -> ret results; } - fn map_task(ctrl: chan, input: str) { + fn map_task(ctrl: chan, input: ~str) { // log(error, "map_task " + input); let intermediates = map::str_hash(); - fn emit(im: map::hashmap>, - ctrl: chan, key: str, val: int) { + fn emit(im: map::hashmap<~str, chan>, + ctrl: chan, key: ~str, val: int) { let mut c; alt im.find(key) { some(_c) { @@ -98,7 +98,7 @@ fn emit(im: map::hashmap>, send(ctrl, mapper_done); } - fn reduce_task(key: str, out: chan>) { + fn reduce_task(key: ~str, out: chan>) { let p = port(); send(out, chan(p)); @@ -128,13 +128,13 @@ fn get(p: port, state: @{mut ref_count: int, reduce(key, || get(p, state) ); } - fn map_reduce(-inputs: ~[str]) { + fn map_reduce(-inputs: ~[~str]) { let ctrl = port::(); // This task becomes the master control task. It task::_spawns // to do the rest. - let mut reducers: map::hashmap>; + let mut reducers: map::hashmap<~str, chan>; reducers = map::str_hash(); @@ -178,7 +178,7 @@ fn map_reduce(-inputs: ~[str]) { } } -fn main(argv: ~[str]) { +fn main(argv: ~[~str]) { let inputs = if vec::len(argv) < 2u { ~[input1(), input2(), input3()] } else { @@ -194,19 +194,19 @@ fn main(argv: ~[str]) { let mut elapsed = stop - start; elapsed /= 1000000u64; - log(error, "MapReduce completed in " - + u64::str(elapsed) + "ms"); + log(error, ~"MapReduce completed in " + + u64::str(elapsed) + ~"ms"); } -fn read_word(r: io::reader) -> option { - let mut w = ""; +fn read_word(r: io::reader) -> option<~str> { + let mut w = ~""; while !r.eof() { let c = r.read_char(); if is_word_char(c) { w += str::from_char(c); - } else { if w != "" { ret some(w); } } + } else { if w != ~"" { ret some(w); } } } ret none; } @@ -297,7 +297,7 @@ fn is_word_char(c: char) -> bool { is_alpha(c) || is_digit(c) || c == '_' } -fn input1() -> str { " Lorem ipsum dolor sit amet, consectetur +fn input1() -> ~str { ~" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum tempor erat a dui commodo congue. Proin ac imperdiet est. Nunc volutpat placerat justo, ac euismod nisl elementum et. Nam a eros eleifend dolor porttitor auctor a a felis. Maecenas dui @@ -337,7 +337,7 @@ fn input1() -> str { " Lorem ipsum dolor sit amet, consectetur placerat vehicula nisl sed egestas. Morbi iaculis diam at erat sollicitudin nec interdum libero tristique. " } -fn input2() -> str { " Lorem ipsum dolor sit amet, consectetur +fn input2() -> ~str { ~" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin enim nibh, scelerisque faucibus accumsan id, feugiat id ipsum. In luctus mauris a massa consequat dignissim. Donec sit amet sem urna. Nullam pellentesque accumsan mi, at convallis arcu @@ -397,7 +397,7 @@ fn input2() -> str { " Lorem ipsum dolor sit amet, consectetur justo varius lacus, aliquet luctus neque nibh quis turpis. Etiam massa sapien, tristique ut consectetur eu, elementum vel orci. " } -fn input3() -> str { " Lorem ipsum dolor sit amet, consectetur +fn input3() -> ~str { ~" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque bibendum sapien ut magna fringilla mollis. Vivamus in neque non metus faucibus accumsan eu pretium nunc. Ut erat augue, pulvinar eget blandit nec, cursus quis diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs index 8b86db098e51..7c0601e7aa6a 100644 --- a/src/test/compile-fail/bad-const-type.rs +++ b/src/test/compile-fail/bad-const-type.rs @@ -1,4 +1,4 @@ -// error-pattern:expected `str/~` but found `int` +// error-pattern:expected `~str` but found `int` const i: str = 10i; fn main() { log(debug, i); } diff --git a/src/test/compile-fail/binop-bitxor-str.rs b/src/test/compile-fail/binop-bitxor-str.rs index 53bb7d8f53d9..b698eb7c426e 100644 --- a/src/test/compile-fail/binop-bitxor-str.rs +++ b/src/test/compile-fail/binop-bitxor-str.rs @@ -1,3 +1,3 @@ -// error-pattern:^ cannot be applied to type `str/~` +// error-pattern:^ cannot be applied to type `~str` fn main() { let x = "a" ^ "b"; } diff --git a/src/test/compile-fail/estr-subtyping.rs b/src/test/compile-fail/estr-subtyping.rs index e5f963733dcc..7e3e29f2b8f5 100644 --- a/src/test/compile-fail/estr-subtyping.rs +++ b/src/test/compile-fail/estr-subtyping.rs @@ -1,14 +1,14 @@ -fn wants_box(x: str/@) { } -fn wants_uniq(x: str/~) { } +fn wants_box(x: @str) { } +fn wants_uniq(x: ~str) { } fn wants_three(x: str/3) { } -fn has_box(x: str/@) { +fn has_box(x: @str) { wants_box(x); wants_uniq(x); //~ ERROR str storage differs: expected ~ but found @ wants_three(x); //~ ERROR str storage differs: expected 3 but found @ } -fn has_uniq(x: str/~) { +fn has_uniq(x: ~str) { wants_box(x); //~ ERROR str storage differs: expected @ but found ~ wants_uniq(x); wants_three(x); //~ ERROR str storage differs: expected 3 but found ~ diff --git a/src/test/compile-fail/fail-type-err.rs b/src/test/compile-fail/fail-type-err.rs index 3f9bda61c80e..e3324cb59b44 100644 --- a/src/test/compile-fail/fail-type-err.rs +++ b/src/test/compile-fail/fail-type-err.rs @@ -1,2 +1,2 @@ -// error-pattern:expected `str/~` but found `~[int]` +// error-pattern:expected `~str` but found `~[int]` fn main() { fail ~[0i]; } diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index 9386c1526484..b929ab0a1ce0 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -8,5 +8,5 @@ fn main() { let x: map = map::str_hash::() as map::; let y: map = x; - //~^ ERROR mismatched types: expected `std::map::map` + //~^ ERROR mismatched types: expected `std::map::map` } diff --git a/src/test/compile-fail/minus-string.rs b/src/test/compile-fail/minus-string.rs index 043d46f121b5..00037ce0fda7 100644 --- a/src/test/compile-fail/minus-string.rs +++ b/src/test/compile-fail/minus-string.rs @@ -1,3 +1,3 @@ -// error-pattern:cannot apply unary operator `-` to type `str/~` +// error-pattern:cannot apply unary operator `-` to type `~str` fn main() { -"foo"; } diff --git a/src/test/compile-fail/missing-do.rs b/src/test/compile-fail/missing-do.rs index 31595875058e..a54c5961d550 100644 --- a/src/test/compile-fail/missing-do.rs +++ b/src/test/compile-fail/missing-do.rs @@ -3,7 +3,7 @@ fn foo(f: fn()) { f() } fn main() { - "" || 42; //~ ERROR binary operation || cannot be applied to type `str/~` + "" || 42; //~ ERROR binary operation || cannot be applied to type `~str` foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn())` //~^ NOTE did you forget the 'do' keyword for the call? } diff --git a/src/test/compile-fail/unsendable-class.rs b/src/test/compile-fail/unsendable-class.rs index 11384408ad85..35b81cdecb18 100644 --- a/src/test/compile-fail/unsendable-class.rs +++ b/src/test/compile-fail/unsendable-class.rs @@ -3,8 +3,8 @@ class foo { let i: int; - let j: @str/~; - new(i:int, j: @str/~) { self.i = i; self.j = j; } + let j: @~str; + new(i:int, j: @~str) { self.i = i; self.j = j; } } fn main() { diff --git a/src/test/run-fail/alt-bot-fail.rs b/src/test/run-fail/alt-bot-fail.rs index dcca16590a57..88c6688b7662 100644 --- a/src/test/run-fail/alt-bot-fail.rs +++ b/src/test/run-fail/alt-bot-fail.rs @@ -1,6 +1,6 @@ // error-pattern:explicit failure -fn foo(s: str) { } +fn foo(s: ~str) { } fn main() { let i = diff --git a/src/test/run-fail/alt-disc-bot.rs b/src/test/run-fail/alt-disc-bot.rs index 2ac519e64194..09770179ebff 100644 --- a/src/test/run-fail/alt-disc-bot.rs +++ b/src/test/run-fail/alt-disc-bot.rs @@ -1,4 +1,4 @@ // error-pattern:quux -fn f() -> ! { fail "quux" } +fn f() -> ! { fail ~"quux" } fn g() -> int { alt f() { true { 1 } false { 0 } } } fn main() { g(); } diff --git a/src/test/run-fail/alt-wildcards.rs b/src/test/run-fail/alt-wildcards.rs index a3426e3a9213..4a428f3cdb16 100644 --- a/src/test/run-fail/alt-wildcards.rs +++ b/src/test/run-fail/alt-wildcards.rs @@ -1,7 +1,7 @@ // error-pattern:squirrelcupcake fn cmp() -> int { alt check (option::some('a'), option::none::) { - (option::some(_), _) { fail "squirrelcupcake"; } + (option::some(_), _) { fail ~"squirrelcupcake"; } (_, option::some(_)) { fail; } } } diff --git a/src/test/run-fail/args-fail.rs b/src/test/run-fail/args-fail.rs index afdaa553ba66..a28762aa9c29 100644 --- a/src/test/run-fail/args-fail.rs +++ b/src/test/run-fail/args-fail.rs @@ -1,4 +1,4 @@ // error-pattern:meep -fn f(a: int, b: int, c: @int) { fail "moop"; } +fn f(a: int, b: int, c: @int) { fail ~"moop"; } -fn main() { f(1, fail "meep", @42); } +fn main() { f(1, fail ~"meep", @42); } diff --git a/src/test/run-fail/binop-fail-2.rs b/src/test/run-fail/binop-fail-2.rs index adef5da4d0e6..feb657efe0c8 100644 --- a/src/test/run-fail/binop-fail-2.rs +++ b/src/test/run-fail/binop-fail-2.rs @@ -1,3 +1,3 @@ // error-pattern:quux -fn my_err(s: str) -> ! { log(error, s); fail "quux"; } -fn main() { 3u == my_err("bye"); } +fn my_err(s: ~str) -> ! { log(error, s); fail ~"quux"; } +fn main() { 3u == my_err(~"bye"); } diff --git a/src/test/run-fail/binop-fail.rs b/src/test/run-fail/binop-fail.rs index 83368cd1a07c..a4aa12003164 100644 --- a/src/test/run-fail/binop-fail.rs +++ b/src/test/run-fail/binop-fail.rs @@ -1,3 +1,3 @@ // error-pattern:quux -fn my_err(s: str) -> ! { log(error, s); fail "quux"; } -fn main() { my_err("bye") == 3u; } +fn my_err(s: ~str) -> ! { log(error, s); fail ~"quux"; } +fn main() { my_err(~"bye") == 3u; } diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs index a7d360ff8fc3..e1b9187e0fb1 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -8,4 +8,4 @@ fn send(ch: chan_t, -data: T) { fail; } -fn main() { fail "quux"; } +fn main() { fail ~"quux"; } diff --git a/src/test/run-fail/explicit-fail-msg.rs b/src/test/run-fail/explicit-fail-msg.rs index 8014ee75c159..f3927f122ed4 100644 --- a/src/test/run-fail/explicit-fail-msg.rs +++ b/src/test/run-fail/explicit-fail-msg.rs @@ -1,4 +1,4 @@ // error-pattern:wooooo fn main() { - let mut a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o"; + let mut a = 1; if 1 == 1 { a = 2; } fail ~"woooo" + ~"o"; } diff --git a/src/test/run-fail/fail-arg.rs b/src/test/run-fail/fail-arg.rs index a5d14f143039..5d1e83d6203d 100644 --- a/src/test/run-fail/fail-arg.rs +++ b/src/test/run-fail/fail-arg.rs @@ -1,4 +1,4 @@ // error-pattern:woe fn f(a: int) { log(debug, a); } -fn main() { f(fail "woe"); } +fn main() { f(fail ~"woe"); } diff --git a/src/test/run-fail/fail-main.rs b/src/test/run-fail/fail-main.rs index 5df6d09896e0..779181122093 100644 --- a/src/test/run-fail/fail-main.rs +++ b/src/test/run-fail/fail-main.rs @@ -1,4 +1,4 @@ // error-pattern:moop use std; import uint; -fn main() { fail "moop"; } +fn main() { fail ~"moop"; } diff --git a/src/test/run-fail/fmt-fail.rs b/src/test/run-fail/fmt-fail.rs index 5ca0ab741473..3950495e9c4a 100644 --- a/src/test/run-fail/fmt-fail.rs +++ b/src/test/run-fail/fmt-fail.rs @@ -1,4 +1,4 @@ // error-pattern:meh use std; -fn main() { let str_var: str = "meh"; fail #fmt["%s", str_var]; } +fn main() { let str_var: ~str = ~"meh"; fail #fmt["%s", str_var]; } diff --git a/src/test/run-fail/fn-constraint-claim.rs b/src/test/run-fail/fn-constraint-claim.rs index 5a5fa5ea81c2..e209a3de4898 100644 --- a/src/test/run-fail/fn-constraint-claim.rs +++ b/src/test/run-fail/fn-constraint-claim.rs @@ -2,6 +2,6 @@ use std; import uint::*; -fn nop(a: uint, b: uint) : le(a, b) { fail "quux"; } +fn nop(a: uint, b: uint) : le(a, b) { fail ~"quux"; } fn main() { let a: uint = 5u; let b: uint = 4u; claim (le(a, b)); nop(a, b); } diff --git a/src/test/run-fail/for-each-loop-fail.rs b/src/test/run-fail/for-each-loop-fail.rs index a52b75f6cad7..847be6952229 100644 --- a/src/test/run-fail/for-each-loop-fail.rs +++ b/src/test/run-fail/for-each-loop-fail.rs @@ -1,4 +1,4 @@ // error-pattern:moop use std; import uint; -fn main() { for uint::range(0u, 10u) |_i| { fail "moop"; } } +fn main() { for uint::range(0u, 10u) |_i| { fail ~"moop"; } } diff --git a/src/test/run-fail/if-check-fail.rs b/src/test/run-fail/if-check-fail.rs index 31e95d5c385d..3aa87f04e2d5 100644 --- a/src/test/run-fail/if-check-fail.rs +++ b/src/test/run-fail/if-check-fail.rs @@ -9,7 +9,7 @@ fn foo(x: uint) { if check even(x) { log(debug, x); } else { - fail "Number is odd"; + fail ~"Number is odd"; } } diff --git a/src/test/run-fail/if-cond-bot.rs b/src/test/run-fail/if-cond-bot.rs index 71b7323240db..0a11fc35fcac 100644 --- a/src/test/run-fail/if-cond-bot.rs +++ b/src/test/run-fail/if-cond-bot.rs @@ -1,3 +1,3 @@ // error-pattern:quux -fn my_err(s: str) -> ! { log(error, s); fail "quux"; } -fn main() { if my_err("bye") { } } +fn my_err(s: ~str) -> ! { log(error, s); fail ~"quux"; } +fn main() { if my_err(~"bye") { } } diff --git a/src/test/run-fail/issue-1459.rs b/src/test/run-fail/issue-1459.rs index 0fc6d8f697a2..0039c5b0358f 100644 --- a/src/test/run-fail/issue-1459.rs +++ b/src/test/run-fail/issue-1459.rs @@ -1,4 +1,4 @@ // error-pattern:roflcopter fn main() { - log (fail "roflcopter", 2); + log (fail ~"roflcopter", 2); } diff --git a/src/test/run-fail/issue-2156.rs b/src/test/run-fail/issue-2156.rs index 921842a32d20..1e8fea9d111f 100644 --- a/src/test/run-fail/issue-2156.rs +++ b/src/test/run-fail/issue-2156.rs @@ -4,7 +4,7 @@ import io::{reader, reader_util}; fn main() { - do io::with_str_reader("") |rdr| { + do io::with_str_reader(~"") |rdr| { alt rdr.read_char() { '=' { } _ { fail } } } } diff --git a/src/test/run-fail/issue-948.rs b/src/test/run-fail/issue-948.rs index 205d9d9466d0..abc67f7c4aaa 100644 --- a/src/test/run-fail/issue-948.rs +++ b/src/test/run-fail/issue-948.rs @@ -1,5 +1,5 @@ // error-pattern:beep boop fn main() { let origin = {x: 0, y: 0}; - let f: {x:int,y:int} = {x: (fail "beep boop") with origin}; + let f: {x:int,y:int} = {x: (fail ~"beep boop") with origin}; } diff --git a/src/test/run-fail/linked-failure3.rs b/src/test/run-fail/linked-failure3.rs index 22f6661716c6..926317c78366 100644 --- a/src/test/run-fail/linked-failure3.rs +++ b/src/test/run-fail/linked-failure3.rs @@ -6,7 +6,7 @@ import comm::port; import comm::recv; -fn grandchild() { fail "grandchild dies"; } +fn grandchild() { fail ~"grandchild dies"; } fn child() { let p = port::(); diff --git a/src/test/run-fail/morestack2.rs b/src/test/run-fail/morestack2.rs index 7a7fd5daa961..649d00dc1f4d 100644 --- a/src/test/run-fail/morestack2.rs +++ b/src/test/run-fail/morestack2.rs @@ -8,7 +8,7 @@ use std; extern mod rustrt { - fn last_os_error() -> str; + fn last_os_error() -> ~str; } fn getbig_call_c_and_fail(i: int) { diff --git a/src/test/run-fail/port-type.rs b/src/test/run-fail/port-type.rs index 3c7ebf8c18ca..e33130df83ce 100644 --- a/src/test/run-fail/port-type.rs +++ b/src/test/run-fail/port-type.rs @@ -15,4 +15,4 @@ fn echo(c: chan, oc: chan>) { send(c, x); } -fn main() { fail "meep"; } +fn main() { fail ~"meep"; } diff --git a/src/test/run-fail/result-get-fail.rs b/src/test/run-fail/result-get-fail.rs index 5a32f7d0ba48..41da3a6b55c8 100644 --- a/src/test/run-fail/result-get-fail.rs +++ b/src/test/run-fail/result-get-fail.rs @@ -1,4 +1,4 @@ // error-pattern:get called on error result: ~"kitty" fn main() { - log(error, result::get(result::err::("kitty"))); + log(error, result::get(result::err::(~"kitty"))); } diff --git a/src/test/run-fail/rhs-type.rs b/src/test/run-fail/rhs-type.rs index 461b2c65b44c..c58f396f2eb9 100644 --- a/src/test/run-fail/rhs-type.rs +++ b/src/test/run-fail/rhs-type.rs @@ -1,4 +1,4 @@ // Tests that trans treats the rhs of pth's decl // as a _|_-typed thing, not a str-typed thing // error-pattern:bye -fn main() { let pth = fail "bye"; let rs: {t: str} = {t: pth}; } +fn main() { let pth = fail ~"bye"; let rs: {t: ~str} = {t: pth}; } diff --git a/src/test/run-fail/rt-log-trunc.rs b/src/test/run-fail/rt-log-trunc.rs index 9ee2ecbcad39..a74cde845582 100644 --- a/src/test/run-fail/rt-log-trunc.rs +++ b/src/test/run-fail/rt-log-trunc.rs @@ -2,7 +2,7 @@ // error-pattern:[...] fn main() { - fail "\ + fail ~"\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ diff --git a/src/test/run-fail/rt-set-exit-status-fail.rs b/src/test/run-fail/rt-set-exit-status-fail.rs index 52f152895ad7..32388eb0992c 100644 --- a/src/test/run-fail/rt-set-exit-status-fail.rs +++ b/src/test/run-fail/rt-set-exit-status-fail.rs @@ -1,7 +1,7 @@ // error-pattern:whatever fn main() { - log(error, "whatever"); + log(error, ~"whatever"); // Setting the exit status only works when the scheduler terminates // normally. In this case we're going to fail, so instead of of // returning 50 the process will return the typical rt failure code. diff --git a/src/test/run-fail/rt-set-exit-status-fail2.rs b/src/test/run-fail/rt-set-exit-status-fail2.rs index 4f8e357bfd8d..1cd6784cf42c 100644 --- a/src/test/run-fail/rt-set-exit-status-fail2.rs +++ b/src/test/run-fail/rt-set-exit-status-fail2.rs @@ -12,7 +12,7 @@ } fn main() { - log(error, "whatever"); + log(error, ~"whatever"); do task::spawn { let i = r(5); }; diff --git a/src/test/run-fail/rt-set-exit-status.rs b/src/test/run-fail/rt-set-exit-status.rs index 6b83256036ba..c4e86715980f 100644 --- a/src/test/run-fail/rt-set-exit-status.rs +++ b/src/test/run-fail/rt-set-exit-status.rs @@ -1,7 +1,7 @@ // error-pattern:whatever fn main() { - log(error, "whatever"); + log(error, ~"whatever"); // 101 is the code the runtime uses on task failure and the value // compiletest expects run-fail tests to return. os::set_exit_status(101); diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs index c0512a4e2134..3275e30eb5b2 100644 --- a/src/test/run-fail/run-unexported-tests.rs +++ b/src/test/run-fail/run-unexported-tests.rs @@ -9,5 +9,5 @@ mod m { fn exported() { } #[test] - fn unexported() { fail "runned an unexported test"; } + fn unexported() { fail ~"runned an unexported test"; } } diff --git a/src/test/run-fail/str-overrun.rs b/src/test/run-fail/str-overrun.rs index 31346964d4c2..b8bccfe82d47 100644 --- a/src/test/run-fail/str-overrun.rs +++ b/src/test/run-fail/str-overrun.rs @@ -2,7 +2,7 @@ // error-pattern:bounds check fn main() { - let s: str = "hello"; + let s: ~str = ~"hello"; // Bounds-check failure. assert (s[5] == 0x0 as u8); diff --git a/src/test/run-fail/task-comm-recv-block.rs b/src/test/run-fail/task-comm-recv-block.rs index 1e703bc47f93..f55758d7196e 100644 --- a/src/test/run-fail/task-comm-recv-block.rs +++ b/src/test/run-fail/task-comm-recv-block.rs @@ -6,7 +6,7 @@ fn goodfail() { task::yield(); - fail "goodfail"; + fail ~"goodfail"; } fn main() { @@ -15,5 +15,5 @@ fn main() { // We shouldn't be able to get past this recv since there's no // message available let i: int = comm::recv(po); - fail "badfail"; + fail ~"badfail"; } diff --git a/src/test/run-fail/task-spawn-barefn.rs b/src/test/run-fail/task-spawn-barefn.rs index fe1b926160a5..e9a20e813246 100644 --- a/src/test/run-fail/task-spawn-barefn.rs +++ b/src/test/run-fail/task-spawn-barefn.rs @@ -7,5 +7,5 @@ fn main() { } fn startfn() { - assert str::is_empty("Ensure that the child task runs by failing"); + assert str::is_empty(~"Ensure that the child task runs by failing"); } diff --git a/src/test/run-fail/too-much-recursion.rs b/src/test/run-fail/too-much-recursion.rs index 6939670ff0bc..36dd47c373b2 100644 --- a/src/test/run-fail/too-much-recursion.rs +++ b/src/test/run-fail/too-much-recursion.rs @@ -3,6 +3,6 @@ // Test that the task fails after hiting the recursion limit fn main() { - log(debug, "don't optimize me out"); + log(debug, ~"don't optimize me out"); main(); } \ No newline at end of file diff --git a/src/test/run-fail/unwind-alt.rs b/src/test/run-fail/unwind-alt.rs index 1cd512cfc41b..751dc722fc89 100644 --- a/src/test/run-fail/unwind-alt.rs +++ b/src/test/run-fail/unwind-alt.rs @@ -4,8 +4,8 @@ fn test_box() { @0; } fn test_str() { - let res = alt check false { true { "happy" } }; - assert res == "happy"; + let res = alt check false { true { ~"happy" } }; + assert res == ~"happy"; } fn main() { test_box(); diff --git a/src/test/run-fail/unwind-box-str.rs b/src/test/run-fail/unwind-box-str.rs index e0cd34b784b9..fa28160d8126 100644 --- a/src/test/run-fail/unwind-box-str.rs +++ b/src/test/run-fail/unwind-box-str.rs @@ -5,7 +5,7 @@ fn failfn() { } fn main() { - let x = @"hi"; + let x = @~"hi"; failfn(); log(error, x); } \ No newline at end of file diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index 360d9cdeba36..d97c66b4b9b1 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -1,16 +1,16 @@ // error-pattern:fail fn main() { - let cheese = "roquefort"; - let carrots = @"crunchy"; + let cheese = ~"roquefort"; + let carrots = @~"crunchy"; - fn@(tasties: @str/~, macerate: fn(str)) { + fn@(tasties: @~str, macerate: fn(~str)) { macerate(*tasties); } (carrots, |food| { let mush = food + cheese; let f = fn@() { let chew = mush + cheese; - fail "so yummy" + fail ~"so yummy" }; f(); }); diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs index 9eb7f88caee8..7a0324a0f16e 100644 --- a/src/test/run-fail/unwind-misc-1.rs +++ b/src/test/run-fail/unwind-misc-1.rs @@ -7,19 +7,19 @@ fn main() { let count = @mut 0u; - fn hash(&&s: ~[@str/~]) -> uint { - if (vec::len(s) > 0u && str::eq(*s[0], "boom")) { fail; } + fn hash(&&s: ~[@~str]) -> uint { + if (vec::len(s) > 0u && str::eq(*s[0], ~"boom")) { fail; } ret 10u; } - fn eq(&&s: ~[@str/~], &&t: ~[@str/~]) -> bool { + fn eq(&&s: ~[@~str], &&t: ~[@~str]) -> bool { ret s == t; } let map = map::hashmap(hash, eq); let mut arr = ~[]; for uint::range(0u, 10u) |i| { - arr += ~[@"key stuff"]; - map.insert(arr, arr + ~[@"value stuff"]); + arr += ~[@~"key stuff"]; + map.insert(arr, arr + ~[@~"value stuff"]); } - map.insert(~[@"boom"], ~[]); + map.insert(~[@~"boom"], ~[]); } diff --git a/src/test/run-fail/while-body-fails.rs b/src/test/run-fail/while-body-fails.rs index da241afe8a3d..4e422fc095e4 100644 --- a/src/test/run-fail/while-body-fails.rs +++ b/src/test/run-fail/while-body-fails.rs @@ -1,2 +1,2 @@ // error-pattern:quux -fn main() { let x: int = { while true { fail "quux"; } ; 8 } ; } +fn main() { let x: int = { while true { fail ~"quux"; } ; 8 } ; } diff --git a/src/test/run-fail/while-fail.rs b/src/test/run-fail/while-fail.rs index 3f1f9f3e6551..8dc923ab60e9 100644 --- a/src/test/run-fail/while-fail.rs +++ b/src/test/run-fail/while-fail.rs @@ -1,4 +1,4 @@ // error-pattern:giraffe fn main() { - fail { while true { fail "giraffe"}; "clandestine" }; + fail { while true { fail ~"giraffe"}; ~"clandestine" }; } diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index 91f9827a6764..ae98291777a8 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -32,5 +32,5 @@ fn main() { check (same_length(chars, ints)); let ps = zip(chars, ints); - fail "the impossible happened"; + fail ~"the impossible happened"; } diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index ecd9ee45034c..171531c5fb80 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -32,65 +32,65 @@ fn main() { let ext_cx = mk_ctxt(); let abc = #ast{23}; - check_pp(abc, pprust::print_expr, "23"); + check_pp(abc, pprust::print_expr, ~"23"); let expr3 = #ast{2 - $(abc) + 7}; - check_pp(expr3, pprust::print_expr, "2 - 23 + 7"); + check_pp(expr3, pprust::print_expr, ~"2 - 23 + 7"); let expr4 = #ast{2 - $(#ast{3}) + 9}; - check_pp(expr4, pprust::print_expr, "2 - 3 + 9"); + check_pp(expr4, pprust::print_expr, ~"2 - 3 + 9"); let ty = #ast(ty){int}; - check_pp(ty, pprust::print_type, "int"); + check_pp(ty, pprust::print_type, ~"int"); let ty2 = #ast(ty){option<$(ty)>}; - check_pp(ty2, pprust::print_type, "option"); + check_pp(ty2, pprust::print_type, ~"option"); let item = #ast(item){const x : int = 10;}; - check_pp(item, pprust::print_item, "const x: int = 10;"); + check_pp(item, pprust::print_item, ~"const x: int = 10;"); let item2: @ast::item = #ast(item){const x : int = $(abc);}; - check_pp(item2, pprust::print_item, "const x: int = 23;"); + check_pp(item2, pprust::print_item, ~"const x: int = 23;"); let stmt = #ast(stmt){let x = 20;}; - check_pp(*stmt, pprust::print_stmt, "let x = 20;"); + check_pp(*stmt, pprust::print_stmt, ~"let x = 20;"); let stmt2 = #ast(stmt){let x : $(ty) = $(abc);}; - check_pp(*stmt2, pprust::print_stmt, "let x: int = 23;"); + check_pp(*stmt2, pprust::print_stmt, ~"let x: int = 23;"); let pat = #ast(pat){some(_)}; - check_pp(pat, pprust::print_pat, "some(_)"); + check_pp(pat, pprust::print_pat, ~"some(_)"); // issue #1785 let x = #ast{1}; let test1 = #ast{1+$(x)}; - check_pp(test1, pprust::print_expr, "1 + 1"); + check_pp(test1, pprust::print_expr, ~"1 + 1"); let test2 = #ast{$(x)+1}; - check_pp(test2, pprust::print_expr, "1 + 1"); + check_pp(test2, pprust::print_expr, ~"1 + 1"); let y = #ast{2}; let test3 = #ast{$(x) + $(y)}; - check_pp(test3, pprust::print_expr, "1 + 2"); + check_pp(test3, pprust::print_expr, ~"1 + 2"); let crate = #ast(crate) { fn a() { } }; - check_pp(crate, pprust::print_crate_, "fn a() { }\n"); + check_pp(crate, pprust::print_crate_, ~"fn a() { }\n"); // issue #1926 let s = #ast(expr){__s}; let e = #ast(expr){__e}; let call = #ast(expr){$(s).foo(|__e| $(e) )}; - check_pp(call, pprust::print_expr, "__s.foo(|__e| __e)") + check_pp(call, pprust::print_expr, ~"__s.foo(|__e| __e)") } -fn check_pp(expr: T, f: fn(pprust::ps, T), expect: str) { +fn check_pp(expr: T, f: fn(pprust::ps, T), expect: ~str) { let buf = mem_buffer(); let pp = pprust::rust_printer(buf as io::writer); f(pp, expr); pp::eof(pp.s); let str = mem_buffer_str(buf); stdout().write_line(str); - if expect != "" { + if expect != ~"" { #error("expect: '%s', got: '%s'", expect, str); assert str == expect; } diff --git a/src/test/run-pass/alias-uninit-value.rs b/src/test/run-pass/alias-uninit-value.rs index 0679022d37a9..866ed58f842c 100644 --- a/src/test/run-pass/alias-uninit-value.rs +++ b/src/test/run-pass/alias-uninit-value.rs @@ -7,10 +7,10 @@ enum sty { ty_nil, } -type raw_t = {struct: sty, cname: option, hash: uint}; +type raw_t = {struct: sty, cname: option<~str>, hash: uint}; -fn mk_raw_ty(st: sty, cname: option) -> raw_t { +fn mk_raw_ty(st: sty, cname: option<~str>) -> raw_t { ret {struct: st, cname: cname, hash: 0u}; } -fn main() { mk_raw_ty(ty_nil, none::); } +fn main() { mk_raw_ty(ty_nil, none::<~str>); } diff --git a/src/test/run-pass/alt-range.rs b/src/test/run-pass/alt-range.rs index e85a82a2fd44..29bbc452d476 100644 --- a/src/test/run-pass/alt-range.rs +++ b/src/test/run-pass/alt-range.rs @@ -1,30 +1,30 @@ fn main() { alt 5u { 1u to 5u {} - _ { fail "should match range"; } + _ { fail ~"should match range"; } } alt 5u { - 6u to 7u { fail "shouldn't match range"; } + 6u to 7u { fail ~"shouldn't match range"; } _ {} } alt check 5u { - 1u { fail "should match non-first range"; } + 1u { fail ~"should match non-first range"; } 2u to 6u {} } alt 'c' { 'a' to 'z' {} - _ { fail "should suppport char ranges"; } + _ { fail ~"should suppport char ranges"; } } alt -3 { -7 to 5 {} - _ { fail "should match signed range"; } + _ { fail ~"should match signed range"; } } alt 3.0 { 1.0 to 5.0 {} - _ { fail "should match float range"; } + _ { fail ~"should match float range"; } } alt -1.5 { -3.6 to 3.6 {} - _ { fail "should match negative float range"; } + _ { fail ~"should match negative float range"; } } } diff --git a/src/test/run-pass/alt-str.rs b/src/test/run-pass/alt-str.rs index c0a096cc2c94..708932b2e1a7 100644 --- a/src/test/run-pass/alt-str.rs +++ b/src/test/run-pass/alt-str.rs @@ -1,21 +1,21 @@ // Issue #53 fn main() { - alt check "test" { "not-test" { fail; } "test" { } _ { fail; } } + alt check ~"test" { ~"not-test" { fail; } ~"test" { } _ { fail; } } - enum t { tag1(str), tag2, } + enum t { tag1(~str), tag2, } - alt tag1("test") { + alt tag1(~"test") { tag2 { fail; } - tag1("not-test") { fail; } - tag1("test") { } + tag1(~"not-test") { fail; } + tag1(~"test") { } _ { fail; } } - let x = alt check "a" { "a" { 1 } "b" { 2 } }; + let x = alt check ~"a" { ~"a" { 1 } ~"b" { 2 } }; assert (x == 1); - alt check "a" { "a" { } "b" { } } + alt check ~"a" { ~"a" { } ~"b" { } } } diff --git a/src/test/run-pass/alt-with-ret-arm.rs b/src/test/run-pass/alt-with-ret-arm.rs index 20fe17d4847b..b12841dd2290 100644 --- a/src/test/run-pass/alt-with-ret-arm.rs +++ b/src/test/run-pass/alt-with-ret-arm.rs @@ -2,7 +2,7 @@ fn main() { // sometimes we have had trouble finding // the right type for f, as we unified // bot and u32 here - let f = alt uint::from_str("1234") { + let f = alt uint::from_str(~"1234") { none { ret () } some(num) { num as u32 } }; diff --git a/src/test/run-pass/argv.rs b/src/test/run-pass/argv.rs index fa2a05365e94..79d7e4e5b0fc 100644 --- a/src/test/run-pass/argv.rs +++ b/src/test/run-pass/argv.rs @@ -1,5 +1,5 @@ -fn main(args: ~[str]) { - let vs: ~[str] = ~["hi", "there", "this", "is", "a", "vec"]; - let vvs: ~[~[str]] = ~[args, vs]; +fn main(args: ~[~str]) { + let vs: ~[~str] = ~[~"hi", ~"there", ~"this", ~"is", ~"a", ~"vec"]; + let vvs: ~[~[~str]] = ~[args, vs]; for vvs.each |vs| { for vs.each |s| { log(debug, s); } } } diff --git a/src/test/run-pass/auto_serialize.rs b/src/test/run-pass/auto_serialize.rs index 5e9c22d05094..1f1c2a6c7077 100644 --- a/src/test/run-pass/auto_serialize.rs +++ b/src/test/run-pass/auto_serialize.rs @@ -11,7 +11,7 @@ import std::serialization::{serialize_uint, deserialize_uint}; fn test_ser_and_deser(a1: A, - expected: str, + expected: ~str, ebml_ser_fn: fn(ebml::writer, A), ebml_deser_fn: fn(ebml::ebml_deserializer) -> A, io_ser_fn: fn(io::writer, A)) { @@ -28,11 +28,11 @@ fn test_ser_and_deser(a1: A, ebml_ser_fn(w, a1); let d = ebml::doc(@io::mem_buffer_buf(buf)); let a2 = ebml_deser_fn(ebml::ebml_deserializer(d)); - io::print("\na1 = "); + io::print(~"\na1 = "); io_ser_fn(io::stdout(), a1); - io::print("\na2 = "); + io::print(~"\na2 = "); io_ser_fn(io::stdout(), a2); - io::print("\n"); + io::print(~"\n"); assert a1 == a2; } @@ -79,56 +79,56 @@ fn main() { test_ser_and_deser(plus(@minus(@val(3u), @val(10u)), @plus(@val(22u), @val(5u))), - "plus(@minus(@val(3u), @val(10u)), \ + ~"plus(@minus(@val(3u), @val(10u)), \ @plus(@val(22u), @val(5u)))", serialize_expr, deserialize_expr, serialize_expr); test_ser_and_deser({lo: 0u, hi: 5u, node: 22u}, - "{lo: 0u, hi: 5u, node: 22u}", + ~"{lo: 0u, hi: 5u, node: 22u}", serialize_spanned_uint, deserialize_spanned_uint, serialize_spanned_uint); test_ser_and_deser(an_enum({v: ~[1u, 2u, 3u]}), - "an_enum({v: [1u, 2u, 3u]})", + ~"an_enum({v: [1u, 2u, 3u]})", serialize_an_enum, deserialize_an_enum, serialize_an_enum); test_ser_and_deser({x: 3u, y: 5u}, - "{x: 3u, y: 5u}", + ~"{x: 3u, y: 5u}", serialize_point, deserialize_point, serialize_point); test_ser_and_deser(~[1u, 2u, 3u], - "[1u, 2u, 3u]", + ~"[1u, 2u, 3u]", serialize_uint_vec, deserialize_uint_vec, serialize_uint_vec); test_ser_and_deser(top(22u), - "top(22u)", + ~"top(22u)", serialize_uint_quark, deserialize_uint_quark, serialize_uint_quark); test_ser_and_deser(bottom(222u), - "bottom(222u)", + ~"bottom(222u)", serialize_uint_quark, deserialize_uint_quark, serialize_uint_quark); test_ser_and_deser(a, - "a", + ~"a", serialize_c_like, deserialize_c_like, serialize_c_like); test_ser_and_deser(b, - "b", + ~"b", serialize_c_like, deserialize_c_like, serialize_c_like); diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 1a50b3ba3e6c..4b8f33e45bb9 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -4,6 +4,6 @@ fn main() { assert (g(f) == 1); - let f1: fn(~[str]) -> str = f; - assert (f1(~["x", "y", "z"]) == "x"); + let f1: fn(~[~str]) -> ~str = f; + assert (f1(~[~"x", ~"y", ~"z"]) == ~"x"); } diff --git a/src/test/run-pass/basic.rs b/src/test/run-pass/basic.rs index 9c2b4311b909..b0fa0e3576ec 100644 --- a/src/test/run-pass/basic.rs +++ b/src/test/run-pass/basic.rs @@ -20,7 +20,7 @@ fn a(c: chan) { fn k(x: int) -> int { ret 15; } -fn g(x: int, y: str) -> int { +fn g(x: int, y: ~str) -> int { log(debug, x); log(debug, y); let z: int = k(1); @@ -29,7 +29,7 @@ fn g(x: int, y: str) -> int { fn main() { let mut n: int = 2 + 3 * 7; - let s: str = "hello there"; + let s: ~str = ~"hello there"; let p = comm::port(); let ch = comm::chan(p); task::spawn(|| a(ch) ); diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index 2bcdcfccdfd5..cebafd03f005 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -25,14 +25,14 @@ fn main() { assert false; } alt do vec::all(v) |e| { float::is_negative(e) } { - true { fail "incorrect answer."; } + true { fail ~"incorrect answer."; } false { } } alt 3 { _ if do vec::any(v) |e| { float::is_negative(e) } { } _ { - fail "wrong answer."; + fail ~"wrong answer."; } } diff --git a/src/test/run-pass/block-explicit-types.rs b/src/test/run-pass/block-explicit-types.rs index ca6fe9b659da..3e87bbbe6592 100644 --- a/src/test/run-pass/block-explicit-types.rs +++ b/src/test/run-pass/block-explicit-types.rs @@ -1,4 +1,4 @@ fn main() { - fn as_buf(s: str, f: fn(str) -> T) -> T { f(s) } - as_buf("foo", |foo: str| -> () log(error, foo) ); + fn as_buf(s: ~str, f: fn(~str) -> T) -> T { f(s) } + as_buf(~"foo", |foo: ~str| -> () log(error, foo) ); } diff --git a/src/test/run-pass/box-compare.rs b/src/test/run-pass/box-compare.rs index 51eeb6e8eb7a..5cfb4e0009ea 100644 --- a/src/test/run-pass/box-compare.rs +++ b/src/test/run-pass/box-compare.rs @@ -2,6 +2,6 @@ fn main() { assert (@1 < @3); - assert (@@"hello " > @@"hello"); - assert (@@@"hello" != @@@"there"); + assert (@@~"hello " > @@~"hello"); + assert (@@@~"hello" != @@@~"there"); } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index 4c7c2af982b4..8af9f6d25998 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -8,16 +8,16 @@ fn atoll(x: *u8) -> i64; } -fn atol(s: str) -> int { +fn atol(s: ~str) -> int { ret str::as_buf(s, { |x| libc::atol(x) }); } -fn atoll(s: str) -> i64 { +fn atoll(s: ~str) -> i64 { ret str::as_buf(s, { |x| libc::atoll(x) }); } fn main() { - assert atol("1024") * 10 == atol("10240"); - assert (atoll("11111111111111111") * 10i64) - == atoll("111111111111111110"); + assert atol(~"1024") * 10 == atol(~"10240"); + assert (atoll(~"11111111111111111") * 10i64) + == atoll(~"111111111111111110"); } diff --git a/src/test/run-pass/cci_nested_exe.rs b/src/test/run-pass/cci_nested_exe.rs index cf75dd6c57b2..de1d6e69fcb2 100644 --- a/src/test/run-pass/cci_nested_exe.rs +++ b/src/test/run-pass/cci_nested_exe.rs @@ -6,14 +6,14 @@ fn main() { let lst = new_int_alist(); - alist_add(lst, 22, "hi"); - alist_add(lst, 44, "ho"); - assert alist_get(lst, 22) == "hi"; - assert alist_get(lst, 44) == "ho"; + alist_add(lst, 22, ~"hi"); + alist_add(lst, 44, ~"ho"); + assert alist_get(lst, 22) == ~"hi"; + assert alist_get(lst, 44) == ~"ho"; let lst = new_int_alist_2(); - alist_add(lst, 22, "hi"); - alist_add(lst, 44, "ho"); - assert alist_get(lst, 22) == "hi"; - assert alist_get(lst, 44) == "ho"; + alist_add(lst, 22, ~"hi"); + alist_add(lst, 44, ~"ho"); + assert alist_get(lst, 22) == ~"hi"; + assert alist_get(lst, 44) == ~"ho"; } diff --git a/src/test/run-pass/check-pattern-bound.rs b/src/test/run-pass/check-pattern-bound.rs index fe8a650afe21..936947701adc 100644 --- a/src/test/run-pass/check-pattern-bound.rs +++ b/src/test/run-pass/check-pattern-bound.rs @@ -5,5 +5,5 @@ fn f(x: int) : p(x) { } fn main() { - alt some(5) { some(y) { check (p(y)); f(y); } _ { fail "yuck"; } } + alt some(5) { some(y) { check (p(y)); f(y); } _ { fail ~"yuck"; } } } diff --git a/src/test/run-pass/child-outlives-parent.rs b/src/test/run-pass/child-outlives-parent.rs index 1c3ad872477b..4342d40262c9 100644 --- a/src/test/run-pass/child-outlives-parent.rs +++ b/src/test/run-pass/child-outlives-parent.rs @@ -3,6 +3,6 @@ use std; import task; -fn child2(&&s: str) { } +fn child2(&&s: ~str) { } -fn main() { let x = task::spawn(|| child2("hi") ); } +fn main() { let x = task::spawn(|| child2(~"hi") ); } diff --git a/src/test/run-pass/class-cast-to-iface-cross-crate-2.rs b/src/test/run-pass/class-cast-to-iface-cross-crate-2.rs index 2e4dc4f32b3c..0afe1cedfaa8 100644 --- a/src/test/run-pass/class-cast-to-iface-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-iface-cross-crate-2.rs @@ -4,14 +4,14 @@ import to_str::to_str; import cci_class_cast::kitty::*; -fn print_out(thing: T, expected: str) { +fn print_out(thing: T, expected: ~str) { let actual = thing.to_str(); #debug("%s", actual); assert(actual == expected); } fn main() { - let nyan : to_str = cat(0u, 2, "nyan") as to_str; - print_out(nyan, "nyan"); + let nyan : to_str = cat(0u, 2, ~"nyan") as to_str; + print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/class-cast-to-iface-multiple-types.rs b/src/test/run-pass/class-cast-to-iface-multiple-types.rs index 89f5e656a68b..23d0a203a706 100644 --- a/src/test/run-pass/class-cast-to-iface-multiple-types.rs +++ b/src/test/run-pass/class-cast-to-iface-multiple-types.rs @@ -40,9 +40,9 @@ fn meow() -> uint { } let how_hungry : @mut int; - let name : str; + let name : ~str; - new(in_x : uint, in_y : int, in_name: str) + new(in_x : uint, in_y : int, in_name: ~str) { self.meows = @mut in_x; self.how_hungry = @mut in_y; self.name = in_name; } @@ -55,7 +55,7 @@ fn annoy_neighbors(critter: T) { } fn main() { - let nyan : cat = cat(0u, 2, "nyan"); + let nyan : cat = cat(0u, 2, ~"nyan"); let whitefang : dog = dog(); annoy_neighbors(nyan as noisy); annoy_neighbors(whitefang as noisy); diff --git a/src/test/run-pass/class-cast-to-iface.rs b/src/test/run-pass/class-cast-to-iface.rs index 10222acc45aa..e35152bd1d99 100644 --- a/src/test/run-pass/class-cast-to-iface.rs +++ b/src/test/run-pass/class-cast-to-iface.rs @@ -15,9 +15,9 @@ fn meow() { } let mut how_hungry : int; - let name : str; + let name : ~str; - new(in_x : uint, in_y : int, in_name: str) + new(in_x : uint, in_y : int, in_name: ~str) { self.meows = in_x; self.how_hungry = in_y; self.name = in_name; } fn speak() { self.meow(); } @@ -36,6 +36,6 @@ fn eat() -> bool { } fn main() { - let nyan : noisy = cat(0u, 2, "nyan") as noisy; + let nyan : noisy = cat(0u, 2, ~"nyan") as noisy; nyan.speak(); } \ No newline at end of file diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs index 8753553d8de6..b9f99f2076d7 100644 --- a/src/test/run-pass/class-exports.rs +++ b/src/test/run-pass/class-exports.rs @@ -7,13 +7,13 @@ mod kitty { export cat; class cat { let meows: uint; - let name: str; + let name: ~str; - fn get_name() -> str { self.name } - new(in_name: str) { self.name = in_name; self.meows = 0u; } + fn get_name() -> ~str { self.name } + new(in_name: ~str) { self.name = in_name; self.meows = 0u; } } } fn main() { - assert(cat("Spreckles").get_name() == "Spreckles"); + assert(cat(~"Spreckles").get_name() == ~"Spreckles"); } \ No newline at end of file diff --git a/src/test/run-pass/class-impl-very-parameterized-iface.rs b/src/test/run-pass/class-impl-very-parameterized-iface.rs index 8d710d0e6b44..425364945f0b 100644 --- a/src/test/run-pass/class-impl-very-parameterized-iface.rs +++ b/src/test/run-pass/class-impl-very-parameterized-iface.rs @@ -49,7 +49,7 @@ fn contains_key(&&k: int) -> bool { k <= self.meows } fn get(&&k:int) -> T { alt self.find(k) { some(v) { v } - none { fail "epic fail"; } + none { fail ~"epic fail"; } } } fn [](&&k:int) -> T { self.get(k) } @@ -87,9 +87,9 @@ fn clear() { } fn main() { - let nyan : cat = cat(0, 2, "nyan"); + let nyan : cat<~str> = cat(0, 2, ~"nyan"); for uint::range(1u, 5u) |_i| { nyan.speak(); } - assert(nyan.find(1) == some("nyan")); + assert(nyan.find(1) == some(~"nyan")); assert(nyan.find(10) == none); let spotty : cat = cat(2, 57, tuxedo); for uint::range(0u, 6u) |_i| { spotty.speak(); } diff --git a/src/test/run-pass/class-implement-iface-cross-crate.rs b/src/test/run-pass/class-implement-iface-cross-crate.rs index 5a778217b5fd..a8a22f444474 100644 --- a/src/test/run-pass/class-implement-iface-cross-crate.rs +++ b/src/test/run-pass/class-implement-iface-cross-crate.rs @@ -16,9 +16,9 @@ fn meow() { } let mut how_hungry : int; - let name : str; + let name : ~str; - new(in_x : uint, in_y : int, in_name: str) + new(in_x : uint, in_y : int, in_name: ~str) { self.meows = in_x; self.how_hungry = in_y; self.name = in_name; } fn speak() { self.meow(); } @@ -37,7 +37,7 @@ fn eat() -> bool { } fn main() { - let nyan = cat(0u, 2, "nyan"); + let nyan = cat(0u, 2, ~"nyan"); nyan.eat(); assert(!nyan.eat()); for uint::range(1u, 10u) |_i| { nyan.speak(); }; diff --git a/src/test/run-pass/class-implement-ifaces.rs b/src/test/run-pass/class-implement-ifaces.rs index 1f5923234882..c506e031c98e 100644 --- a/src/test/run-pass/class-implement-ifaces.rs +++ b/src/test/run-pass/class-implement-ifaces.rs @@ -15,9 +15,9 @@ fn meow() { } let mut how_hungry : int; - let name : str; + let name : ~str; - new(in_x : uint, in_y : int, in_name: str) + new(in_x : uint, in_y : int, in_name: ~str) { self.meows = in_x; self.how_hungry = in_y; self.name = in_name; } fn speak() { self.meow(); } @@ -40,7 +40,7 @@ fn make_speak(c: C) { } fn main() { - let nyan = cat(0u, 2, "nyan"); + let nyan = cat(0u, 2, ~"nyan"); nyan.eat(); assert(!nyan.eat()); for uint::range(1u, 10u) |_i| { make_speak(nyan); }; diff --git a/src/test/run-pass/class-poly-methods-cross-crate.rs b/src/test/run-pass/class-poly-methods-cross-crate.rs index 1703ad035c81..8789489336d5 100644 --- a/src/test/run-pass/class-poly-methods-cross-crate.rs +++ b/src/test/run-pass/class-poly-methods-cross-crate.rs @@ -5,11 +5,11 @@ fn main() { let nyan : cat = cat::(52u, 99, ~['p']); - let kitty = cat(1000u, 2, ~["tabby"]); + let kitty = cat(1000u, 2, ~[~"tabby"]); assert(nyan.how_hungry == 99); assert(kitty.how_hungry == 2); nyan.speak(~[1u,2u,3u]); assert(nyan.meow_count() == 55u); - kitty.speak(~["meow", "mew", "purr", "chirp"]); + kitty.speak(~[~"meow", ~"mew", ~"purr", ~"chirp"]); assert(kitty.meow_count() == 1004u); } diff --git a/src/test/run-pass/class-poly-methods.rs b/src/test/run-pass/class-poly-methods.rs index d40e2441b692..5808b0789d16 100644 --- a/src/test/run-pass/class-poly-methods.rs +++ b/src/test/run-pass/class-poly-methods.rs @@ -18,11 +18,11 @@ fn meow_count() -> uint { self.meows } fn main() { let nyan : cat = cat::(52u, 99, ~[9]); - let kitty = cat(1000u, 2, ~["tabby"]); + let kitty = cat(1000u, 2, ~[~"tabby"]); assert(nyan.how_hungry == 99); assert(kitty.how_hungry == 2); nyan.speak(~[1,2,3]); assert(nyan.meow_count() == 55u); - kitty.speak(~["meow", "mew", "purr", "chirp"]); + kitty.speak(~[~"meow", ~"mew", ~"purr", ~"chirp"]); assert(kitty.meow_count() == 1004u); } diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 905ac9626f62..82f46c748745 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -15,9 +15,9 @@ fn meow() { } let mut how_hungry : int; - let name : str; + let name : ~str; - new(in_x : uint, in_y : int, in_name: str) + new(in_x : uint, in_y : int, in_name: ~str) { self.meows = in_x; self.how_hungry = in_y; self.name = in_name; } fn speak() { self.meow(); } @@ -36,16 +36,16 @@ fn eat() -> bool { } impl of to_str for cat { - fn to_str() -> str { self.name } + fn to_str() -> ~str { self.name } } -fn print_out(thing: T, expected: str) { +fn print_out(thing: T, expected: ~str) { let actual = thing.to_str(); #debug("%s", actual); assert(actual == expected); } fn main() { - let nyan : to_str = cat(0u, 2, "nyan") as to_str; - print_out(nyan, "nyan"); + let nyan : to_str = cat(0u, 2, ~"nyan") as to_str; + print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/class-str-field.rs b/src/test/run-pass/class-str-field.rs index fab99f259108..e0f7441db856 100644 --- a/src/test/run-pass/class-str-field.rs +++ b/src/test/run-pass/class-str-field.rs @@ -1,11 +1,11 @@ class cat { - let name : str; + let name : ~str; - new(in_name: str) + new(in_name: ~str) { self.name = in_name; } } fn main() { - let nyan = cat("nyan"); + let nyan = cat(~"nyan"); } \ No newline at end of file diff --git a/src/test/run-pass/classes-cross-crate.rs b/src/test/run-pass/classes-cross-crate.rs index 5e454368e473..1f71c2405907 100644 --- a/src/test/run-pass/classes-cross-crate.rs +++ b/src/test/run-pass/classes-cross-crate.rs @@ -4,7 +4,7 @@ import cci_class_4::kitties::*; fn main() { - let nyan = cat(0u, 2, "nyan"); + let nyan = cat(0u, 2, ~"nyan"); nyan.eat(); assert(!nyan.eat()); for uint::range(1u, 10u) |_i| { nyan.speak(); }; diff --git a/src/test/run-pass/classes.rs b/src/test/run-pass/classes.rs index d7aaf6e3b048..697b4c796760 100644 --- a/src/test/run-pass/classes.rs +++ b/src/test/run-pass/classes.rs @@ -11,9 +11,9 @@ fn meow() { } let mut how_hungry : int; - let name : str; + let name : ~str; - new(in_x : uint, in_y : int, in_name: str) + new(in_x : uint, in_y : int, in_name: ~str) { self.meows = in_x; self.how_hungry = in_y; self.name = in_name; } fn speak() { self.meow(); } @@ -32,7 +32,7 @@ fn eat() -> bool { } fn main() { - let nyan = cat(0u, 2, "nyan"); + let nyan = cat(0u, 2, ~"nyan"); nyan.eat(); assert(!nyan.eat()); for uint::range(1u, 10u) |_i| { nyan.speak(); }; diff --git a/src/test/run-pass/command-line-args.rs b/src/test/run-pass/command-line-args.rs index 0bffb2687620..16e0951d2384 100644 --- a/src/test/run-pass/command-line-args.rs +++ b/src/test/run-pass/command-line-args.rs @@ -1,3 +1,3 @@ -fn main(args: ~[str]) { log(debug, args[0]); } +fn main(args: ~[~str]) { log(debug, args[0]); } diff --git a/src/test/run-pass/companionmod-src/b/x.rs b/src/test/run-pass/companionmod-src/b/x.rs index 413b834fb110..d81ff2ba9a50 100644 --- a/src/test/run-pass/companionmod-src/b/x.rs +++ b/src/test/run-pass/companionmod-src/b/x.rs @@ -1 +1 @@ -fn f() -> str { "ralph" } \ No newline at end of file +fn f() -> ~str { ~"ralph" } \ No newline at end of file diff --git a/src/test/run-pass/companionmod-src/d/x.rs b/src/test/run-pass/companionmod-src/d/x.rs index 94f006f9a1f7..b27e39327f17 100644 --- a/src/test/run-pass/companionmod-src/d/x.rs +++ b/src/test/run-pass/companionmod-src/d/x.rs @@ -1 +1 @@ -fn f() -> str { "nelson" } \ No newline at end of file +fn f() -> ~str { ~"nelson" } \ No newline at end of file diff --git a/src/test/run-pass/companionmod.rs b/src/test/run-pass/companionmod.rs index 9b9d1a00f0f6..99c21e06d3a6 100644 --- a/src/test/run-pass/companionmod.rs +++ b/src/test/run-pass/companionmod.rs @@ -2,6 +2,6 @@ // xfail-test fn main() { - assert a::b::g() == "ralph"; - assert a::c::g() == "nelson"; + assert a::b::g() == ~"ralph"; + assert a::c::g() == ~"nelson"; } \ No newline at end of file diff --git a/src/test/run-pass/complex.rs b/src/test/run-pass/complex.rs index c715f3b677b1..3ac0c75da11d 100644 --- a/src/test/run-pass/complex.rs +++ b/src/test/run-pass/complex.rs @@ -6,18 +6,18 @@ fn nothing() { } -fn putstr(s: str) { } +fn putstr(s: ~str) { } fn putint(i: int) { let mut i: int = 33; - while i < 36 { putstr("hi"); i = i + 1; } + while i < 36 { putstr(~"hi"); i = i + 1; } } fn zerg(i: int) -> int { ret i; } fn foo(x: int) -> int { let mut y: t = x + 2; - putstr("hello"); + putstr(~"hello"); while y < 10 { putint(y); if y * 3 == 4 { y = y + 2; nothing(); } } let mut z: t; z = 0x55; diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 36ca25cd1bb1..e5e60f184f26 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -6,7 +6,7 @@ fn foo(x: T) -> T { x } fn main() { foo(1); - foo("hi"); + foo(~"hi"); foo(~[1, 2, 3]); foo({field: 42}); foo((1, 2u)); diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs index 3325b36bc3f7..8d5260290b49 100644 --- a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs +++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs @@ -12,5 +12,5 @@ fn main() { let x = @(); x.cx(); let y = (); - y.add("hi"); + y.add(~"hi"); } diff --git a/src/test/run-pass/drop-on-ret.rs b/src/test/run-pass/drop-on-ret.rs index 821601baae8b..16722714bc36 100644 --- a/src/test/run-pass/drop-on-ret.rs +++ b/src/test/run-pass/drop-on-ret.rs @@ -2,6 +2,6 @@ // -*- rust -*- -fn f() -> int { if true { let s: str = "should not leak"; ret 1; } ret 0; } +fn f() -> int { if true { let s: ~str = ~"should not leak"; ret 1; } ret 0; } fn main() { f(); } diff --git a/src/test/run-pass/enum-disr-val-pretty.rs b/src/test/run-pass/enum-disr-val-pretty.rs index b050b4d2b862..89c916b6c722 100644 --- a/src/test/run-pass/enum-disr-val-pretty.rs +++ b/src/test/run-pass/enum-disr-val-pretty.rs @@ -3,13 +3,13 @@ enum color { red = 1, green, blue, imaginary = -1, } fn main() { - test_color(red, 1, "red"); - test_color(green, 2, "green"); - test_color(blue, 3, "blue"); - test_color(imaginary, -1, "imaginary"); + test_color(red, 1, ~"red"); + test_color(green, 2, ~"green"); + test_color(blue, 3, ~"blue"); + test_color(imaginary, -1, ~"imaginary"); } -fn test_color(color: color, val: int, name: str) { +fn test_color(color: color, val: int, name: ~str) { assert color as int == val; assert color as float == val as float; } diff --git a/src/test/run-pass/estr-shared.rs b/src/test/run-pass/estr-shared.rs index 6fc0f296d8d2..b853d855030b 100644 --- a/src/test/run-pass/estr-shared.rs +++ b/src/test/run-pass/estr-shared.rs @@ -1,4 +1,4 @@ // xfail-test fn main() { - let x : str/@ = "hello"/@; + let x : @str = @"hello"; } diff --git a/src/test/run-pass/estr-slice.rs b/src/test/run-pass/estr-slice.rs index af31e546c6af..6af1dee89266 100644 --- a/src/test/run-pass/estr-slice.rs +++ b/src/test/run-pass/estr-slice.rs @@ -1,8 +1,8 @@ fn main() { - let x = "hello"/&; - let v = "hello"/&; - let mut y : str/& = "there"/&; + let x = &"hello"; + let v = &"hello"; + let mut y : &str = &"there"; log(debug, x); log(debug, y); @@ -10,14 +10,14 @@ fn main() { assert x[0] == 'h' as u8; assert x[4] == 'o' as u8; - let z : str/& = "thing"/&; + let z : &str = &"thing"; assert v == x; assert x != z; - let a = "aaaa"/&; - let b = "bbbb"/&; - let c = "cccc"/&; - let cc = "ccccc"/&; + let a = &"aaaa"; + let b = &"bbbb"; + let c = &"cccc"; + let cc = &"ccccc"; log(debug, a); diff --git a/src/test/run-pass/estr-uniq.rs b/src/test/run-pass/estr-uniq.rs index 07b7fcf58d6e..bd6641a93de0 100644 --- a/src/test/run-pass/estr-uniq.rs +++ b/src/test/run-pass/estr-uniq.rs @@ -1,7 +1,7 @@ fn main() { - let x : str/~ = "hello"/~; - let _y : str/~ = "there"/~; - let mut z = "thing"/~; + let x : ~str = ~"hello"; + let _y : ~str = ~"there"; + let mut z = ~"thing"; z = x; assert z[0] == ('h' as u8); assert z[4] == ('o' as u8); diff --git a/src/test/run-pass/exec-env.rs b/src/test/run-pass/exec-env.rs index cddcd4987e5f..86960fbad1f4 100644 --- a/src/test/run-pass/exec-env.rs +++ b/src/test/run-pass/exec-env.rs @@ -2,5 +2,5 @@ // exec-env:TEST_EXEC_ENV=22 fn main() { - assert os::getenv("TEST_EXEC_ENV") == some("22"); + assert os::getenv(~"TEST_EXEC_ENV") == some(~"22"); } diff --git a/src/test/run-pass/expr-alt-box.rs b/src/test/run-pass/expr-alt-box.rs index 93a65d629776..9953838b2743 100644 --- a/src/test/run-pass/expr-alt-box.rs +++ b/src/test/run-pass/expr-alt-box.rs @@ -10,8 +10,8 @@ fn test_box() { } fn test_str() { - let res = alt check true { true { "happy" } }; - assert (res == "happy"); + let res = alt check true { true { ~"happy" } }; + assert (res == ~"happy"); } fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-if-box.rs b/src/test/run-pass/expr-if-box.rs index 7d9e2320e939..d53528515166 100644 --- a/src/test/run-pass/expr-if-box.rs +++ b/src/test/run-pass/expr-if-box.rs @@ -10,8 +10,8 @@ fn test_box() { } fn test_str() { - let rs = if true { "happy" } else { "sad" }; - assert (rs == "happy"); + let rs = if true { ~"happy" } else { ~"sad" }; + assert (rs == ~"happy"); } fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/fixed_length_vec_glue.rs b/src/test/run-pass/fixed_length_vec_glue.rs index b8d894bef7d1..017a17684ec9 100644 --- a/src/test/run-pass/fixed_length_vec_glue.rs +++ b/src/test/run-pass/fixed_length_vec_glue.rs @@ -2,5 +2,5 @@ fn main() { let arr = [1,2,3]/3; let struct = {a: 13u8, b: arr, c: 42}; let s = sys::log_str(struct); - assert(s == "(13, [1, 2, 3]/3, 42)"); + assert(s == ~"(13, [1, 2, 3]/3, 42)"); } diff --git a/src/test/run-pass/for-loop-fail.rs b/src/test/run-pass/for-loop-fail.rs index 82551bbc6ff8..6edebcbabd67 100644 --- a/src/test/run-pass/for-loop-fail.rs +++ b/src/test/run-pass/for-loop-fail.rs @@ -1 +1 @@ -fn main() { let x: ~[int] = ~[]; for x.each |_i| { fail "moop"; } } +fn main() { let x: ~[int] = ~[]; for x.each |_i| { fail ~"moop"; } } diff --git a/src/test/run-pass/foreign-dupe.rs b/src/test/run-pass/foreign-dupe.rs index ab6a7320e457..b780e95f5441 100644 --- a/src/test/run-pass/foreign-dupe.rs +++ b/src/test/run-pass/foreign-dupe.rs @@ -4,13 +4,13 @@ #[abi = "cdecl"] #[link_name = "rustrt"] extern mod rustrt1 { - fn last_os_error() -> str; + fn last_os_error() -> ~str; } #[abi = "cdecl"] #[link_name = "rustrt"] extern mod rustrt2 { - fn last_os_error() -> str; + fn last_os_error() -> ~str; } fn main() { diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index 46fa8cf97cd3..010df0158ed1 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -10,13 +10,13 @@ fn my_strlen(str: *u8) -> uint; } -fn strlen(str: str) -> uint unsafe { +fn strlen(str: ~str) -> uint unsafe { // C string is terminated with a zero let bytes = str::bytes(str) + ~[0u8]; ret libc::my_strlen(vec::unsafe::to_ptr(bytes)); } fn main() { - let len = strlen("Rust"); + let len = strlen(~"Rust"); assert(len == 4u); } diff --git a/src/test/run-pass/foreign2.rs b/src/test/run-pass/foreign2.rs index b801051d4f68..7af41e8dc415 100644 --- a/src/test/run-pass/foreign2.rs +++ b/src/test/run-pass/foreign2.rs @@ -24,4 +24,4 @@ fn write(fd: int, buf: *u8, #[nolink] extern mod baz { } -fn main(args: ~[str]) { } +fn main(args: ~[~str]) { } diff --git a/src/test/run-pass/generic-tag-corruption.rs b/src/test/run-pass/generic-tag-corruption.rs index f1313f8cb6b8..6e1985d2a6f3 100644 --- a/src/test/run-pass/generic-tag-corruption.rs +++ b/src/test/run-pass/generic-tag-corruption.rs @@ -4,4 +4,4 @@ // This causes memory corruption in stage0. enum thing { some(K), } -fn main() { let x = some("hi"); } +fn main() { let x = some(~"hi"); } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 212a6febef5b..a29fd7afc1d1 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -20,30 +20,30 @@ import comm::recv; import comm; -fn map(filename: str, emit: map_reduce::putter) { emit(filename, "1"); } +fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); } mod map_reduce { export putter; export mapper; export map_reduce; - type putter = fn@(str, str); + type putter = fn@(~str, ~str); - type mapper = extern fn(str, putter); + type mapper = extern fn(~str, putter); enum ctrl_proto { find_reducer(~[u8], chan), mapper_done, } - fn start_mappers(ctrl: chan, inputs: ~[str]) { + fn start_mappers(ctrl: chan, inputs: ~[~str]) { for inputs.each |i| { task::spawn(|| map_task(ctrl, i) ); } } - fn map_task(ctrl: chan, input: str) { + fn map_task(ctrl: chan, input: ~str) { let intermediates = map::str_hash(); - fn emit(im: map::hashmap, ctrl: chan, key: str, - val: str) { + fn emit(im: map::hashmap<~str, int>, ctrl: chan, key: ~str, + val: ~str) { let mut c; alt im.find(key) { some(_c) { c = _c } @@ -63,13 +63,13 @@ fn emit(im: map::hashmap, ctrl: chan, key: str, send(ctrl, mapper_done); } - fn map_reduce(inputs: ~[str]) { + fn map_reduce(inputs: ~[~str]) { let ctrl = port(); // This task becomes the master control task. It spawns others // to do the rest. - let mut reducers: map::hashmap; + let mut reducers: map::hashmap<~str, int>; reducers = map::str_hash(); @@ -94,5 +94,5 @@ fn map_reduce(inputs: ~[str]) { } fn main() { - map_reduce::map_reduce(~["../src/test/run-pass/hashmap-memory.rs"]); + map_reduce::map_reduce(~[~"../src/test/run-pass/hashmap-memory.rs"]); } diff --git a/src/test/run-pass/iface-cast.rs b/src/test/run-pass/iface-cast.rs index 1377bb2a2790..b53a4c06ee91 100644 --- a/src/test/run-pass/iface-cast.rs +++ b/src/test/run-pass/iface-cast.rs @@ -8,31 +8,31 @@ }; iface to_str { - fn to_str() -> str; + fn to_str() -> ~str; } impl of to_str for option { - fn to_str() -> str { + fn to_str() -> ~str { alt self { - none { "none" } - some(t) { "some(" + t.to_str() + ")" } + none { ~"none" } + some(t) { ~"some(" + t.to_str() + ~")" } } } } impl of to_str for int { - fn to_str() -> str { int::str(self) } + fn to_str() -> ~str { int::str(self) } } impl of to_str for Tree { - fn to_str() -> str { + fn to_str() -> ~str { let l = self.left, r = self.right; #fmt["[%s, %s, %s]", self.val.to_str(), l.to_str(), r.to_str()] } } -fn foo(x: T) -> str { x.to_str() } +fn foo(x: T) -> ~str { x.to_str() } fn main() { let t1 = Tree(@{mut left: none, @@ -41,7 +41,7 @@ fn main() { let t2 = Tree(@{mut left: some(t1), mut right: some(t1), val: 2 as to_str }); - let expected = "[2, some([1, none, none]), some([1, none, none])]"; + let expected = ~"[2, some([1, none, none]), some([1, none, none])]"; assert t2.to_str() == expected; assert foo(t2 as to_str) == expected; t1.left = some(t2); // create cycle diff --git a/src/test/run-pass/iface-generic.rs b/src/test/run-pass/iface-generic.rs index 13be78d86161..f60dd6e1f18c 100644 --- a/src/test/run-pass/iface-generic.rs +++ b/src/test/run-pass/iface-generic.rs @@ -1,14 +1,14 @@ iface to_str { - fn to_str() -> str; + fn to_str() -> ~str; } impl of to_str for int { - fn to_str() -> str { int::str(self) } + fn to_str() -> ~str { int::str(self) } } -impl of to_str for str { - fn to_str() -> str { self } +impl of to_str for ~str { + fn to_str() -> ~str { self } } impl of to_str for () { - fn to_str() -> str { "()" } + fn to_str() -> ~str { ~"()" } } iface map { @@ -22,16 +22,16 @@ fn map(f: fn(T) -> U) -> ~[U] { } } -fn foo>(x: T) -> ~[str] { - x.map(|_e| "hi" ) +fn foo>(x: T) -> ~[~str] { + x.map(|_e| ~"hi" ) } -fn bar>(x: T) -> ~[str] { +fn bar>(x: T) -> ~[~str] { x.map(|_e| _e.to_str() ) } fn main() { - assert foo(~[1]) == ~["hi"]; - assert bar::(~[4, 5]) == ~["4", "5"]; - assert bar::(~["x", "y"]) == ~["x", "y"]; - assert bar::<(), ~[()]>(~[()]) == ~["()"]; + assert foo(~[1]) == ~[~"hi"]; + assert bar::(~[4, 5]) == ~[~"4", ~"5"]; + assert bar::<~str, ~[~str]>(~[~"x", ~"y"]) == ~[~"x", ~"y"]; + assert bar::<(), ~[()]>(~[()]) == ~[~"()"]; } diff --git a/src/test/run-pass/iface-to-str.rs b/src/test/run-pass/iface-to-str.rs index a3d5b535371e..71d25b4efd57 100644 --- a/src/test/run-pass/iface-to-str.rs +++ b/src/test/run-pass/iface-to-str.rs @@ -1,28 +1,28 @@ iface to_str { - fn to_str() -> str; + fn to_str() -> ~str; } impl of to_str for int { - fn to_str() -> str { int::str(self) } + fn to_str() -> ~str { int::str(self) } } impl of to_str for ~[T] { - fn to_str() -> str { - "[" + str::connect(vec::map(self, |e| e.to_str() ), ", ") + "]" + fn to_str() -> ~str { + ~"[" + str::connect(vec::map(self, |e| e.to_str() ), ~", ") + ~"]" } } fn main() { - assert 1.to_str() == "1"; - assert (~[2, 3, 4]).to_str() == "[2, 3, 4]"; + assert 1.to_str() == ~"1"; + assert (~[2, 3, 4]).to_str() == ~"[2, 3, 4]"; - fn indirect(x: T) -> str { - x.to_str() + "!" + fn indirect(x: T) -> ~str { + x.to_str() + ~"!" } - assert indirect(~[10, 20]) == "[10, 20]!"; + assert indirect(~[10, 20]) == ~"[10, 20]!"; - fn indirect2(x: T) -> str { + fn indirect2(x: T) -> ~str { indirect(x) } - assert indirect2(~[1]) == "[1]!"; + assert indirect2(~[1]) == ~"[1]!"; } diff --git a/src/test/run-pass/import4.rs b/src/test/run-pass/import4.rs index 9f3207f6b6fa..f6d2a9c9b5b3 100644 --- a/src/test/run-pass/import4.rs +++ b/src/test/run-pass/import4.rs @@ -5,4 +5,4 @@ mod zed { fn bar() { #debug("bar"); } } -fn main(args: ~[str]) { let zed = 42; bar(); } +fn main(args: ~[~str]) { let zed = 42; bar(); } diff --git a/src/test/run-pass/import5.rs b/src/test/run-pass/import5.rs index f389dc61e53c..ef8df1b9399a 100644 --- a/src/test/run-pass/import5.rs +++ b/src/test/run-pass/import5.rs @@ -7,4 +7,4 @@ mod zed { } } -fn main(args: ~[str]) { bar(); } +fn main(args: ~[~str]) { bar(); } diff --git a/src/test/run-pass/import7.rs b/src/test/run-pass/import7.rs index b76ec2ccb4f8..eeb8484e5749 100644 --- a/src/test/run-pass/import7.rs +++ b/src/test/run-pass/import7.rs @@ -12,4 +12,4 @@ mod foo { mod zed { } } } -fn main(args: ~[str]) { baz(); } +fn main(args: ~[~str]) { baz(); } diff --git a/src/test/run-pass/inferred-suffix-in-pattern-range.rs b/src/test/run-pass/inferred-suffix-in-pattern-range.rs index d0647dd1ec91..eadb3503bda9 100644 --- a/src/test/run-pass/inferred-suffix-in-pattern-range.rs +++ b/src/test/run-pass/inferred-suffix-in-pattern-range.rs @@ -1,22 +1,22 @@ fn main() { let x = 2; let x_message = alt x { - 0 to 1 { "not many" } - _ { "lots" } + 0 to 1 { ~"not many" } + _ { ~"lots" } }; - assert x_message == "lots"; + assert x_message == ~"lots"; let y = 2i; let y_message = alt y { - 0 to 1 { "not many" } - _ { "lots" } + 0 to 1 { ~"not many" } + _ { ~"lots" } }; - assert y_message == "lots"; + assert y_message == ~"lots"; let z = 1u64; let z_message = alt z { - 0 to 1 { "not many" } - _ { "lots" } + 0 to 1 { ~"not many" } + _ { ~"lots" } }; - assert z_message == "not many"; + assert z_message == ~"not many"; } diff --git a/src/test/run-pass/integral-indexing.rs b/src/test/run-pass/integral-indexing.rs index 222e63d4928e..f6fbd20c7329 100644 --- a/src/test/run-pass/integral-indexing.rs +++ b/src/test/run-pass/integral-indexing.rs @@ -4,7 +4,7 @@ // This is a testcase for issue #94. fn main() { let v: ~[int] = ~[0, 1, 2, 3, 4, 5]; - let s: str = "abcdef"; + let s: ~str = ~"abcdef"; assert (v[3u] == 3); assert (v[3u8] == 3); assert (v[3i8] == 3); diff --git a/src/test/run-pass/issue-1257.rs b/src/test/run-pass/issue-1257.rs index 870d4aec4031..7471f7ab8ad7 100644 --- a/src/test/run-pass/issue-1257.rs +++ b/src/test/run-pass/issue-1257.rs @@ -1,8 +1,8 @@ fn main () { - let mut line = ""; + let mut line = ~""; let mut i = 0; - while line != "exit" { - line = if i == 9 { "exit" } else { "notexit" }; + while line != ~"exit" { + line = if i == 9 { ~"exit" } else { ~"notexit" }; i += 1; } } diff --git a/src/test/run-pass/issue-1466.rs b/src/test/run-pass/issue-1466.rs index a40de7d44137..a9a665a0a7fc 100644 --- a/src/test/run-pass/issue-1466.rs +++ b/src/test/run-pass/issue-1466.rs @@ -1,6 +1,6 @@ // exec-env:RUST_CC_ZEAL=1 fn main() { - #error["%?", os::getenv("RUST_CC_ZEAL")]; + #error["%?", os::getenv(~"RUST_CC_ZEAL")]; let _x = @{a: @10, b: ~true}; } diff --git a/src/test/run-pass/issue-1696.rs b/src/test/run-pass/issue-1696.rs index ab142a895e55..615c7be62413 100644 --- a/src/test/run-pass/issue-1696.rs +++ b/src/test/run-pass/issue-1696.rs @@ -4,6 +4,6 @@ fn main() { let m = map::bytes_hash(); - m.insert(str::bytes("foo"), str::bytes("bar")); + m.insert(str::bytes(~"foo"), str::bytes(~"bar")); log(error, m); } diff --git a/src/test/run-pass/issue-1701.rs b/src/test/run-pass/issue-1701.rs index b3b364c80901..f550c98d337d 100644 --- a/src/test/run-pass/issue-1701.rs +++ b/src/test/run-pass/issue-1701.rs @@ -1,21 +1,21 @@ enum pattern { tabby, tortoiseshell, calico } enum breed { beagle, rottweiler, pug } -type name = str; +type name = ~str; enum ear_kind { lop, upright } enum animal { cat(pattern), dog(breed), rabbit(name, ear_kind), tiger } -fn noise(a: animal) -> option { +fn noise(a: animal) -> option<~str> { alt a { - cat(*) { some("meow") } - dog(*) { some("woof") } + cat(*) { some(~"meow") } + dog(*) { some(~"woof") } rabbit(*) { none } - tiger(*) { some("roar") } + tiger(*) { some(~"roar") } } } fn main() { - assert noise(cat(tabby)) == some("meow"); - assert noise(dog(pug)) == some("woof"); - assert noise(rabbit("Hilbert", upright)) == none; - assert noise(tiger) == some("roar"); + assert noise(cat(tabby)) == some(~"meow"); + assert noise(dog(pug)) == some(~"woof"); + assert noise(rabbit(~"Hilbert", upright)) == none; + assert noise(tiger) == some(~"roar"); } \ No newline at end of file diff --git a/src/test/run-pass/issue-1974.rs b/src/test/run-pass/issue-1974.rs index ba84ad967c50..e8d27aa5e5ce 100644 --- a/src/test/run-pass/issue-1974.rs +++ b/src/test/run-pass/issue-1974.rs @@ -1,8 +1,8 @@ // Issue 1974 // Don't double free the condition allocation fn main() { - let s = "hej"; - while s != "" { + let s = ~"hej"; + while s != ~"" { ret; } } \ No newline at end of file diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs index fbacb4fee729..41006ba3d65f 100644 --- a/src/test/run-pass/issue-2631-b.rs +++ b/src/test/run-pass/issue-2631-b.rs @@ -10,8 +10,8 @@ import dvec; fn main() { - let v = ~[mut @"hi"]; + let v = ~[mut @~"hi"]; let m: req::header_map = str_hash(); - m.insert("METHOD", @dvec::from_vec(v)); + m.insert(~"METHOD", @dvec::from_vec(v)); request::(m); } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 96e8af30ed48..412bcb5b66a9 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -65,7 +65,7 @@ fn send(-p: send_packet, -payload: T) { // The receiver will eventually clean this up. unsafe { forget(p); } } - full { fail "duplicate send" } + full { fail ~"duplicate send" } blocked { // The receiver will eventually clean this up. @@ -108,7 +108,7 @@ fn sender_terminate(p: *packet) { } full { // This is impossible - fail "you dun goofed" + fail ~"you dun goofed" } terminated { // I have to clean up, use drop_glue @@ -125,7 +125,7 @@ fn receiver_terminate(p: *packet) { } blocked { // this shouldn't happen. - fail "terminating a blocked packet" + fail ~"terminating a blocked packet" } terminated | full { // I have to clean up, use drop_glue @@ -213,7 +213,7 @@ fn do_ping(-c: ping) -> pong { fn do_pong(-c: pong) -> (ping, ()) { let packet = pipes::recv(c); if packet == none { - fail "sender closed the connection" + fail ~"sender closed the connection" } (liberate_pong(option::unwrap(packet)), ()) } @@ -226,7 +226,7 @@ mod server { fn do_ping(-c: ping) -> (pong, ()) { let packet = pipes::recv(c); if packet == none { - fail "sender closed the connection" + fail ~"sender closed the connection" } (liberate_ping(option::unwrap(packet)), ()) } @@ -241,16 +241,16 @@ fn do_pong(-c: pong) -> ping { fn client(-chan: pingpong::client::ping) { let chan = pingpong::client::do_ping(chan); - log(error, "Sent ping"); + log(error, ~"Sent ping"); let (chan, _data) = pingpong::client::do_pong(chan); - log(error, "Received pong"); + log(error, ~"Received pong"); } fn server(-chan: pingpong::server::ping) { let (chan, _data) = pingpong::server::do_ping(chan); - log(error, "Received ping"); + log(error, ~"Received ping"); let chan = pingpong::server::do_pong(chan); - log(error, "Sent pong"); + log(error, ~"Sent pong"); } fn main() { diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 4b7c09bd1e90..63bc1dc7d6f7 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -6,7 +6,7 @@ fn perform_hax(x: @T) -> hax { } fn deadcode() { - perform_hax(@"deadcode"); + perform_hax(@~"deadcode"); } fn main() { diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index d896473d20f5..4ba77e0266c5 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -6,7 +6,7 @@ fn perform_hax(x: @T) -> hax { } fn deadcode() { - perform_hax(@"deadcode"); + perform_hax(@~"deadcode"); } fn main() { diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs index 245d0d0ab244..4ac9ea0eb6ee 100644 --- a/src/test/run-pass/issue-2804-2.rs +++ b/src/test/run-pass/issue-2804-2.rs @@ -3,8 +3,8 @@ use std; import std::map::hashmap; -fn add_interfaces(managed_ip: str, device: std::map::hashmap) { - #error["%s, %?", managed_ip, device["interfaces"]]; +fn add_interfaces(managed_ip: ~str, device: std::map::hashmap<~str, int>) { + #error["%s, %?", managed_ip, device[~"interfaces"]]; } fn main() {} diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index ae63e1ab22e6..926a8086cc27 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -9,7 +9,7 @@ enum object int_value(i64), } -fn lookup(table: std::map::hashmap, key: str, default: str) -> str +fn lookup(table: std::map::hashmap<~str, std::json::json>, key: ~str, default: ~str) -> ~str { alt table.find(key) { @@ -29,13 +29,13 @@ fn lookup(table: std::map::hashmap, key: str, default: str } } -fn add_interface(store: int, managed_ip: str, data: std::json::json) -> (str, object) +fn add_interface(store: int, managed_ip: ~str, data: std::json::json) -> (~str, object) { alt data { std::json::dict(interface) { - let name = lookup(interface, "ifDescr", ""); + let name = lookup(interface, ~"ifDescr", ~""); let label = #fmt["%s-%s", managed_ip, name]; (label, bool_value(false)) @@ -43,14 +43,14 @@ fn add_interface(store: int, managed_ip: str, data: std::json::json) -> (str, ob _ { #error["Expected dict for %s interfaces but found %?", managed_ip, data]; - ("gnos:missing-interface", bool_value(true)) + (~"gnos:missing-interface", bool_value(true)) } } } -fn add_interfaces(store: int, managed_ip: str, device: std::map::hashmap) -> [(str, object)]/~ +fn add_interfaces(store: int, managed_ip: ~str, device: std::map::hashmap<~str, std::json::json>) -> ~[(~str, object)] { - alt device["interfaces"] + alt device[~"interfaces"] { std::json::list(interfaces) { @@ -60,8 +60,8 @@ fn add_interfaces(store: int, managed_ip: str, device: std::map::hashmap(s: str, f: fn(str) -> T) -> T { +fn lp(s: ~str, f: fn(~str) -> T) -> T { while false { let r = f(s); ret r; @@ -8,8 +8,8 @@ fn lp(s: str, f: fn(str) -> T) -> T { fail; } -fn apply(s: str, f: fn(str) -> T) -> T { - fn g(s: str, f: fn(str) -> T) -> T {f(s)} +fn apply(s: ~str, f: fn(~str) -> T) -> T { + fn g(s: ~str, f: fn(~str) -> T) -> T {f(s)} g(s, |v| { let r = f(v); r }) } diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs index 7bb9c3060cf0..5091020508d6 100644 --- a/src/test/run-pass/linear-for-loop.rs +++ b/src/test/run-pass/linear-for-loop.rs @@ -6,7 +6,7 @@ fn main() { for x.each |i| { log(debug, i); y += i; } log(debug, y); assert (y == 6); - let s = "hello there"; + let s = ~"hello there"; let mut i: int = 0; for str::each(s) |c| { if i == 0 { assert (c == 'h' as u8); } diff --git a/src/test/run-pass/log-err-phi.rs b/src/test/run-pass/log-err-phi.rs index 5b4ae8799c8e..0c96279e707b 100644 --- a/src/test/run-pass/log-err-phi.rs +++ b/src/test/run-pass/log-err-phi.rs @@ -1,3 +1,3 @@ -fn main() { if false { log(error, "foo" + "bar"); } } +fn main() { if false { log(error, ~"foo" + ~"bar"); } } diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index c099375cb7ce..575425708602 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -3,16 +3,16 @@ enum foo { a(uint), - b(str), + b(~str), } -fn check_log(exp: str, v: T) { +fn check_log(exp: ~str, v: T) { assert exp == #fmt["%?", v]; } fn main() { - let x = list::from_vec(~[a(22u), b("hi")]); - let exp = "@cons(a(22), @cons(b(~\"hi\"), @nil))"; + let x = list::from_vec(~[a(22u), b(~"hi")]); + let exp = ~"@cons(a(22), @cons(b(~\"hi\"), @nil))"; assert #fmt["%?", x] == exp; check_log(exp, x); } diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs index 4df6d5882094..f2d066277d42 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants.rs @@ -1,11 +1,11 @@ enum foo { a(uint), - b(str), + b(~str), c, } fn main() { - assert "a(22)" == #fmt["%?", a(22u)]; - assert "b(~\"hi\")" == #fmt["%?", b("hi")]; - assert "c" == #fmt["%?", c]; + assert ~"a(22)" == #fmt["%?", a(22u)]; + assert ~"b(~\"hi\")" == #fmt["%?", b(~"hi")]; + assert ~"c" == #fmt["%?", c]; } diff --git a/src/test/run-pass/log-str.rs b/src/test/run-pass/log-str.rs index 7f424bf69f70..5f406d5fbbf1 100644 --- a/src/test/run-pass/log-str.rs +++ b/src/test/run-pass/log-str.rs @@ -1,4 +1,4 @@ fn main() { - assert "~[1, 2, 3]" == sys::log_str(~[1, 2, 3]); - assert #fmt["%?/%6?", [1, 2, 3]/~, "hi"] == "~[1, 2, 3]/ ~\"hi\""; + assert ~"~[1, 2, 3]" == sys::log_str(~[1, 2, 3]); + assert #fmt["%?/%6?", ~[1, 2, 3], ~"hi"] == ~"~[1, 2, 3]/ ~\"hi\""; } diff --git a/src/test/run-pass/loop-break-cont.rs b/src/test/run-pass/loop-break-cont.rs index 2fa706e5777f..7cdfddc5d7fa 100644 --- a/src/test/run-pass/loop-break-cont.rs +++ b/src/test/run-pass/loop-break-cont.rs @@ -1,7 +1,7 @@ fn main() { let mut i = 0u; loop { - log(error, "a"); + log(error, ~"a"); i += 1u; if i == 10u { break; @@ -13,7 +13,7 @@ fn main() { if i == 21u { break; } - log(error, "b"); + log(error, ~"b"); is_even = false; i += 1u; if i % 2u != 0u { @@ -23,7 +23,7 @@ fn main() { } assert !is_even; loop { - log(error, "c"); + log(error, ~"c"); if i == 22u { break; } diff --git a/src/test/run-pass/main-ivec.rs b/src/test/run-pass/main-ivec.rs index a62147f286fd..2cd454a1ccfc 100644 --- a/src/test/run-pass/main-ivec.rs +++ b/src/test/run-pass/main-ivec.rs @@ -1 +1 @@ -fn main(args: ~[str]) { for args.each |s| { log(debug, s); } } +fn main(args: ~[~str]) { for args.each |s| { log(debug, s); } } diff --git a/src/test/run-pass/module-polymorphism4-files/cat.rs b/src/test/run-pass/module-polymorphism4-files/cat.rs index 9bcb03f611c3..1f186036e136 100644 --- a/src/test/run-pass/module-polymorphism4-files/cat.rs +++ b/src/test/run-pass/module-polymorphism4-files/cat.rs @@ -5,10 +5,10 @@ enum cat { meowlycat } -fn animal() -> str { "cat" } -fn talk(c: cat) -> str { +fn animal() -> ~str { ~"cat" } +fn talk(c: cat) -> ~str { alt c { - howlycat { "howl" } - meowlycat { "meow" } + howlycat { ~"howl" } + meowlycat { ~"meow" } } } diff --git a/src/test/run-pass/module-polymorphism4-files/dog.rs b/src/test/run-pass/module-polymorphism4-files/dog.rs index 4826f48b6f30..4fd212deb8d7 100644 --- a/src/test/run-pass/module-polymorphism4-files/dog.rs +++ b/src/test/run-pass/module-polymorphism4-files/dog.rs @@ -4,6 +4,6 @@ enum dog { dog } -fn animal() -> str { "dog" } -fn talk(_d: dog) -> str { "woof" } +fn animal() -> ~str { ~"dog" } +fn talk(_d: dog) -> ~str { ~"woof" } diff --git a/src/test/run-pass/module-polymorphism4-files/trait.rs b/src/test/run-pass/module-polymorphism4-files/trait.rs index 79296359d774..e5762d156a0d 100644 --- a/src/test/run-pass/module-polymorphism4-files/trait.rs +++ b/src/test/run-pass/module-polymorphism4-files/trait.rs @@ -2,8 +2,8 @@ impl talky for T { // 'animal' and 'talk' functions are implemented by the module // instantiating the talky trait. They are 'abstract' - fn says() -> str { - animal() + " says '" + talk(self) + "'" + fn says() -> ~str { + animal() + ~" says '" + talk(self) + ~"'" } } diff --git a/src/test/run-pass/module-polymorphism4.rs b/src/test/run-pass/module-polymorphism4.rs index 074a9272a973..5c061c4d3b57 100644 --- a/src/test/run-pass/module-polymorphism4.rs +++ b/src/test/run-pass/module-polymorphism4.rs @@ -8,7 +8,7 @@ fn main() { let cat1 = cat::inst::meowlycat; let cat2 = cat::inst::howlycat; let dog = dog::inst::dog; - assert cat1.says() == "cat says 'meow'"; - assert cat2.says() == "cat says 'howl'"; - assert dog.says() == "dog says 'woof'"; + assert cat1.says() == ~"cat says 'meow'"; + assert cat2.says() == ~"cat says 'howl'"; + assert dog.says() == ~"dog says 'woof'"; } \ No newline at end of file diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 674460a6a801..a1e52d44e6ba 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -15,13 +15,13 @@ fn bind(f: fn(A) -> option) -> option { } } -fn transform(x: option) -> option { +fn transform(x: option) -> option<~str> { x.bind(|n| some(n + 1) ).bind(|n| some(int::str(n)) ) } fn main() { - assert transform(some(10)) == some("11"); + assert transform(some(10)) == some(~"11"); assert transform(none) == none; - assert (~["hi"]).bind(|x| ~[x, x + "!"] ).bind(|x| ~[x, x + "?"] ) == - ~["hi", "hi?", "hi!", "hi!?"]; + assert (~[~"hi"]).bind(|x| ~[x, x + ~"!"] ).bind(|x| ~[x, x + ~"?"] ) == + ~[~"hi", ~"hi?", ~"hi!", ~"hi!?"]; } diff --git a/src/test/run-pass/morestack6.rs b/src/test/run-pass/morestack6.rs index 69a904e00cdd..62b73cd6a76b 100644 --- a/src/test/run-pass/morestack6.rs +++ b/src/test/run-pass/morestack6.rs @@ -9,8 +9,8 @@ fn debug_get_stk_seg() -> *u8; fn unsupervise(); - fn last_os_error() -> str; - fn rust_getcwd() -> str; + fn last_os_error() -> ~str; + fn rust_getcwd() -> ~str; fn get_task_id(); fn sched_threads(); fn rust_get_task(); diff --git a/src/test/run-pass/move-arg-2-unique.rs b/src/test/run-pass/move-arg-2-unique.rs index 10dc7937be9c..e312d2afb4b8 100644 --- a/src/test/run-pass/move-arg-2-unique.rs +++ b/src/test/run-pass/move-arg-2-unique.rs @@ -1,10 +1,10 @@ -fn test(-foo: ~[int]/~) { assert (foo[0] == 10); } +fn test(-foo: ~~[int]) { assert (foo[0] == 10); } fn main() { - let x = ~[10]/~; + let x = ~~[10]; // Test forgetting a local by move-in test(x); // Test forgetting a temporary by move-in. - test(~[10]/~); + test(~~[10]); } diff --git a/src/test/run-pass/option-ext.rs b/src/test/run-pass/option-ext.rs index 12c0feac8914..0dbe60aca2e6 100644 --- a/src/test/run-pass/option-ext.rs +++ b/src/test/run-pass/option-ext.rs @@ -1,8 +1,8 @@ -fn main(args: ~[str]) { - let thing = "{{ f }}"; - let f = str::find_str(thing, "{{"); +fn main(args: ~[~str]) { + let thing = ~"{{ f }}"; + let f = str::find_str(thing, ~"{{"); if f.is_none() { - io::println("None!"); + io::println(~"None!"); } } \ No newline at end of file diff --git a/src/test/run-pass/path.rs b/src/test/run-pass/path.rs index 6bccf726921f..345f93f760dc 100644 --- a/src/test/run-pass/path.rs +++ b/src/test/run-pass/path.rs @@ -4,4 +4,4 @@ mod foo { fn bar(offset: uint) { } } -fn main(args: ~[str]) { foo::bar(0u); } +fn main(args: ~[~str]) { foo::bar(0u); } diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs index 8c3f1c00c707..72bdfff9f426 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -6,8 +6,8 @@ import pipes::try_recv; -type username = str; -type password = str; +type username = ~str; +type password = ~str; type money = float; type amount = float; @@ -42,26 +42,26 @@ fn macros() { fn bank_client(+bank: bank::client::login) { import bank::*; - let bank = client::login(bank, "theincredibleholk", "1234"); + let bank = client::login(bank, ~"theincredibleholk", ~"1234"); let bank = alt try_recv(bank) { some(ok(connected)) { #move(connected) } - some(invalid(_)) { fail "login unsuccessful" } - none { fail "bank closed the connection" } + some(invalid(_)) { fail ~"login unsuccessful" } + none { fail ~"bank closed the connection" } }; let bank = client::deposit(bank, 100.00); let bank = client::withdrawal(bank, 50.00); alt try_recv(bank) { some(money(m, _)) { - io::println("Yay! I got money!"); + io::println(~"Yay! I got money!"); } some(insufficient_funds(_)) { - fail "someone stole my money" + fail ~"someone stole my money" } none { - fail "bank closed the connection" + fail ~"bank closed the connection" } } } diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs index d0ea4a9a877e..f5eaf26f4a8a 100644 --- a/src/test/run-pass/pipe-pingpong-proto.rs +++ b/src/test/run-pass/pipe-pingpong-proto.rs @@ -20,18 +20,18 @@ fn client(-chan: pingpong::client::ping) { import pingpong::client; let chan = client::ping(chan); - log(error, "Sent ping"); + log(error, ~"Sent ping"); let pong(_chan) = recv(chan); - log(error, "Received pong"); + log(error, ~"Received pong"); } fn server(-chan: pingpong::server::ping) { import pingpong::server; let ping(chan) = recv(chan); - log(error, "Received ping"); + log(error, ~"Received ping"); let _chan = server::pong(chan); - log(error, "Sent pong"); + log(error, ~"Sent pong"); } } diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index 3f109d78e521..81f11395e042 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -50,5 +50,5 @@ fn main() { // because `inner`s alignment was 4. assert sys::size_of::() == m::size(); - assert y == "(22, (44))"; + assert y == ~"(22, (44))"; } diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index 2476cf7d8183..433ca581ab3e 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -64,5 +64,5 @@ fn main() { // because `inner`s alignment was 4. assert sys::size_of::() == m::m::size(); - assert y == "(22, (44))"; + assert y == ~"(22, (44))"; } diff --git a/src/test/run-pass/rec-auto.rs b/src/test/run-pass/rec-auto.rs index 8b2274817f74..0bb521c9dfba 100644 --- a/src/test/run-pass/rec-auto.rs +++ b/src/test/run-pass/rec-auto.rs @@ -5,7 +5,7 @@ // Issue #50. fn main() { - let x = {foo: "hello", bar: "world"}; + let x = {foo: ~"hello", bar: ~"world"}; log(debug, x.foo); log(debug, x.bar); } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index c3e7709cf006..b654cf9bd19b 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -172,30 +172,30 @@ fn visit_char() -> bool { } fn visit_str() -> bool { - self.align_to::(); + self.align_to::<~str>(); if ! self.inner.visit_str() { ret false; } - self.bump_past::(); + self.bump_past::<~str>(); true } fn visit_estr_box() -> bool { - self.align_to::(); + self.align_to::<@str>(); if ! self.inner.visit_estr_box() { ret false; } - self.bump_past::(); + self.bump_past::<@str>(); true } fn visit_estr_uniq() -> bool { - self.align_to::(); + self.align_to::<~str>(); if ! self.inner.visit_estr_uniq() { ret false; } - self.bump_past::(); + self.bump_past::<~str>(); true } fn visit_estr_slice() -> bool { - self.align_to::(); + self.align_to::<&static/str>(); if ! self.inner.visit_estr_slice() { ret false; } - self.bump_past::(); + self.bump_past::<&static/str>(); true } @@ -289,7 +289,7 @@ fn visit_enter_rec(n_fields: uint, sz: uint, align: uint) -> bool { true } - fn visit_rec_field(i: uint, name: str/&, + fn visit_rec_field(i: uint, name: &str, mtbl: uint, inner: *tydesc) -> bool { if ! self.inner.visit_rec_field(i, name, mtbl, inner) { ret false; } true @@ -308,7 +308,7 @@ fn visit_enter_class(n_fields: uint, sz: uint, align: uint) -> bool { true } - fn visit_class_field(i: uint, name: str/&, + fn visit_class_field(i: uint, name: &str, mtbl: uint, inner: *tydesc) -> bool { if ! self.inner.visit_class_field(i, name, mtbl, inner) { ret false; @@ -374,7 +374,7 @@ fn visit_enter_enum(n_variants: uint, sz: uint, align: uint) -> bool { fn visit_enter_enum_variant(variant: uint, disr_val: int, n_fields: uint, - name: str/&) -> bool { + name: &str) -> bool { if ! self.inner.visit_enter_enum_variant(variant, disr_val, n_fields, name) { ret false; @@ -390,7 +390,7 @@ fn visit_enum_variant_field(i: uint, inner: *tydesc) -> bool { fn visit_leave_enum_variant(variant: uint, disr_val: int, n_fields: uint, - name: str/&) -> bool { + name: &str) -> bool { if ! self.inner.visit_leave_enum_variant(variant, disr_val, n_fields, name) { ret false; @@ -460,7 +460,7 @@ fn visit_closure_ptr(ck: uint) -> bool { enum my_visitor = @{ mut ptr1: *c_void, mut ptr2: *c_void, - mut vals: ~[str] + mut vals: ~[~str] }; impl extra_methods for my_visitor { @@ -540,7 +540,7 @@ fn visit_evec_fixed(_n: uint, _mtbl: uint, fn visit_enter_rec(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } - fn visit_rec_field(_i: uint, _name: str/&, + fn visit_rec_field(_i: uint, _name: &str, _mtbl: uint, inner: *tydesc) -> bool { #error("rec field!"); self.visit_inner(inner) @@ -550,7 +550,7 @@ fn visit_leave_rec(_n_fields: uint, fn visit_enter_class(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } - fn visit_class_field(_i: uint, _name: str/&, + fn visit_class_field(_i: uint, _name: &str, _mtbl: uint, inner: *tydesc) -> bool { self.visit_inner(inner) } @@ -574,14 +574,14 @@ fn visit_enter_enum(_n_variants: uint, fn visit_enter_enum_variant(_variant: uint, _disr_val: int, _n_fields: uint, - _name: str/&) -> bool { true } + _name: &str) -> bool { true } fn visit_enum_variant_field(_i: uint, inner: *tydesc) -> bool { self.visit_inner(inner) } fn visit_leave_enum_variant(_variant: uint, _disr_val: int, _n_fields: uint, - _name: str/&) -> bool { true } + _name: &str) -> bool { true } fn visit_leave_enum(_n_variants: uint, _sz: uint, _align: uint) -> bool { true } @@ -625,5 +625,5 @@ fn main() { io::println(#fmt("val: %s", s)); } #error("%?", copy u.vals); - assert u.vals == ~["1", "2", "3", "true", "false", "5", "4", "3"]; + assert u.vals == ~[~"1", ~"2", ~"3", ~"true", ~"false", ~"5", ~"4", ~"3"]; } diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 0ba4bf0730c2..2d9227e22ef7 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -77,14 +77,14 @@ fn visit_evec_fixed(_n: uint, _mtbl: uint, fn visit_enter_rec(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } - fn visit_rec_field(_i: uint, _name: str/&, + fn visit_rec_field(_i: uint, _name: &str, _mtbl: uint, _inner: *tydesc) -> bool { true } fn visit_leave_rec(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } fn visit_enter_class(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } - fn visit_class_field(_i: uint, _name: str/&, + fn visit_class_field(_i: uint, _name: &str, _mtbl: uint, _inner: *tydesc) -> bool { true } fn visit_leave_class(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } @@ -100,12 +100,12 @@ fn visit_enter_enum(_n_variants: uint, fn visit_enter_enum_variant(_variant: uint, _disr_val: int, _n_fields: uint, - _name: str/&) -> bool { true } + _name: &str) -> bool { true } fn visit_enum_variant_field(_i: uint, _inner: *tydesc) -> bool { true } fn visit_leave_enum_variant(_variant: uint, _disr_val: int, _n_fields: uint, - _name: str/&) -> bool { true } + _name: &str) -> bool { true } fn visit_leave_enum(_n_variants: uint, _sz: uint, _align: uint) -> bool { true } diff --git a/src/test/run-pass/regions-borrow-estr-uniq.rs b/src/test/run-pass/regions-borrow-estr-uniq.rs index f118b96bb417..dbbdcc9fc34d 100644 --- a/src/test/run-pass/regions-borrow-estr-uniq.rs +++ b/src/test/run-pass/regions-borrow-estr-uniq.rs @@ -1,13 +1,13 @@ -fn foo(x: str/&) -> u8 { +fn foo(x: &str) -> u8 { x[0] } fn main() { - let p = "hello"/~; + let p = ~"hello"; let r = foo(p); assert r == 'h' as u8; - let p = "hello"; + let p = ~"hello"; let r = foo(p); assert r == 'h' as u8; } diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index 0ae85a5af0b7..3ccf15c9daf4 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -2,7 +2,7 @@ let i: @@mut int; fn look_at() -> int { ret **(self.i); } new(i: @@mut int) { self.i = i; } - drop { log(error, "Hello!"); **(self.i) -= 1; } + drop { log(error, ~"Hello!"); **(self.i) -= 1; } } fn main() { diff --git a/src/test/run-pass/ret-bang.rs b/src/test/run-pass/ret-bang.rs index db8b86fe4a41..122188643de8 100644 --- a/src/test/run-pass/ret-bang.rs +++ b/src/test/run-pass/ret-bang.rs @@ -2,10 +2,10 @@ // -*- rust -*- -fn my_err(s: str) -> ! { log(error, s); fail; } +fn my_err(s: ~str) -> ! { log(error, s); fail; } fn okay(i: uint) -> int { - if i == 3u { my_err("I don't like three"); } else { ret 42; } + if i == 3u { my_err(~"I don't like three"); } else { ret 42; } } fn main() { okay(4u); } diff --git a/src/test/run-pass/ret-break-cont-in-block.rs b/src/test/run-pass/ret-break-cont-in-block.rs index c94f0640180f..5dc448a3e6cb 100644 --- a/src/test/run-pass/ret-break-cont-in-block.rs +++ b/src/test/run-pass/ret-break-cont-in-block.rs @@ -26,13 +26,13 @@ fn bail_deep(x: ~[~[bool]]) { assert !seen; } -fn ret_deep() -> str { +fn ret_deep() -> ~str { for iter(~[1, 2]) |e| { for iter(~[3, 4]) |x| { - if e + x > 4 { ret "hi"; } + if e + x > 4 { ret ~"hi"; } } } - ret "bye"; + ret ~"bye"; } fn main() { @@ -47,11 +47,11 @@ fn main() { assert find_pos(1, ~[0, 1, 2, 3]) == some(1u); assert find_pos(1, ~[0, 4, 2, 3]) == none; - assert find_pos("hi", ~["foo", "bar", "baz", "hi"]) == some(3u); + assert find_pos(~"hi", ~[~"foo", ~"bar", ~"baz", ~"hi"]) == some(3u); bail_deep(~[~[false, false], ~[true, true], ~[false, true]]); bail_deep(~[~[true]]); bail_deep(~[~[false, false, false]]); - assert ret_deep() == "hi"; + assert ret_deep() == ~"hi"; } diff --git a/src/test/run-pass/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index bc8ecd7047a4..2a4d675c3213 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -11,16 +11,16 @@ fn make_generic_record(a: A, b: B) -> pair { ret {a: a, b: b}; } -fn test05_start(&&f: fn~(&&float, &&str) -> pair) { - let p = f(22.22f, "Hi"); +fn test05_start(&&f: fn~(&&float, &&~str) -> pair) { + let p = f(22.22f, ~"Hi"); log(debug, p); assert p.a == 22.22f; - assert p.b == "Hi"; + assert p.b == ~"Hi"; - let q = f(44.44f, "Ho"); + let q = f(44.44f, ~"Ho"); log(debug, q); assert q.a == 44.44f; - assert q.b == "Ho"; + assert q.b == ~"Ho"; } fn spawn(f: extern fn(fn~(A,B)->pair)) { @@ -31,5 +31,5 @@ fn spawn(f: extern fn(fn~(A,B)->pair)) { } fn test05() { - spawn::(test05_start); + spawn::(test05_start); } diff --git a/src/test/run-pass/seq-compare.rs b/src/test/run-pass/seq-compare.rs index 00ddcbd9a654..e310184c6c80 100644 --- a/src/test/run-pass/seq-compare.rs +++ b/src/test/run-pass/seq-compare.rs @@ -1,9 +1,9 @@ fn main() { - assert ("hello" < "hellr"); - assert ("hello " > "hello"); - assert ("hello" != "there"); + assert (~"hello" < ~"hellr"); + assert (~"hello " > ~"hello"); + assert (~"hello" != ~"there"); assert (~[1, 2, 3, 4] > ~[1, 2, 3]); assert (~[1, 2, 3] < ~[1, 2, 3, 4]); assert (~[1, 2, 4, 4] > ~[1, 2, 3, 4]); diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs index 151d6b123c74..6e050704e1f5 100644 --- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs +++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs @@ -16,14 +16,14 @@ enum opt_span { type span = {lo: uint, hi: uint, expanded_from: opt_span}; type spanned = { data: T, span: span }; type ty_ = uint; -type path_ = { global: bool, idents: ~[str], types: ~[@ty] }; +type path_ = { global: bool, idents: ~[~str], types: ~[@ty] }; type path = spanned; type ty = spanned; fn main() { let sp: span = {lo: 57451u, hi: 57542u, expanded_from: os_none}; let t: @ty = @{ data: 3u, span: sp }; - let p_: path_ = { global: true, idents: ~["hi"], types: ~[t] }; + let p_: path_ = { global: true, idents: ~[~"hi"], types: ~[t] }; let p: path = { data: p_, span: sp }; let x = { sp: sp, path: p }; log(error, x.path); diff --git a/src/test/run-pass/shebang.rs b/src/test/run-pass/shebang.rs index 5354dde74100..462546e24b8f 100644 --- a/src/test/run-pass/shebang.rs +++ b/src/test/run-pass/shebang.rs @@ -3,4 +3,4 @@ import io::println; -fn main() { io::println("Hello World"); } +fn main() { io::println(~"Hello World"); } diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs index 502b62e3a520..2f749ca82754 100644 --- a/src/test/run-pass/spawn-fn.rs +++ b/src/test/run-pass/spawn-fn.rs @@ -4,15 +4,15 @@ import task::yield; import task; -fn x(s: str, n: int) { +fn x(s: ~str, n: int) { log(debug, s); log(debug, n); } fn main() { - task::spawn(|| x("hello from first spawned fn", 65) ); - task::spawn(|| x("hello from second spawned fn", 66) ); - task::spawn(|| x("hello from third spawned fn", 67) ); + task::spawn(|| x(~"hello from first spawned fn", 65) ); + task::spawn(|| x(~"hello from second spawned fn", 66) ); + task::spawn(|| x(~"hello from third spawned fn", 67) ); let mut i: int = 30; while i > 0 { i = i - 1; #debug("parent sleeping"); yield(); } } diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index 420d6793a44d..58229d0e5da2 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -12,12 +12,12 @@ type ctx = comm::chan; -fn iotask(cx: ctx, ip: str) { - assert (str::eq(ip, "localhost")); +fn iotask(cx: ctx, ip: ~str) { + assert (str::eq(ip, ~"localhost")); } fn main() { let p = comm::port::(); let ch = comm::chan(p); - task::spawn(|| iotask(ch, "localhost") ); + task::spawn(|| iotask(ch, ~"localhost") ); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index fe0838727926..468002e0d5be 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -6,11 +6,11 @@ impl foo for uint { fn plus() -> int { self as int + 20 } } } mod b { - impl baz for str { fn plus() -> int { 200 } } + impl baz for ~str { fn plus() -> int { 200 } } } impl util for uint { - fn str() -> str { uint::str(self) } + fn str() -> ~str { uint::str(self) } fn multi(f: fn(uint)) { let mut c = 0u; while c < self { f(c); c += 1u; } @@ -31,9 +31,9 @@ fn main() { impl foo for int { fn plus() -> int { self + 10 } } assert 10.plus() == 20; assert 10u.plus() == 30; - assert "hi".plus() == 200; + assert (~"hi").plus() == 200; - assert (~[1]).length_().str() == "1"; + assert (~[1]).length_().str() == ~"1"; assert (~[3, 4]).map_(|a| a + 4 )[0] == 7; assert (~[3, 4]).map_::(|a| a as uint + 4u )[0] == 7u; let mut x = 0u; diff --git a/src/test/run-pass/str-append.rs b/src/test/run-pass/str-append.rs index 03cda225bf6f..b460c63fe43d 100644 --- a/src/test/run-pass/str-append.rs +++ b/src/test/run-pass/str-append.rs @@ -5,8 +5,8 @@ import str; fn test1() { - let mut s: str = "hello"; - s += "world"; + let mut s: ~str = ~"hello"; + s += ~"world"; log(debug, s); assert (s[9] == 'd' as u8); } @@ -14,13 +14,13 @@ fn test1() { fn test2() { // This tests for issue #163 - let ff: str = "abc"; - let a: str = ff + "ABC" + ff; - let b: str = "ABC" + ff + "ABC"; + let ff: ~str = ~"abc"; + let a: ~str = ff + ~"ABC" + ff; + let b: ~str = ~"ABC" + ff + ~"ABC"; log(debug, a); log(debug, b); - assert (str::eq(a, "abcABCabc")); - assert (str::eq(b, "ABCabcABC")); + assert (str::eq(a, ~"abcABCabc")); + assert (str::eq(b, ~"ABCabcABC")); } fn main() { test1(); test2(); } diff --git a/src/test/run-pass/str-concat.rs b/src/test/run-pass/str-concat.rs index 69d26469677c..daba08e7378d 100644 --- a/src/test/run-pass/str-concat.rs +++ b/src/test/run-pass/str-concat.rs @@ -3,9 +3,9 @@ // -*- rust -*- fn main() { - let a: str = "hello"; - let b: str = "world"; - let s: str = a + b; + let a: ~str = ~"hello"; + let b: ~str = ~"world"; + let s: ~str = a + b; log(debug, s); assert (s[9] == 'd' as u8); } diff --git a/src/test/run-pass/str-growth.rs b/src/test/run-pass/str-growth.rs index eca411a35aa1..fb17ef212b7a 100644 --- a/src/test/run-pass/str-growth.rs +++ b/src/test/run-pass/str-growth.rs @@ -1,12 +1,12 @@ fn main() { - let mut s = "a"; - s += "b"; + let mut s = ~"a"; + s += ~"b"; assert (s[0] == 'a' as u8); assert (s[1] == 'b' as u8); - s += "c"; - s += "d"; + s += ~"c"; + s += ~"d"; assert (s[0] == 'a' as u8); assert (s[1] == 'b' as u8); assert (s[2] == 'c' as u8); diff --git a/src/test/run-pass/str-idx.rs b/src/test/run-pass/str-idx.rs index ef7e2c71eaa4..5b81123ac947 100644 --- a/src/test/run-pass/str-idx.rs +++ b/src/test/run-pass/str-idx.rs @@ -1,7 +1,7 @@ fn main() { - let s = "hello"; + let s = ~"hello"; let c: u8 = s[4]; log(debug, c); assert (c == 0x6f as u8); diff --git a/src/test/run-pass/str-multiline.rs b/src/test/run-pass/str-multiline.rs index 6523ce47df30..e9f27b23debc 100644 --- a/src/test/run-pass/str-multiline.rs +++ b/src/test/run-pass/str-multiline.rs @@ -5,13 +5,13 @@ import str; fn main() { - let a: str = "this \ + let a: ~str = ~"this \ is a test"; - let b: str = - "this \ + let b: ~str = + ~"this \ is \ another \ test"; - assert (str::eq(a, "this is a test")); - assert (str::eq(b, "this is another test")); + assert (str::eq(a, ~"this is a test")); + assert (str::eq(b, ~"this is another test")); } diff --git a/src/test/run-pass/string-self-append.rs b/src/test/run-pass/string-self-append.rs index c293c8741e28..1c360bea3daf 100644 --- a/src/test/run-pass/string-self-append.rs +++ b/src/test/run-pass/string-self-append.rs @@ -3,7 +3,7 @@ fn main() { // Make sure we properly handle repeated self-appends. - let mut a: str = "A"; + let mut a: ~str = ~"A"; let mut i = 20; let mut expected_len = 1u; while i > 0 { diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs index 141523609a27..eee76140edea 100644 --- a/src/test/run-pass/syntax-extension-fmt.rs +++ b/src/test/run-pass/syntax-extension-fmt.rs @@ -1,17 +1,17 @@ use std; import str; -fn test(actual: str, expected: str) { +fn test(actual: ~str, expected: ~str) { log(debug, actual); log(debug, expected); assert (str::eq(actual, expected)); } fn main() { - test(#fmt["hello %d friends and %s things", 10, "formatted"], - "hello 10 friends and formatted things"); + test(#fmt["hello %d friends and %s things", 10, ~"formatted"], + ~"hello 10 friends and formatted things"); - test(#fmt["test"], "test"); + test(#fmt["test"], ~"test"); // a quadratic optimization in LLVM (jump-threading) makes this test a // bit slow to compile unless we break it up @@ -28,224 +28,224 @@ fn main() { fn part1() { // Simple tests for types - test(#fmt["%d", 1], "1"); - test(#fmt["%i", 2], "2"); - test(#fmt["%i", -1], "-1"); - test(#fmt["%u", 10u], "10"); - test(#fmt["%s", "test"], "test"); - test(#fmt["%b", true], "true"); - test(#fmt["%b", false], "false"); - test(#fmt["%c", 'A'], "A"); - test(#fmt["%x", 0xff_u], "ff"); - test(#fmt["%X", 0x12ab_u], "12AB"); - test(#fmt["%o", 10u], "12"); - test(#fmt["%t", 0b11010101_u], "11010101"); - test(#fmt["%f", 5.82], "5.82"); + test(#fmt["%d", 1], ~"1"); + test(#fmt["%i", 2], ~"2"); + test(#fmt["%i", -1], ~"-1"); + test(#fmt["%u", 10u], ~"10"); + test(#fmt["%s", ~"test"], ~"test"); + test(#fmt["%b", true], ~"true"); + test(#fmt["%b", false], ~"false"); + test(#fmt["%c", 'A'], ~"A"); + test(#fmt["%x", 0xff_u], ~"ff"); + test(#fmt["%X", 0x12ab_u], ~"12AB"); + test(#fmt["%o", 10u], ~"12"); + test(#fmt["%t", 0b11010101_u], ~"11010101"); + test(#fmt["%f", 5.82], ~"5.82"); // 32-bit limits - test(#fmt["%i", -2147483648], "-2147483648"); - test(#fmt["%i", 2147483647], "2147483647"); - test(#fmt["%u", 4294967295u], "4294967295"); - test(#fmt["%x", 0xffffffff_u], "ffffffff"); - test(#fmt["%o", 0xffffffff_u], "37777777777"); - test(#fmt["%t", 0xffffffff_u], "11111111111111111111111111111111"); + test(#fmt["%i", -2147483648], ~"-2147483648"); + test(#fmt["%i", 2147483647], ~"2147483647"); + test(#fmt["%u", 4294967295u], ~"4294967295"); + test(#fmt["%x", 0xffffffff_u], ~"ffffffff"); + test(#fmt["%o", 0xffffffff_u], ~"37777777777"); + test(#fmt["%t", 0xffffffff_u], ~"11111111111111111111111111111111"); } fn part2() { // Widths - test(#fmt["%1d", 500], "500"); - test(#fmt["%10d", 500], " 500"); - test(#fmt["%10d", -500], " -500"); - test(#fmt["%10u", 500u], " 500"); - test(#fmt["%10s", "test"], " test"); - test(#fmt["%10b", true], " true"); - test(#fmt["%10x", 0xff_u], " ff"); - test(#fmt["%10X", 0xff_u], " FF"); - test(#fmt["%10o", 10u], " 12"); - test(#fmt["%10t", 0xff_u], " 11111111"); - test(#fmt["%10c", 'A'], " A"); - test(#fmt["%10f", 5.82], " 5.82"); + test(#fmt["%1d", 500], ~"500"); + test(#fmt["%10d", 500], ~" 500"); + test(#fmt["%10d", -500], ~" -500"); + test(#fmt["%10u", 500u], ~" 500"); + test(#fmt["%10s", ~"test"], ~" test"); + test(#fmt["%10b", true], ~" true"); + test(#fmt["%10x", 0xff_u], ~" ff"); + test(#fmt["%10X", 0xff_u], ~" FF"); + test(#fmt["%10o", 10u], ~" 12"); + test(#fmt["%10t", 0xff_u], ~" 11111111"); + test(#fmt["%10c", 'A'], ~" A"); + test(#fmt["%10f", 5.82], ~" 5.82"); // Left justify - test(#fmt["%-10d", 500], "500 "); - test(#fmt["%-10d", -500], "-500 "); - test(#fmt["%-10u", 500u], "500 "); - test(#fmt["%-10s", "test"], "test "); - test(#fmt["%-10b", true], "true "); - test(#fmt["%-10x", 0xff_u], "ff "); - test(#fmt["%-10X", 0xff_u], "FF "); - test(#fmt["%-10o", 10u], "12 "); - test(#fmt["%-10t", 0xff_u], "11111111 "); - test(#fmt["%-10c", 'A'], "A "); - test(#fmt["%-10f", 5.82], "5.82 "); + test(#fmt["%-10d", 500], ~"500 "); + test(#fmt["%-10d", -500], ~"-500 "); + test(#fmt["%-10u", 500u], ~"500 "); + test(#fmt["%-10s", ~"test"], ~"test "); + test(#fmt["%-10b", true], ~"true "); + test(#fmt["%-10x", 0xff_u], ~"ff "); + test(#fmt["%-10X", 0xff_u], ~"FF "); + test(#fmt["%-10o", 10u], ~"12 "); + test(#fmt["%-10t", 0xff_u], ~"11111111 "); + test(#fmt["%-10c", 'A'], ~"A "); + test(#fmt["%-10f", 5.82], ~"5.82 "); } fn part3() { // Precision - test(#fmt["%.d", 0], ""); - test(#fmt["%.u", 0u], ""); - test(#fmt["%.x", 0u], ""); - test(#fmt["%.t", 0u], ""); - test(#fmt["%.d", 10], "10"); - test(#fmt["%.d", -10], "-10"); - test(#fmt["%.u", 10u], "10"); - test(#fmt["%.s", "test"], ""); - test(#fmt["%.x", 127u], "7f"); - test(#fmt["%.o", 10u], "12"); - test(#fmt["%.t", 3u], "11"); - test(#fmt["%.c", 'A'], "A"); - test(#fmt["%.f", 5.82], "6"); - test(#fmt["%.0d", 0], ""); - test(#fmt["%.0u", 0u], ""); - test(#fmt["%.0x", 0u], ""); - test(#fmt["%.0t", 0u], ""); - test(#fmt["%.0d", 10], "10"); - test(#fmt["%.0d", -10], "-10"); - test(#fmt["%.0u", 10u], "10"); - test(#fmt["%.0s", "test"], ""); - test(#fmt["%.0x", 127u], "7f"); - test(#fmt["%.0o", 10u], "12"); - test(#fmt["%.0t", 3u], "11"); - test(#fmt["%.0c", 'A'], "A"); - test(#fmt["%.0f", 5.892], "6"); - test(#fmt["%.1d", 0], "0"); - test(#fmt["%.1u", 0u], "0"); - test(#fmt["%.1x", 0u], "0"); - test(#fmt["%.1t", 0u], "0"); - test(#fmt["%.1d", 10], "10"); - test(#fmt["%.1d", -10], "-10"); - test(#fmt["%.1u", 10u], "10"); - test(#fmt["%.1s", "test"], "t"); - test(#fmt["%.1x", 127u], "7f"); - test(#fmt["%.1o", 10u], "12"); - test(#fmt["%.1t", 3u], "11"); - test(#fmt["%.1c", 'A'], "A"); - test(#fmt["%.1f", 5.82], "5.8"); + test(#fmt["%.d", 0], ~""); + test(#fmt["%.u", 0u], ~""); + test(#fmt["%.x", 0u], ~""); + test(#fmt["%.t", 0u], ~""); + test(#fmt["%.d", 10], ~"10"); + test(#fmt["%.d", -10], ~"-10"); + test(#fmt["%.u", 10u], ~"10"); + test(#fmt["%.s", ~"test"], ~""); + test(#fmt["%.x", 127u], ~"7f"); + test(#fmt["%.o", 10u], ~"12"); + test(#fmt["%.t", 3u], ~"11"); + test(#fmt["%.c", 'A'], ~"A"); + test(#fmt["%.f", 5.82], ~"6"); + test(#fmt["%.0d", 0], ~""); + test(#fmt["%.0u", 0u], ~""); + test(#fmt["%.0x", 0u], ~""); + test(#fmt["%.0t", 0u], ~""); + test(#fmt["%.0d", 10], ~"10"); + test(#fmt["%.0d", -10], ~"-10"); + test(#fmt["%.0u", 10u], ~"10"); + test(#fmt["%.0s", ~"test"], ~""); + test(#fmt["%.0x", 127u], ~"7f"); + test(#fmt["%.0o", 10u], ~"12"); + test(#fmt["%.0t", 3u], ~"11"); + test(#fmt["%.0c", 'A'], ~"A"); + test(#fmt["%.0f", 5.892], ~"6"); + test(#fmt["%.1d", 0], ~"0"); + test(#fmt["%.1u", 0u], ~"0"); + test(#fmt["%.1x", 0u], ~"0"); + test(#fmt["%.1t", 0u], ~"0"); + test(#fmt["%.1d", 10], ~"10"); + test(#fmt["%.1d", -10], ~"-10"); + test(#fmt["%.1u", 10u], ~"10"); + test(#fmt["%.1s", ~"test"], ~"t"); + test(#fmt["%.1x", 127u], ~"7f"); + test(#fmt["%.1o", 10u], ~"12"); + test(#fmt["%.1t", 3u], ~"11"); + test(#fmt["%.1c", 'A'], ~"A"); + test(#fmt["%.1f", 5.82], ~"5.8"); } fn part4() { - test(#fmt["%.5d", 0], "00000"); - test(#fmt["%.5u", 0u], "00000"); - test(#fmt["%.5x", 0u], "00000"); - test(#fmt["%.5t", 0u], "00000"); - test(#fmt["%.5d", 10], "00010"); - test(#fmt["%.5d", -10], "-00010"); - test(#fmt["%.5u", 10u], "00010"); - test(#fmt["%.5s", "test"], "test"); - test(#fmt["%.5x", 127u], "0007f"); - test(#fmt["%.5o", 10u], "00012"); - test(#fmt["%.5t", 3u], "00011"); - test(#fmt["%.5c", 'A'], "A"); - test(#fmt["%.5f", 5.82], "5.82000"); - test(#fmt["%.5f", 5.0], "5.00000"); + test(#fmt["%.5d", 0], ~"00000"); + test(#fmt["%.5u", 0u], ~"00000"); + test(#fmt["%.5x", 0u], ~"00000"); + test(#fmt["%.5t", 0u], ~"00000"); + test(#fmt["%.5d", 10], ~"00010"); + test(#fmt["%.5d", -10], ~"-00010"); + test(#fmt["%.5u", 10u], ~"00010"); + test(#fmt["%.5s", ~"test"], ~"test"); + test(#fmt["%.5x", 127u], ~"0007f"); + test(#fmt["%.5o", 10u], ~"00012"); + test(#fmt["%.5t", 3u], ~"00011"); + test(#fmt["%.5c", 'A'], ~"A"); + test(#fmt["%.5f", 5.82], ~"5.82000"); + test(#fmt["%.5f", 5.0], ~"5.00000"); // Bool precision. I'm not sure if it's good or bad to have bool // conversions support precision - it's not standard printf so we // can do whatever. For now I'm making it behave the same as string // conversions. - test(#fmt["%.b", true], ""); - test(#fmt["%.0b", true], ""); - test(#fmt["%.1b", true], "t"); + test(#fmt["%.b", true], ~""); + test(#fmt["%.0b", true], ~""); + test(#fmt["%.1b", true], ~"t"); } fn part5() { // Explicit + sign. Only for signed conversions - test(#fmt["%+d", 0], "+0"); - test(#fmt["%+d", 1], "+1"); - test(#fmt["%+d", -1], "-1"); - test(#fmt["%+f", 0.0], "+0"); + test(#fmt["%+d", 0], ~"+0"); + test(#fmt["%+d", 1], ~"+1"); + test(#fmt["%+d", -1], ~"-1"); + test(#fmt["%+f", 0.0], ~"+0"); // Leave space for sign - test(#fmt["% d", 0], " 0"); - test(#fmt["% d", 1], " 1"); - test(#fmt["% d", -1], "-1"); - test(#fmt["% f", 0.0], " 0"); + test(#fmt["% d", 0], ~" 0"); + test(#fmt["% d", 1], ~" 1"); + test(#fmt["% d", -1], ~"-1"); + test(#fmt["% f", 0.0], ~" 0"); // Plus overrides space - test(#fmt["% +d", 0], "+0"); - test(#fmt["%+ d", 0], "+0"); - test(#fmt["% +f", 0.0], "+0"); - test(#fmt["%+ f", 0.0], "+0"); + test(#fmt["% +d", 0], ~"+0"); + test(#fmt["%+ d", 0], ~"+0"); + test(#fmt["% +f", 0.0], ~"+0"); + test(#fmt["%+ f", 0.0], ~"+0"); // 0-padding - test(#fmt["%05d", 0], "00000"); - test(#fmt["%05d", 1], "00001"); - test(#fmt["%05d", -1], "-0001"); - test(#fmt["%05u", 1u], "00001"); - test(#fmt["%05x", 127u], "0007f"); - test(#fmt["%05X", 127u], "0007F"); - test(#fmt["%05o", 10u], "00012"); - test(#fmt["%05t", 3u], "00011"); - test(#fmt["%05f", 5.82], "05.82"); + test(#fmt["%05d", 0], ~"00000"); + test(#fmt["%05d", 1], ~"00001"); + test(#fmt["%05d", -1], ~"-0001"); + test(#fmt["%05u", 1u], ~"00001"); + test(#fmt["%05x", 127u], ~"0007f"); + test(#fmt["%05X", 127u], ~"0007F"); + test(#fmt["%05o", 10u], ~"00012"); + test(#fmt["%05t", 3u], ~"00011"); + test(#fmt["%05f", 5.82], ~"05.82"); // 0-padding a string is undefined but glibc does this: - test(#fmt["%05s", "test"], " test"); - test(#fmt["%05c", 'A'], " A"); - test(#fmt["%05b", true], " true"); + test(#fmt["%05s", ~"test"], ~" test"); + test(#fmt["%05c", 'A'], ~" A"); + test(#fmt["%05b", true], ~" true"); // Left-justify overrides 0-padding - test(#fmt["%-05d", 0], "0 "); - test(#fmt["%-05d", 1], "1 "); - test(#fmt["%-05d", -1], "-1 "); - test(#fmt["%-05u", 1u], "1 "); - test(#fmt["%-05x", 127u], "7f "); - test(#fmt["%-05X", 127u], "7F "); - test(#fmt["%-05o", 10u], "12 "); - test(#fmt["%-05t", 3u], "11 "); - test(#fmt["%-05s", "test"], "test "); - test(#fmt["%-05c", 'A'], "A "); - test(#fmt["%-05b", true], "true "); - test(#fmt["%-05f", 5.82], "5.82 "); + test(#fmt["%-05d", 0], ~"0 "); + test(#fmt["%-05d", 1], ~"1 "); + test(#fmt["%-05d", -1], ~"-1 "); + test(#fmt["%-05u", 1u], ~"1 "); + test(#fmt["%-05x", 127u], ~"7f "); + test(#fmt["%-05X", 127u], ~"7F "); + test(#fmt["%-05o", 10u], ~"12 "); + test(#fmt["%-05t", 3u], ~"11 "); + test(#fmt["%-05s", ~"test"], ~"test "); + test(#fmt["%-05c", 'A'], ~"A "); + test(#fmt["%-05b", true], ~"true "); + test(#fmt["%-05f", 5.82], ~"5.82 "); } fn part6() { // Precision overrides 0-padding // FIXME #2481: Recent gcc's report some of these as warnings - test(#fmt["%06.5d", 0], " 00000"); - test(#fmt["%06.5u", 0u], " 00000"); - test(#fmt["%06.5x", 0u], " 00000"); - test(#fmt["%06.5d", 10], " 00010"); - test(#fmt["%06.5d", -10], "-00010"); - test(#fmt["%06.5u", 10u], " 00010"); - test(#fmt["%06.5s", "test"], " test"); - test(#fmt["%06.5c", 'A'], " A"); - test(#fmt["%06.5x", 127u], " 0007f"); - test(#fmt["%06.5X", 127u], " 0007F"); - test(#fmt["%06.5o", 10u], " 00012"); + test(#fmt["%06.5d", 0], ~" 00000"); + test(#fmt["%06.5u", 0u], ~" 00000"); + test(#fmt["%06.5x", 0u], ~" 00000"); + test(#fmt["%06.5d", 10], ~" 00010"); + test(#fmt["%06.5d", -10], ~"-00010"); + test(#fmt["%06.5u", 10u], ~" 00010"); + test(#fmt["%06.5s", ~"test"], ~" test"); + test(#fmt["%06.5c", 'A'], ~" A"); + test(#fmt["%06.5x", 127u], ~" 0007f"); + test(#fmt["%06.5X", 127u], ~" 0007F"); + test(#fmt["%06.5o", 10u], ~" 00012"); // Precision does not override zero-padding for floats - test(#fmt["%08.5f", 5.82], "05.82000"); + test(#fmt["%08.5f", 5.82], ~"05.82000"); // Signed combinations - test(#fmt["% 5d", 1], " 1"); - test(#fmt["% 5d", -1], " -1"); - test(#fmt["%+5d", 1], " +1"); - test(#fmt["%+5d", -1], " -1"); - test(#fmt["% 05d", 1], " 0001"); - test(#fmt["% 05d", -1], "-0001"); - test(#fmt["%+05d", 1], "+0001"); - test(#fmt["%+05d", -1], "-0001"); - test(#fmt["%- 5d", 1], " 1 "); - test(#fmt["%- 5d", -1], "-1 "); - test(#fmt["%-+5d", 1], "+1 "); - test(#fmt["%-+5d", -1], "-1 "); - test(#fmt["%- 05d", 1], " 1 "); - test(#fmt["%- 05d", -1], "-1 "); - test(#fmt["%-+05d", 1], "+1 "); - test(#fmt["%-+05d", -1], "-1 "); + test(#fmt["% 5d", 1], ~" 1"); + test(#fmt["% 5d", -1], ~" -1"); + test(#fmt["%+5d", 1], ~" +1"); + test(#fmt["%+5d", -1], ~" -1"); + test(#fmt["% 05d", 1], ~" 0001"); + test(#fmt["% 05d", -1], ~"-0001"); + test(#fmt["%+05d", 1], ~"+0001"); + test(#fmt["%+05d", -1], ~"-0001"); + test(#fmt["%- 5d", 1], ~" 1 "); + test(#fmt["%- 5d", -1], ~"-1 "); + test(#fmt["%-+5d", 1], ~"+1 "); + test(#fmt["%-+5d", -1], ~"-1 "); + test(#fmt["%- 05d", 1], ~" 1 "); + test(#fmt["%- 05d", -1], ~"-1 "); + test(#fmt["%-+05d", 1], ~"+1 "); + test(#fmt["%-+05d", -1], ~"-1 "); } fn percent() { let s = #fmt["ab%%cd"]; - assert(s == "ab%cd"); + assert(s == ~"ab%cd"); } fn more_floats() { - assert "3.1416" == #fmt["%.4f", 3.14159]; - assert "3" == #fmt["%.0f", 3.14159]; - assert "99" == #fmt["%.0f", 98.5]; - assert "7.0000" == #fmt["%.4f", 6.999999999]; - assert "3.141590000" == #fmt["%.9f", 3.14159]; + assert ~"3.1416" == #fmt["%.4f", 3.14159]; + assert ~"3" == #fmt["%.0f", 3.14159]; + assert ~"99" == #fmt["%.0f", 98.5]; + assert ~"7.0000" == #fmt["%.4f", 6.999999999]; + assert ~"3.141590000" == #fmt["%.9f", 3.14159]; } \ No newline at end of file diff --git a/src/test/run-pass/syntax-extension-minor.rs b/src/test/run-pass/syntax-extension-minor.rs index 509399975234..346a85ada0e6 100644 --- a/src/test/run-pass/syntax-extension-minor.rs +++ b/src/test/run-pass/syntax-extension-minor.rs @@ -1,8 +1,8 @@ fn main() { - let asdf_fdsa = "<.<"; - assert (#concat_idents[asd, f_f, dsa] == "<.<"); + let asdf_fdsa = ~"<.<"; + assert (#concat_idents[asd, f_f, dsa] == ~"<.<"); assert (#ident_to_str[use_mention_distinction] == - "use_mention_distinction"); + ~"use_mention_distinction"); } diff --git a/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment b/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment index 5db5b0f6ff5c..0d355518bfbe 100644 --- a/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment +++ b/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment @@ -1,7 +1,7 @@ /* this is for run-pass/syntax-extension-source-utils.rs */ { - assert(#file[].ends_with("utils-files/includeme.fragment")); + assert(#file[].ends_with(~"utils-files/includeme.fragment")); assert(#line[] == 5u); #fmt["victory robot %u", #line[]] -} \ No newline at end of file +} diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index 29bd6e65f4f0..1ed41491fc34 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -3,24 +3,24 @@ mod m1 { mod m2 { - fn where_am_i() -> str { #mod[] } + fn where_am_i() -> ~str { #mod[] } } } fn main() { assert(#line[] == 11u); assert(#col[] == 11u); - assert(#file[].ends_with("syntax-extension-source-utils.rs")); - assert(#stringify[(2*3) + 5] == "2 * 3 + 5"); + assert(#file[].ends_with(~"syntax-extension-source-utils.rs")); + assert(#stringify[(2*3) + 5] == ~"2 * 3 + 5"); assert(#include["syntax-extension-source-utils-files/includeme.fragment"] - == "victory robot 6"); + == ~"victory robot 6"); + assert( #include_str["syntax-extension-source-utils-files/includeme.fragment"] - .starts_with("/* this is for ")); + .starts_with(~"/* this is for ")); assert( #include_bin["syntax-extension-source-utils-files/includeme.fragment"] [1] == (42 as u8)); // '*' // The Windows tests are wrapped in an extra module for some reason - assert(m1::m2::where_am_i().ends_with("m1::m2")); - + assert(m1::m2::where_am_i().ends_with(~"m1::m2")); } diff --git a/src/test/run-pass/tag-in-block.rs b/src/test/run-pass/tag-in-block.rs index 9107249b2b0f..f529a8d96ae9 100644 --- a/src/test/run-pass/tag-in-block.rs +++ b/src/test/run-pass/tag-in-block.rs @@ -6,4 +6,4 @@ enum bar { nil, } fn baz() { zed(nil); } } -fn main(args: ~[str]) { } +fn main(args: ~[~str]) { } diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index c33b167128a6..45c2c2ef94db 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -10,17 +10,17 @@ enum color { } fn main() { - test_color(red, 0xff0000, "red"); - test_color(green, 0x00ff00, "green"); - test_color(blue, 0x0000ff, "blue"); - test_color(black, 0x000000, "black"); - test_color(white, 0xFFFFFF, "white"); - test_color(imaginary, -1, "imaginary"); - test_color(purple, 2, "purple"); - test_color(orange, 4, "orange"); + test_color(red, 0xff0000, ~"red"); + test_color(green, 0x00ff00, ~"green"); + test_color(blue, 0x0000ff, ~"blue"); + test_color(black, 0x000000, ~"black"); + test_color(white, 0xFFFFFF, ~"white"); + test_color(imaginary, -1, ~"imaginary"); + test_color(purple, 2, ~"purple"); + test_color(orange, 4, ~"orange"); } -fn test_color(color: color, val: int, name: str) unsafe { +fn test_color(color: color, val: int, name: ~str) unsafe { //assert unsafe::reinterpret_cast(color) == val; assert color as int == val; assert color as float == val as float; @@ -28,29 +28,29 @@ fn test_color(color: color, val: int, name: str) unsafe { assert get_color_if(color) == name; } -fn get_color_alt(color: color) -> str { +fn get_color_alt(color: color) -> ~str { alt color { - red {"red"} - green {"green"} - blue {"blue"} - black {"black"} - white {"white"} - imaginary {"imaginary"} - purple {"purple"} - orange {"orange"} + red {~"red"} + green {~"green"} + blue {~"blue"} + black {~"black"} + white {~"white"} + imaginary {~"imaginary"} + purple {~"purple"} + orange {~"orange"} } } -fn get_color_if(color: color) -> str { - if color == red {"red"} - else if color == green {"green"} - else if color == blue {"blue"} - else if color == black {"black"} - else if color == white {"white"} - else if color == imaginary {"imaginary"} - else if color == purple {"purple"} - else if color == orange {"orange"} - else {"unknown"} +fn get_color_if(color: color) -> ~str { + if color == red {~"red"} + else if color == green {~"green"} + else if color == blue {~"blue"} + else if color == black {~"black"} + else if color == white {~"white"} + else if color == imaginary {~"imaginary"} + else if color == purple {~"purple"} + else if color == orange {~"orange"} + else {~"unknown"} } diff --git a/src/test/run-pass/tail-call-arg-leak.rs b/src/test/run-pass/tail-call-arg-leak.rs index 269fa53211d0..9b9631867e28 100644 --- a/src/test/run-pass/tail-call-arg-leak.rs +++ b/src/test/run-pass/tail-call-arg-leak.rs @@ -2,6 +2,6 @@ // use of tail calls causes arg slot leaks, issue #160. -fn inner(dummy: str, b: bool) { if b { ret inner(dummy, false); } } +fn inner(dummy: ~str, b: bool) { if b { ret inner(dummy, false); } } -fn main() { inner("hi", true); } +fn main() { inner(~"hi", true); } diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs index 90ad35631520..1d0963a29dca 100644 --- a/src/test/run-pass/task-comm-10.rs +++ b/src/test/run-pass/task-comm-10.rs @@ -2,17 +2,17 @@ import task; import comm; -fn start(c: comm::chan>) { +fn start(c: comm::chan>) { let p = comm::port(); comm::send(c, comm::chan(p)); let mut a; let mut b; a = comm::recv(p); - assert a == "A"; + assert a == ~"A"; log(error, a); b = comm::recv(p); - assert b == "B"; + assert b == ~"B"; log(error, b); } @@ -22,7 +22,7 @@ fn main() { let child = task::spawn(|| start(ch) ); let c = comm::recv(p); - comm::send(c, "A"); - comm::send(c, "B"); + comm::send(c, ~"A"); + comm::send(c, ~"B"); task::yield(); } diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index 009661acedbb..bc46de64cd72 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -36,7 +36,7 @@ fn test_vec() { fn test_str() { let po = port(); let ch = chan(po); - let s0 = "test"; + let s0 = ~"test"; send(ch, s0); let s1 = recv(po); assert (s1[0] == 't' as u8); diff --git a/src/test/run-pass/task-comm-chan-cleanup.rs b/src/test/run-pass/task-comm-chan-cleanup.rs index 32756ce494ba..39c3eefd7748 100644 --- a/src/test/run-pass/task-comm-chan-cleanup.rs +++ b/src/test/run-pass/task-comm-chan-cleanup.rs @@ -4,5 +4,5 @@ fn main() { let p = comm::port(); let c = comm::chan(p); - comm::send(c, "coffee"); + comm::send(c, ~"coffee"); } \ No newline at end of file diff --git a/src/test/run-pass/task-comm-chan-cleanup3.rs b/src/test/run-pass/task-comm-chan-cleanup3.rs index 79c32e5f1fd7..a153d4a8e5d2 100644 --- a/src/test/run-pass/task-comm-chan-cleanup3.rs +++ b/src/test/run-pass/task-comm-chan-cleanup3.rs @@ -6,5 +6,5 @@ fn main() { let p = comm::port(); comm::chan(p) }; - comm::send(c, "coffee"); + comm::send(c, ~"coffee"); } \ No newline at end of file diff --git a/src/test/run-pass/task-comm-chan-cleanup4.rs b/src/test/run-pass/task-comm-chan-cleanup4.rs index 65c6ab79ce80..e5e6ed08fc73 100644 --- a/src/test/run-pass/task-comm-chan-cleanup4.rs +++ b/src/test/run-pass/task-comm-chan-cleanup4.rs @@ -6,9 +6,9 @@ // We're trying to trigger a race between send and port destruction that // results in the string not being freed -fn starship(&&ch: comm::chan) { +fn starship(&&ch: comm::chan<~str>) { for int::range(0, 10) |_i| { - comm::send(ch, "pew pew"); + comm::send(ch, ~"pew pew"); } } diff --git a/src/test/run-pass/task-life-0.rs b/src/test/run-pass/task-life-0.rs index 2232bff1bc71..12fddc294dc2 100644 --- a/src/test/run-pass/task-life-0.rs +++ b/src/test/run-pass/task-life-0.rs @@ -1,9 +1,9 @@ use std; import task; fn main() { - task::spawn(|| child("Hello") ); + task::spawn(|| child(~"Hello") ); } -fn child(&&s: str) { +fn child(&&s: ~str) { } diff --git a/src/test/run-pass/test-ignore-cfg.rs b/src/test/run-pass/test-ignore-cfg.rs index 0aad5bd13d3c..49fc6e88ec46 100644 --- a/src/test/run-pass/test-ignore-cfg.rs +++ b/src/test/run-pass/test-ignore-cfg.rs @@ -22,10 +22,10 @@ fn checktests() { let tests = __test::tests(); let shouldignore = option::get( - vec::find(tests, |t| t.name == "shouldignore" )); + vec::find(tests, |t| t.name == ~"shouldignore" )); assert shouldignore.ignore == true; let shouldnotignore = option::get( - vec::find(tests, |t| t.name == "shouldnotignore" )); + vec::find(tests, |t| t.name == ~"shouldnotignore" )); assert shouldnotignore.ignore == false; } \ No newline at end of file diff --git a/src/test/run-pass/type-param.rs b/src/test/run-pass/type-param.rs index a2afde8d73f3..525891fc1c3e 100644 --- a/src/test/run-pass/type-param.rs +++ b/src/test/run-pass/type-param.rs @@ -2,4 +2,4 @@ type lteq = extern fn(T) -> bool; -fn main(args: ~[str]) { } +fn main(args: ~[~str]) { } diff --git a/src/test/run-pass/type-ptr.rs b/src/test/run-pass/type-ptr.rs index f469ebd3dd0b..dd572d8655ca 100644 --- a/src/test/run-pass/type-ptr.rs +++ b/src/test/run-pass/type-ptr.rs @@ -2,4 +2,4 @@ fn g(a: *int) -> *int { let b = f(a); ret b; } -fn main(args: ~[str]) { ret; } +fn main(args: ~[~str]) { ret; } diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs index cd05e2175468..d72c8f82cba6 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -15,7 +15,7 @@ fn make_uniq_closure(a: A) -> fn~() -> uint { fn empty_pointy() -> @pointy { ret @{ mut a : none, - d : make_uniq_closure("hi") + d : make_uniq_closure(~"hi") } } diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index 43d894ed3acc..4ed8aba84474 100644 --- a/src/test/run-pass/unique-autoderef-index.rs +++ b/src/test/run-pass/unique-autoderef-index.rs @@ -1,4 +1,4 @@ fn main() { - let i = ~[100]/~; + let i = ~~[100]; assert i[0] == 100; -} \ No newline at end of file +} diff --git a/src/test/run-pass/unique-drop-complex.rs b/src/test/run-pass/unique-drop-complex.rs index 6ae3224ccfcb..72a09f5dddea 100644 --- a/src/test/run-pass/unique-drop-complex.rs +++ b/src/test/run-pass/unique-drop-complex.rs @@ -1,3 +1,3 @@ fn main() { - let x = ~[0,0,0,0,0]/~; -} \ No newline at end of file + let x = ~~[0,0,0,0,0]; +} diff --git a/src/test/run-pass/utf8.rs b/src/test/run-pass/utf8.rs index c18133f7051c..5b81e84fe124 100644 --- a/src/test/run-pass/utf8.rs +++ b/src/test/run-pass/utf8.rs @@ -14,22 +14,22 @@ fn main() { assert (pi as int == '\u03a0' as int); assert ('\x0a' as int == '\n' as int); - let bhutan: str = "འབྲུག་ཡུལ།"; - let japan: str = "日本"; - let uzbekistan: str = "Ўзбекистон"; - let austria: str = "Österreich"; + let bhutan: ~str = ~"འབྲུག་ཡུལ།"; + let japan: ~str = ~"日本"; + let uzbekistan: ~str = ~"Ўзбекистон"; + let austria: ~str = ~"Österreich"; - let bhutan_e: str = - "\u0f60\u0f56\u0fb2\u0f74\u0f42\u0f0b\u0f61\u0f74\u0f63\u0f0d"; - let japan_e: str = "\u65e5\u672c"; - let uzbekistan_e: str = - "\u040e\u0437\u0431\u0435\u043a\u0438\u0441\u0442\u043e\u043d"; - let austria_e: str = "\u00d6sterreich"; + let bhutan_e: ~str = + ~"\u0f60\u0f56\u0fb2\u0f74\u0f42\u0f0b\u0f61\u0f74\u0f63\u0f0d"; + let japan_e: ~str = ~"\u65e5\u672c"; + let uzbekistan_e: ~str = + ~"\u040e\u0437\u0431\u0435\u043a\u0438\u0441\u0442\u043e\u043d"; + let austria_e: ~str = ~"\u00d6sterreich"; let oo: char = 'Ö'; assert (oo as int == 0xd6); - fn check_str_eq(a: str, b: str) { + fn check_str_eq(a: ~str, b: ~str) { let mut i: int = 0; for str::each(a) |ab| { log(debug, i); diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index ad7bc8fe2dc0..fa89765c9d9e 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -5,7 +5,7 @@ fn main() { // Chars of 1, 2, 3, and 4 bytes let chs: ~[char] = ~['e', 'é', '€', 0x10000 as char]; - let s: str = str::from_chars(chs); + let s: ~str = str::from_chars(chs); assert (str::len(s) == 10u); assert (str::char_len(s) == 4u); @@ -19,13 +19,13 @@ fn main() { assert (!str::is_utf8(~[0xc0_u8])); assert (!str::is_utf8(~[0xc0_u8, 0x10_u8])); - let mut stack = "a×c€"; + let mut stack = ~"a×c€"; assert (str::pop_char(stack) == '€'); assert (str::pop_char(stack) == 'c'); str::push_char(stack, 'u'); - assert (str::eq(stack, "a×u")); + assert (str::eq(stack, ~"a×u")); assert (str::shift_char(stack) == 'a'); assert (str::shift_char(stack) == '×'); str::unshift_char(stack, 'ß'); - assert (str::eq(stack, "ßu")); + assert (str::eq(stack, ~"ßu")); } diff --git a/src/test/run-pass/variant-attributes.rs b/src/test/run-pass/variant-attributes.rs index 45d79c835325..cbdf650d60e3 100644 --- a/src/test/run-pass/variant-attributes.rs +++ b/src/test/run-pass/variant-attributes.rs @@ -24,6 +24,6 @@ enum crew_of_enterprise_d { geordi_la_forge, } -fn boldly_go(_crew_member: crew_of_enterprise_d, _where: str) { } +fn boldly_go(_crew_member: crew_of_enterprise_d, _where: ~str) { } -fn main() { boldly_go(worf, "where no one has gone before"); } +fn main() { boldly_go(worf, ~"where no one has gone before"); } diff --git a/src/test/run-pass/while-prelude-drop.rs b/src/test/run-pass/while-prelude-drop.rs index 9e4a2a170b7f..dcc19b8ca20e 100644 --- a/src/test/run-pass/while-prelude-drop.rs +++ b/src/test/run-pass/while-prelude-drop.rs @@ -1,12 +1,12 @@ -enum t { a, b(str), } +enum t { a, b(~str), } fn make(i: int) -> t { if i > 10 { ret a; } - let mut s = "hello"; + let mut s = ~"hello"; // Ensure s is non-const. - s += "there"; + s += ~"there"; ret b(s); }