1
Fork 0

Get rid of all of the remaining /~s in the code base.

This commit is contained in:
Michael Sullivan 2012-07-11 16:49:02 -07:00
parent 46fba10fe8
commit 1c62f5ff74
17 changed files with 68 additions and 70 deletions

View file

@ -30,8 +30,6 @@ for t in os.listdir(run_pass):
"xfail-fast" in s or
"xfail-win32" in s):
stage2_tests.append(t)
if "main(args: [str]/~)" in s:
take_args[t] = True
if "main(args: [str])" in s:
take_args[t] = True
if "main(args: ~[str])" in s:

View file

@ -32,7 +32,7 @@ export unwrap;
* # WARNING
*
* For maximum performance, this type is implemented using some rather
* unsafe code. In particular, this innocent looking `[mut A]/~` pointer
* unsafe code. In particular, this innocent looking `~[mut A]` pointer
* *may be null!* Therefore, it is important you not reach into the
* data structure manually but instead use the provided extensions.
*

View file

@ -236,7 +236,7 @@ fn to_str(num: float, digits: uint) -> str {
* # Return value
*
* `none` if the string did not represent a valid number. Otherwise,
* `some(n)` where `n` is the floating-point number represented by `[num]/~`.
* `some(n)` where `n` is the floating-point number represented by `[num]`.
*/
fn from_str(num: str) -> option<float> {
if num == "inf" {
@ -261,7 +261,7 @@ fn from_str(num: str) -> option<float> {
_ { ret none; }
}
//Determine if first char is '-'/'+'. Set ~[pos] and ~[neg] accordingly.
//Determine if first char is '-'/'+'. Set [pos] and [neg] accordingly.
let mut neg = false; //Sign of the result
alt str::char_at(num, 0u) {
'-' {

View file

@ -247,8 +247,8 @@ impl extensions<T:copy, E:copy> for result<T,E> {
* if x == uint::max_value { ret err("overflow"); }
* else { ret ok(x+1u); }
* }
* map([1u, 2u, 3u]/~, inc_conditionally).chain {|incd|
* assert incd == [2u, 3u, 4u]/~;
* map(~[1u, 2u, 3u], inc_conditionally).chain {|incd|
* assert incd == ~[2u, 3u, 4u];
* }
*/
fn map_vec<T,U:copy,V:copy>(

View file

@ -39,7 +39,7 @@ unsafe fn bump_box_refcount<T>(+t: @T) { forget(t); }
*
* # Example
*
* assert transmute("L") == [76u8, 0u8]/~;
* assert transmute("L") == ~[76u8, 0u8];
*/
unsafe fn transmute<L, G>(-thing: L) -> G {
let newthing = reinterpret_cast(thing);

View file

@ -666,14 +666,14 @@ pure fn filter<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[T] {
*
* Flattens a vector of vectors of T into a single vector of T.
*/
pure fn concat<T: copy>(v: &[[T]/~]) -> ~[T] {
pure fn concat<T: copy>(v: &[~[T]]) -> ~[T] {
let mut r = ~[];
for each(v) |inner| { unsafe { push_all(r, inner); } }
ret r;
}
/// Concatenate a vector of vectors, placing a given separator between each
pure fn connect<T: copy>(v: &[[T]/~], sep: T) -> ~[T] {
pure fn connect<T: copy>(v: &[~[T]], sep: T) -> ~[T] {
let mut r: ~[T] = ~[];
let mut first = true;
for each(v) |inner| {

View file

@ -28,21 +28,21 @@
* }
*
* fn print_usage(program: str) {
* io::println("Usage: " + program + " [options]/~");
* io::println("Usage: " + program + " [options]");
* io::println("-o\t\tOutput");
* io::println("-h --help\tUsage");
* }
*
* fn main(args: [str]/~) {
* fn main(args: ~[str]) {
* check vec::is_not_empty(args);
*
* let program : str = vec::head(args);
*
* let opts = [
* let opts = ~[
* optopt("o"),
* optflag("h"),
* optflag("help")
* ]/~;
* ];
* let match = alt getopts(vec::tail(args), opts) {
* result::ok(m) { m }
* result::err(f) { fail fail_str(f) }

View file

@ -84,12 +84,12 @@ enum ip_get_addr_err {
*
* # Returns
*
* A `result<[ip_addr]/~, ip_get_addr_err>` instance that will contain
* A `result<~[ip_addr], ip_get_addr_err>` instance that will contain
* 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)
-> result::result<[ip_addr]/~, ip_get_addr_err> unsafe {
-> result::result<~[ip_addr], ip_get_addr_err> unsafe {
do comm::listen |output_ch| {
do str::unpack_slice(node) |node_ptr, len| {
log(debug, #fmt("slice len %?", len));
@ -249,7 +249,7 @@ mod v6 {
}
type get_addr_data = {
output_ch: comm::chan<result::result<[ip_addr]/~,ip_get_addr_err>>
output_ch: comm::chan<result::result<~[ip_addr],ip_get_addr_err>>
};
extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
@ -259,7 +259,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
*get_addr_data;
if status == 0i32 {
if res != (ptr::null::<addrinfo>()) {
let mut out_vec = []/~;
let mut out_vec = ~[];
log(debug, #fmt("initial addrinfo: %?", res));
let mut curr_addr = res;
loop {
@ -278,7 +278,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
result::err(get_addr_unknown_error));
break;
};
out_vec += [new_ip_addr]/~;
out_vec += ~[new_ip_addr];
let next_addr = ll::get_next_addrinfo(curr_addr);
if next_addr == ptr::null::<addrinfo>() as *addrinfo {

View file

@ -248,7 +248,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint,
* # Arguments
*
* * sock - a `tcp_socket` to write to
* * raw_write_data - a vector of `[u8]/~` that will be written to the stream.
* * raw_write_data - a vector of `~[u8]` that will be written to the stream.
* This value must remain valid for the duration of the `write` call
*
* # Returns
@ -284,7 +284,7 @@ fn write(sock: tcp_socket, raw_write_data: ~[u8])
* # Arguments
*
* * sock - a `tcp_socket` to write to
* * raw_write_data - a vector of `[u8]/~` that will be written to the stream.
* * raw_write_data - a vector of `~[u8]` that will be written to the stream.
* This value must remain valid for the duration of the `write` call
*
* # Returns
@ -331,7 +331,7 @@ fn read_start(sock: tcp_socket)
* * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on
*/
fn read_stop(sock: tcp_socket,
-read_port: comm::port<result::result<[u8]/~, tcp_err_data>>) ->
-read_port: comm::port<result::result<~[u8], tcp_err_data>>) ->
result::result<(), tcp_err_data> unsafe {
log(debug, #fmt("taking the read_port out of commission %?", read_port));
let socket_data = ptr::addr_of(*sock.socket_data);
@ -360,7 +360,7 @@ fn read(sock: tcp_socket, timeout_msecs: uint)
}
/**
* Reads a single chunk of data; returns a `future::future<[u8]/~>`
* Reads a single chunk of data; returns a `future::future<~[u8]>`
* immediately
*
* Does a non-blocking read operation for a single chunk of data from a
@ -731,7 +731,7 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
* A buffered wrapper that you can cast as an `io::reader` or `io::writer`
*/
fn socket_buf(-sock: tcp_socket) -> tcp_socket_buf {
tcp_socket_buf(@{ sock: sock, mut buf: []/~ })
tcp_socket_buf(@{ sock: sock, mut buf: ~[] })
}
/// Convenience methods extending `net::tcp::tcp_socket`
@ -741,7 +741,7 @@ impl tcp_socket for tcp_socket {
read_start(self)
}
fn read_stop(-read_port:
comm::port<result::result<[u8]/~, tcp_err_data>>) ->
comm::port<result::result<~[u8], tcp_err_data>>) ->
result::result<(), tcp_err_data> {
read_stop(self, read_port)
}
@ -765,14 +765,14 @@ impl tcp_socket for tcp_socket {
/// Implementation of `io::reader` iface for a buffered `net::tcp::tcp_socket`
impl tcp_socket_buf of io::reader for @tcp_socket_buf {
fn read_bytes(amt: uint) -> [u8]/~ {
fn read_bytes(amt: uint) -> ~[u8] {
let has_amt_available =
vec::len((*(self.data)).buf) >= amt;
if has_amt_available {
// no arbitrary-length shift in vec::?
let mut ret_buf = []/~;
let mut ret_buf = ~[];
while vec::len(ret_buf) < amt {
ret_buf += [vec::shift((*(self.data)).buf)]/~;
ret_buf += ~[vec::shift((*(self.data)).buf)];
}
ret_buf
}
@ -782,7 +782,7 @@ impl tcp_socket_buf of io::reader for @tcp_socket_buf {
let err_data = read_result.get_err();
log(debug, #fmt("ERROR sock_buf as io::reader.read err %? %?",
err_data.err_name, err_data.err_msg));
[]/~
~[]
}
else {
let new_chunk = result::unwrap(read_result);
@ -811,7 +811,7 @@ impl tcp_socket_buf of io::reader for @tcp_socket_buf {
/// Implementation of `io::reader` iface for a buffered `net::tcp::tcp_socket`
impl tcp_socket_buf of io::writer for @tcp_socket_buf {
fn write(data: [const u8]/&) unsafe {
fn write(data: &[const u8]) unsafe {
let socket_data_ptr =
ptr::addr_of(*((*(self.data)).sock).socket_data);
let w_result = write_common_impl(socket_data_ptr,
@ -1221,7 +1221,7 @@ type tcp_socket_data = {
type tcp_buffered_socket_data = {
sock: tcp_socket,
mut buf: [u8]/~
mut buf: ~[u8]
};
//#[cfg(test)]

View file

@ -146,7 +146,7 @@ fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
/**
* Fancy quicksort. Sorts a mut vector in place.
*
* Based on algorithm presented by [Sedgewick and Bentley]/~
* Based on algorithm presented by ~[Sedgewick and Bentley]
* (http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf).
* According to these slides this is the algorithm of choice for
* 'randomly ordered keys, abstract compare' & 'small number of key values'.

View file

@ -23,7 +23,7 @@ const color_bright_magenta: u8 = 13u8;
const color_bright_cyan: u8 = 14u8;
const color_bright_white: u8 = 15u8;
fn esc(writer: io::writer) { writer.write([0x1bu8, '[' as u8]/~); }
fn esc(writer: io::writer) { writer.write(~[0x1bu8, '[' as u8]); }
/// Reset the foreground and background colors to default
fn reset(writer: io::writer) {

View file

@ -819,8 +819,8 @@ unsafe fn ip6_addr(ip: str, port: int)
}
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]/~;
let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8];
let size = 16 as libc::size_t;
do vec::as_buf(dst) |dst_buf| {
rustrt::rust_uv_ip4_name(src as *sockaddr_in,
@ -836,12 +836,12 @@ unsafe fn ip4_name(src: &sockaddr_in) -> 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,
let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8]/~;
0u8,0u8,0u8,0u8,0u8,0u8];
let size = 46 as libc::size_t;
do vec::as_buf(dst) |dst_buf| {
let src_unsafe_ptr = src as *sockaddr_in6;

View file

@ -162,7 +162,7 @@ impl methods for state {
cx.ty_path(path(self.name).add_tys(cx.ty_vars(self.ty_params)))
}
fn to_type_decls(cx: ext_ctxt) -> [@ast::item]/~ {
fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] {
// This compiles into two different type declarations. Say the
// state is called ping. This will generate both `ping` and
// `ping_message`. The first contains data that the user cares
@ -171,7 +171,7 @@ impl methods for state {
let name = self.data_name();
let mut items_msg = []/~;
let mut items_msg = ~[];
for self.messages.each |m| {
let message(_, tys, this, next, next_tys) = m;
@ -197,7 +197,7 @@ impl methods for state {
~[cx.item_enum_poly(name, items_msg, self.ty_params)]
}
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> [@ast::item]/~ {
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] {
let dir = alt dir {
send { (*self).dir }
recv { (*self).dir.reverse() }
@ -285,7 +285,7 @@ impl methods for protocol {
start_state.to_ty(cx).to_source(),
body.to_source()),
cx.cfg(),
[]/~,
~[],
ast::public,
cx.parse_sess()).get()
}
@ -325,7 +325,7 @@ impl of to_source for @ast::item {
}
}
impl of to_source for [@ast::item]/~ {
impl of to_source for ~[@ast::item] {
fn to_source() -> str {
str::connect(self.map(|i| i.to_source()), "\n\n")
}
@ -337,7 +337,7 @@ impl of to_source for @ast::ty {
}
}
impl of to_source for [@ast::ty]/~ {
impl of to_source for ~[@ast::ty] {
fn to_source() -> str {
str::connect(self.map(|i| i.to_source()), ", ")
}
@ -361,7 +361,7 @@ impl parse_utils for ext_ctxt {
"***protocol expansion***",
@(copy s),
self.cfg(),
[]/~,
~[],
ast::public,
self.parse_sess());
alt res {
@ -382,13 +382,13 @@ impl parse_utils for ext_ctxt {
}
}
impl methods<A: copy, B: copy> for ([A]/~, [B]/~) {
fn zip() -> [(A, B)]/~ {
impl methods<A: copy, B: copy> for (~[A], ~[B]) {
fn zip() -> ~[(A, B)] {
let (a, b) = self;
vec::zip(a, b)
}
fn map<C>(f: fn(A, B) -> C) -> [C]/~ {
fn map<C>(f: fn(A, B) -> C) -> ~[C] {
let (a, b) = self;
vec::map2(a, b, f)
}

View file

@ -50,7 +50,7 @@ impl parser_attr for parser {
if self.look_ahead(1u) != token::LBRACKET {
break;
}
attrs += [self.parse_attribute(ast::attr_outer)]/~;
attrs += ~[self.parse_attribute(ast::attr_outer)];
}
token::DOC_COMMENT(s) {
let attr = ::attr::mk_sugared_doc_attr(
@ -58,7 +58,7 @@ impl parser_attr for parser {
if attr.node.style != ast::attr_outer {
self.fatal("expected outer comment");
}
attrs += [attr]/~;
attrs += ~[attr];
self.bump();
}
_ {
@ -105,14 +105,14 @@ impl parser_attr for parser {
let attr = self.parse_attribute(ast::attr_inner);
if self.token == token::SEMI {
self.bump();
inner_attrs += [attr]/~;
inner_attrs += ~[attr];
} else {
// It's not really an inner attribute
let outer_attr =
spanned(attr.span.lo, attr.span.hi,
{style: ast::attr_outer, value: attr.node.value,
is_sugared_doc: false});
next_outer_attrs += [outer_attr]/~;
next_outer_attrs += ~[outer_attr];
break;
}
}
@ -121,9 +121,9 @@ impl parser_attr for parser {
*self.get_str(s), self.span.lo, self.span.hi);
self.bump();
if attr.node.style == ast::attr_inner {
inner_attrs += [attr]/~;
inner_attrs += ~[attr];
} else {
next_outer_attrs += [attr]/~;
next_outer_attrs += ~[attr];
break;
}
}

View file

@ -39,7 +39,7 @@ fn doc_comment_style(comment: str) -> ast::attr_style {
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 strip_doc_comment_decoration(comment: str) -> str {
}
// drop leftmost columns that contain only values in chars
fn block_trim(lines: [str]/~, chars: str, max: option<uint>) -> [str]/~ {
fn block_trim(lines: ~[str], chars: str, max: option<uint>) -> ~[str] {
let mut i = max.get_default(uint::max_value);
for lines.each |line| {
@ -136,7 +136,7 @@ fn consume_whitespace_counting_blank_lines(rdr: string_reader,
fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
&comments: [cmnt]/~) {
&comments: ~[cmnt]) {
#debug(">>> shebang comment");
let p = rdr.chpos;
#debug("<<< shebang comment");
@ -148,7 +148,7 @@ fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
}
fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
&comments: [cmnt]/~) {
&comments: ~[cmnt]) {
#debug(">>> line comments");
let p = rdr.chpos;
let mut lines: ~[str] = ~[];
@ -191,7 +191,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[str],
}
fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
&comments: [cmnt]/~) {
&comments: ~[cmnt]) {
#debug(">>> block comment");
let p = rdr.chpos;
let mut lines: ~[str] = ~[];

View file

@ -52,11 +52,11 @@ fn thread_ring(i: uint,
};
}
fn main(args: [str]/~) {
fn main(args: ~[str]) {
let args = if os::getenv("RUST_BENCH").is_some() {
["", "100", "10000"]/~
~["", "100", "10000"]
} else if args.len() <= 1u {
["", "100", "1000"]/~
~["", "100", "1000"]
} else {
copy args
};
@ -70,7 +70,7 @@ fn main(args: [str]/~) {
let start = time::precise_time_s();
// create the ring
let mut futures = []/~;
let mut futures = ~[];
for uint::range(1u, num_tasks) |i| {
//#error("spawning %?", i);
@ -78,7 +78,7 @@ fn main(args: [str]/~) {
let num_chan2 = ~mut none;
*num_chan2 <-> num_chan;
let num_port = ~mut some(num_port);
futures += [future::spawn(|move num_chan2, move num_port| {
futures += ~[future::spawn(|move num_chan2, move num_port| {
let mut num_chan = none;
num_chan <-> *num_chan2;
let mut num_port1 = none;
@ -86,7 +86,7 @@ fn main(args: [str]/~) {
thread_ring(i, msg_per_task,
option::unwrap(num_chan),
option::unwrap(num_port1))
})]/~;
})];
num_chan = some(new_chan);
};

View file

@ -254,23 +254,23 @@ impl ptr_visitor<V: ty_visitor movable_ptr>
}
fn visit_evec_box(mtbl: uint, inner: *tydesc) -> bool {
self.align_to::<[u8]/@>();
self.align_to::<@[u8]>();
if ! self.inner.visit_evec_box(mtbl, inner) { ret false; }
self.bump_past::<[u8]/@>();
self.bump_past::<@[u8]>();
true
}
fn visit_evec_uniq(mtbl: uint, inner: *tydesc) -> bool {
self.align_to::<[u8]/~>();
self.align_to::<~[u8]>();
if ! self.inner.visit_evec_uniq(mtbl, inner) { ret false; }
self.bump_past::<[u8]/~>();
self.bump_past::<~[u8]>();
true
}
fn visit_evec_slice(mtbl: uint, inner: *tydesc) -> bool {
self.align_to::<[u8]/&static>();
self.align_to::<&static.[u8]>();
if ! self.inner.visit_evec_slice(mtbl, inner) { ret false; }
self.bump_past::<[u8]/&static>();
self.bump_past::<&static.[u8]>();
true
}