diff --git a/doc/rust.md b/doc/rust.md index e559af62e360c..3030fc3555a5a 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -1228,7 +1228,7 @@ to pointers to the trait name, used as a type. # impl Shape for int { } # let mycircle = 0; -let myshape: Shape = @mycircle as @Shape; +let myshape: @Shape = @mycircle as @Shape; ~~~~ The resulting value is a managed box containing the value that was cast, diff --git a/src/libcore/flate.rs b/src/libcore/flate.rs index f9348ae538073..c830648e9dffe 100644 --- a/src/libcore/flate.rs +++ b/src/libcore/flate.rs @@ -17,6 +17,7 @@ Simple compression use libc; use libc::{c_void, size_t, c_int}; use ptr; +use rand::RngUtil; use vec; #[cfg(test)] use rand; diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 2adcee495a738..931866999c408 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -20,6 +20,7 @@ pub mod linear { use hash::Hash; use iter; use option::{None, Option, Some}; + use rand::RngUtil; use rand; use uint; use vec; diff --git a/src/libcore/io.rs b/src/libcore/io.rs index b04bb15f5e30b..b96400318e0fe 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -785,8 +785,7 @@ pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer { pub fn mk_file_writer(path: &Path, flags: &[FileFlag]) - -> Result { - + -> Result<@Writer, ~str> { #[cfg(windows)] fn wb() -> c_int { (O_WRONLY | libc::consts::os::extra::O_BINARY) as c_int @@ -1079,22 +1078,24 @@ impl WriterUtil for T { } #[allow(non_implicitly_copyable_typarams)] -pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result { +pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<@Writer, ~str> { mk_file_writer(path, flags).chain(|w| result::Ok(w)) } // FIXME: fileflags // #2004 -pub fn buffered_file_writer(path: &Path) -> Result { +pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> { unsafe { let f = do os::as_c_charp(path.to_str()) |pathbuf| { do os::as_c_charp("w") |modebuf| { libc::fopen(pathbuf, modebuf) } }; - return if f as uint == 0u { result::Err(~"error opening " - + path.to_str()) } - else { result::Ok(FILE_writer(f, true)) } + return if f as uint == 0u { + result::Err(~"error opening " + path.to_str()) + } else { + result::Ok(FILE_writer(f, true)) + } } } @@ -1142,14 +1143,14 @@ pub pure fn BytesWriter() -> BytesWriter { BytesWriter { bytes: ~[], mut pos: 0u } } -pub pure fn with_bytes_writer(f: &fn(Writer)) -> ~[u8] { +pub pure fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] { let wr = @BytesWriter(); - f(wr as Writer); + f(wr as @Writer); let @BytesWriter{bytes, _} = wr; return bytes; } -pub pure fn with_str_writer(f: &fn(Writer)) -> ~str { +pub pure fn with_str_writer(f: &fn(@Writer)) -> ~str { let mut v = with_bytes_writer(f); // FIXME (#3758): This should not be needed. @@ -1277,8 +1278,8 @@ pub mod fsync { pub trait FSyncable { fn fsync(&self, l: Level) -> int; } // Call o.fsync after executing blk - pub fn obj_sync(o: FSyncable, opt_level: Option, - blk: &fn(v: Res)) { + pub fn obj_sync(o: @FSyncable, opt_level: Option, + blk: &fn(v: Res<@FSyncable>)) { blk(Res(Arg { val: o, opt_level: opt_level, fsync_fn: |o, l| o.fsync(l) @@ -1306,12 +1307,12 @@ mod tests { ~"A hoopy frood who really knows where his towel is."; log(debug, copy frood); { - let out: io::Writer = + let out: @io::Writer = result::get( &io::file_writer(tmpfile, ~[io::Create, io::Truncate])); out.write_str(frood); } - let inp: io::Reader = result::get(&io::file_reader(tmpfile)); + let inp: @io::Reader = result::get(&io::file_reader(tmpfile)); let frood2: ~str = inp.read_c_str(); log(debug, copy frood2); fail_unless!(frood == frood2); diff --git a/src/libcore/os.rs b/src/libcore/os.rs index aa4a6feb76f71..74aa520de83ef 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1267,6 +1267,7 @@ mod tests { use os::{remove_file, setenv}; use os; use path::Path; + use rand::RngUtil; use rand; use run; use str; @@ -1284,7 +1285,7 @@ mod tests { } fn make_rand_name() -> ~str { - let rng: rand::Rng = rand::Rng(); + let rng: @rand::Rng = rand::Rng(); let n = ~"TEST" + rng.gen_str(10u); fail_unless!(getenv(n).is_none()); n diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index cf90edf86f421..a29659a9eab23 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -22,97 +22,100 @@ use libc::size_t; /// A type that can be randomly generated using an RNG pub trait Rand { - static fn rand(rng: rand::Rng) -> Self; + static fn rand(rng: @rand::Rng) -> Self; } impl Rand for int { - static fn rand(rng: rand::Rng) -> int { + static fn rand(rng: @rand::Rng) -> int { rng.gen_int() } } impl Rand for i8 { - static fn rand(rng: rand::Rng) -> i8 { + static fn rand(rng: @rand::Rng) -> i8 { rng.gen_i8() } } impl Rand for i16 { - static fn rand(rng: rand::Rng) -> i16 { + static fn rand(rng: @rand::Rng) -> i16 { rng.gen_i16() } } impl Rand for i32 { - static fn rand(rng: rand::Rng) -> i32 { + static fn rand(rng: @rand::Rng) -> i32 { rng.gen_i32() } } impl Rand for i64 { - static fn rand(rng: rand::Rng) -> i64 { + static fn rand(rng: @rand::Rng) -> i64 { rng.gen_i64() } } impl Rand for u8 { - static fn rand(rng: rand::Rng) -> u8 { + static fn rand(rng: @rand::Rng) -> u8 { rng.gen_u8() } } impl Rand for u16 { - static fn rand(rng: rand::Rng) -> u16 { + static fn rand(rng: @rand::Rng) -> u16 { rng.gen_u16() } } impl Rand for u32 { - static fn rand(rng: rand::Rng) -> u32 { + static fn rand(rng: @rand::Rng) -> u32 { rng.gen_u32() } } impl Rand for u64 { - static fn rand(rng: rand::Rng) -> u64 { + static fn rand(rng: @rand::Rng) -> u64 { rng.gen_u64() } } impl Rand for float { - static fn rand(rng: rand::Rng) -> float { + static fn rand(rng: @rand::Rng) -> float { rng.gen_float() } } impl Rand for f32 { - static fn rand(rng: rand::Rng) -> f32 { + static fn rand(rng: @rand::Rng) -> f32 { rng.gen_f32() } } impl Rand for f64 { - static fn rand(rng: rand::Rng) -> f64 { + static fn rand(rng: @rand::Rng) -> f64 { rng.gen_f64() } } impl Rand for char { - static fn rand(rng: rand::Rng) -> char { + static fn rand(rng: @rand::Rng) -> char { rng.gen_char() } } impl Rand for bool { - static fn rand(rng: rand::Rng) -> bool { + static fn rand(rng: @rand::Rng) -> bool { rng.gen_bool() } } impl Rand for Option { - static fn rand(rng: rand::Rng) -> Option { - if rng.gen_bool() { Some(Rand::rand(rng)) } - else { None } + static fn rand(rng: @rand::Rng) -> Option { + if rng.gen_bool() { + Some(Rand::rand(rng)) + } else { + None + } } } @@ -145,8 +148,83 @@ pub struct Weighted { item: T, } +pub trait RngUtil { + fn gen(&self) -> T; + /// Return a random int + fn gen_int(&self) -> int; + fn gen_int_range(&self, start: int, end: int) -> int; + /// Return a random i8 + fn gen_i8(&self) -> i8; + /// Return a random i16 + fn gen_i16(&self) -> i16; + /// Return a random i32 + fn gen_i32(&self) -> i32; + /// Return a random i64 + fn gen_i64(&self) -> i64; + /// Return a random uint + fn gen_uint(&self) -> uint; + /** + * Return a uint randomly chosen from the range [start, end), + * failing if start >= end + */ + fn gen_uint_range(&self, start: uint, end: uint) -> uint; + /// Return a random u8 + fn gen_u8(&self) -> u8; + /// Return a random u16 + fn gen_u16(&self) -> u16; + /// Return a random u32 + fn gen_u32(&self) -> u32; + /// Return a random u64 + fn gen_u64(&self) -> u64; + /// Return a random float in the interval [0,1] + fn gen_float(&self) -> float; + /// Return a random f32 in the interval [0,1] + fn gen_f32(&self) -> f32; + /// Return a random f64 in the interval [0,1] + fn gen_f64(&self) -> f64; + /// Return a random char + fn gen_char(&self) -> char; + /** + * Return a char randomly chosen from chars, failing if chars is empty + */ + fn gen_char_from(&self, chars: &str) -> char; + /// Return a random bool + fn gen_bool(&self) -> bool; + /// Return a bool with a 1 in n chance of true + fn gen_weighted_bool(&self, n: uint) -> bool; + /** + * Return a random string of the specified length composed of A-Z,a-z,0-9 + */ + fn gen_str(&self, len: uint) -> ~str; + /// Return a random byte string of the specified length + fn gen_bytes(&self, len: uint) -> ~[u8]; + /// Choose an item randomly, failing if values is empty + fn choose(&self, values: &[T]) -> T; + /// Choose Some(item) randomly, returning None if values is empty + fn choose_option(&self, values: &[T]) -> Option; + /** + * Choose an item respecting the relative weights, failing if the sum of + * the weights is 0 + */ + fn choose_weighted(&self, v : &[Weighted]) -> T; + /** + * Choose Some(item) respecting the relative weights, returning none if + * the sum of the weights is 0 + */ + fn choose_weighted_option(&self, v: &[Weighted]) -> Option; + /** + * Return a vec containing copies of the items, in order, where + * the weight of the item determines how many copies there are + */ + fn weighted_vec(&self, v: &[Weighted]) -> ~[T]; + /// Shuffle a vec + fn shuffle(&self, values: &[T]) -> ~[T]; + /// Shuffle a mutable vec in place + fn shuffle_mut(&self, values: &mut [T]); +} + /// Extension methods for random number generators -pub impl Rng { +impl RngUtil for @Rng { /// Return a random value for a Rand type fn gen(&self) -> T { Rand::rand(*self) @@ -407,7 +485,7 @@ pub fn seed() -> ~[u8] { } /// Create a random number generator with a system specified seed -pub fn Rng() -> Rng { +pub fn Rng() -> @Rng { seeded_rng(seed()) } @@ -449,7 +527,7 @@ impl Rng for XorShiftState { } } -pub pure fn xorshift() -> Rng { +pub pure fn xorshift() -> @Rng { // constants taken from http://en.wikipedia.org/wiki/Xorshift seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32) } @@ -467,7 +545,7 @@ fn tls_rng_state(_v: @RandRes) {} * seeded by the system. Intended to be used in method chaining style, ie * task_rng().gen_int(). */ -pub fn task_rng() -> Rng { +pub fn task_rng() -> @Rng { let r : Option<@RandRes>; unsafe { r = task::local_data::local_data_get(tls_rng_state); diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index ad85c5e5ceff4..e6a4a99df4419 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -41,7 +41,7 @@ trait EscapedCharWriter { fn write_escaped_char(&self, ch: char); } -impl EscapedCharWriter for Writer { +impl EscapedCharWriter for @Writer { fn write_escaped_char(&self, ch: char) { match ch { '\t' => self.write_str("\\t"), diff --git a/src/libcore/run.rs b/src/libcore/run.rs index a9d96d891c944..f205d2f6b83bb 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -45,13 +45,13 @@ pub trait Program { fn get_id(&mut self) -> pid_t; /// Returns an io::writer that can be used to write to stdin - fn input(&mut self) -> io::Writer; + fn input(&mut self) -> @io::Writer; /// Returns an io::reader that can be used to read from stdout - fn output(&mut self) -> io::Reader; + fn output(&mut self) -> @io::Reader; /// Returns an io::reader that can be used to read from stderr - fn err(&mut self) -> io::Reader; + fn err(&mut self) -> @io::Reader; /// Closes the handle to the child processes standard input fn close_input(&mut self); @@ -207,7 +207,7 @@ pub fn run_program(prog: &str, args: &[~str]) -> int { * * A class with a field */ -pub fn start_program(prog: &str, args: &[~str]) -> Program { +pub fn start_program(prog: &str, args: &[~str]) -> @Program { let pipe_input = os::pipe(); let pipe_output = os::pipe(); let pipe_err = os::pipe(); @@ -274,13 +274,13 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { impl Program for ProgRes { fn get_id(&mut self) -> pid_t { return self.r.pid; } - fn input(&mut self) -> io::Writer { + fn input(&mut self) -> @io::Writer { io::fd_writer(self.r.in_fd, false) } - fn output(&mut self) -> io::Reader { + fn output(&mut self) -> @io::Reader { io::FILE_reader(self.r.out_file, false) } - fn err(&mut self) -> io::Reader { + fn err(&mut self) -> @io::Reader { io::FILE_reader(self.r.err_file, false) } fn close_input(&mut self) { close_repr_input(&mut self.r); } diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index bb05520e1a363..6a933ef515f1f 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -23,7 +23,7 @@ use super::rt::rust_task; pub trait LocalData { } impl LocalData for @T { } -impl Eq for LocalData { +impl Eq for @LocalData { pure fn eq(&self, other: &@LocalData) -> bool { unsafe { let ptr_a: (uint, uint) = cast::reinterpret_cast(&(*self)); @@ -36,7 +36,7 @@ impl Eq for LocalData { // If TLS is used heavily in future, this could be made more efficient with a // proper map. -type TaskLocalElement = (*libc::c_void, *libc::c_void, LocalData); +type TaskLocalElement = (*libc::c_void, *libc::c_void, @LocalData); // Has to be a pointer at outermost layer; the foreign call returns void *. type TaskLocalMap = @mut ~[Option]; diff --git a/src/libcore/unstable/at_exit.rs b/src/libcore/unstable/at_exit.rs index f878161eca19c..99ba5030f83b0 100644 --- a/src/libcore/unstable/at_exit.rs +++ b/src/libcore/unstable/at_exit.rs @@ -8,12 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use sys; use cast; +use libc::{c_void, size_t}; +use rand::RngUtil; +use rand; +use sys; use task; use vec; -use rand; -use libc::{c_void, size_t}; #[cfg(test)] use uint; diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index 90ada832327f4..3f1aa46dd1457 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -202,10 +202,13 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint, newexpr: ast::expr, tm: test_mode) -> ast::crate { let j: @mut uint = @mut 0u; - fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_, - original: &ast::expr_, fld: fold::ast_fold, - tm_: test_mode) -> - ast::expr_ { + fn fold_expr_rep(j_: @mut uint, + i_: uint, + newexpr_: ast::expr_, + original: &ast::expr_, + fld: @fold::ast_fold, + tm_: test_mode) + -> ast::expr_ { *j_ += 1u; if i_ + 1u == *j_ && safe_to_replace_expr(original, tm_) { newexpr_ @@ -229,10 +232,13 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint, pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty, tm: test_mode) -> ast::crate { let j: @mut uint = @mut 0u; - fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_, - original: &ast::ty_, fld: fold::ast_fold, - tm_: test_mode) -> - ast::ty_ { + fn fold_ty_rep(j_: @mut uint, + i_: uint, + newty_: ast::ty_, + original: &ast::ty_, + fld: @fold::ast_fold, + tm_: test_mode) + -> ast::ty_ { *j_ += 1u; if i_ + 1u == *j_ && safe_to_replace_ty(original, tm_) { newty_ @@ -252,7 +258,7 @@ pub fn under(n: uint, it: &fn(uint)) { while i < n { it(i); i += 1u; } } -pub fn as_str(f: @fn(+x: io::Writer)) -> ~str { +pub fn as_str(f: @fn(+x: @io::Writer)) -> ~str { io::with_str_writer(f) } @@ -304,7 +310,8 @@ pub fn check_variants_T( diagnostic::mk_span_handler(handler, codemap), crate2, fname, - rdr, a, + rdr, + a, pprust::no_ann(), false)) }; diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 2b61c9480457d..10a4d81bf6988 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -681,7 +681,7 @@ pub fn build_session(sopts: @session::options, pub fn build_session_(sopts: @session::options, cm: @codemap::CodeMap, demitter: diagnostic::Emitter, - span_diagnostic_handler: diagnostic::span_handler) + span_diagnostic_handler: @diagnostic::span_handler) -> Session { let target_cfg = build_target_config(sopts, demitter); let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler, @@ -870,7 +870,7 @@ pub fn early_error(emitter: diagnostic::Emitter, msg: ~str) -> ! { fail!(); } -pub fn list_metadata(sess: Session, path: &Path, out: io::Writer) { +pub fn list_metadata(sess: Session, path: &Path, out: @io::Writer) { metadata::loader::list_file_metadata( sess.parse_sess.interner, session::sess_os_to_meta_os(sess.targ_cfg.os), path, out); diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index d2d0ceff6331d..22b4fd3615429 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -154,8 +154,8 @@ pub struct Session_ { codemap: @codemap::CodeMap, // For a library crate, this is always none main_fn: @mut Option<(node_id, codemap::span)>, - span_diagnostic: diagnostic::span_handler, - filesearch: filesearch::FileSearch, + span_diagnostic: @diagnostic::span_handler, + filesearch: @filesearch::FileSearch, building_library: @mut bool, working_dir: Path, lint_settings: lint::LintSettings @@ -227,7 +227,7 @@ pub impl Session { fn next_node_id(&self) -> ast::node_id { return syntax::parse::next_node_id(self.parse_sess); } - fn diagnostic(&self) -> diagnostic::span_handler { + fn diagnostic(&self) -> @diagnostic::span_handler { self.span_diagnostic } fn debugging_opt(&self, opt: uint) -> bool { diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index cdf63c49de3a4..bb0080ba53570 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -63,7 +63,7 @@ fn filter_view_item(cx: @Context, &&view_item: @ast::view_item } } -fn fold_mod(cx: @Context, m: &ast::_mod, fld: fold::ast_fold) -> ast::_mod { +fn fold_mod(cx: @Context, m: &ast::_mod, fld: @fold::ast_fold) -> ast::_mod { let filtered_items = m.items.filter_mapped(|a| filter_item(cx, *a)); let filtered_view_items = @@ -84,7 +84,7 @@ fn filter_foreign_item(cx: @Context, &&item: @ast::foreign_item) -> fn fold_foreign_mod( cx: @Context, nm: &ast::foreign_mod, - fld: fold::ast_fold + fld: @fold::ast_fold ) -> ast::foreign_mod { let filtered_items = nm.items.filter_mapped(|a| filter_foreign_item(cx, *a)); @@ -99,7 +99,7 @@ fn fold_foreign_mod( } fn fold_item_underscore(cx: @Context, item: &ast::item_, - fld: fold::ast_fold) -> ast::item_ { + fld: @fold::ast_fold) -> ast::item_ { let item = match *item { ast::item_impl(ref a, b, c, ref methods) => { let methods = methods.filtered(|m| method_in_cfg(cx, *m) ); @@ -135,7 +135,7 @@ fn filter_stmt(cx: @Context, &&stmt: @ast::stmt) -> fn fold_block( cx: @Context, b: &ast::blk_, - fld: fold::ast_fold + fld: @fold::ast_fold ) -> ast::blk_ { let filtered_stmts = b.stmts.filter_mapped(|a| filter_stmt(cx, *a)); diff --git a/src/librustc/front/intrinsic.rs b/src/librustc/front/intrinsic.rs index e7ffc6c55cbc5..6cfcac3e85a28 100644 --- a/src/librustc/front/intrinsic.rs +++ b/src/librustc/front/intrinsic.rs @@ -128,7 +128,7 @@ pub mod intrinsic { #[abi = "rust-intrinsic"] pub extern { pub fn get_tydesc() -> *(); - pub fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor); + pub fn visit_tydesc(++td: *TyDesc, &&tv: @TyVisitor); } } } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index d13993bf5697a..48db758ef42ed 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -39,7 +39,7 @@ struct TestCtxt { sess: session::Session, crate: @ast::crate, path: ~[ast::ident], - ext_cx: ext_ctxt, + ext_cx: @ext_ctxt, testfns: ~[Test] } @@ -102,7 +102,7 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate { fn fold_mod(cx: @mut TestCtxt, m: &ast::_mod, - fld: fold::ast_fold) + fld: @fold::ast_fold) -> ast::_mod { // Remove any #[main] from the AST so it doesn't clash with // the one we're going to add. Only if compiling an executable. @@ -125,7 +125,7 @@ fn fold_mod(cx: @mut TestCtxt, fn fold_crate(cx: @mut TestCtxt, c: &ast::crate_, - fld: fold::ast_fold) + fld: @fold::ast_fold) -> ast::crate_ { let folded = fold::noop_fold_crate(c, fld); @@ -138,7 +138,7 @@ fn fold_crate(cx: @mut TestCtxt, } -fn fold_item(cx: @mut TestCtxt, &&i: @ast::item, fld: fold::ast_fold) +fn fold_item(cx: @mut TestCtxt, &&i: @ast::item, fld: @fold::ast_fold) -> Option<@ast::item> { cx.path.push(i.ident); debug!("current path: %s", diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 890a58243a1cd..ea0389f9ec9e0 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -30,10 +30,10 @@ use std::oldmap::HashMap; // Traverses an AST, reading all the information about use'd crates and extern // libraries necessary for later resolving, typechecking, linking, etc. -pub fn read_crates(diag: span_handler, +pub fn read_crates(diag: @span_handler, crate: ast::crate, cstore: @mut cstore::CStore, - filesearch: FileSearch, + filesearch: @FileSearch, os: loader::os, statik: bool, intr: @ident_interner) { @@ -75,7 +75,7 @@ fn dump_crates(crate_cache: @mut ~[cache_entry]) { } fn warn_if_multiple_versions(e: @mut Env, - diag: span_handler, + diag: @span_handler, crate_cache: @mut ~[cache_entry]) { use core::either::*; @@ -115,8 +115,8 @@ fn warn_if_multiple_versions(e: @mut Env, } struct Env { - diag: span_handler, - filesearch: FileSearch, + diag: @span_handler, + filesearch: @FileSearch, cstore: @mut cstore::CStore, os: loader::os, statik: bool, diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 2643012d30ae2..6d56328b406c9 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1017,14 +1017,15 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] { } fn list_meta_items(intr: @ident_interner, - meta_items: ebml::Doc, out: io::Writer) { + meta_items: ebml::Doc, + out: @io::Writer) { for get_meta_items(meta_items).each |mi| { out.write_str(fmt!("%s\n", pprust::meta_item_to_str(*mi, intr))); } } fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: &str, - out: io::Writer) { + out: @io::Writer) { out.write_str(fmt!("=Crate Attributes (%s)=\n", hash)); for get_attributes(md).each |attr| { @@ -1063,7 +1064,7 @@ pub fn get_crate_deps(intr: @ident_interner, data: @~[u8]) -> ~[crate_dep] { return deps; } -fn list_crate_deps(intr: @ident_interner, data: @~[u8], out: io::Writer) { +fn list_crate_deps(intr: @ident_interner, data: @~[u8], out: @io::Writer) { out.write_str(~"=External Dependencies=\n"); for get_crate_deps(intr, data).each |dep| { @@ -1106,7 +1107,7 @@ fn iter_crate_items(intr: @ident_interner, cdata: cmd, } pub fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8], - out: io::Writer) { + out: @io::Writer) { let hash = get_crate_hash(bytes); let md = reader::Doc(bytes); list_crate_attributes(intr, md, *hash, out); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index fc42ac2ffedb9..4b1260e76d0d4 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -57,7 +57,7 @@ pub type encode_inlined_item = @fn(ecx: @EncodeContext, ii: ast::inlined_item); pub struct EncodeParams { - diag: span_handler, + diag: @span_handler, tcx: ty::ctxt, reachable: HashMap, reexports2: middle::resolve::ExportMap2, @@ -83,7 +83,7 @@ struct Stats { } pub struct EncodeContext { - diag: span_handler, + diag: @span_handler, tcx: ty::ctxt, stats: @mut Stats, reachable: HashMap, @@ -1054,7 +1054,7 @@ fn create_index(index: ~[entry]) -> } fn encode_index(ebml_w: writer::Encoder, buckets: ~[@~[entry]], - write_fn: &fn(io::Writer, T)) { + write_fn: &fn(@io::Writer, T)) { let writer = ebml_w.writer; ebml_w.start_tag(tag_index); let mut bucket_locs: ~[uint] = ~[]; @@ -1081,9 +1081,9 @@ fn encode_index(ebml_w: writer::Encoder, 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) { +fn write_int(writer: @io::Writer, &&n: int) { fail_unless!(n < 0x7fff_ffff); writer.write_be_u32(n as u32); } @@ -1326,7 +1326,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { type_abbrevs: ty::new_ty_hash() }; - let ebml_w = writer::Encoder(wr as io::Writer); + let ebml_w = writer::Encoder(wr as @io::Writer); encode_hash(ebml_w, ecx.link_meta.extras_hash); diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index cd2c26a5ff46c..02203222e057e 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -37,7 +37,8 @@ pub trait FileSearch { pub fn mk_filesearch(maybe_sysroot: Option, target_triple: &str, - +addl_lib_search_paths: ~[Path]) -> FileSearch { + +addl_lib_search_paths: ~[Path]) + -> @FileSearch { struct FileSearchImpl { sysroot: Path, addl_lib_search_paths: ~[Path], @@ -78,7 +79,7 @@ pub fn mk_filesearch(maybe_sysroot: Option, } as @FileSearch } -pub fn search(filesearch: FileSearch, pick: pick) -> Option { +pub fn search(filesearch: @FileSearch, pick: pick) -> Option { let mut rslt = None; for filesearch.lib_search_paths().each |lib_search_path| { debug!("searching %s", lib_search_path.to_str()); diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index d45cefdbf081f..bf9e4ec536895 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -44,8 +44,8 @@ pub enum os { } pub struct Context { - diag: span_handler, - filesearch: FileSearch, + diag: @span_handler, + filesearch: @FileSearch, span: span, ident: ast::ident, metas: ~[@ast::meta_item], @@ -87,7 +87,7 @@ fn libname(cx: Context) -> (~str, ~str) { fn find_library_crate_aux( cx: Context, (prefix, suffix): (~str, ~str), - filesearch: filesearch::FileSearch + filesearch: @filesearch::FileSearch ) -> Option<(~str, @~[u8])> { let crate_name = crate_name_from_metas(cx.metas); let prefix: ~str = prefix + *crate_name + ~"-"; @@ -156,7 +156,8 @@ pub fn crate_name_from_metas(metas: &[@ast::meta_item]) -> @~str { } } -pub fn note_linkage_attrs(intr: @ident_interner, diag: span_handler, +pub fn note_linkage_attrs(intr: @ident_interner, + diag: @span_handler, attrs: ~[ast::attribute]) { for attr::find_linkage_metas(attrs).each |mi| { diag.handler().note(fmt!("meta: %s", @@ -252,7 +253,9 @@ pub fn meta_section_name(os: os) -> ~str { // A diagnostic function for dumping crate metadata to an output stream pub fn list_file_metadata(intr: @ident_interner, - os: os, path: &Path, out: io::Writer) { + os: os, + path: &Path, + out: @io::Writer) { match get_metadata_section(os, path) { option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out), option::None => { diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 63b14cc51be1c..370dfceb3d9c8 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -157,6 +157,16 @@ fn parse_vstore(st: @mut PState) -> ty::vstore { } } +fn parse_trait_store(st: @mut PState) -> ty::TraitStore { + match next(st) { + '~' => ty::UniqTraitStore, + '@' => ty::BoxTraitStore, + '&' => ty::RegionTraitStore(parse_region(st)), + '.' => ty::BareTraitStore, + c => st.tcx.sess.bug(fmt!("parse_trait_store(): bad input '%c'", c)) + } +} + fn parse_substs(st: @mut PState, conv: conv_did) -> ty::substs { let self_r = parse_opt(st, || parse_region(st) ); @@ -269,9 +279,9 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t { fail_unless!(next(st) == '['); let def = parse_def(st, NominalType, conv); let substs = parse_substs(st, conv); - let vstore = parse_vstore(st); + let store = parse_trait_store(st); fail_unless!(next(st) == ']'); - return ty::mk_trait(st.tcx, def, substs, vstore); + return ty::mk_trait(st.tcx, def, substs, store); } 'p' => { let did = parse_def(st, TypeParameter, conv); diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index b9cb0b1d4b5a3..6977e18ab7e67 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -27,7 +27,7 @@ use syntax::print::pprust::*; use middle::ty::Vid; pub struct ctxt { - diag: span_handler, + diag: @span_handler, // Def -> str Callback: ds: @fn(def_id) -> ~str, // The type context. @@ -57,7 +57,7 @@ fn cx_uses_abbrevs(cx: @ctxt) -> bool { } } -pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) { +pub fn enc_ty(w: @io::Writer, cx: @ctxt, t: ty::t) { match cx.abbrevs { ac_no_abbrevs => { let result_str = match cx.tcx.short_names_cache.find(&t) { @@ -113,7 +113,7 @@ pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) { } } } -fn enc_mt(w: io::Writer, cx: @ctxt, mt: ty::mt) { +fn enc_mt(w: @io::Writer, cx: @ctxt, mt: ty::mt) { match mt.mutbl { m_imm => (), m_mutbl => w.write_char('m'), @@ -122,7 +122,7 @@ fn enc_mt(w: io::Writer, cx: @ctxt, mt: ty::mt) { enc_ty(w, cx, mt.ty); } -fn enc_opt(w: io::Writer, t: Option, enc_f: &fn(T)) { +fn enc_opt(w: @io::Writer, t: Option, enc_f: &fn(T)) { match &t { &None => w.write_char('n'), &Some(ref v) => { @@ -132,7 +132,7 @@ fn enc_opt(w: io::Writer, t: Option, enc_f: &fn(T)) { } } -fn enc_substs(w: io::Writer, cx: @ctxt, substs: ty::substs) { +fn enc_substs(w: @io::Writer, cx: @ctxt, substs: ty::substs) { do enc_opt(w, substs.self_r) |r| { enc_region(w, cx, r) } do enc_opt(w, substs.self_ty) |t| { enc_ty(w, cx, t) } w.write_char('['); @@ -140,7 +140,7 @@ fn enc_substs(w: io::Writer, cx: @ctxt, substs: ty::substs) { w.write_char(']'); } -fn enc_region(w: io::Writer, cx: @ctxt, r: ty::Region) { +fn enc_region(w: @io::Writer, cx: @ctxt, r: ty::Region) { match r { ty::re_bound(br) => { w.write_char('b'); @@ -169,7 +169,7 @@ fn enc_region(w: io::Writer, cx: @ctxt, r: ty::Region) { } } -fn enc_bound_region(w: io::Writer, cx: @ctxt, br: ty::bound_region) { +fn enc_bound_region(w: @io::Writer, cx: @ctxt, br: ty::bound_region) { match br { ty::br_self => w.write_char('s'), ty::br_anon(idx) => { @@ -194,7 +194,7 @@ fn enc_bound_region(w: io::Writer, cx: @ctxt, br: ty::bound_region) { } } -pub fn enc_vstore(w: io::Writer, cx: @ctxt, v: ty::vstore) { +pub fn enc_vstore(w: @io::Writer, cx: @ctxt, v: ty::vstore) { w.write_char('/'); match v { ty::vstore_fixed(u) => { @@ -214,7 +214,19 @@ pub fn enc_vstore(w: io::Writer, cx: @ctxt, v: ty::vstore) { } } -fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) { +pub fn enc_trait_store(w: @io::Writer, cx: @ctxt, s: ty::TraitStore) { + match s { + ty::UniqTraitStore => w.write_char('~'), + ty::BoxTraitStore => w.write_char('@'), + ty::BareTraitStore => w.write_char('.'), + ty::RegionTraitStore(re) => { + w.write_char('&'); + enc_region(w, cx, re); + } + } +} + +fn enc_sty(w: @io::Writer, cx: @ctxt, +st: ty::sty) { match st { ty::ty_nil => w.write_char('n'), ty::ty_bot => w.write_char('z'), @@ -252,12 +264,12 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) { enc_substs(w, cx, (*substs)); w.write_char(']'); } - ty::ty_trait(def, ref substs, vstore) => { + ty::ty_trait(def, ref substs, store) => { w.write_str(&"x["); w.write_str((cx.ds)(def)); w.write_char('|'); enc_substs(w, cx, (*substs)); - enc_vstore(w, cx, vstore); + enc_trait_store(w, cx, store); w.write_char(']'); } ty::ty_tup(ts) => { @@ -325,7 +337,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) { } } -fn enc_sigil(w: io::Writer, sigil: Sigil) { +fn enc_sigil(w: @io::Writer, sigil: Sigil) { match sigil { ManagedSigil => w.write_str("@"), OwnedSigil => w.write_str("~"), @@ -333,12 +345,12 @@ fn enc_sigil(w: io::Writer, sigil: Sigil) { } } -pub fn enc_arg(w: io::Writer, cx: @ctxt, arg: ty::arg) { +pub fn enc_arg(w: @io::Writer, cx: @ctxt, arg: ty::arg) { enc_mode(w, cx, arg.mode); enc_ty(w, cx, arg.ty); } -pub fn enc_mode(w: io::Writer, cx: @ctxt, m: mode) { +pub fn enc_mode(w: @io::Writer, cx: @ctxt, m: mode) { match ty::resolved_mode(cx.tcx, m) { by_copy => w.write_char('+'), by_ref => w.write_char('='), @@ -346,7 +358,7 @@ pub fn enc_mode(w: io::Writer, cx: @ctxt, m: mode) { } } -fn enc_purity(w: io::Writer, p: purity) { +fn enc_purity(w: @io::Writer, p: purity) { match p { pure_fn => w.write_char('p'), impure_fn => w.write_char('i'), @@ -355,26 +367,26 @@ fn enc_purity(w: io::Writer, p: purity) { } } -fn enc_abi(w: io::Writer, a: Abi) { +fn enc_abi(w: @io::Writer, a: Abi) { match a { RustAbi => w.write_char('r'), } } -fn enc_onceness(w: io::Writer, o: Onceness) { +fn enc_onceness(w: @io::Writer, o: Onceness) { match o { Once => w.write_char('o'), Many => w.write_char('m') } } -fn enc_bare_fn_ty(w: io::Writer, cx: @ctxt, ft: &ty::BareFnTy) { +fn enc_bare_fn_ty(w: @io::Writer, cx: @ctxt, ft: &ty::BareFnTy) { enc_purity(w, ft.purity); enc_abi(w, ft.abi); enc_fn_sig(w, cx, &ft.sig); } -fn enc_closure_ty(w: io::Writer, cx: @ctxt, ft: &ty::ClosureTy) { +fn enc_closure_ty(w: @io::Writer, cx: @ctxt, ft: &ty::ClosureTy) { enc_sigil(w, ft.sigil); enc_purity(w, ft.purity); enc_onceness(w, ft.onceness); @@ -382,7 +394,7 @@ fn enc_closure_ty(w: io::Writer, cx: @ctxt, ft: &ty::ClosureTy) { enc_fn_sig(w, cx, &ft.sig); } -fn enc_fn_sig(w: io::Writer, cx: @ctxt, fsig: &ty::FnSig) { +fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) { w.write_char('['); for fsig.inputs.each |arg| { enc_arg(w, cx, *arg); @@ -391,7 +403,7 @@ fn enc_fn_sig(w: io::Writer, cx: @ctxt, fsig: &ty::FnSig) { enc_ty(w, cx, fsig.output); } -pub fn enc_bounds(w: io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) { +pub fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) { for vec::each(*bs) |bound| { match *bound { ty::bound_owned => w.write_char('S'), diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index c1a8f79b9b131..18434e7fc332a 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -292,7 +292,7 @@ fn encode_ast(ebml_w: writer::Encoder, item: ast::inlined_item) { // nested items, as otherwise it would get confused when translating // inlined items. fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { - fn drop_nested_items(blk: &ast::blk_, fld: fold::ast_fold) -> ast::blk_ { + fn drop_nested_items(blk: &ast::blk_, fld: @fold::ast_fold) -> ast::blk_ { let stmts_sans_items = do blk.stmts.filtered |stmt| { match stmt.node { ast::stmt_expr(_, _) | ast::stmt_semi(_, _) | diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 48d136ce65f36..99781a80c62c1 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -462,7 +462,7 @@ pub fn check_cast_for_escaping_regions( pub fn check_kind_bounds_of_cast(cx: Context, source: @expr, target: @expr) { let target_ty = ty::expr_ty(cx.tcx, target); match ty::get(target_ty).sty { - ty::ty_trait(_, _, ty::vstore_uniq) => { + ty::ty_trait(_, _, ty::UniqTraitStore) => { let source_ty = ty::expr_ty(cx.tcx, source); if !ty::type_is_owned(cx.tcx, source_ty) { cx.tcx.sess.span_err( diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index d300698da59d1..3cbb2e9e26c8e 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -825,7 +825,8 @@ pub impl Liveness { } } - fn write_vars(&self, wr: io::Writer, + fn write_vars(&self, + wr: @io::Writer, ln: LiveNode, test: &fn(uint) -> LiveNode) { let node_base_idx = self.idx(ln, Variable(0)); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index d4ed0004c8f9b..f13887d215fae 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -802,13 +802,36 @@ pub fn trans_external_path(ccx: @CrateContext, did: ast::def_id, t: ty::t) pub fn invoke(bcx: block, llfn: ValueRef, +llargs: ~[ValueRef]) -> block { let _icx = bcx.insn_ctxt("invoke_"); if bcx.unreachable { return bcx; } + + match bcx.node_info { + None => error!("invoke at ???"), + Some(node_info) => { + error!("invoke at %s", + bcx.sess().codemap.span_to_str(node_info.span)); + } + } + if need_invoke(bcx) { - log(debug, ~"invoking"); + unsafe { + debug!("invoking %x at %x", + ::core::cast::transmute(llfn), + ::core::cast::transmute(bcx.llbb)); + for llargs.each |&llarg| { + debug!("arg: %x", ::core::cast::transmute(llarg)); + } + } let normal_bcx = sub_block(bcx, ~"normal return"); Invoke(bcx, llfn, llargs, normal_bcx.llbb, get_landing_pad(bcx)); return normal_bcx; } else { - log(debug, ~"calling"); + unsafe { + debug!("calling %x at %x", + ::core::cast::transmute(llfn), + ::core::cast::transmute(bcx.llbb)); + for llargs.each |&llarg| { + debug!("arg: %x", ::core::cast::transmute(llarg)); + } + } Call(bcx, llfn, llargs); return bcx; } diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index d5877ec563123..f7226812b967a 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -406,6 +406,6 @@ impl ABIInfo for X86_64_ABIInfo { } } -pub fn x86_64_abi_info() -> ABIInfo { +pub fn x86_64_abi_info() -> @ABIInfo { return @X86_64_ABIInfo as @ABIInfo; } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index c4b80c504dabc..b9ee548df019f 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -1033,17 +1033,22 @@ pub fn T_captured_tydescs(cx: @CrateContext, n: uint) -> TypeRef { return T_struct(vec::from_elem::(n, T_ptr(cx.tydesc_type))); } -pub fn T_opaque_trait(cx: @CrateContext, vstore: ty::vstore) -> TypeRef { - match vstore { - ty::vstore_box => { +pub fn T_opaque_trait(cx: @CrateContext, store: ty::TraitStore) -> TypeRef { + match store { + ty::BoxTraitStore => { T_struct(~[T_ptr(cx.tydesc_type), T_opaque_box_ptr(cx)]) } - ty::vstore_uniq => { + ty::UniqTraitStore => { T_struct(~[T_ptr(cx.tydesc_type), T_unique_ptr(T_unique(cx, T_i8())), T_ptr(cx.tydesc_type)]) } - _ => T_struct(~[T_ptr(cx.tydesc_type), T_ptr(T_i8())]) + ty::RegionTraitStore(_) => { + T_struct(~[T_ptr(cx.tydesc_type), T_ptr(T_i8())]) + } + ty::BareTraitStore => { + cx.sess.bug(~"can't make T_opaque_trait with bare trait store") + } } } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index c163183bfc8ef..e986d0bdae31f 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -678,9 +678,9 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr, } ast::expr_cast(val, _) => { match ty::get(node_id_type(bcx, expr.id)).sty { - ty::ty_trait(_, _, vstore) => { + ty::ty_trait(_, _, store) => { return meth::trans_trait_cast(bcx, val, expr.id, dest, - vstore); + store); } _ => { bcx.tcx().sess.span_bug(expr.span, diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 1e3c4f21bd875..0e4fa3766ea4a 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -42,7 +42,7 @@ use syntax::{ast, ast_util}; use syntax::{attr, ast_map}; use syntax::parse::token::special_idents; -fn abi_info(arch: session::arch) -> cabi::ABIInfo { +fn abi_info(arch: session::arch) -> @cabi::ABIInfo { return match arch { arch_x86_64 => x86_64_abi_info(), arch_arm => cabi_arm::abi_info(), diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 7f860bc0c8556..f32cfb59b4a6f 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -551,11 +551,12 @@ pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { ty::ty_closure(_) => { closure::make_closure_glue(bcx, v0, t, drop_ty) } - ty::ty_trait(_, _, ty::vstore_box) => { + ty::ty_trait(_, _, ty::BoxTraitStore) | + ty::ty_trait(_, _, ty::BareTraitStore) => { let llbox = Load(bcx, GEPi(bcx, v0, [0u, 1u])); decr_refcnt_maybe_free(bcx, llbox, ty::mk_opaque_box(ccx.tcx)) } - ty::ty_trait(_, _, ty::vstore_uniq) => { + ty::ty_trait(_, _, ty::UniqTraitStore) => { let lluniquevalue = GEPi(bcx, v0, [0, 1]); let lltydesc = Load(bcx, GEPi(bcx, v0, [0, 2])); call_tydesc_glue_full(bcx, lluniquevalue, lltydesc, @@ -617,12 +618,13 @@ pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { ty::ty_closure(_) => { closure::make_closure_glue(bcx, v, t, take_ty) } - ty::ty_trait(_, _, ty::vstore_box) => { + ty::ty_trait(_, _, ty::BoxTraitStore) | + ty::ty_trait(_, _, ty::BareTraitStore) => { let llbox = Load(bcx, GEPi(bcx, v, [0u, 1u])); incr_refcnt_of_boxed(bcx, llbox); bcx } - ty::ty_trait(_, _, ty::vstore_uniq) => { + ty::ty_trait(_, _, ty::UniqTraitStore) => { let llval = GEPi(bcx, v, [0, 1]); let lltydesc = Load(bcx, GEPi(bcx, v, [0, 2])); call_tydesc_glue_full(bcx, llval, lltydesc, diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 2f4e8d715e0a0..3df6af85cde95 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -249,12 +249,12 @@ pub fn trans_method_callee(bcx: block, None => fail!(~"trans_method_callee: missing param_substs") } } - typeck::method_trait(_, off, vstore) => { + typeck::method_trait(_, off, store) => { trans_trait_callee(bcx, callee_id, off, self, - vstore, + store, mentry.explicit_self) } typeck::method_self(*) | typeck::method_super(*) => { @@ -570,7 +570,7 @@ pub fn trans_trait_callee(bcx: block, callee_id: ast::node_id, n_method: uint, self_expr: @ast::expr, - vstore: ty::vstore, + store: ty::TraitStore, explicit_self: ast::self_ty_) -> Callee { //! @@ -599,7 +599,7 @@ pub fn trans_trait_callee(bcx: block, callee_ty, n_method, llpair, - vstore, + store, explicit_self) } @@ -607,7 +607,7 @@ pub fn trans_trait_callee_from_llval(bcx: block, callee_ty: ty::t, n_method: uint, llpair: ValueRef, - vstore: ty::vstore, + store: ty::TraitStore, explicit_self: ast::self_ty_) -> Callee { //! @@ -641,16 +641,15 @@ pub fn trans_trait_callee_from_llval(bcx: block, } ast::sty_by_ref => { // We need to pass a pointer to a pointer to the payload. - match vstore { - ty::vstore_box | ty::vstore_uniq => { + match store { + ty::BoxTraitStore | + ty::BareTraitStore | + ty::UniqTraitStore => { llself = GEPi(bcx, llbox, [0u, abi::box_field_body]); } - ty::vstore_slice(_) => { + ty::RegionTraitStore(_) => { llself = llbox; } - ty::vstore_fixed(*) => { - bcx.tcx().sess.bug(~"vstore_fixed trait"); - } } self_mode = ast::by_ref; @@ -662,16 +661,15 @@ pub fn trans_trait_callee_from_llval(bcx: block, ast::sty_region(_) => { // As before, we need to pass a pointer to a pointer to the // payload. - match vstore { - ty::vstore_box | ty::vstore_uniq => { + match store { + ty::BoxTraitStore | + ty::BareTraitStore | + ty::UniqTraitStore => { llself = GEPi(bcx, llbox, [0u, abi::box_field_body]); } - ty::vstore_slice(_) => { + ty::RegionTraitStore(_) => { llself = llbox; } - ty::vstore_fixed(*) => { - bcx.tcx().sess.bug(~"vstore_fixed trait"); - } } let llscratch = alloca(bcx, val_ty(llself)); @@ -687,8 +685,8 @@ pub fn trans_trait_callee_from_llval(bcx: block, bcx = glue::take_ty(bcx, llbox, callee_ty); // Pass a pointer to the box. - match vstore { - ty::vstore_box => llself = llbox, + match store { + ty::BoxTraitStore | ty::BareTraitStore => llself = llbox, _ => bcx.tcx().sess.bug(~"@self receiver with non-@Trait") } @@ -700,8 +698,8 @@ pub fn trans_trait_callee_from_llval(bcx: block, } ast::sty_uniq(_) => { // Pass the unique pointer. - match vstore { - ty::vstore_uniq => llself = llbox, + match store { + ty::UniqTraitStore => llself = llbox, _ => bcx.tcx().sess.bug(~"~self receiver with non-~Trait") } @@ -796,7 +794,9 @@ pub fn make_impl_vtable(ccx: @CrateContext, // XXX: This should support multiple traits. let trt_id = driver::session::expect( tcx.sess, - ty::ty_to_def_id(ty::impl_traits(tcx, impl_id, ty::vstore_box)[0]), + ty::ty_to_def_id(ty::impl_traits(tcx, + impl_id, + ty::BoxTraitStore)[0]), || ~"make_impl_vtable: non-trait-type implemented"); let has_tps = (*ty::lookup_item_type(ccx.tcx, impl_id).bounds).len() > 0u; @@ -834,7 +834,7 @@ pub fn trans_trait_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: expr::Dest, - vstore: ty::vstore) + store: ty::TraitStore) -> block { let mut bcx = bcx; let _icx = bcx.insn_ctxt("impl::trans_cast"); @@ -849,8 +849,8 @@ pub fn trans_trait_cast(bcx: block, let ccx = bcx.ccx(); let v_ty = expr_ty(bcx, val); - match vstore { - ty::vstore_slice(*) | ty::vstore_box => { + match store { + ty::RegionTraitStore(_) | ty::BoxTraitStore | ty::BareTraitStore => { let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]); // Just store the pointer into the pair. llboxdest = PointerCast(bcx, @@ -858,7 +858,7 @@ pub fn trans_trait_cast(bcx: block, T_ptr(type_of(bcx.ccx(), v_ty))); bcx = expr::trans_into(bcx, val, SaveIn(llboxdest)); } - ty::vstore_uniq => { + ty::UniqTraitStore => { // Translate the uniquely-owned value into the second element of // the triple. (The first element is the vtable.) let mut llvaldest = GEPi(bcx, lldest, [0, 1]); @@ -874,10 +874,6 @@ pub fn trans_trait_cast(bcx: block, let lltydescdest = GEPi(bcx, lldest, [0, 2]); Store(bcx, tydesc.tydesc, lltydescdest); } - _ => { - bcx.tcx().sess.span_bug(val.span, ~"unexpected vstore in \ - trans_trait_cast"); - } } // Store the vtable into the pair or triple. diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index f970d8f26b33b..320fc3ed77a92 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -286,14 +286,11 @@ pub fn normalize_for_monomorphization(tcx: ty::ctxt, ty::ty_closure(ref fty) => { Some(normalized_closure_ty(tcx, fty.sigil)) } - ty::ty_trait(_, _, ref vstore) => { - let sigil = match *vstore { - ty::vstore_uniq => ast::OwnedSigil, - ty::vstore_box => ast::ManagedSigil, - ty::vstore_slice(_) => ast::BorrowedSigil, - ty::vstore_fixed(*) => { - tcx.sess.bug(fmt!("ty_trait with vstore_fixed")); - } + ty::ty_trait(_, _, ref store) => { + let sigil = match *store { + ty::UniqTraitStore => ast::OwnedSigil, + ty::BoxTraitStore | ty::BareTraitStore => ast::ManagedSigil, + ty::RegionTraitStore(_) => ast::BorrowedSigil, }; // Traits have the same runtime representation as closures. diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 85c0bc80292b6..032179c7e2ccd 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -96,14 +96,14 @@ pub impl Reflector { } let bool_ty = ty::mk_bool(tcx); let scratch = scratch_datum(bcx, bool_ty, false); - // XXX: Should not be vstore_box! + // XXX: Should not be BoxTraitStore! let bcx = callee::trans_call_inner( self.bcx, None, mth_ty, bool_ty, |bcx| meth::trans_trait_callee_from_llval(bcx, mth_ty, mth_idx, v, - ty::vstore_box, + ty::BoxTraitStore, ast::sty_region( ast::m_imm)), ArgVals(args), SaveIn(scratch.val), DontAutorefArg); diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 68eb0852445e0..c5f4701fafecc 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -133,7 +133,7 @@ pub fn sizing_type_of(cx: @CrateContext, t: ty::t) -> TypeRef { ty::ty_bare_fn(*) => T_ptr(T_i8()), ty::ty_closure(*) => T_struct(~[T_ptr(T_i8()), T_ptr(T_i8())]), - ty::ty_trait(_, _, vstore) => T_opaque_trait(cx, vstore), + ty::ty_trait(_, _, store) => T_opaque_trait(cx, store), ty::ty_estr(ty::vstore_fixed(size)) => T_array(T_i8(), size), ty::ty_evec(mt, ty::vstore_fixed(size)) => { @@ -237,7 +237,7 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef { ty::ty_bare_fn(_) => T_ptr(type_of_fn_from_ty(cx, t)), ty::ty_closure(_) => T_fn_pair(cx, type_of_fn_from_ty(cx, t)), - ty::ty_trait(_, _, vstore) => T_opaque_trait(cx, vstore), + ty::ty_trait(_, _, store) => T_opaque_trait(cx, store), ty::ty_type => T_ptr(cx.tydesc_type), ty::ty_tup(*) => { let repr = adt::represent_type(cx, t); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 6e21439fc3563..92a7ffbc5a456 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -24,7 +24,7 @@ use middle::typeck; use middle; use util::ppaux::{note_and_explain_region, bound_region_to_str}; use util::ppaux::{region_to_str, explain_region, vstore_to_str}; -use util::ppaux::{ty_to_str, tys_to_str}; +use util::ppaux::{trait_store_to_str, ty_to_str, tys_to_str}; use util::common::{indenter}; use core::cast; @@ -84,6 +84,7 @@ pub struct mt { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum vstore { vstore_fixed(uint), vstore_uniq, @@ -91,6 +92,16 @@ pub enum vstore { vstore_slice(Region) } +#[auto_encode] +#[auto_decode] +#[deriving_eq] +pub enum TraitStore { + BareTraitStore, // a plain trait without a sigil + BoxTraitStore, // @Trait + UniqTraitStore, // ~Trait + RegionTraitStore(Region), // &Trait +} + pub struct field_ty { ident: ident, id: def_id, @@ -233,7 +244,7 @@ pub struct InstantiatedTraitRef { pub type ctxt = @ctxt_; struct ctxt_ { - diag: syntax::diagnostic::span_handler, + diag: @syntax::diagnostic::span_handler, interner: HashMap, next_id: @mut uint, vecs_implicitly_copyable: bool, @@ -506,7 +517,7 @@ pub enum sty { ty_rptr(Region, mt), ty_bare_fn(BareFnTy), ty_closure(ClosureTy), - ty_trait(def_id, substs, vstore), + ty_trait(def_id, substs, TraitStore), ty_struct(def_id, substs), ty_tup(~[t]), @@ -565,6 +576,7 @@ pub enum type_err { terr_regions_insufficiently_polymorphic(bound_region, Region), terr_regions_overly_polymorphic(bound_region, Region), terr_vstores_differ(terr_vstore_kind, expected_found), + terr_trait_stores_differ(terr_vstore_kind, expected_found), terr_in_field(@type_err, ast::ident), terr_sorts(expected_found), terr_self_substs, @@ -1048,10 +1060,13 @@ pub fn mk_ctor_fn(cx: ctxt, input_tys: &[ty::t], output: ty::t) -> t { } -pub fn mk_trait(cx: ctxt, did: ast::def_id, +substs: substs, vstore: vstore) - -> t { +pub fn mk_trait(cx: ctxt, + did: ast::def_id, + +substs: substs, + store: TraitStore) + -> t { // take a copy of substs so that we own the vectors inside - mk_t(cx, ty_trait(did, substs, vstore)) + mk_t(cx, ty_trait(did, substs, store)) } pub fn mk_struct(cx: ctxt, struct_id: ast::def_id, +substs: substs) -> t { @@ -1213,8 +1228,8 @@ fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty { ty_enum(tid, ref substs) => { ty_enum(tid, fold_substs(substs, fldop)) } - ty_trait(did, ref substs, vst) => { - ty_trait(did, fold_substs(substs, fldop), vst) + ty_trait(did, ref substs, st) => { + ty_trait(did, fold_substs(substs, fldop), st) } ty_tup(ts) => { let new_ts = vec::map(ts, |tt| fldop(*tt)); @@ -1304,8 +1319,8 @@ pub fn fold_regions_and_ty( ty_struct(def_id, ref substs) => { ty::mk_struct(cx, def_id, fold_substs(substs, fldr, fldt)) } - ty_trait(def_id, ref substs, vst) => { - ty::mk_trait(cx, def_id, fold_substs(substs, fldr, fldt), vst) + ty_trait(def_id, ref substs, st) => { + ty::mk_trait(cx, def_id, fold_substs(substs, fldr, fldt), st) } ty_bare_fn(ref f) => { ty::mk_bare_fn(cx, BareFnTy {sig: fold_sig(&f.sig, fldfnt), @@ -1893,15 +1908,16 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { TC_MANAGED + nonowned(tc_mt(cx, mt, cache)) } - ty_trait(_, _, vstore_uniq) => { + ty_trait(_, _, UniqTraitStore) => { TC_OWNED_CLOSURE } - ty_trait(_, _, vstore_box) => { + ty_trait(_, _, BoxTraitStore) | + ty_trait(_, _, BareTraitStore) => { TC_MANAGED } - ty_trait(_, _, vstore_slice(r)) => { + ty_trait(_, _, RegionTraitStore(r)) => { borrowed_contents(r, m_imm) } @@ -2013,7 +2029,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { } ty_type => TC_NONE, - ty_trait(_, _, vstore_fixed(_)) => TC_NONE, ty_err => { cx.sess.bug(~"Asked to compute contents of fictitious type"); @@ -2557,6 +2572,17 @@ impl to_bytes::IterBytes for vstore { } } +impl to_bytes::IterBytes for TraitStore { + pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { + match *self { + BareTraitStore => 0u8.iter_bytes(lsb0, f), + UniqTraitStore => 1u8.iter_bytes(lsb0, f), + BoxTraitStore => 2u8.iter_bytes(lsb0, f), + RegionTraitStore(ref r) => to_bytes::iter_bytes_2(&3u8, r, lsb0, f), + } + } +} + impl to_bytes::IterBytes for substs { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_3(&self.self_r, @@ -3419,6 +3445,11 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str { vstore_to_str(cx, (*values).expected), vstore_to_str(cx, (*values).found)) } + terr_trait_stores_differ(_, ref values) => { + fmt!("trait storage differs: expected %s but found %s", + trait_store_to_str(cx, (*values).expected), + trait_store_to_str(cx, (*values).found)) + } terr_in_field(err, fname) => { fmt!("in field `%s`, %s", *cx.sess.str_of(fname), type_err_to_str(cx, err)) @@ -3565,12 +3596,15 @@ pub fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { /* Could this return a list of (def_id, substs) pairs? */ -pub fn impl_traits(cx: ctxt, id: ast::def_id, vstore: vstore) -> ~[t] { - fn vstoreify(cx: ctxt, ty: t, vstore: vstore) -> t { +pub fn impl_traits(cx: ctxt, id: ast::def_id, store: TraitStore) -> ~[t] { + fn storeify(cx: ctxt, ty: t, store: TraitStore) -> t { match ty::get(ty).sty { - ty::ty_trait(_, _, trait_vstore) if vstore == trait_vstore => ty, - ty::ty_trait(did, ref substs, _) => { - mk_trait(cx, did, (/*bad*/copy *substs), vstore) + ty::ty_trait(did, ref substs, trait_store) => { + if store == trait_store { + ty + } else { + mk_trait(cx, did, (/*bad*/copy *substs), store) + } } _ => cx.sess.bug(~"impl_traits: not a trait") } @@ -3585,16 +3619,16 @@ pub fn impl_traits(cx: ctxt, id: ast::def_id, vstore: vstore) -> ~[t] { _)) => { do option::map_default(&opt_trait, ~[]) |trait_ref| { - ~[vstoreify(cx, - node_id_to_type(cx, trait_ref.ref_id), - vstore)] + ~[storeify(cx, + node_id_to_type(cx, trait_ref.ref_id), + store)] } } _ => ~[] } } else { vec::map(csearch::get_impl_traits(cx, id), - |x| vstoreify(cx, *x, vstore)) + |x| storeify(cx, *x, store)) } } @@ -4163,6 +4197,9 @@ pub fn normalize_ty(cx: ctxt, t: t) -> t { t }, + ty_trait(did, ref substs, BareTraitStore) => + mk_trait(cx, did, copy *substs, BoxTraitStore), + _ => t }; @@ -4318,38 +4355,6 @@ impl cmp::Eq for mt { pure fn ne(&self, other: &mt) -> bool { !(*self).eq(other) } } -impl cmp::Eq for vstore { - pure fn eq(&self, other: &vstore) -> bool { - match (*self) { - vstore_fixed(e0a) => { - match (*other) { - vstore_fixed(e0b) => e0a == e0b, - _ => false - } - } - vstore_uniq => { - match (*other) { - vstore_uniq => true, - _ => false - } - } - vstore_box => { - match (*other) { - vstore_box => true, - _ => false - } - } - vstore_slice(e0a) => { - match (*other) { - vstore_slice(e0b) => e0a == e0b, - _ => false - } - } - } - } - pure fn ne(&self, other: &vstore) -> bool { !(*self).eq(other) } -} - impl cmp::Eq for Region { pure fn eq(&self, other: &Region) -> bool { match (*self) { diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 6c27decc28345..61603f7b57824 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -218,7 +218,7 @@ pub fn ast_ty_to_ty( // Handle @, ~, and & being able to mean estrs and evecs. // If a_seq_ty is a str or a vec, make it an estr/evec. - // Also handle function sigils and first-class trait types. + // Also handle first-class trait types. fn mk_pointer( self: &AC, rscope: &RS, @@ -249,20 +249,26 @@ pub fn ast_ty_to_ty( type_def_id, path); match ty::get(result.ty).sty { ty::ty_trait(trait_def_id, ref substs, _) => { - match vst { - ty::vstore_box | ty::vstore_slice(*) | - ty::vstore_uniq => {} - _ => { + let trait_store = match vst { + ty::vstore_box => ty::BoxTraitStore, + ty::vstore_uniq => ty::UniqTraitStore, + ty::vstore_slice(r) => { + ty::RegionTraitStore(r) + } + ty::vstore_fixed(*) => { tcx.sess.span_err( path.span, ~"@trait, ~trait or &trait \ are the only supported \ forms of casting-to-\ trait"); + ty::BoxTraitStore } - } - return ty::mk_trait(tcx, trait_def_id, - /*bad*/copy *substs, vst); + }; + return ty::mk_trait(tcx, + trait_def_id, + /*bad*/copy *substs, + trait_store); } _ => {} diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index d6060c1ae316d..5d2469db285eb 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -288,9 +288,9 @@ pub impl LookupContext/&self { ty_param(p) => { self.push_inherent_candidates_from_param(self_ty, p); } - ty_trait(did, ref substs, vstore) => { + ty_trait(did, ref substs, store) => { self.push_inherent_candidates_from_trait( - self_ty, did, substs, vstore); + self_ty, did, substs, store); self.push_inherent_impl_candidates_for_type(did); } ty_self => { @@ -490,7 +490,7 @@ pub impl LookupContext/&self { self_ty: ty::t, did: def_id, substs: &ty::substs, - vstore: ty::vstore) { + store: ty::TraitStore) { debug!("push_inherent_candidates_from_trait(did=%s, substs=%s)", self.did_to_str(did), substs_to_str(self.tcx(), substs)); @@ -539,7 +539,7 @@ pub impl LookupContext/&self { explicit_self: method.self_ty, num_method_tps: method.tps.len(), self_mode: get_mode_from_self_type(method.self_ty), - origin: method_trait(did, index, vstore) + origin: method_trait(did, index, store) }); } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 445cab4ba95fd..53c255ed35864 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3205,6 +3205,19 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { fail_unless!(ccx.tcx.intrinsic_defs.contains_key(&ty_visitor_name)); let (_, tydesc_ty) = tcx.intrinsic_defs.get(&tydesc_name); let (_, visitor_trait) = tcx.intrinsic_defs.get(&ty_visitor_name); + + let visitor_trait = match ty::get(visitor_trait).sty { + ty::ty_trait(trait_def_id, ref trait_substs, _) => { + ty::mk_trait(tcx, + trait_def_id, + copy *trait_substs, + ty::BoxTraitStore) + } + _ => { + tcx.sess.span_bug(it.span, ~"TyVisitor wasn't a trait?!") + } + }; + let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty, mutbl: ast::m_imm}); (0u, ~[arg(ast::by_val, td_ptr), diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 1dd88e6408ba0..4ff8431d88a37 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -263,7 +263,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) { // explaining how it goes about doing that. let target_ty = rcx.resolve_node_type(expr.id); match ty::get(target_ty).sty { - ty::ty_trait(_, _, vstore_slice(trait_region)) => { + ty::ty_trait(_, _, ty::RegionTraitStore(trait_region)) => { let source_ty = rcx.fcx.expr_ty(source); constrain_regions_in_type(rcx, trait_region, expr.span, source_ty); diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 7c9ca4ba85a4c..48a37c9e72ad0 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -140,7 +140,9 @@ pub fn fixup_substs(vcx: &VtableContext, location_info: &LocationInfo, is_early: bool) -> Option { let tcx = vcx.tcx(); // use a dummy type just to package up the substs that need fixing up - let t = ty::mk_trait(tcx, id, substs, ty::vstore_slice(ty::re_static)); + let t = ty::mk_trait(tcx, + id, substs, + ty::RegionTraitStore(ty::re_static)); do fixup_ty(vcx, location_info, t, is_early).map |t_f| { match ty::get(*t_f).sty { ty::ty_trait(_, ref substs_f, _) => (/*bad*/copy *substs_f), @@ -167,9 +169,9 @@ pub fn lookup_vtable(vcx: &VtableContext, let _i = indenter(); let tcx = vcx.tcx(); - let (trait_id, trait_substs, trait_vstore) = match ty::get(trait_ty).sty { - ty::ty_trait(did, ref substs, vstore) => - (did, (/*bad*/copy *substs), vstore), + let (trait_id, trait_substs, trait_store) = match ty::get(trait_ty).sty { + ty::ty_trait(did, ref substs, store) => + (did, (/*bad*/copy *substs), store), _ => tcx.sess.impossible_case(location_info.span, "lookup_vtable: \ don't know how to handle a non-trait") @@ -196,12 +198,19 @@ pub fn lookup_vtable(vcx: &VtableContext, vcx.infcx.ty_to_str(ity)); match ty::get(ity).sty { - ty::ty_trait(idid, _, _) => { + ty::ty_trait(idid, ref isubsts, _) => { if trait_id == idid { debug!("(checking vtable) @0 \ relating ty to trait \ ty with did %?", idid); + + // Convert `ity` so that it has the right vstore. + let ity = ty::mk_trait(vcx.tcx(), + idid, + copy *isubsts, + trait_store); + relate_trait_tys(vcx, location_info, trait_ty, ity); let vtable = vtable_param(n, n_bound); @@ -261,8 +270,9 @@ pub fn lookup_vtable(vcx: &VtableContext, // it's the same trait as trait_ty, we need to // unify it with trait_ty in order to get all // the ty vars sorted out. - for vec::each(ty::impl_traits(tcx, im.did, - trait_vstore)) |of_ty| { + for vec::each(ty::impl_traits(tcx, + im.did, + trait_store)) |of_ty| { match ty::get(*of_ty).sty { ty::ty_trait(id, _, _) => { // Not the trait we're looking for @@ -381,7 +391,7 @@ pub fn lookup_vtable(vcx: &VtableContext, /*bad*/copy substs_f.tps, trait_tps, im.did, - trait_vstore); + trait_store); let subres = lookup_vtables( vcx, location_info, im_bs, &substs_f, is_early); @@ -455,11 +465,11 @@ pub fn connect_trait_tps(vcx: &VtableContext, impl_tys: ~[ty::t], trait_tys: ~[ty::t], impl_did: ast::def_id, - vstore: ty::vstore) { + store: ty::TraitStore) { let tcx = vcx.tcx(); // XXX: This should work for multiple traits. - let ity = ty::impl_traits(tcx, impl_did, vstore)[0]; + let ity = ty::impl_traits(tcx, impl_did, store)[0]; let trait_ty = ty::subst_tps(tcx, impl_tys, None, ity); debug!("(connect trait tps) trait type is %?, impl did is %?", ty::get(trait_ty).sty, impl_did); @@ -557,17 +567,18 @@ pub fn early_resolve_expr(ex: @ast::expr, ast::expr_cast(src, _) => { let target_ty = fcx.expr_ty(ex); match ty::get(target_ty).sty { - ty::ty_trait(_, _, vstore) => { + ty::ty_trait(_, _, store) => { // Look up vtables for the type we're casting to, // passing in the source and target type. The source // must be a pointer type suitable to the object sigil, // e.g.: `@x as @Trait`, `&x as &Trait` or `~x as ~Trait` let ty = structurally_resolved_type(fcx, ex.span, fcx.expr_ty(src)); - match (&ty::get(ty).sty, vstore) { - (&ty::ty_box(mt), ty::vstore_box) | - (&ty::ty_uniq(mt), ty::vstore_uniq) | - (&ty::ty_rptr(_, mt), ty::vstore_slice(*)) => { + match (&ty::get(ty).sty, store) { + (&ty::ty_box(mt), ty::BoxTraitStore) | + // XXX: Bare trait store is deprecated. + (&ty::ty_uniq(mt), ty::UniqTraitStore) | + (&ty::ty_rptr(_, mt), ty::RegionTraitStore(*)) => { let location_info = &location_info_for_expr(ex); let vcx = VtableContext { @@ -604,9 +615,9 @@ pub fn early_resolve_expr(ex: @ast::expr, // Now, if this is &trait, we need to link the // regions. - match (&ty::get(ty).sty, vstore) { + match (&ty::get(ty).sty, store) { (&ty::ty_rptr(ra, _), - ty::vstore_slice(rb)) => { + ty::RegionTraitStore(rb)) => { infer::mk_subr(fcx.infcx(), false, ex.span, @@ -617,7 +628,14 @@ pub fn early_resolve_expr(ex: @ast::expr, } } - (_, ty::vstore_box(*)) => { + (_, ty::BareTraitStore) => { + fcx.ccx.tcx.sess.span_err( + ex.span, + ~"a sigil (`@`, `~`, or `&`) must be specified \ + when casting to a trait"); + } + + (_, ty::BoxTraitStore) => { fcx.ccx.tcx.sess.span_err( ex.span, fmt!("can only cast an @-pointer \ @@ -625,7 +643,7 @@ pub fn early_resolve_expr(ex: @ast::expr, ty::ty_sort_str(fcx.tcx(), ty))); } - (_, ty::vstore_uniq(*)) => { + (_, ty::UniqTraitStore) => { fcx.ccx.tcx.sess.span_err( ex.span, fmt!("can only cast an ~-pointer \ @@ -633,19 +651,13 @@ pub fn early_resolve_expr(ex: @ast::expr, ty::ty_sort_str(fcx.tcx(), ty))); } - (_, ty::vstore_slice(*)) => { + (_, ty::RegionTraitStore(_)) => { fcx.ccx.tcx.sess.span_err( ex.span, fmt!("can only cast an &-pointer \ to an &-object, not a %s", ty::ty_sort_str(fcx.tcx(), ty))); } - - (_, ty::vstore_fixed(*)) => { - fcx.tcx().sess.span_bug( - ex.span, - fmt!("trait with fixed vstore")); - } } } _ => { /* not a cast to a trait; ignore */ } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 6c8bfdb041ddd..29d1f81cdd60e 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -81,8 +81,10 @@ pub fn collect_item_types(ccx: @mut CrateCtxt, crate: @ast::crate) { match intrinsic_item.node { ast::item_trait(*) => { - let ty = ty::mk_trait(ccx.tcx, def_id, substs, - ty::vstore_box); + let ty = ty::mk_trait(ccx.tcx, + def_id, + substs, + ty::BareTraitStore); ccx.tcx.intrinsic_defs.insert (intrinsic_item.ident, (def_id, ty)); } @@ -893,7 +895,10 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: @ast::item) } ast::item_trait(ref generics, _, _) => { let (bounds, substs) = mk_substs(ccx, generics, rp); - let t = ty::mk_trait(tcx, local_def(it.id), substs, ty::vstore_box); + let t = ty::mk_trait(tcx, + local_def(it.id), + substs, + ty::BareTraitStore); let tpt = ty_param_bounds_and_ty { bounds: bounds, region_param: rp, diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index 1f5e9707e2ddd..3ec4fcb6d2e81 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -102,10 +102,16 @@ pub trait Combine { fn purities(&self, a: purity, b: purity) -> cres; fn abis(&self, a: ast::Abi, b: ast::Abi) -> cres; fn oncenesses(&self, a: Onceness, b: Onceness) -> cres; - fn contraregions(&self, a: ty::Region, b: ty::Region) -> cres; + fn contraregions(&self, a: ty::Region, b: ty::Region) + -> cres; fn regions(&self, a: ty::Region, b: ty::Region) -> cres; fn vstores(&self, vk: ty::terr_vstore_kind, a: ty::vstore, b: ty::vstore) -> cres; + fn trait_stores(&self, + vk: ty::terr_vstore_kind, + a: ty::TraitStore, + b: ty::TraitStore) + -> cres; } pub struct CombineFields { @@ -349,6 +355,30 @@ pub fn super_vstores( } } +pub fn super_trait_stores(self: &C, + vk: ty::terr_vstore_kind, + a: ty::TraitStore, + b: ty::TraitStore) + -> cres { + debug!("%s.super_vstores(a=%?, b=%?)", self.tag(), a, b); + + match (a, b) { + (ty::RegionTraitStore(a_r), ty::RegionTraitStore(b_r)) => { + do self.contraregions(a_r, b_r).chain |r| { + Ok(ty::RegionTraitStore(r)) + } + } + + _ if a == b => { + Ok(a) + } + + _ => { + Err(ty::terr_trait_stores_differ(vk, expected_found(self, a, b))) + } + } +} + pub fn super_closure_tys( self: &C, a_f: &ty::ClosureTy, b_f: &ty::ClosureTy) -> cres { @@ -491,12 +521,12 @@ pub fn super_tys( } } - (ty::ty_trait(a_id, ref a_substs, a_vstore), - ty::ty_trait(b_id, ref b_substs, b_vstore)) + (ty::ty_trait(a_id, ref a_substs, a_store), + ty::ty_trait(b_id, ref b_substs, b_store)) if a_id == b_id => { do self.substs(a_id, a_substs, b_substs).chain |substs| { - do self.vstores(ty::terr_trait, a_vstore, b_vstore).chain |vs| { - Ok(ty::mk_trait(tcx, a_id, /*bad*/copy substs, vs)) + do self.trait_stores(ty::terr_trait, a_store, b_store).chain |s| { + Ok(ty::mk_trait(tcx, a_id, /*bad*/copy substs, s)) } } } diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index bba35f02b0c1e..ff13f7ee576ec 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -145,6 +145,14 @@ impl Combine for Glb { super_vstores(self, vk, a, b) } + fn trait_stores(&self, + vk: ty::terr_vstore_kind, + a: ty::TraitStore, + b: ty::TraitStore) + -> cres { + super_trait_stores(self, vk, a, b) + } + fn modes(&self, a: ast::mode, b: ast::mode) -> cres { super_modes(self, a, b) } diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 3a12fb31a1a6f..933ad44a79e62 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -227,6 +227,14 @@ impl Combine for Lub { super_vstores(self, vk, a, b) } + fn trait_stores(&self, + vk: ty::terr_vstore_kind, + a: ty::TraitStore, + b: ty::TraitStore) + -> cres { + super_trait_stores(self, vk, a, b) + } + fn modes(&self, a: ast::mode, b: ast::mode) -> cres { super_modes(self, a, b) } diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index b4d8905a93627..580aefe5b1ab1 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -239,6 +239,14 @@ impl Combine for Sub { super_vstores(self, vk, a, b) } + fn trait_stores(&self, + vk: ty::terr_vstore_kind, + a: ty::TraitStore, + b: ty::TraitStore) + -> cres { + super_trait_stores(self, vk, a, b) + } + fn modes(&self, a: ast::mode, b: ast::mode) -> cres { super_modes(self, a, b) } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index abaf658a1a43e..b8b89659c29f8 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -90,7 +90,7 @@ pub enum method_origin { method_param(method_param), // method invoked on a trait instance - method_trait(ast::def_id, uint, ty::vstore), + method_trait(ast::def_id, uint, ty::TraitStore), // method invoked on "self" inside a default method method_self(ast::def_id, uint) diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index f74a0960f6674..e29e63c41ecca 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -125,7 +125,8 @@ pub struct binding_rscope { pub fn in_binding_rscope(self: &RS) -> binding_rscope { - let base = @(copy *self) as @region_scope; + let base = @copy *self; + let base = base as @region_scope; binding_rscope { base: base, anon_bindings: @mut 0 } } impl region_scope for binding_rscope { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 7add8dd2dbe0d..05dc967e3797d 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -237,6 +237,15 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { } } +pub fn trait_store_to_str(cx: ctxt, s: ty::TraitStore) -> ~str { + match s { + ty::BareTraitStore => ~"", + ty::UniqTraitStore => ~"~", + ty::BoxTraitStore => ~"@", + ty::RegionTraitStore(r) => region_to_str_adorned(cx, "&", r, "") + } +} + pub fn vstore_ty_to_str(cx: ctxt, ty: ~str, vs: ty::vstore) -> ~str { match vs { ty::vstore_fixed(_) => { @@ -441,11 +450,11 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { let base = ast_map::path_to_str(path, cx.sess.intr()); parameterized(cx, base, substs.self_r, substs.tps) } - ty_trait(did, ref substs, vs) => { + ty_trait(did, ref substs, s) => { let path = ty::item_path(cx, did); let base = ast_map::path_to_str(path, cx.sess.intr()); let ty = parameterized(cx, base, substs.self_r, substs.tps); - fmt!("%s%s", vstore_to_str(cx, vs), ty) + fmt!("%s%s", trait_store_to_str(cx, s), ty) } ty_evec(mt, vs) => { vstore_ty_to_str(cx, fmt!("%s", mt_to_str(cx, mt)), vs) diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc index 0367a771ffbd1..182cfc43ade9e 100644 --- a/src/librusti/rusti.rc +++ b/src/librusti/rusti.rc @@ -59,7 +59,7 @@ enum CmdAction { /// A utility function that hands off a pretty printer to a callback. fn with_pp(intr: @token::ident_interner, - cb: &fn(@pprust::ps, io::Writer)) -> ~str { + cb: &fn(@pprust::ps, @io::Writer)) -> ~str { do io::with_str_writer |writer| { let pp = pprust::rust_printer(writer, intr); @@ -257,7 +257,7 @@ fn get_line(prompt: ~str) -> Option<~str> { } /// Run a command, e.g. :clear, :exit, etc. -fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer, +fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer, cmd: ~str, args: ~[~str]) -> CmdAction { let mut action = action_none; match cmd { @@ -334,7 +334,7 @@ fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer, /// Executes a line of input, which may either be rust code or a /// :command. Returns a new Repl if it has changed. -fn run_line(repl: &mut Repl, in: io::Reader, out: io::Writer, line: ~str) +fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str) -> Option { if line.starts_with(~":") { let full = line.substr(1, line.len() - 1); diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 7d2b8eccd6c0e..0572cf771dbed 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -70,13 +70,14 @@ struct ListenerFn { struct ReadyCtx { sess: session::Session, crate: @ast::crate, - ext_cx: ext_ctxt, + ext_cx: @ext_ctxt, path: ~[ast::ident], fns: ~[ListenerFn] } -fn fold_mod(_ctx: @mut ReadyCtx, m: &ast::_mod, - fold: fold::ast_fold) -> ast::_mod { +fn fold_mod(_ctx: @mut ReadyCtx, + m: &ast::_mod, + fold: @fold::ast_fold) -> ast::_mod { fn strip_main(item: @ast::item) -> @ast::item { @ast::item { attrs: do item.attrs.filtered |attr| { @@ -94,9 +95,9 @@ fn fold_mod(_ctx: @mut ReadyCtx, m: &ast::_mod, }, fold) } -fn fold_item(ctx: @mut ReadyCtx, item: @ast::item, - fold: fold::ast_fold) -> Option<@ast::item> { - +fn fold_item(ctx: @mut ReadyCtx, + item: @ast::item, + fold: @fold::ast_fold) -> Option<@ast::item> { ctx.path.push(item.ident); let attrs = attr::find_attrs_by_name(item.attrs, ~"pkg_do"); diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 8dbdb83698c6f..9cf2d145eacb4 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -1424,7 +1424,7 @@ mod tests { fail_unless!(a.capacity() == uint::bits); } - fn rng() -> rand::Rng { + fn rng() -> @rand::Rng { let seed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; rand::seeded_rng(seed) } diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index a55d4bc97ec56..4ab119abf1c94 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -415,11 +415,11 @@ pub mod writer { // ebml writing pub struct Encoder { - writer: io::Writer, + writer: @io::Writer, priv mut size_positions: ~[uint], } - fn write_sized_vuint(w: io::Writer, n: uint, size: uint) { + fn write_sized_vuint(w: @io::Writer, n: uint, size: uint) { match size { 1u => w.write(&[0x80u8 | (n as u8)]), 2u => w.write(&[0x40u8 | ((n >> 8_u) as u8), n as u8]), @@ -431,7 +431,7 @@ pub mod writer { }; } - fn write_vuint(w: io::Writer, n: uint) { + fn write_vuint(w: @io::Writer, n: uint) { if n < 0x7f_u { write_sized_vuint(w, n, 1u); return; } if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; } if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; } @@ -439,7 +439,7 @@ pub mod writer { fail!(fmt!("vint to write too big: %?", n)); } - pub fn Encoder(w: io::Writer) -> Encoder { + pub fn Encoder(w: @io::Writer) -> Encoder { let size_positions: ~[uint] = ~[]; Encoder { writer: w, mut size_positions: size_positions } } diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 897cb4c203403..e2e09f1d6750a 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -459,15 +459,15 @@ pub mod flatteners { } pub trait FromReader { - static fn from_reader(r: Reader) -> Self; + static fn from_reader(r: @Reader) -> Self; } pub trait FromWriter { - static fn from_writer(w: Writer) -> Self; + static fn from_writer(w: @Writer) -> Self; } impl FromReader for json::Decoder/&self { - static fn from_reader(r: Reader) -> json::Decoder/&self { + static fn from_reader(r: @Reader) -> json::Decoder/&self { match json::from_reader(r) { Ok(json) => { json::Decoder(json) @@ -478,13 +478,13 @@ pub mod flatteners { } impl FromWriter for json::Encoder { - static fn from_writer(w: Writer) -> json::Encoder { + static fn from_writer(w: @Writer) -> json::Encoder { json::Encoder(w) } } impl FromReader for ebml::reader::Decoder { - static fn from_reader(r: Reader) -> ebml::reader::Decoder { + static fn from_reader(r: @Reader) -> ebml::reader::Decoder { let buf = @r.read_whole_stream(); let doc = ebml::reader::Doc(buf); ebml::reader::Decoder(doc) @@ -492,7 +492,7 @@ pub mod flatteners { } impl FromWriter for ebml::writer::Encoder { - static fn from_writer(w: Writer) -> ebml::writer::Encoder { + static fn from_writer(w: @Writer) -> ebml::writer::Encoder { ebml::writer::Encoder(w) } } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 8c6a870b98cd4..56f2611c91447 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -74,10 +74,10 @@ fn spaces(n: uint) -> ~str { } pub struct Encoder { - priv wr: io::Writer, + priv wr: @io::Writer, } -pub fn Encoder(wr: io::Writer) -> Encoder { +pub fn Encoder(wr: @io::Writer) -> Encoder { Encoder { wr: wr } } @@ -208,11 +208,11 @@ impl serialize::Encoder for Encoder { } pub struct PrettyEncoder { - priv wr: io::Writer, + priv wr: @io::Writer, priv mut indent: uint, } -pub fn PrettyEncoder(wr: io::Writer) -> PrettyEncoder { +pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder { PrettyEncoder { wr: wr, indent: 0 } } @@ -346,7 +346,7 @@ impl serialize::Encodable for Json { } /// Encodes a json value into a io::writer -pub fn to_writer(wr: io::Writer, json: &Json) { +pub fn to_writer(wr: @io::Writer, json: &Json) { json.encode(&Encoder(wr)) } @@ -359,7 +359,7 @@ pub pure fn to_str(json: &Json) -> ~str { } /// Encodes a json value into a io::writer -pub fn to_pretty_writer(wr: io::Writer, json: &Json) { +pub fn to_pretty_writer(wr: @io::Writer, json: &Json) { json.encode(&PrettyEncoder(wr)) } @@ -369,14 +369,14 @@ pub fn to_pretty_str(json: &Json) -> ~str { } pub struct Parser { - priv rdr: io::Reader, + priv rdr: @io::Reader, priv mut ch: char, priv mut line: uint, priv mut col: uint, } /// Decode a json value from an io::reader -pub fn Parser(rdr: io::Reader) -> Parser { +pub fn Parser(rdr: @io::Reader) -> Parser { Parser { rdr: rdr, ch: rdr.read_char(), @@ -734,8 +734,8 @@ priv impl Parser { } } -/// Decodes a json value from an io::reader -pub fn from_reader(rdr: io::Reader) -> Result { +/// Decodes a json value from an @io::Reader +pub fn from_reader(rdr: @io::Reader) -> Result { Parser(rdr).parse() } diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 5328975f82aba..9a2d9be3cfd0b 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -1799,7 +1799,7 @@ pub mod test { let sock_buf = @socket_buf(result::unwrap(conn_result)); buf_write(sock_buf, expected_req); - let buf_reader = sock_buf as Reader; + let buf_reader = sock_buf as @Reader; let actual_response = str::from_bytes(buf_reader.read_whole_stream()); debug!("Actual response: %s", actual_response); fail_unless!(expected_resp == actual_response); diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 18527cfece111..6a234b9dc9bea 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -326,7 +326,7 @@ pub mod chained { } pub impl T { - fn to_writer(&self, wr: io::Writer) { + fn to_writer(&self, wr: @io::Writer) { if self.count == 0u { wr.write_str(~"{}"); return; diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index d2d80eb7da803..f823d73cf0bff 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -14,10 +14,10 @@ use core::io::WriterUtil; use core::io; pub struct Serializer { - wr: io::Writer, + wr: @io::Writer, } -pub fn Serializer(wr: io::Writer) -> Serializer { +pub fn Serializer(wr: @io::Writer) -> Serializer { Serializer { wr: wr } } diff --git a/src/libstd/semver.rs b/src/libstd/semver.rs index 7b8a06f1b93af..85996c8ac4ad4 100644 --- a/src/libstd/semver.rs +++ b/src/libstd/semver.rs @@ -138,7 +138,7 @@ condition! { bad_parse: () -> (); } -fn take_nonempty_prefix(rdr: io::Reader, +fn take_nonempty_prefix(rdr: @io::Reader, ch: char, pred: &fn(char) -> bool) -> (~str, char) { let mut buf = ~""; @@ -154,7 +154,7 @@ fn take_nonempty_prefix(rdr: io::Reader, (buf, ch) } -fn take_num(rdr: io::Reader, ch: char) -> (uint, char) { +fn take_num(rdr: @io::Reader, ch: char) -> (uint, char) { let (s, ch) = take_nonempty_prefix(rdr, ch, char::is_digit); match uint::from_str(s) { None => { bad_parse::cond.raise(()); (0, ch) }, @@ -162,7 +162,7 @@ fn take_num(rdr: io::Reader, ch: char) -> (uint, char) { } } -fn take_ident(rdr: io::Reader, ch: char) -> (Identifier, char) { +fn take_ident(rdr: @io::Reader, ch: char) -> (Identifier, char) { let (s,ch) = take_nonempty_prefix(rdr, ch, char::is_alphanumeric); if s.all(char::is_digit) { match uint::from_str(s) { @@ -180,8 +180,7 @@ fn expect(ch: char, c: char) { } } -fn parse_reader(rdr: io::Reader) -> Version { - +fn parse_reader(rdr: @io::Reader) -> Version { let (major, ch) = take_num(rdr, rdr.read_char()); expect(ch, '.'); let (minor, ch) = take_num(rdr, rdr.read_char()); diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 50de528762f26..eae697476e0d2 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -893,6 +893,7 @@ mod test_tim_sort { use sort::tim_sort; + use core::rand::RngUtil; use core::rand; use core::vec; @@ -990,6 +991,7 @@ mod big_tests { use sort::*; + use core::rand::RngUtil; use core::rand; use core::task; use core::uint; diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index cd023962c8846..7704ec158e565 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -12,6 +12,7 @@ use core::os; use core::prelude::*; +use core::rand::RngUtil; use core::rand; pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option { diff --git a/src/libstd/term.rs b/src/libstd/term.rs index fb63755a572ee..2a8c8b3b06bbd 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -36,10 +36,10 @@ pub const color_bright_magenta: u8 = 13u8; pub const color_bright_cyan: u8 = 14u8; pub const color_bright_white: u8 = 15u8; -pub fn esc(writer: io::Writer) { writer.write(~[0x1bu8, '[' as u8]); } +pub fn esc(writer: @io::Writer) { writer.write(~[0x1bu8, '[' as u8]); } /// Reset the foreground and background colors to default -pub fn reset(writer: io::Writer) { +pub fn reset(writer: @io::Writer) { esc(writer); writer.write(~['0' as u8, 'm' as u8]); } @@ -59,7 +59,7 @@ pub fn color_supported() -> bool { }; } -pub fn set_color(writer: io::Writer, first_char: u8, color: u8) { +pub fn set_color(writer: @io::Writer, first_char: u8, color: u8) { fail_unless!((color < 16u8)); esc(writer); let mut color = color; @@ -68,12 +68,12 @@ pub fn set_color(writer: io::Writer, first_char: u8, color: u8) { } /// Set the foreground color -pub fn fg(writer: io::Writer, color: u8) { +pub fn fg(writer: @io::Writer, color: u8) { return set_color(writer, '3' as u8, color); } /// Set the background color -pub fn bg(writer: io::Writer, color: u8) { +pub fn bg(writer: @io::Writer, color: u8) { return set_color(writer, '4' as u8, color); } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 7286ce5e2bdff..5c0894edb3d86 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -199,8 +199,8 @@ pub struct BenchSamples { pub enum TestResult { TrOk, TrFailed, TrIgnored, TrBench(BenchSamples) } struct ConsoleTestState { - out: io::Writer, - log_out: Option, + out: @io::Writer, + log_out: Option<@io::Writer>, use_color: bool, mut total: uint, mut passed: uint, @@ -317,7 +317,7 @@ pub fn run_tests_console(opts: &TestOpts, } } - fn write_log(out: io::Writer, result: TestResult, test: &TestDesc) { + fn write_log(out: @io::Writer, result: TestResult, test: &TestDesc) { out.write_line(fmt!("%s %s", match result { TrOk => ~"ok", @@ -327,23 +327,26 @@ pub fn run_tests_console(opts: &TestOpts, }, test.name.to_str())); } - fn write_ok(out: io::Writer, use_color: bool) { + fn write_ok(out: @io::Writer, use_color: bool) { write_pretty(out, ~"ok", term::color_green, use_color); } - fn write_failed(out: io::Writer, use_color: bool) { + fn write_failed(out: @io::Writer, use_color: bool) { write_pretty(out, ~"FAILED", term::color_red, use_color); } - fn write_ignored(out: io::Writer, use_color: bool) { + fn write_ignored(out: @io::Writer, use_color: bool) { write_pretty(out, ~"ignored", term::color_yellow, use_color); } - fn write_bench(out: io::Writer, use_color: bool) { + fn write_bench(out: @io::Writer, use_color: bool) { write_pretty(out, ~"bench", term::color_cyan, 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); } @@ -602,6 +605,7 @@ pub mod bench { use stats::Stats; use core::num; + use core::rand::RngUtil; use core::rand; use core::u64; use core::vec; @@ -701,7 +705,6 @@ pub mod bench { let mut prev_madp = 0.0; loop { - let n_samples = rng.gen_uint_range(50, 60); let n_iter = rng.gen_uint_range(magnitude, magnitude * 2); diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 60469d0b0f235..15d091412a108 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -179,6 +179,7 @@ mod test { use uv; use core::iter; + use core::rand::RngUtil; use core::rand; use core::task; use core::pipes::{stream, SharedChan}; diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 42a84da43d254..56ee3bd5893da 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -706,6 +706,7 @@ fn remove(node: &mut Option<~TreeNode>, mod test_treemap { use core::prelude::*; use super::*; + use core::rand::RngUtil; use core::rand; #[test] diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index a7d5c0ce75fa0..f798bc603a40c 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -110,7 +110,7 @@ pub struct Ctx { map: @map, path: path, local_id: uint, - diag: span_handler, + diag: @span_handler, } pub type vt = visit::vt<@mut Ctx>; @@ -132,7 +132,7 @@ pub fn mk_ast_map_visitor() -> vt { }); } -pub fn map_crate(diag: span_handler, c: crate) -> map { +pub fn map_crate(diag: @span_handler, c: crate) -> map { let cx = @mut Ctx { map: @std::oldmap::HashMap(), path: ~[], @@ -146,7 +146,7 @@ pub fn map_crate(diag: span_handler, c: crate) -> map { // Used for items loaded from external crate that are being inlined into this // crate. The `path` should be the path to the item but should not include // the item itself. -pub fn map_decoded_item(diag: span_handler, +pub fn map_decoded_item(diag: @span_handler, map: map, path: path, ii: inlined_item) { diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index fb7143f7c1438..1d912c53483c2 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -360,7 +360,7 @@ pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { } -pub fn require_unique_names(diagnostic: span_handler, +pub fn require_unique_names(diagnostic: @span_handler, metas: &[@ast::meta_item]) { let mut set = LinearSet::new(); for metas.each |meta| { diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 4e177fecec9e6..93d28f31c8db4 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -55,7 +55,7 @@ pub trait span_handler { fn span_note(@mut self, sp: span, msg: &str); fn span_bug(@mut self, sp: span, msg: &str) -> !; fn span_unimpl(@mut self, sp: span, msg: &str) -> !; - fn handler(@mut self) -> handler; + fn handler(@mut self) -> @handler; } struct HandlerT { @@ -64,7 +64,7 @@ struct HandlerT { } struct CodemapT { - handler: handler, + handler: @handler, cm: @codemap::CodeMap, } @@ -89,7 +89,7 @@ impl span_handler for CodemapT { fn span_unimpl(@mut self, sp: span, msg: &str) -> ! { self.span_bug(sp, ~"unimplemented " + msg); } - fn handler(@mut self) -> handler { + fn handler(@mut self) -> @handler { self.handler } } @@ -143,8 +143,8 @@ pub fn ice_msg(msg: &str) -> ~str { fmt!("internal compiler error: %s", msg) } -pub fn mk_span_handler(handler: handler, cm: @codemap::CodeMap) - -> span_handler { +pub fn mk_span_handler(handler: @handler, cm: @codemap::CodeMap) + -> @span_handler { @mut CodemapT { handler: handler, cm: cm } as @span_handler } @@ -304,7 +304,7 @@ fn print_macro_backtrace(cm: @codemap::CodeMap, sp: span) { } } -pub fn expect(diag: span_handler, +pub fn expect(diag: @span_handler, opt: Option, msg: &fn() -> ~str) -> T { match opt { diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 8051a67d8fdc7..4f2fd68ff9567 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -41,10 +41,10 @@ fn next_state(s: State) -> Option { } } -pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) - -> base::MacResult { - - let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), +pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) + -> base::MacResult { + let p = parse::new_parser_from_tts(cx.parse_sess(), + cx.cfg(), vec::from_slice(tts)); let mut asm = ~""; diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index c99d89776431a..8c02b4323715d 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -110,7 +110,7 @@ mod syntax { } pub fn expand_auto_encode( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, _mitem: @ast::meta_item, in_items: ~[@ast::item] @@ -165,7 +165,7 @@ pub fn expand_auto_encode( } pub fn expand_auto_decode( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, _mitem: @ast::meta_item, in_items: ~[@ast::item] @@ -219,7 +219,7 @@ pub fn expand_auto_decode( } } -priv impl ext_ctxt { +priv impl @ext_ctxt { fn bind_path( &self, span: span, @@ -426,7 +426,7 @@ priv impl ext_ctxt { } fn mk_impl( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, ident: ast::ident, ty_param: ast::TyParam, @@ -499,7 +499,7 @@ fn mk_impl( } fn mk_ser_impl( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, ident: ast::ident, generics: &ast::Generics, @@ -543,7 +543,7 @@ fn mk_ser_impl( } fn mk_deser_impl( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, ident: ast::ident, generics: &ast::Generics, @@ -587,7 +587,7 @@ fn mk_deser_impl( } fn mk_ser_method( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, +ser_body: ast::blk ) -> @ast::method { @@ -647,7 +647,7 @@ fn mk_ser_method( } fn mk_deser_method( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, ty: @ast::Ty, +deser_body: ast::blk @@ -701,7 +701,7 @@ fn mk_deser_method( } fn mk_struct_ser_impl( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, ident: ast::ident, fields: &[@ast::struct_field], @@ -762,7 +762,7 @@ fn mk_struct_ser_impl( } fn mk_struct_deser_impl( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, ident: ast::ident, fields: ~[@ast::struct_field], @@ -866,7 +866,7 @@ fn mk_struct_fields(fields: &[@ast::struct_field]) -> ~[field] { } fn mk_enum_ser_impl( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, ident: ast::ident, +enum_def: ast::enum_def, @@ -883,7 +883,7 @@ fn mk_enum_ser_impl( } fn mk_enum_deser_impl( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, ident: ast::ident, +enum_def: ast::enum_def, @@ -900,7 +900,7 @@ fn mk_enum_deser_impl( } fn ser_variant( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, v_name: ast::ident, v_idx: uint, @@ -982,7 +982,7 @@ fn ser_variant( } fn mk_enum_ser_body( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, name: ast::ident, +variants: ~[ast::variant] @@ -1032,7 +1032,7 @@ fn mk_enum_ser_body( } fn mk_enum_deser_variant_nary( - cx: ext_ctxt, + cx: @ext_ctxt, span: span, name: ast::ident, args: ~[ast::variant_arg] @@ -1069,7 +1069,7 @@ fn mk_enum_deser_variant_nary( } fn mk_enum_deser_body( - ext_cx: ext_ctxt, + ext_cx: @ext_ctxt, span: span, name: ast::ident, variants: ~[ast::variant] diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index c8363e3daa847..f0822ea4d256a 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -36,7 +36,7 @@ pub struct MacroDef { ext: SyntaxExtension } -pub type ItemDecorator = @fn(ext_ctxt, +pub type ItemDecorator = @fn(@ext_ctxt, span, @ast::meta_item, ~[@ast::item]) @@ -47,7 +47,7 @@ pub struct SyntaxExpanderTT { span: Option } -pub type SyntaxExpanderTTFun = @fn(ext_ctxt, +pub type SyntaxExpanderTTFun = @fn(@ext_ctxt, span, &[ast::token_tree]) -> MacResult; @@ -57,7 +57,7 @@ pub struct SyntaxExpanderTTItem { span: Option } -pub type SyntaxExpanderTTItemFun = @fn(ext_ctxt, +pub type SyntaxExpanderTTItemFun = @fn(@ext_ctxt, span, ast::ident, ~[ast::token_tree]) @@ -238,8 +238,8 @@ pub trait ext_ctxt { fn ident_of(@mut self, st: ~str) -> ast::ident; } -pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, - +cfg: ast::crate_cfg) -> ext_ctxt { +pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, +cfg: ast::crate_cfg) + -> @ext_ctxt { struct CtxtRepr { parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg, @@ -333,7 +333,7 @@ pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, ((imp) as @ext_ctxt) } -pub fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str { +pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str { match expr.node { ast::expr_lit(l) => match l.node { ast::lit_str(s) => copy *s, @@ -343,7 +343,7 @@ pub fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str { } } -pub fn expr_to_ident(cx: ext_ctxt, +pub fn expr_to_ident(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ast::ident { match expr.node { @@ -357,14 +357,14 @@ pub fn expr_to_ident(cx: ext_ctxt, } } -pub fn check_zero_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree], +pub fn check_zero_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree], name: &str) { if tts.len() != 0 { cx.span_fatal(sp, fmt!("%s takes no arguments", name)); } } -pub fn get_single_str_from_tts(cx: ext_ctxt, +pub fn get_single_str_from_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree], name: &str) -> ~str { @@ -379,7 +379,7 @@ pub fn get_single_str_from_tts(cx: ext_ctxt, } } -pub fn get_exprs_from_tts(cx: ext_ctxt, tts: &[ast::token_tree]) +pub fn get_exprs_from_tts(cx: @ext_ctxt, tts: &[ast::token_tree]) -> ~[@ast::expr] { let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 5d071b8d517f3..18c7cd3f86138 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -25,7 +25,7 @@ pub struct Field { ex: @ast::expr } -pub fn mk_expr(cx: ext_ctxt, +pub fn mk_expr(cx: @ext_ctxt, sp: codemap::span, +expr: ast::expr_) -> @ast::expr { @@ -37,28 +37,28 @@ pub fn mk_expr(cx: ext_ctxt, } } -pub fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr { +pub fn mk_lit(cx: @ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr { let sp_lit = @codemap::spanned { node: lit, span: sp }; mk_expr(cx, sp, ast::expr_lit(sp_lit)) } -pub fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr { +pub fn mk_int(cx: @ext_ctxt, sp: span, i: int) -> @ast::expr { let lit = ast::lit_int(i as i64, ast::ty_i); return mk_lit(cx, sp, lit); } -pub fn mk_uint(cx: ext_ctxt, sp: span, u: uint) -> @ast::expr { +pub fn mk_uint(cx: @ext_ctxt, sp: span, u: uint) -> @ast::expr { let lit = ast::lit_uint(u as u64, ast::ty_u); return mk_lit(cx, sp, lit); } -pub fn mk_u8(cx: ext_ctxt, sp: span, u: u8) -> @ast::expr { +pub fn mk_u8(cx: @ext_ctxt, sp: span, u: u8) -> @ast::expr { let lit = ast::lit_uint(u as u64, ast::ty_u8); return mk_lit(cx, sp, lit); } -pub fn mk_binary(cx: ext_ctxt, sp: span, op: ast::binop, +pub fn mk_binary(cx: @ext_ctxt, sp: span, op: ast::binop, lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr { cx.next_id(); // see ast_util::op_expr_callee_id mk_expr(cx, sp, ast::expr_binary(op, lhs, rhs)) } -pub fn mk_unary(cx: ext_ctxt, sp: span, op: ast::unop, e: @ast::expr) +pub fn mk_unary(cx: @ext_ctxt, sp: span, op: ast::unop, e: @ast::expr) -> @ast::expr { cx.next_id(); // see ast_util::op_expr_callee_id mk_expr(cx, sp, ast::expr_unary(op, e)) @@ -88,69 +88,70 @@ pub fn mk_raw_path_global(sp: span, +idents: ~[ast::ident]) -> @ast::path { rp: None, types: ~[] } } -pub fn mk_path(cx: ext_ctxt, sp: span, +idents: ~[ast::ident]) -> @ast::expr { +pub fn mk_path(cx: @ext_ctxt, sp: span, +idents: ~[ast::ident]) + -> @ast::expr { mk_expr(cx, sp, ast::expr_path(mk_raw_path(sp, idents))) } -pub fn mk_path_global(cx: ext_ctxt, sp: span, +idents: ~[ast::ident]) +pub fn mk_path_global(cx: @ext_ctxt, sp: span, +idents: ~[ast::ident]) -> @ast::expr { mk_expr(cx, sp, ast::expr_path(mk_raw_path_global(sp, idents))) } -pub fn mk_access_(cx: ext_ctxt, sp: span, p: @ast::expr, m: ast::ident) +pub fn mk_access_(cx: @ext_ctxt, sp: span, p: @ast::expr, m: ast::ident) -> @ast::expr { mk_expr(cx, sp, ast::expr_field(p, m, ~[])) } -pub fn mk_access(cx: ext_ctxt, sp: span, +p: ~[ast::ident], m: ast::ident) +pub fn mk_access(cx: @ext_ctxt, sp: span, +p: ~[ast::ident], m: ast::ident) -> @ast::expr { let pathexpr = mk_path(cx, sp, p); return mk_access_(cx, sp, pathexpr, m); } -pub fn mk_addr_of(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { +pub fn mk_addr_of(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { return mk_expr(cx, sp, ast::expr_addr_of(ast::m_imm, e)); } -pub fn mk_call_(cx: ext_ctxt, sp: span, fn_expr: @ast::expr, +pub fn mk_call_(cx: @ext_ctxt, sp: span, fn_expr: @ast::expr, +args: ~[@ast::expr]) -> @ast::expr { mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar)) } -pub fn mk_call(cx: ext_ctxt, sp: span, +fn_path: ~[ast::ident], +pub fn mk_call(cx: @ext_ctxt, sp: span, +fn_path: ~[ast::ident], +args: ~[@ast::expr]) -> @ast::expr { let pathexpr = mk_path(cx, sp, fn_path); return mk_call_(cx, sp, pathexpr, args); } -pub fn mk_call_global(cx: ext_ctxt, sp: span, +fn_path: ~[ast::ident], +pub fn mk_call_global(cx: @ext_ctxt, sp: span, +fn_path: ~[ast::ident], +args: ~[@ast::expr]) -> @ast::expr { let pathexpr = mk_path_global(cx, sp, fn_path); return mk_call_(cx, sp, pathexpr, args); } // e = expr, t = type -pub fn mk_base_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr]) +pub fn mk_base_vec_e(cx: @ext_ctxt, sp: span, +exprs: ~[@ast::expr]) -> @ast::expr { let vecexpr = ast::expr_vec(exprs, ast::m_imm); mk_expr(cx, sp, vecexpr) } -pub fn mk_vstore_e(cx: ext_ctxt, sp: span, expr: @ast::expr, +pub fn mk_vstore_e(cx: @ext_ctxt, sp: span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr { mk_expr(cx, sp, ast::expr_vstore(expr, vst)) } -pub fn mk_uniq_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr]) +pub fn mk_uniq_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::expr_vstore_uniq) } -pub fn mk_slice_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr]) +pub fn mk_slice_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::expr_vstore_slice) } -pub fn mk_fixed_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr]) +pub 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::expr_vstore_fixed(None)) } -pub fn mk_base_str(cx: ext_ctxt, sp: span, +s: ~str) -> @ast::expr { +pub fn mk_base_str(cx: @ext_ctxt, sp: span, +s: ~str) -> @ast::expr { let lit = ast::lit_str(@s); return mk_lit(cx, sp, lit); } -pub fn mk_uniq_str(cx: ext_ctxt, sp: span, +s: ~str) -> @ast::expr { +pub 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::expr_vstore_uniq) } pub fn mk_field(sp: span, f: &Field) -> ast::field { @@ -162,7 +163,7 @@ pub fn mk_field(sp: span, f: &Field) -> ast::field { pub fn mk_fields(sp: span, fields: ~[Field]) -> ~[ast::field] { fields.map(|f| mk_field(sp, f)) } -pub fn mk_struct_e(cx: ext_ctxt, +pub fn mk_struct_e(cx: @ext_ctxt, sp: span, +ctor_path: ~[ast::ident], +fields: ~[Field]) @@ -172,7 +173,7 @@ pub fn mk_struct_e(cx: ext_ctxt, mk_fields(sp, fields), option::None::<@ast::expr>)) } -pub fn mk_global_struct_e(cx: ext_ctxt, +pub fn mk_global_struct_e(cx: @ext_ctxt, sp: span, +ctor_path: ~[ast::ident], +fields: ~[Field]) @@ -182,7 +183,7 @@ pub fn mk_global_struct_e(cx: ext_ctxt, mk_fields(sp, fields), option::None::<@ast::expr>)) } -pub fn mk_glob_use(cx: ext_ctxt, +pub fn mk_glob_use(cx: @ext_ctxt, sp: span, +path: ~[ast::ident]) -> @ast::view_item { let glob = @codemap::spanned { @@ -194,7 +195,7 @@ pub fn mk_glob_use(cx: ext_ctxt, vis: ast::private, span: sp } } -pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool, +pub fn mk_local(cx: @ext_ctxt, sp: span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt { let pat = @ast::pat { @@ -219,7 +220,7 @@ pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool, let decl = codemap::spanned {node: ast::decl_local(~[local]), span: sp}; @codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp } } -pub fn mk_block(cx: ext_ctxt, span: span, +pub fn mk_block(cx: @ext_ctxt, span: span, +view_items: ~[@ast::view_item], +stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> @ast::expr { @@ -235,7 +236,7 @@ pub fn mk_block(cx: ext_ctxt, span: span, }; mk_expr(cx, span, ast::expr_block(blk)) } -pub fn mk_block_(cx: ext_ctxt, +pub fn mk_block_(cx: @ext_ctxt, span: span, +stmts: ~[@ast::stmt]) -> ast::blk { @@ -250,7 +251,7 @@ pub fn mk_block_(cx: ext_ctxt, span: span, } } -pub fn mk_simple_block(cx: ext_ctxt, +pub fn mk_simple_block(cx: @ext_ctxt, span: span, expr: @ast::expr) -> ast::blk { @@ -265,21 +266,21 @@ pub fn mk_simple_block(cx: ext_ctxt, span: span, } } -pub fn mk_copy(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { +pub fn mk_copy(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { mk_expr(cx, sp, ast::expr_copy(e)) } -pub fn mk_managed(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { +pub fn mk_managed(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { mk_expr(cx, sp, ast::expr_unary(ast::box(ast::m_imm), e)) } -pub fn mk_pat(cx: ext_ctxt, span: span, +pat: ast::pat_) -> @ast::pat { +pub fn mk_pat(cx: @ext_ctxt, span: span, +pat: ast::pat_) -> @ast::pat { @ast::pat { id: cx.next_id(), node: pat, span: span } } -pub fn mk_pat_ident(cx: ext_ctxt, +pub fn mk_pat_ident(cx: @ext_ctxt, span: span, ident: ast::ident) -> @ast::pat { mk_pat_ident_with_binding_mode(cx, span, ident, ast::bind_by_copy) } -pub fn mk_pat_ident_with_binding_mode(cx: ext_ctxt, +pub fn mk_pat_ident_with_binding_mode(cx: @ext_ctxt, span: span, ident: ast::ident, bm: ast::binding_mode) -> @ast::pat { @@ -287,7 +288,7 @@ pub fn mk_pat_ident_with_binding_mode(cx: ext_ctxt, let pat = ast::pat_ident(bm, path, None); mk_pat(cx, span, pat) } -pub fn mk_pat_enum(cx: ext_ctxt, +pub fn mk_pat_enum(cx: @ext_ctxt, span: span, path: @ast::path, +subpats: ~[@ast::pat]) @@ -295,7 +296,7 @@ pub fn mk_pat_enum(cx: ext_ctxt, let pat = ast::pat_enum(path, Some(subpats)); mk_pat(cx, span, pat) } -pub fn mk_pat_struct(cx: ext_ctxt, +pub fn mk_pat_struct(cx: @ext_ctxt, span: span, path: @ast::path, +field_pats: ~[ast::field_pat]) @@ -303,17 +304,17 @@ pub fn mk_pat_struct(cx: ext_ctxt, let pat = ast::pat_struct(path, field_pats, false); mk_pat(cx, span, pat) } -pub fn mk_bool(cx: ext_ctxt, span: span, value: bool) -> @ast::expr { +pub fn mk_bool(cx: @ext_ctxt, span: span, value: bool) -> @ast::expr { let lit_expr = ast::expr_lit(@codemap::spanned { node: ast::lit_bool(value), span: span }); build::mk_expr(cx, span, lit_expr) } -pub fn mk_stmt(cx: ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt { +pub fn mk_stmt(cx: @ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt { let stmt_ = ast::stmt_semi(expr, cx.next_id()); @codemap::spanned { node: stmt_, span: span } } -pub fn mk_ty_path(cx: ext_ctxt, +pub fn mk_ty_path(cx: @ext_ctxt, span: span, +idents: ~[ ast::ident ]) -> @ast::Ty { @@ -322,7 +323,7 @@ pub fn mk_ty_path(cx: ext_ctxt, let ty = @ast::Ty { id: cx.next_id(), node: ty, span: span }; ty } -pub fn mk_ty_path_global(cx: ext_ctxt, +pub fn mk_ty_path_global(cx: @ext_ctxt, span: span, +idents: ~[ ast::ident ]) -> @ast::Ty { @@ -331,13 +332,13 @@ pub fn mk_ty_path_global(cx: ext_ctxt, let ty = @ast::Ty { id: cx.next_id(), node: ty, span: span }; ty } -pub fn mk_simple_ty_path(cx: ext_ctxt, +pub fn mk_simple_ty_path(cx: @ext_ctxt, span: span, ident: ast::ident) -> @ast::Ty { mk_ty_path(cx, span, ~[ ident ]) } -pub fn mk_arg(cx: ext_ctxt, +pub fn mk_arg(cx: @ext_ctxt, span: span, ident: ast::ident, ty: @ast::Ty) @@ -354,13 +355,13 @@ pub fn mk_arg(cx: ext_ctxt, pub fn mk_fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl { ast::fn_decl { inputs: inputs, output: output, cf: ast::return_val } } -pub fn mk_ty_param(cx: ext_ctxt, +pub fn mk_ty_param(cx: @ext_ctxt, ident: ast::ident, bounds: @OptVec) -> ast::TyParam { ast::TyParam { ident: ident, id: cx.next_id(), bounds: bounds } } -pub fn mk_lifetime(cx: ext_ctxt, +pub fn mk_lifetime(cx: @ext_ctxt, span: span, ident: ast::ident) -> ast::Lifetime { diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 4f53bf62efbab..0c3bef56459b5 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -16,7 +16,7 @@ use ext::base::*; use ext::base; use parse::token; -pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let mut res_str = ~""; for tts.eachi |i, e| { diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index 093327ec32e09..26b5b4566b7f7 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -45,18 +45,18 @@ pub impl Junction { } } -type ExpandDerivingStructDefFn = &self/fn(ext_ctxt, +type ExpandDerivingStructDefFn = &self/fn(@ext_ctxt, span, x: &struct_def, ident, y: &Generics) -> @item; -type ExpandDerivingEnumDefFn = &self/fn(ext_ctxt, +type ExpandDerivingEnumDefFn = &self/fn(@ext_ctxt, span, x: &enum_def, ident, y: &Generics) -> @item; -pub fn expand_meta_deriving(cx: ext_ctxt, +pub fn expand_meta_deriving(cx: @ext_ctxt, _span: span, mitem: @meta_item, in_items: ~[@item]) @@ -98,7 +98,7 @@ pub fn expand_meta_deriving(cx: ext_ctxt, } } -pub fn expand_deriving_eq(cx: ext_ctxt, +pub fn expand_deriving_eq(cx: @ext_ctxt, span: span, _mitem: @meta_item, in_items: ~[@item]) @@ -110,7 +110,7 @@ pub fn expand_deriving_eq(cx: ext_ctxt, expand_deriving_eq_enum_def) } -pub fn expand_deriving_iter_bytes(cx: ext_ctxt, +pub fn expand_deriving_iter_bytes(cx: @ext_ctxt, span: span, _mitem: @meta_item, in_items: ~[@item]) @@ -122,7 +122,7 @@ pub fn expand_deriving_iter_bytes(cx: ext_ctxt, expand_deriving_iter_bytes_enum_def) } -pub fn expand_deriving_clone(cx: ext_ctxt, +pub fn expand_deriving_clone(cx: @ext_ctxt, span: span, _: @meta_item, in_items: ~[@item]) @@ -134,7 +134,7 @@ pub fn expand_deriving_clone(cx: ext_ctxt, expand_deriving_clone_enum_def) } -fn expand_deriving(cx: ext_ctxt, +fn expand_deriving(cx: @ext_ctxt, span: span, in_items: ~[@item], expand_deriving_struct_def: ExpandDerivingStructDefFn, @@ -164,7 +164,7 @@ fn expand_deriving(cx: ext_ctxt, result } -fn create_impl_item(cx: ext_ctxt, span: span, +item: item_) -> @item { +fn create_impl_item(cx: @ext_ctxt, span: span, +item: item_) -> @item { @ast::item { ident: clownshoes_extensions, attrs: ~[], @@ -177,7 +177,7 @@ fn create_impl_item(cx: ext_ctxt, span: span, +item: item_) -> @item { /// Creates a method from the given expression, the signature of which /// conforms to the `eq` or `ne` method. -fn create_eq_method(cx: ext_ctxt, +fn create_eq_method(cx: @ext_ctxt, span: span, method_ident: ident, type_ident: ident, @@ -236,7 +236,7 @@ fn create_eq_method(cx: ext_ctxt, } } -fn create_self_type_with_params(cx: ext_ctxt, +fn create_self_type_with_params(cx: @ext_ctxt, span: span, type_ident: ident, generics: &Generics) @@ -258,7 +258,7 @@ fn create_self_type_with_params(cx: ext_ctxt, @ast::Ty { id: cx.next_id(), node: self_type, span: span } } -fn create_derived_impl(cx: ext_ctxt, +fn create_derived_impl(cx: @ext_ctxt, span: span, type_ident: ident, generics: &Generics, @@ -320,7 +320,7 @@ fn create_derived_impl(cx: ext_ctxt, return create_impl_item(cx, span, impl_item); } -fn create_derived_eq_impl(cx: ext_ctxt, +fn create_derived_eq_impl(cx: @ext_ctxt, span: span, type_ident: ident, generics: &Generics, @@ -336,7 +336,7 @@ fn create_derived_eq_impl(cx: ext_ctxt, create_derived_impl(cx, span, type_ident, generics, methods, trait_path) } -fn create_derived_iter_bytes_impl(cx: ext_ctxt, +fn create_derived_iter_bytes_impl(cx: @ext_ctxt, span: span, type_ident: ident, generics: &Generics, @@ -351,7 +351,7 @@ fn create_derived_iter_bytes_impl(cx: ext_ctxt, create_derived_impl(cx, span, type_ident, generics, methods, trait_path) } -fn create_derived_clone_impl(cx: ext_ctxt, +fn create_derived_clone_impl(cx: @ext_ctxt, span: span, type_ident: ident, generics: &Generics, @@ -368,7 +368,7 @@ fn create_derived_clone_impl(cx: ext_ctxt, // Creates a method from the given set of statements conforming to the // signature of the `iter_bytes` method. -fn create_iter_bytes_method(cx: ext_ctxt, +fn create_iter_bytes_method(cx: @ext_ctxt, span: span, +statements: ~[@stmt]) -> @method { @@ -417,7 +417,7 @@ fn create_iter_bytes_method(cx: ext_ctxt, // Creates a method from the given expression conforming to the signature of // the `clone` method. -fn create_clone_method(cx: ext_ctxt, +fn create_clone_method(cx: @ext_ctxt, span: span, +type_ident: ast::ident, generics: &Generics, @@ -467,7 +467,7 @@ fn create_clone_method(cx: ext_ctxt, } } -fn create_subpatterns(cx: ext_ctxt, +fn create_subpatterns(cx: @ext_ctxt, span: span, prefix: ~str, n: uint) @@ -496,7 +496,7 @@ fn is_struct_tuple(struct_def: &struct_def) -> bool { }) } -fn create_enum_variant_pattern(cx: ext_ctxt, +fn create_enum_variant_pattern(cx: @ext_ctxt, span: span, variant: &variant, prefix: ~str) @@ -542,7 +542,7 @@ fn create_enum_variant_pattern(cx: ext_ctxt, } } -fn call_substructure_eq_method(cx: ext_ctxt, +fn call_substructure_eq_method(cx: @ext_ctxt, span: span, self_field: @expr, other_field_ref: @expr, @@ -571,7 +571,7 @@ fn call_substructure_eq_method(cx: ext_ctxt, }; } -fn finish_eq_chain_expr(cx: ext_ctxt, +fn finish_eq_chain_expr(cx: @ext_ctxt, span: span, chain_expr: Option<@expr>, junction: Junction) @@ -587,7 +587,7 @@ fn finish_eq_chain_expr(cx: ext_ctxt, } } -fn call_substructure_iter_bytes_method(cx: ext_ctxt, +fn call_substructure_iter_bytes_method(cx: @ext_ctxt, span: span, self_field: @expr) -> @stmt { @@ -612,7 +612,7 @@ fn call_substructure_iter_bytes_method(cx: ext_ctxt, build::mk_stmt(cx, span, self_call) } -fn call_substructure_clone_method(cx: ext_ctxt, +fn call_substructure_clone_method(cx: @ext_ctxt, span: span, self_field: @expr) -> @expr { @@ -622,7 +622,7 @@ fn call_substructure_clone_method(cx: ext_ctxt, build::mk_call_(cx, span, self_method, ~[]) } -fn variant_arg_count(cx: ext_ctxt, span: span, variant: &variant) -> uint { +fn variant_arg_count(cx: @ext_ctxt, span: span, variant: &variant) -> uint { match variant.node.kind { tuple_variant_kind(ref args) => args.len(), struct_variant_kind(ref struct_def) => struct_def.fields.len(), @@ -632,7 +632,7 @@ fn variant_arg_count(cx: ext_ctxt, span: span, variant: &variant) -> uint { } } -fn expand_deriving_eq_struct_def(cx: ext_ctxt, +fn expand_deriving_eq_struct_def(cx: @ext_ctxt, span: span, struct_def: &struct_def, type_ident: ident, @@ -672,7 +672,7 @@ fn expand_deriving_eq_struct_def(cx: ext_ctxt, ne_method); } -fn expand_deriving_eq_enum_def(cx: ext_ctxt, +fn expand_deriving_eq_enum_def(cx: @ext_ctxt, span: span, enum_definition: &enum_def, type_ident: ident, @@ -705,7 +705,7 @@ fn expand_deriving_eq_enum_def(cx: ext_ctxt, ne_method); } -fn expand_deriving_iter_bytes_struct_def(cx: ext_ctxt, +fn expand_deriving_iter_bytes_struct_def(cx: @ext_ctxt, span: span, struct_def: &struct_def, type_ident: ident, @@ -724,7 +724,7 @@ fn expand_deriving_iter_bytes_struct_def(cx: ext_ctxt, method); } -fn expand_deriving_iter_bytes_enum_def(cx: ext_ctxt, +fn expand_deriving_iter_bytes_enum_def(cx: @ext_ctxt, span: span, enum_definition: &enum_def, type_ident: ident, @@ -743,7 +743,7 @@ fn expand_deriving_iter_bytes_enum_def(cx: ext_ctxt, method); } -fn expand_deriving_clone_struct_def(cx: ext_ctxt, +fn expand_deriving_clone_struct_def(cx: @ext_ctxt, span: span, struct_def: &struct_def, type_ident: ident, @@ -768,7 +768,7 @@ fn expand_deriving_clone_struct_def(cx: ext_ctxt, create_derived_clone_impl(cx, span, type_ident, generics, method) } -fn expand_deriving_clone_enum_def(cx: ext_ctxt, +fn expand_deriving_clone_enum_def(cx: @ext_ctxt, span: span, enum_definition: &enum_def, type_ident: ident, @@ -785,7 +785,7 @@ fn expand_deriving_clone_enum_def(cx: ext_ctxt, create_derived_clone_impl(cx, span, type_ident, generics, method) } -fn expand_deriving_eq_struct_method(cx: ext_ctxt, +fn expand_deriving_eq_struct_method(cx: @ext_ctxt, span: span, struct_def: &struct_def, method_ident: ident, @@ -841,7 +841,7 @@ fn expand_deriving_eq_struct_method(cx: ext_ctxt, body); } -fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt, +fn expand_deriving_iter_bytes_struct_method(cx: @ext_ctxt, span: span, struct_def: &struct_def) -> @method { @@ -875,7 +875,7 @@ fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt, return create_iter_bytes_method(cx, span, statements); } -fn expand_deriving_clone_struct_method(cx: ext_ctxt, +fn expand_deriving_clone_struct_method(cx: @ext_ctxt, span: span, struct_def: &struct_def, type_ident: ident, @@ -918,7 +918,7 @@ fn expand_deriving_clone_struct_method(cx: ext_ctxt, create_clone_method(cx, span, type_ident, generics, struct_literal) } -fn expand_deriving_clone_tuple_struct_method(cx: ext_ctxt, +fn expand_deriving_clone_tuple_struct_method(cx: @ext_ctxt, span: span, struct_def: &struct_def, type_ident: ident, @@ -962,7 +962,7 @@ fn expand_deriving_clone_tuple_struct_method(cx: ext_ctxt, create_clone_method(cx, span, type_ident, generics, self_match_expr) } -fn expand_deriving_eq_enum_method(cx: ext_ctxt, +fn expand_deriving_eq_enum_method(cx: @ext_ctxt, span: span, enum_definition: &enum_def, method_ident: ident, @@ -1096,7 +1096,7 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt, self_match_expr); } -fn expand_deriving_eq_struct_tuple_method(cx: ext_ctxt, +fn expand_deriving_eq_struct_tuple_method(cx: @ext_ctxt, span: span, struct_def: &struct_def, method_ident: ident, @@ -1155,7 +1155,7 @@ fn expand_deriving_eq_struct_tuple_method(cx: ext_ctxt, type_ident, generics, self_match_expr) } -fn expand_enum_or_struct_match(cx: ext_ctxt, +fn expand_enum_or_struct_match(cx: @ext_ctxt, span: span, arms: ~[ ast::arm ]) -> @expr { @@ -1166,7 +1166,7 @@ fn expand_enum_or_struct_match(cx: ext_ctxt, build::mk_expr(cx, span, self_match_expr) } -fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt, +fn expand_deriving_iter_bytes_enum_method(cx: @ext_ctxt, span: span, enum_definition: &enum_def) -> @method { @@ -1221,7 +1221,7 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt, create_iter_bytes_method(cx, span, ~[ self_match_stmt ]) } -fn expand_deriving_clone_enum_method(cx: ext_ctxt, +fn expand_deriving_clone_enum_method(cx: @ext_ctxt, span: span, enum_definition: &enum_def, type_ident: ident, diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index c8fb83224ac74..c21a9fa8739ff 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -23,7 +23,7 @@ use ext::base::*; use ext::base; use ext::build::mk_uniq_str; -pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let var = get_single_str_from_tts(cx, sp, tts, "env!"); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e61e8a1a594ce..3e7406f23e49b 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -26,11 +26,11 @@ use core::option; use core::vec; pub fn expand_expr(extsbox: @mut SyntaxEnv, - cx: ext_ctxt, + cx: @ext_ctxt, e: &expr_, s: span, - fld: ast_fold, - orig: @fn(&expr_, span, ast_fold) -> (expr_, span)) + fld: @ast_fold, + orig: @fn(&expr_, span, @ast_fold) -> (expr_, span)) -> (expr_, span) { match *e { // expr_mac should really be expr_ext or something; it's the @@ -112,10 +112,10 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, // NB: there is some redundancy between this and expand_item, below, and // they might benefit from some amount of semantic and language-UI merger. pub fn expand_mod_items(extsbox: @mut SyntaxEnv, - cx: ext_ctxt, + cx: @ext_ctxt, module_: &ast::_mod, - fld: ast_fold, - orig: @fn(&ast::_mod, ast_fold) -> ast::_mod) + fld: @ast_fold, + orig: @fn(&ast::_mod, @ast_fold) -> ast::_mod) -> ast::_mod { // Fold the contents first: let module_ = orig(module_, fld); @@ -163,10 +163,10 @@ macro_rules! with_exts_frame ( // When we enter a module, record it, for the sake of `module!` pub fn expand_item(extsbox: @mut SyntaxEnv, - cx: ext_ctxt, + cx: @ext_ctxt, it: @ast::item, - fld: ast_fold, - orig: @fn(@ast::item, ast_fold) -> Option<@ast::item>) + fld: @ast_fold, + orig: @fn(@ast::item, @ast_fold) -> Option<@ast::item>) -> Option<@ast::item> { // need to do expansion first... it might turn out to be a module. let maybe_it = match it.node { @@ -239,9 +239,9 @@ macro_rules! without_macro_scoping( // Support for item-position macro invocations, exactly the same // logic as for expression-position macro invocations. pub fn expand_item_mac(+extsbox: @mut SyntaxEnv, - cx: ext_ctxt, &&it: @ast::item, - fld: ast_fold) -> Option<@ast::item> { - + cx: @ext_ctxt, &&it: @ast::item, + fld: @ast_fold) + -> Option<@ast::item> { let (pth, tts) = match it.node { item_mac(codemap::spanned { node: mac_invoc_tt(pth, ref tts), _}) => { (pth, copy *tts) @@ -307,11 +307,11 @@ pub fn expand_item_mac(+extsbox: @mut SyntaxEnv, // expand a stmt pub fn expand_stmt(extsbox: @mut SyntaxEnv, - cx: ext_ctxt, + cx: @ext_ctxt, s: &stmt_, sp: span, - fld: ast_fold, - orig: @fn(&stmt_, span, ast_fold) -> (stmt_, span)) + fld: @ast_fold, + orig: @fn(&stmt_, span, @ast_fold) -> (stmt_, span)) -> (stmt_, span) { let (mac, pth, tts, semi) = match *s { stmt_mac(ref mac, semi) => { @@ -373,11 +373,11 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, pub fn expand_block(extsbox: @mut SyntaxEnv, - cx: ext_ctxt, + cx: @ext_ctxt, blk: &blk_, sp: span, - fld: ast_fold, - orig: @fn(&blk_, span, ast_fold) -> (blk_, span)) + fld: @ast_fold, + orig: @fn(&blk_, span, @ast_fold) -> (blk_, span)) -> (blk_, span) { match (*extsbox).find(&@~" block") { // no scope limit on macros in this block, no need @@ -395,7 +395,7 @@ pub fn expand_block(extsbox: @mut SyntaxEnv, } } -pub fn new_span(cx: ext_ctxt, sp: span) -> span { +pub fn new_span(cx: @ext_ctxt, sp: span) -> span { /* this discards information in the case of macro-defining macros */ return span {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()}; } @@ -488,7 +488,7 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess, // every method/element of AstFoldFns in fold.rs. let extsbox = @mut syntax_expander_table(); let afp = default_ast_fold(); - let cx: ext_ctxt = mk_ctxt(parse_sess, copy cfg); + let cx: @ext_ctxt = mk_ctxt(parse_sess, copy cfg); let f_pre = @AstFoldFns { fold_expr: |expr,span,recur| expand_expr(extsbox, cx, expr, span, recur, afp.fold_expr), diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index af558e6b330d9..bd5fdf3cd5817 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -27,7 +27,7 @@ use ext::build::*; use core::unstable::extfmt::ct::*; -pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let args = get_exprs_from_tts(cx, tts); if args.len() == 0 { @@ -39,7 +39,7 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) 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(&str) -> ! = |s| parse_fmt_err_(cx, fmtspan, s); @@ -51,23 +51,23 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) // probably be factored out in common with other code that builds // expressions. Also: Cleanup the naming of these functions. // Note: Moved many of the common ones to build.rs --kevina -fn pieces_to_expr(cx: ext_ctxt, sp: span, +fn pieces_to_expr(cx: @ext_ctxt, sp: span, pieces: ~[Piece], args: ~[@ast::expr]) -> @ast::expr { - fn make_path_vec(cx: ext_ctxt, ident: @~str) -> ~[ast::ident] { + fn make_path_vec(cx: @ext_ctxt, ident: @~str) -> ~[ast::ident] { let intr = cx.parse_sess().interner; return ~[intr.intern(@~"unstable"), intr.intern(@~"extfmt"), intr.intern(@~"rt"), intr.intern(ident)]; } - fn make_rt_path_expr(cx: ext_ctxt, sp: span, nm: @~str) -> @ast::expr { + fn make_rt_path_expr(cx: @ext_ctxt, sp: span, nm: @~str) -> @ast::expr { let path = make_path_vec(cx, nm); return mk_path_global(cx, sp, path); } // Produces an AST expression that represents a RT::conv record, // which tells the RT::conv* functions how to perform the conversion - 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 { + 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"); for flags.each |f| { let fstr = match *f { @@ -82,7 +82,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } return tmp_expr; } - fn make_count(cx: ext_ctxt, sp: span, cnt: Count) -> @ast::expr { + fn make_count(cx: @ext_ctxt, sp: span, cnt: Count) -> @ast::expr { match cnt { CountImplied => { return make_rt_path_expr(cx, sp, @~"CountImplied"); @@ -96,7 +96,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, _ => cx.span_unimpl(sp, ~"unimplemented fmt! conversion") } } - fn make_ty(cx: ext_ctxt, sp: span, t: Ty) -> @ast::expr { + fn make_ty(cx: @ext_ctxt, sp: span, t: Ty) -> @ast::expr { let mut rt_type; match t { TyHex(c) => match c { @@ -109,7 +109,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } return make_rt_path_expr(cx, sp, @rt_type); } - fn make_conv_struct(cx: ext_ctxt, sp: span, flags_expr: @ast::expr, + fn make_conv_struct(cx: @ext_ctxt, sp: span, flags_expr: @ast::expr, width_expr: @ast::expr, precision_expr: @ast::expr, ty_expr: @ast::expr) -> @ast::expr { let intr = cx.parse_sess().interner; @@ -140,7 +140,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, make_conv_struct(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 path = make_path_vec(cx, @fname); @@ -149,7 +149,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, return mk_call_global(cx, arg.span, path, args); } - fn make_new_conv(cx: ext_ctxt, sp: span, cnv: Conv, arg: @ast::expr) -> + fn make_new_conv(cx: @ext_ctxt, sp: span, cnv: Conv, arg: @ast::expr) -> @ast::expr { // FIXME: Move validation code into core::extfmt (Issue #2249) diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 8a8583420f8fc..bf4a997bc171f 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -17,7 +17,7 @@ use ext::base::*; use ext::base; use print; -pub fn expand_syntax_ext(cx: ext_ctxt, +pub fn expand_syntax_ext(cx: @ext_ctxt, sp: codemap::span, tt: &[ast::token_tree]) -> base::MacResult { diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index e6f0cdde8c150..76b70225c6c84 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -138,7 +138,7 @@ pub trait ext_ctxt_ast_builder { fn strip_bounds(&self, bounds: &Generics) -> Generics; } -impl ext_ctxt_ast_builder for ext_ctxt { +impl ext_ctxt_ast_builder for @ext_ctxt { fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty { self.ty_path_ast_builder(path_global(~[ self.ident_of(~"core"), diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index b543ef5fdaef0..30e7e832db197 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -37,9 +37,8 @@ use ext::base::ext_ctxt; use ext::pipes::proto::{state, protocol, next_state}; use ext::pipes::proto; -impl proto::visitor<(), (), ()> for ext_ctxt { - fn visit_proto(&self, _proto: protocol, - _states: &[()]) { } +impl proto::visitor<(), (), ()> for @ext_ctxt { + fn visit_proto(&self, _proto: protocol, _states: &[()]) { } fn visit_state(&self, state: state, _m: &[()]) { if state.messages.len() == 0 { diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index c5bed32a24f2a..97f2e516603be 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -45,7 +45,7 @@ use ext::pipes::proto::protocol; use core::str; use std::bitv::Bitv; -pub fn analyze(proto: protocol, _cx: ext_ctxt) { +pub fn analyze(proto: protocol, _cx: @ext_ctxt) { debug!("initializing colive analysis"); let num_states = proto.num_states(); let mut colive = do (copy proto.states).map_to_vec |state| { diff --git a/src/libsyntax/ext/pipes/mod.rs b/src/libsyntax/ext/pipes/mod.rs index df17c960ba21d..327cb0ae517e2 100644 --- a/src/libsyntax/ext/pipes/mod.rs +++ b/src/libsyntax/ext/pipes/mod.rs @@ -63,13 +63,15 @@ pub mod check; pub mod liveness; -pub fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident, +pub fn expand_proto(cx: @ext_ctxt, _sp: span, id: ast::ident, tt: ~[ast::token_tree]) -> base::MacResult { let sess = cx.parse_sess(); let cfg = cx.cfg(); let tt_rdr = new_tt_reader(copy cx.parse_sess().span_diagnostic, - cx.parse_sess().interner, None, copy tt); - let rdr = tt_rdr as reader; + cx.parse_sess().interner, + None, + copy tt); + let rdr = tt_rdr as @reader; let rust_parser = Parser(sess, cfg, rdr.dup()); let mut proto = rust_parser.parse_proto(cx.str_of(id)); diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index fd8b2dbf72f81..a7725eab695ed 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -26,27 +26,27 @@ use core::to_str::ToStr; use core::vec; pub trait gen_send { - fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item; - fn to_ty(&mut self, cx: ext_ctxt) -> @ast::Ty; + fn gen_send(&mut self, cx: @ext_ctxt, try: bool) -> @ast::item; + fn to_ty(&mut self, cx: @ext_ctxt) -> @ast::Ty; } pub trait to_type_decls { - fn to_type_decls(&self, cx: ext_ctxt) -> ~[@ast::item]; - fn to_endpoint_decls(&self, cx: ext_ctxt, + fn to_type_decls(&self, cx: @ext_ctxt) -> ~[@ast::item]; + fn to_endpoint_decls(&self, cx: @ext_ctxt, dir: direction) -> ~[@ast::item]; } pub trait gen_init { - fn gen_init(&self, cx: ext_ctxt) -> @ast::item; - fn compile(&self, cx: ext_ctxt) -> @ast::item; - fn buffer_ty_path(&self, cx: ext_ctxt) -> @ast::Ty; - fn gen_buffer_type(&self, cx: ext_ctxt) -> @ast::item; - fn gen_buffer_init(&self, ext_cx: ext_ctxt) -> @ast::expr; - fn gen_init_bounded(&self, ext_cx: ext_ctxt) -> @ast::expr; + fn gen_init(&self, cx: @ext_ctxt) -> @ast::item; + fn compile(&self, cx: @ext_ctxt) -> @ast::item; + fn buffer_ty_path(&self, cx: @ext_ctxt) -> @ast::Ty; + fn gen_buffer_type(&self, cx: @ext_ctxt) -> @ast::item; + fn gen_buffer_init(&self, ext_cx: @ext_ctxt) -> @ast::expr; + fn gen_init_bounded(&self, ext_cx: @ext_ctxt) -> @ast::expr; } impl gen_send for message { - fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item { + fn gen_send(&mut self, cx: @ext_ctxt, try: bool) -> @ast::item { debug!("pipec: gen_send"); let name = self.name(); @@ -188,14 +188,14 @@ impl gen_send for message { } } - fn to_ty(&mut self, cx: ext_ctxt) -> @ast::Ty { + fn to_ty(&mut self, cx: @ext_ctxt) -> @ast::Ty { cx.ty_path_ast_builder(path(~[cx.ident_of(self.name())], self.span()) .add_tys(cx.ty_vars_global(&self.get_generics().ty_params))) } } impl to_type_decls for state { - fn to_type_decls(&self, cx: ext_ctxt) -> ~[@ast::item] { + fn to_type_decls(&self, cx: @ext_ctxt) -> ~[@ast::item] { debug!("pipec: to_type_decls"); // This compiles into two different type declarations. Say the // state is called ping. This will generate both `ping` and @@ -244,7 +244,7 @@ impl to_type_decls for state { ] } - fn to_endpoint_decls(&self, cx: ext_ctxt, + fn to_endpoint_decls(&self, cx: @ext_ctxt, dir: direction) -> ~[@ast::item] { debug!("pipec: to_endpoint_decls"); let dir = match dir { @@ -306,7 +306,7 @@ impl to_type_decls for state { } impl gen_init for protocol { - fn gen_init(&self, cx: ext_ctxt) -> @ast::item { + fn gen_init(&self, cx: @ext_ctxt) -> @ast::item { let ext_cx = cx; debug!("gen_init"); @@ -344,7 +344,7 @@ impl gen_init for protocol { body.to_source(cx))) } - fn gen_buffer_init(&self, ext_cx: ext_ctxt) -> @ast::expr { + fn gen_buffer_init(&self, ext_cx: @ext_ctxt) -> @ast::expr { ext_cx.struct_expr(path(~[ext_cx.ident_of(~"__Buffer")], dummy_sp()), self.states.map_to_vec(|s| { @@ -356,7 +356,7 @@ impl gen_init for protocol { })) } - fn gen_init_bounded(&self, ext_cx: ext_ctxt) -> @ast::expr { + fn gen_init_bounded(&self, ext_cx: @ext_ctxt) -> @ast::expr { debug!("gen_init_bounded"); let buffer_fields = self.gen_buffer_init(ext_cx); let buffer = quote_expr!(~::core::pipes::Buffer { @@ -382,7 +382,7 @@ impl gen_init for protocol { }) } - fn buffer_ty_path(&self, cx: ext_ctxt) -> @ast::Ty { + fn buffer_ty_path(&self, cx: @ext_ctxt) -> @ast::Ty { let mut params: OptVec = opt_vec::Empty; for (copy self.states).each |s| { for s.generics.ty_params.each |tp| { @@ -399,7 +399,7 @@ impl gen_init for protocol { .add_tys(cx.ty_vars_global(¶ms))) } - fn gen_buffer_type(&self, cx: ext_ctxt) -> @ast::item { + fn gen_buffer_type(&self, cx: @ext_ctxt) -> @ast::item { let ext_cx = cx; let mut params: OptVec = opt_vec::Empty; let fields = do (copy self.states).map_to_vec |s| { @@ -442,7 +442,7 @@ impl gen_init for protocol { cx.strip_bounds(&generics)) } - fn compile(&self, cx: ext_ctxt) -> @ast::item { + fn compile(&self, cx: @ext_ctxt) -> @ast::item { let mut items = ~[self.gen_init(cx)]; let mut client_states = ~[]; let mut server_states = ~[]; diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index dc9abd536d11f..60df7623e40f0 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -96,7 +96,7 @@ pub impl state_ { } /// Returns the type that is used for the messages. - fn to_ty(&self, cx: ext_ctxt) -> @ast::Ty { + fn to_ty(&self, cx: @ext_ctxt) -> @ast::Ty { cx.ty_path_ast_builder (path(~[cx.ident_of(self.name)],self.span).add_tys( cx.ty_vars(&self.generics.ty_params))) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 49d5ed1d0cc88..6deffbe0ae146 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -49,11 +49,11 @@ pub mod rt { use print::pprust::{item_to_str, ty_to_str}; pub trait ToTokens { - pub fn to_tokens(&self, _cx: ext_ctxt) -> ~[token_tree]; + pub fn to_tokens(&self, _cx: @ext_ctxt) -> ~[token_tree]; } impl ToTokens for ~[token_tree] { - pub fn to_tokens(&self, _cx: ext_ctxt) -> ~[token_tree] { + pub fn to_tokens(&self, _cx: @ext_ctxt) -> ~[token_tree] { copy *self } } @@ -62,10 +62,10 @@ pub mod rt { trait ToSource : ToTokens { // Takes a thing and generates a string containing rust code for it. - pub fn to_source(cx: ext_ctxt) -> ~str; + pub fn to_source(cx: @ext_ctxt) -> ~str; // If you can make source, you can definitely make tokens. - pub fn to_tokens(cx: ext_ctxt) -> ~[token_tree] { + pub fn to_tokens(cx: @ext_ctxt) -> ~[token_tree] { cx.parse_tts(self.to_source(cx)) } } @@ -74,47 +74,47 @@ pub mod rt { pub trait ToSource { // Takes a thing and generates a string containing rust code for it. - pub fn to_source(&self, cx: ext_ctxt) -> ~str; + pub fn to_source(&self, cx: @ext_ctxt) -> ~str; } impl ToSource for ast::ident { - fn to_source(&self, cx: ext_ctxt) -> ~str { + fn to_source(&self, cx: @ext_ctxt) -> ~str { copy *cx.parse_sess().interner.get(*self) } } impl ToSource for @ast::item { - fn to_source(&self, cx: ext_ctxt) -> ~str { + fn to_source(&self, cx: @ext_ctxt) -> ~str { item_to_str(*self, cx.parse_sess().interner) } } impl ToSource for ~[@ast::item] { - fn to_source(&self, cx: ext_ctxt) -> ~str { + fn to_source(&self, cx: @ext_ctxt) -> ~str { str::connect(self.map(|i| i.to_source(cx)), ~"\n\n") } } impl ToSource for @ast::Ty { - fn to_source(&self, cx: ext_ctxt) -> ~str { + fn to_source(&self, cx: @ext_ctxt) -> ~str { ty_to_str(*self, cx.parse_sess().interner) } } impl ToSource for ~[@ast::Ty] { - fn to_source(&self, cx: ext_ctxt) -> ~str { + fn to_source(&self, cx: @ext_ctxt) -> ~str { str::connect(self.map(|i| i.to_source(cx)), ~", ") } } impl ToSource for Generics { - fn to_source(&self, cx: ext_ctxt) -> ~str { + fn to_source(&self, cx: @ext_ctxt) -> ~str { pprust::generics_to_str(self, cx.parse_sess().interner) } } impl ToSource for @ast::expr { - fn to_source(&self, cx: ext_ctxt) -> ~str { + fn to_source(&self, cx: @ext_ctxt) -> ~str { pprust::expr_to_str(*self, cx.parse_sess().interner) } } @@ -122,43 +122,43 @@ pub mod rt { // Alas ... we write these out instead. All redundant. impl ToTokens for ast::ident { - fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] { + fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { cx.parse_tts(self.to_source(cx)) } } impl ToTokens for @ast::item { - fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] { + fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { cx.parse_tts(self.to_source(cx)) } } impl ToTokens for ~[@ast::item] { - fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] { + fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { cx.parse_tts(self.to_source(cx)) } } impl ToTokens for @ast::Ty { - fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] { + fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { cx.parse_tts(self.to_source(cx)) } } impl ToTokens for ~[@ast::Ty] { - fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] { + fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { cx.parse_tts(self.to_source(cx)) } } impl ToTokens for Generics { - fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] { + fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { cx.parse_tts(self.to_source(cx)) } } impl ToTokens for @ast::expr { - fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] { + fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { cx.parse_tts(self.to_source(cx)) } } @@ -170,7 +170,7 @@ pub mod rt { fn parse_tts(&self, s: ~str) -> ~[ast::token_tree]; } - impl ExtParseUtils for ext_ctxt { + impl ExtParseUtils for @ext_ctxt { fn parse_item(&self, s: ~str) -> @ast::item { let res = parse::parse_item_from_source_str( @@ -216,19 +216,19 @@ pub mod rt { } -pub fn expand_quote_tokens(cx: ext_ctxt, +pub fn expand_quote_tokens(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::MRExpr(expand_tts(cx, sp, tts)) } -pub fn expand_quote_expr(cx: ext_ctxt, +pub fn expand_quote_expr(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::MRExpr(expand_parse_call(cx, sp, ~"parse_expr", ~[], tts)) } -pub fn expand_quote_item(cx: ext_ctxt, +pub fn expand_quote_item(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]); @@ -236,7 +236,7 @@ pub fn expand_quote_item(cx: ext_ctxt, ~[e_attrs], tts)) } -pub fn expand_quote_pat(cx: ext_ctxt, +pub fn expand_quote_pat(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let e_refutable = build::mk_lit(cx, sp, ast::lit_bool(true)); @@ -244,7 +244,7 @@ pub fn expand_quote_pat(cx: ext_ctxt, ~[e_refutable], tts)) } -pub fn expand_quote_ty(cx: ext_ctxt, +pub fn expand_quote_ty(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let e_param_colons = build::mk_lit(cx, sp, ast::lit_bool(false)); @@ -252,7 +252,7 @@ pub fn expand_quote_ty(cx: ext_ctxt, ~[e_param_colons], tts)) } -pub fn expand_quote_stmt(cx: ext_ctxt, +pub fn expand_quote_stmt(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]); @@ -260,16 +260,16 @@ pub fn expand_quote_stmt(cx: ext_ctxt, ~[e_attrs], tts)) } -fn ids_ext(cx: ext_ctxt, strs: ~[~str]) -> ~[ast::ident] { +fn ids_ext(cx: @ext_ctxt, strs: ~[~str]) -> ~[ast::ident] { strs.map(|str| cx.parse_sess().interner.intern(@copy *str)) } -fn id_ext(cx: ext_ctxt, +str: ~str) -> ast::ident { +fn id_ext(cx: @ext_ctxt, +str: ~str) -> ast::ident { cx.parse_sess().interner.intern(@str) } // Lift an ident to the expr that evaluates to that ident. -fn mk_ident(cx: ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr { +fn mk_ident(cx: @ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr { let e_meth = build::mk_access(cx, sp, ids_ext(cx, ~[~"ext_cx"]), id_ext(cx, ~"ident_of")); @@ -277,13 +277,13 @@ fn mk_ident(cx: ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr { build::mk_call_(cx, sp, e_meth, ~[e_str]) } -fn mk_bytepos(cx: ext_ctxt, sp: span, bpos: BytePos) -> @ast::expr { +fn mk_bytepos(cx: @ext_ctxt, sp: span, bpos: BytePos) -> @ast::expr { let path = ids_ext(cx, ~[~"BytePos"]); let arg = build::mk_uint(cx, sp, bpos.to_uint()); build::mk_call(cx, sp, path, ~[arg]) } -fn mk_binop(cx: ext_ctxt, sp: span, bop: token::binop) -> @ast::expr { +fn mk_binop(cx: @ext_ctxt, sp: span, bop: token::binop) -> @ast::expr { let name = match bop { PLUS => "PLUS", MINUS => "MINUS", @@ -300,7 +300,7 @@ fn mk_binop(cx: ext_ctxt, sp: span, bop: token::binop) -> @ast::expr { ids_ext(cx, ~[name.to_owned()])) } -fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { +fn mk_token(cx: @ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { match tok { BINOP(binop) => { @@ -443,7 +443,7 @@ fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { } -fn mk_tt(cx: ext_ctxt, sp: span, tt: &ast::token_tree) +fn mk_tt(cx: @ext_ctxt, sp: span, tt: &ast::token_tree) -> ~[@ast::stmt] { match *tt { @@ -494,7 +494,7 @@ fn mk_tt(cx: ext_ctxt, sp: span, tt: &ast::token_tree) } } -fn mk_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +fn mk_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> ~[@ast::stmt] { let mut ss = ~[]; for tts.each |tt| { @@ -503,7 +503,7 @@ fn mk_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) ss } -fn expand_tts(cx: ext_ctxt, +fn expand_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> @ast::expr { @@ -577,7 +577,7 @@ fn expand_tts(cx: ext_ctxt, ids_ext(cx, ~[~"tt"])))) } -fn expand_parse_call(cx: ext_ctxt, +fn expand_parse_call(cx: @ext_ctxt, sp: span, +parse_method: ~str, +arg_exprs: ~[@ast::expr], diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 296305bb62e17..b2de322be5531 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -29,7 +29,7 @@ use core::vec; // a given file into the current one. /* line!(): expands to the current line number */ -pub fn expand_line(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_line(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "line!"); @@ -40,7 +40,7 @@ pub fn expand_line(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) } /* col!(): expands to the current column number */ -pub fn expand_col(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_col(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "col!"); @@ -52,7 +52,7 @@ pub fn expand_col(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) /* file!(): expands to the current filename */ /* The filemap (`loc.file`) contains a bunch more information we could spit * out if we wanted. */ -pub fn expand_file(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_file(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "file!"); @@ -62,13 +62,13 @@ pub fn expand_file(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) base::MRExpr(mk_base_str(cx, topmost.call_site, filename)) } -pub fn expand_stringify(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_stringify(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let s = pprust::tts_to_str(tts, cx.parse_sess().interner); base::MRExpr(mk_base_str(cx, sp, s)) } -pub fn expand_mod(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_mod(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "module_path!"); base::MRExpr(mk_base_str(cx, sp, @@ -79,7 +79,7 @@ pub fn expand_mod(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) // include! : parse the given file as an expr // This is generally a bad idea because it's going to behave // unhygienically. -pub fn expand_include(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_include(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include!"); let p = parse::new_sub_parser_from_file( @@ -89,7 +89,7 @@ pub fn expand_include(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) } // include_str! : read the given file, insert it as a literal string expr -pub fn expand_include_str(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_include_str(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include_str!"); let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path(file))); @@ -103,7 +103,7 @@ pub fn expand_include_str(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) base::MRExpr(mk_base_str(cx, sp, result::unwrap(res))) } -pub fn expand_include_bin(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) +pub fn expand_include_bin(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include_bin!"); match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) { @@ -147,7 +147,7 @@ fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo { // resolve a file-system path to an absolute file-system path (if it // isn't already) -fn res_rel_file(cx: ext_ctxt, sp: codemap::span, arg: &Path) -> Path { +fn res_rel_file(cx: @ext_ctxt, sp: codemap::span, arg: &Path) -> Path { // NB: relative paths are resolved relative to the compilation unit if !arg.is_absolute { let cu = Path(cx.codemap().span_to_filename(sp)); diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index b53523f78a422..29a959013f258 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -17,8 +17,10 @@ use ext::base; use parse::lexer::{new_tt_reader, reader}; use parse::parser::Parser; -pub fn expand_trace_macros(cx: ext_ctxt, sp: span, - tt: &[ast::token_tree]) -> base::MacResult { +pub fn expand_trace_macros(cx: @ext_ctxt, + sp: span, + tt: &[ast::token_tree]) + -> base::MacResult { let sess = cx.parse_sess(); let cfg = cx.cfg(); let tt_rdr = new_tt_reader( @@ -27,7 +29,7 @@ pub fn expand_trace_macros(cx: ext_ctxt, sp: span, None, vec::from_slice(tt) ); - let rdr = tt_rdr as reader; + let rdr = tt_rdr as @reader; let rust_parser = Parser( sess, copy cfg, diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 88797a152066a..b0628437bb0ff 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -224,7 +224,7 @@ pub enum parse_result { pub fn parse_or_else( sess: @mut ParseSess, +cfg: ast::crate_cfg, - rdr: reader, + rdr: @reader, ms: ~[matcher] ) -> HashMap { match parse(sess, cfg, rdr, ms) { @@ -237,7 +237,7 @@ pub fn parse_or_else( pub fn parse( sess: @mut ParseSess, cfg: ast::crate_cfg, - rdr: reader, + rdr: @reader, ms: ~[matcher] ) -> parse_result { let mut cur_eis = ~[]; diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index e5b7152bea240..dcc84ce46fe05 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -27,8 +27,11 @@ use print; use core::io; -pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, - arg: ~[ast::token_tree]) -> base::MacResult { +pub fn add_new_extension(cx: @ext_ctxt, + sp: span, + name: ident, + arg: ~[ast::token_tree]) + -> base::MacResult { // these spans won't matter, anyways fn ms(m: matcher_) -> matcher { spanned { node: copy m, span: dummy_sp() } @@ -54,8 +57,10 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, // Parse the macro_rules! invocation (`none` is for no interpolations): let arg_reader = new_tt_reader(copy cx.parse_sess().span_diagnostic, cx.parse_sess().interner, None, copy arg); - let argument_map = parse_or_else(cx.parse_sess(), cx.cfg(), - arg_reader as reader, argument_gram); + let argument_map = parse_or_else(cx.parse_sess(), + cx.cfg(), + arg_reader as @reader, + argument_gram); // Extract the arguments: let lhses = match argument_map.get(&lhs_nm) { @@ -69,7 +74,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, }; // Given `lhses` and `rhses`, this is the new macro we create - fn generic_extension(cx: ext_ctxt, sp: span, name: ident, + fn generic_extension(cx: @ext_ctxt, sp: span, name: ident, arg: &[ast::token_tree], lhses: ~[@named_match], rhses: ~[@named_match]) -> MacResult { @@ -98,7 +103,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, itr, None, vec::from_slice(arg) - ) as reader; + ) as @reader; match parse(cx.parse_sess(), cx.cfg(), arg_rdr, (*mtcs)) { success(named_matches) => { let rhs = match rhses[i] { @@ -118,8 +123,9 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, // rhs has holes ( `$id` and `$(...)` that need filled) let trncbr = new_tt_reader(s_d, itr, Some(named_matches), rhs); - let p = @Parser(cx.parse_sess(), cx.cfg(), - trncbr as reader); + let p = @Parser(cx.parse_sess(), + cx.cfg(), + trncbr as @reader); // Let the context choose how to interpret the result. // Weird, but useful for X-macros. @@ -140,7 +146,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, cx.span_fatal(best_fail_spot, best_fail_msg); } - let exp: @fn(ext_ctxt, span, &[ast::token_tree]) -> MacResult = + let exp: @fn(@ext_ctxt, span, &[ast::token_tree]) -> MacResult = |cx, sp, arg| generic_extension(cx, sp, name, arg, lhses, rhses); return MRDef(MacroDef{ diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 589b7693f9e3a..908fbd4482510 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -34,7 +34,7 @@ struct TtFrame { } pub struct TtReader { - sp_diag: span_handler, + sp_diag: @span_handler, interner: @ident_interner, // the unzipped tree: cur: @mut TtFrame, @@ -50,7 +50,7 @@ pub struct TtReader { /** This can do Macro-By-Example transcription. On the other hand, if * `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and * should) be none. */ -pub fn new_tt_reader(sp_diag: span_handler, +pub fn new_tt_reader(sp_diag: @span_handler, itr: @ident_interner, interp: Option>, +src: ~[ast::token_tree]) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 15097f57b02e0..1626c55e7211e 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -48,26 +48,26 @@ pub trait ast_fold { pub struct AstFoldFns { //unlike the others, item_ is non-trivial - fold_crate: @fn(&crate_, span, ast_fold) -> (crate_, span), - fold_view_item: @fn(view_item_, ast_fold) -> view_item_, - fold_foreign_item: @fn(@foreign_item, ast_fold) -> @foreign_item, - fold_item: @fn(@item, ast_fold) -> Option<@item>, - fold_struct_field: @fn(@struct_field, ast_fold) -> @struct_field, - fold_item_underscore: @fn(&item_, ast_fold) -> item_, - fold_method: @fn(@method, ast_fold) -> @method, - fold_block: @fn(&blk_, span, ast_fold) -> (blk_, span), - fold_stmt: @fn(&stmt_, span, ast_fold) -> (stmt_, span), - fold_arm: @fn(&arm, ast_fold) -> arm, - fold_pat: @fn(&pat_, span, ast_fold) -> (pat_, span), - fold_decl: @fn(&decl_, span, ast_fold) -> (decl_, span), - fold_expr: @fn(&expr_, span, ast_fold) -> (expr_, span), - fold_ty: @fn(&ty_, span, ast_fold) -> (ty_, span), - fold_mod: @fn(&_mod, ast_fold) -> _mod, - fold_foreign_mod: @fn(&foreign_mod, ast_fold) -> foreign_mod, - fold_variant: @fn(&variant_, span, ast_fold) -> (variant_, span), - fold_ident: @fn(ident, ast_fold) -> ident, - fold_path: @fn(@path, ast_fold) -> path, - fold_local: @fn(&local_, span, ast_fold) -> (local_, span), + fold_crate: @fn(&crate_, span, @ast_fold) -> (crate_, span), + fold_view_item: @fn(view_item_, @ast_fold) -> view_item_, + fold_foreign_item: @fn(@foreign_item, @ast_fold) -> @foreign_item, + fold_item: @fn(@item, @ast_fold) -> Option<@item>, + fold_struct_field: @fn(@struct_field, @ast_fold) -> @struct_field, + fold_item_underscore: @fn(&item_, @ast_fold) -> item_, + fold_method: @fn(@method, @ast_fold) -> @method, + fold_block: @fn(&blk_, span, @ast_fold) -> (blk_, span), + fold_stmt: @fn(&stmt_, span, @ast_fold) -> (stmt_, span), + fold_arm: @fn(&arm, @ast_fold) -> arm, + fold_pat: @fn(&pat_, span, @ast_fold) -> (pat_, span), + fold_decl: @fn(&decl_, span, @ast_fold) -> (decl_, span), + fold_expr: @fn(&expr_, span, @ast_fold) -> (expr_, span), + fold_ty: @fn(&ty_, span, @ast_fold) -> (ty_, span), + fold_mod: @fn(&_mod, @ast_fold) -> _mod, + fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod, + fold_variant: @fn(&variant_, span, @ast_fold) -> (variant_, span), + fold_ident: @fn(ident, @ast_fold) -> ident, + fold_path: @fn(@path, @ast_fold) -> path, + fold_local: @fn(&local_, span, @ast_fold) -> (local_, span), map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr], new_id: @fn(node_id) -> node_id, new_span: @fn(span) -> span @@ -436,8 +436,8 @@ fn noop_fold_decl(d: &decl_, fld: @ast_fold) -> decl_ { } } -pub fn wrap(f: @fn(&T, ast_fold) -> T) - -> @fn(&T, span, ast_fold) -> (T, span) { +pub fn wrap(f: @fn(&T, @ast_fold) -> T) + -> @fn(&T, span, @ast_fold) -> (T, span) { let result: @fn(&T, span, @ast_fold) -> (T, span) = |x, s, fld| { (f(x, fld), s) }; @@ -879,13 +879,13 @@ impl ast_fold for AstFoldFns { } } -pub impl ast_fold { +pub impl @ast_fold { fn fold_attributes(&self, attrs: ~[attribute]) -> ~[attribute] { attrs.map(|x| fold_attribute_(*x, *self)) } } -pub fn make_fold(afp: ast_fold_fns) -> ast_fold { +pub fn make_fold(afp: ast_fold_fns) -> @ast_fold { afp as @ast_fold } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 494ef3a81a0d2..3caea8bd5db7d 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -256,7 +256,7 @@ fn read_block_comment(rdr: @mut StringReader, while level > 0 { debug!("=== block comment level %d", level); if is_eof(rdr) { - (rdr as reader).fatal(~"unterminated block comment"); + (rdr as @reader).fatal(~"unterminated block comment"); } if rdr.curr == '\n' { trim_whitespace_prefix_and_push_line(&mut lines, curr_line, @@ -319,9 +319,11 @@ pub struct lit { pos: BytePos } -pub fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler, +pub fn gather_comments_and_literals(span_diagnostic: + @diagnostic::span_handler, +path: ~str, - srdr: io::Reader) -> (~[cmnt], ~[lit]) { + srdr: @io::Reader) + -> (~[cmnt], ~[lit]) { let src = @str::from_bytes(srdr.read_whole_stream()); let itr = parse::token::mk_fake_ident_interner(); let cm = CodeMap::new(); diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index c7b9a769293d6..1b64a9a6275c1 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -47,7 +47,7 @@ pub fn seq_sep_none() -> SeqSep { } } -pub fn token_to_str(reader: reader, token: &token::Token) -> ~str { +pub fn token_to_str(reader: @reader, token: &token::Token) -> ~str { token::to_str(reader.interner(), token) } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index ab57d17711293..09ffd79c246e3 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -31,17 +31,17 @@ pub trait reader { fn is_eof(@mut self) -> bool; fn next_token(@mut self) -> TokenAndSpan; fn fatal(@mut self, ~str) -> !; - fn span_diag(@mut self) -> span_handler; + fn span_diag(@mut self) -> @span_handler; pure fn interner(@mut self) -> @token::ident_interner; fn peek(@mut self) -> TokenAndSpan; - fn dup(@mut self) -> reader; + fn dup(@mut self) -> @reader; } #[deriving_eq] pub struct TokenAndSpan {tok: token::Token, sp: span} pub struct StringReader { - span_diagnostic: span_handler, + span_diagnostic: @span_handler, src: @~str, // The absolute offset within the codemap of the next character to read pos: BytePos, @@ -58,7 +58,7 @@ pub struct StringReader { peek_span: span } -pub fn new_string_reader(span_diagnostic: span_handler, +pub fn new_string_reader(span_diagnostic: @span_handler, filemap: @codemap::FileMap, itr: @token::ident_interner) -> @mut StringReader { @@ -68,7 +68,7 @@ pub fn new_string_reader(span_diagnostic: span_handler, } /* For comments.rs, which hackily pokes into 'pos' and 'curr' */ -pub fn new_low_level_string_reader(span_diagnostic: span_handler, +pub fn new_low_level_string_reader(span_diagnostic: @span_handler, filemap: @codemap::FileMap, itr: @token::ident_interner) -> @mut StringReader { @@ -121,7 +121,7 @@ impl reader for StringReader { fn fatal(@mut self, m: ~str) -> ! { self.span_diagnostic.span_fatal(copy self.peek_span, m) } - fn span_diag(@mut self) -> span_handler { self.span_diagnostic } + fn span_diag(@mut self) -> @span_handler { self.span_diagnostic } pure fn interner(@mut self) -> @token::ident_interner { self.interner } fn peek(@mut self) -> TokenAndSpan { TokenAndSpan { @@ -129,7 +129,7 @@ impl reader for StringReader { sp: copy self.peek_span, } } - fn dup(@mut self) -> reader { dup_string_reader(self) as reader } + fn dup(@mut self) -> @reader { dup_string_reader(self) as @reader } } impl reader for TtReader { @@ -138,7 +138,7 @@ impl reader for TtReader { fn fatal(@mut self, m: ~str) -> ! { self.sp_diag.span_fatal(copy self.cur_span, m); } - fn span_diag(@mut self) -> span_handler { self.sp_diag } + fn span_diag(@mut self) -> @span_handler { self.sp_diag } pure fn interner(@mut self) -> @token::ident_interner { self.interner } fn peek(@mut self) -> TokenAndSpan { TokenAndSpan { @@ -146,7 +146,7 @@ impl reader for TtReader { sp: copy self.cur_span, } } - fn dup(@mut self) -> reader { dup_tt_reader(self) as reader } + fn dup(@mut self) -> @reader { dup_tt_reader(self) as @reader } } // EFFECT: advance peek_tok and peek_span to refer to the next token. diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index fd84f8670686b..8272ebfb6d8e8 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -48,7 +48,7 @@ pub mod obsolete; pub struct ParseSess { cm: @codemap::CodeMap, next_id: node_id, - span_diagnostic: span_handler, + span_diagnostic: @span_handler, interner: @ident_interner, } @@ -62,8 +62,9 @@ pub fn new_parse_sess(demitter: Option) -> @mut ParseSess { } } -pub fn new_parse_sess_special_handler(sh: span_handler, cm: @codemap::CodeMap) - -> @mut ParseSess { +pub fn new_parse_sess_special_handler(sh: @span_handler, + cm: @codemap::CodeMap) + -> @mut ParseSess { @mut ParseSess { cm: cm, next_id: 1, @@ -201,20 +202,19 @@ pub fn next_node_id(sess: @mut ParseSess) -> node_id { return rv; } -pub fn new_parser_from_source_str( - sess: @mut ParseSess, - +cfg: ast::crate_cfg, - +name: ~str, - +ss: codemap::FileSubstr, - source: @~str -) -> Parser { +pub fn new_parser_from_source_str(sess: @mut ParseSess, + +cfg: ast::crate_cfg, + +name: ~str, + +ss: codemap::FileSubstr, + source: @~str) + -> Parser { let filemap = sess.cm.new_filemap_w_substr(name, ss, source); let srdr = lexer::new_string_reader( copy sess.span_diagnostic, filemap, sess.interner ); - Parser(sess, cfg, srdr as reader) + Parser(sess, cfg, srdr as @reader) } /// Read the entire source file, return a parser @@ -227,12 +227,10 @@ pub fn new_parser_result_from_file( match io::read_whole_file_str(path) { Ok(src) => { let filemap = sess.cm.new_filemap(path.to_str(), @src); - let srdr = lexer::new_string_reader( - copy sess.span_diagnostic, - filemap, - sess.interner - ); - Ok(Parser(sess, cfg, srdr as reader)) + let srdr = lexer::new_string_reader(copy sess.span_diagnostic, + filemap, + sess.interner); + Ok(Parser(sess, cfg, srdr as @reader)) } Err(e) => Err(e) @@ -281,7 +279,7 @@ pub fn new_parser_from_tts( None, tts ); - Parser(sess, cfg, trdr as reader) + Parser(sess, cfg, trdr as @reader) } // abort if necessary diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 51e36d9ec02c1..94fa781b1c6a8 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -214,8 +214,8 @@ struct ParsedItemsAndViewItems { pub fn Parser(sess: @mut ParseSess, +cfg: ast::crate_cfg, - +rdr: reader) -> Parser { - + +rdr: @reader) + -> Parser { let tok0 = copy rdr.next_token(); let interner = rdr.interner(); @@ -253,7 +253,7 @@ pub struct Parser { tokens_consumed: @mut uint, restriction: @mut restriction, quote_depth: @mut uint, // not (yet) related to the quasiquoter - reader: reader, + reader: @reader, interner: @token::ident_interner, keywords: HashMap<~str, ()>, strict_keywords: HashMap<~str, ()>, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9288312378206..d508c166ed8f8 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -76,7 +76,7 @@ pub fn end(s: @ps) { pp::end(s.s); } -pub fn rust_printer(writer: io::Writer, intr: @ident_interner) -> @ps { +pub fn rust_printer(writer: @io::Writer, intr: @ident_interner) -> @ps { return @ps { s: pp::mk_printer(writer, default_columns), cm: None::<@CodeMap>, @@ -100,10 +100,15 @@ pub const default_columns: uint = 78u; // Requires you to pass an input filename and reader so that // it can scan the input text for comments and literals to // copy forward. -pub fn print_crate(cm: @CodeMap, intr: @ident_interner, - span_diagnostic: diagnostic::span_handler, - crate: @ast::crate, filename: ~str, in: io::Reader, - out: io::Writer, ann: pp_ann, is_expanded: bool) { +pub fn print_crate(cm: @CodeMap, + intr: @ident_interner, + span_diagnostic: @diagnostic::span_handler, + crate: @ast::crate, + filename: ~str, + in: @io::Reader, + out: @io::Writer, + ann: pp_ann, + is_expanded: bool) { let (cmnts, lits) = comments::gather_comments_and_literals( span_diagnostic, copy filename, diff --git a/src/libuv b/src/libuv index 576ab1db8ea03..218ab86721eef 160000 --- a/src/libuv +++ b/src/libuv @@ -1 +1 @@ -Subproject commit 576ab1db8ea03889eb7b2274654afe7c5c867230 +Subproject commit 218ab86721eefd7b7e97fa6d9f95a80a1fa8686c diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index afe7d4a6e8b2c..bd1b9d84e0774 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -13,7 +13,7 @@ pub trait i { } -pub fn f() -> i { +pub fn f() -> @i { impl i for () { } @() as @i diff --git a/src/test/compile-fail/class-cast-to-trait.rs b/src/test/compile-fail/class-cast-to-trait.rs index 092fb4a5b6675..9133b80aa1e2b 100644 --- a/src/test/compile-fail/class-cast-to-trait.rs +++ b/src/test/compile-fail/class-cast-to-trait.rs @@ -58,6 +58,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } fn main() { - let nyan : noisy = @cat(0, 2, ~"nyan") as @noisy; + let nyan : @noisy = @cat(0, 2, ~"nyan") as @noisy; nyan.eat(); //~ ERROR type `@noisy` does not implement any method in scope named `eat` } diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index e0651a68fa9d4..4f8269bb11b42 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -14,14 +14,14 @@ impl repeat for @A { fn get() -> A { *self } } -fn repeater(v: @A) -> repeat { +fn repeater(v: @A) -> @repeat { // Note: owned kind is not necessary as A appears in the trait type - @v as repeat:: // No + @v as @repeat:: // No } fn main() { // Error results because the type of is inferred to be - // repeat<&blk/int> where blk is the lifetime of the block below. + // @repeat<&blk/int> where blk is the lifetime of the block below. let y = { //~ ERROR reference is not valid let x: &blk/int = &3; diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index fbbac6e0a641a..391b65e3c818a 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -26,22 +26,22 @@ fn to_foo(t: T) { // the fn body itself. let v = &3; struct F { f: T } - let x = @F {f:t} as foo; + let x = @F {f:t} as @foo; fail_unless!(x.foo(v) == 3); } -fn to_foo_2(t: T) -> foo { +fn to_foo_2(t: T) -> @foo { // Not OK---T may contain borrowed ptrs and it is going to escape // as part of the returned foo value struct F { f: T } - @F {f:t} as foo //~ ERROR value may contain borrowed pointers; use `&static` bound + @F {f:t} as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound } -fn to_foo_3(t: T) -> foo { +fn to_foo_3(t: T) -> @foo { // OK---T may escape as part of the returned foo value, but it is // owned and hence does not contain borrowed ptrs struct F { f: T } - @F {f:t} as foo + @F {f:t} as @foo } fn main() { diff --git a/src/test/compile-fail/kindck-owned-trait.rs b/src/test/compile-fail/kindck-owned-trait.rs index 30f6a5f9b2dd7..a92a764afe746 100644 --- a/src/test/compile-fail/kindck-owned-trait.rs +++ b/src/test/compile-fail/kindck-owned-trait.rs @@ -10,11 +10,11 @@ trait foo { fn foo(); } -fn to_foo(t: T) -> foo { +fn to_foo(t: T) -> @foo { @t as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound } -fn to_foo2(t: T) -> foo { +fn to_foo2(t: T) -> @foo { @t as @foo } diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index c8384c188310e..8b6c6b8410ac0 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -15,7 +15,7 @@ use core::hashmap::linear::LinearMap; fn main() { let x: @Map<~str, ~str> = @LinearMap::new::<~str, ~str>() as - Map::<~str, ~str>; + @Map::<~str, ~str>; let y: @Map = @x; //~^ ERROR mismatched types: expected `@core::container::Map` } diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs index 35bef5a407a55..92d1aab781c4b 100644 --- a/src/test/compile-fail/regions-bounds.rs +++ b/src/test/compile-fail/regions-bounds.rs @@ -22,7 +22,7 @@ fn a_fn1(e: an_enum<'a>) -> an_enum<'b> { return e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a` } -fn a_fn2(e: a_trait<'a>) -> a_trait<'b> { +fn a_fn2(e: @a_trait<'a>) -> @a_trait<'b> { return e; //~ ERROR mismatched types: expected `@a_trait/&b` but found `@a_trait/&a` } diff --git a/src/test/compile-fail/regions-infer-paramd-method.rs b/src/test/compile-fail/regions-infer-paramd-method.rs index 32702663c6e06..93d493314fdce 100644 --- a/src/test/compile-fail/regions-infer-paramd-method.rs +++ b/src/test/compile-fail/regions-infer-paramd-method.rs @@ -18,7 +18,7 @@ trait foo<'self> { } struct with_foo<'self> { - f: foo<'self> + f: @foo<'self> } trait set_foo_foo { diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index f4e41d951aa2a..8104f62595cb9 100644 --- a/src/test/compile-fail/regions-trait-1.rs +++ b/src/test/compile-fail/regions-trait-1.rs @@ -27,12 +27,12 @@ impl get_ctxt for has_ctxt<'self> { } -fn get_v(gc: get_ctxt) -> uint { +fn get_v(gc: @get_ctxt) -> uint { gc.get_ctxt().v } fn main() { let ctxt = ctxt { v: 22u }; let hc = has_ctxt { c: &ctxt }; - fail_unless!(get_v(@hc as get_ctxt) == 22u); + fail_unless!(get_v(@hc as @get_ctxt) == 22u); } diff --git a/src/test/compile-fail/regions-trait-2.rs b/src/test/compile-fail/regions-trait-2.rs index 12ab58ec8907e..d76bc798705fe 100644 --- a/src/test/compile-fail/regions-trait-2.rs +++ b/src/test/compile-fail/regions-trait-2.rs @@ -20,10 +20,10 @@ impl<'self> get_ctxt<'self> for has_ctxt<'self> { fn get_ctxt() -> &self/ctxt { self.c } } -fn make_gc() -> get_ctxt { +fn make_gc() -> @get_ctxt { let ctxt = ctxt { v: 22u }; let hc = has_ctxt { c: &ctxt }; //~ ERROR illegal borrow - return @hc as get_ctxt; + return @hc as @get_ctxt; } fn main() { diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs index a10c239617ec9..414d848a96680 100644 --- a/src/test/compile-fail/regions-trait-3.rs +++ b/src/test/compile-fail/regions-trait-3.rs @@ -12,7 +12,7 @@ trait get_ctxt { fn get_ctxt() -> &self/uint; } -fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b { +fn make_gc1(gc: @get_ctxt/&a) -> @get_ctxt/&b { return gc; //~ ERROR mismatched types: expected `@get_ctxt/&b` but found `@get_ctxt/&a` } @@ -24,8 +24,8 @@ impl get_ctxt/&self for Foo/&self { fn get_ctxt() -> &self/uint { self.r } } -fn make_gc2(foo: Foo/&a) -> get_ctxt/&b { - return @foo as get_ctxt; //~ ERROR cannot infer an appropriate lifetime +fn make_gc2(foo: Foo/&a) -> @get_ctxt/&b { + return @foo as @get_ctxt; //~ ERROR cannot infer an appropriate lifetime } fn main() { diff --git a/src/test/compile-fail/tps-invariant-trait.rs b/src/test/compile-fail/tps-invariant-trait.rs index 9569e5f1e8210..1699534216eb9 100644 --- a/src/test/compile-fail/tps-invariant-trait.rs +++ b/src/test/compile-fail/tps-invariant-trait.rs @@ -24,7 +24,7 @@ impl box_trait for box_impl { fn set(t: T) { self.f = t; } } -fn set_box_trait(b: box_trait<@const T>, v: @const T) { +fn set_box_trait(b: @box_trait<@const T>, v: @const T) { b.set(v); } @@ -34,7 +34,7 @@ fn set_box_impl(b: box_impl<@const T>, v: @const T) { fn main() { let b = box_impl::<@int>(box::<@int> {f: @3}); - set_box_trait(@b as box_trait::<@int>, @mut 5); + set_box_trait(@b as @box_trait::<@int>, @mut 5); //~^ ERROR values differ in mutability set_box_impl(b, @mut 5); //~^ ERROR values differ in mutability diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index a00e63b60d7d5..e63a1dc3563d5 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -15,5 +15,5 @@ impl bar for uint { fn dup() -> uint { self } fn blah() {} } fn main() { 10i.dup::(); //~ ERROR does not take type parameters 10i.blah::(); //~ ERROR incorrect number of type parameters - (@10 as bar).dup(); //~ ERROR contains a self-type + (@10 as @bar).dup(); //~ ERROR contains a self-type } diff --git a/src/test/compile-fail/vtable-res-trait-param.rs b/src/test/compile-fail/vtable-res-trait-param.rs index c825118fa984c..514448c9644fc 100644 --- a/src/test/compile-fail/vtable-res-trait-param.rs +++ b/src/test/compile-fail/vtable-res-trait-param.rs @@ -24,7 +24,7 @@ impl TraitB for int { fn call_it(b: B) -> int { let y = 4u; - b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait @TraitA + b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait TraitA } fn main() { diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 85ed524118b4f..fe32af7b15f6f 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait clam { +trait c lam { fn chowder(y: A); } struct foo { @@ -26,13 +26,13 @@ fn foo(b: A) -> foo { } } -fn f(x: clam, a: A) { +fn f(x: @clam, a: A) { x.chowder(a); } pub fn main() { let c = foo(42); - let d: clam = @c as clam::; + let d: @clam = @c as @clam::; f(d, c.x); } diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index 14e27dce63d15..ef6363043eed4 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -11,7 +11,7 @@ trait hax { } impl hax for A { } -fn perform_hax(x: @T) -> hax { +fn perform_hax(x: @T) -> @hax { @x as @hax } diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index 64af4de46a242..323b5d8ed5ae9 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -25,7 +25,7 @@ pub fn main() { // let y = @({a: 4i}); // let z = @({a: 4i} as it); // let z = @({a: true} as it); - let z = @(@true as it); + let z = @(@true as @it); // x.f(); // y.f(); // (*z).f(); diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index bb6ed754ab676..75b0a6335528a 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -14,9 +14,9 @@ impl repeat for @A { fn get() -> A { *self } } -fn repeater(v: @A) -> repeat { +fn repeater(v: @A) -> @repeat { // Note: owned kind is not necessary as A appears in the trait type - @v as repeat:: // No + @v as @repeat:: // No } pub fn main() { diff --git a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs index 88c317a3c0735..ecf30b206c585 100644 --- a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs +++ b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs @@ -29,7 +29,7 @@ impl Serializable for F { } } -impl Serializer for io::Writer { +impl Serializer for @io::Writer { } pub fn main() { diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs index 22cdd47707770..cc12c1b7dd9f1 100644 --- a/src/test/run-pass/regions-trait.rs +++ b/src/test/run-pass/regions-trait.rs @@ -22,7 +22,7 @@ impl get_ctxt<'self> for HasCtxt<'self> { } } -fn get_v(gc: get_ctxt) -> uint { +fn get_v(gc: @get_ctxt) -> uint { gc.get_ctxt().v }