diff --git a/doc/tutorial-container.md b/doc/tutorial-container.md index 2146b76a4afbd..1b195e9997989 100644 --- a/doc/tutorial-container.md +++ b/doc/tutorial-container.md @@ -192,7 +192,7 @@ let mut it = xs.iter().zip(ys.iter()); // print out the pairs of elements up to (&3, &"baz") for it.advance |(x, y)| { - println(fmt!("%d %s", *x, *y)); + printfln!("%d %s", *x, *y); if *x == 3 { break; @@ -200,7 +200,7 @@ for it.advance |(x, y)| { } // yield and print the last pair from the iterator -println(fmt!("last: %?", it.next())); +printfln!("last: %?", it.next()); // the iterator is now fully consumed assert!(it.next().is_none()); @@ -294,15 +294,59 @@ another `DoubleEndedIterator` with `next` and `next_back` exchanged. ~~~ let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter(); -println(fmt!("%?", it.next())); // prints `Some(&1)` -println(fmt!("%?", it.next())); // prints `Some(&2)` -println(fmt!("%?", it.next_back())); // prints `Some(&6)` +printfln!("%?", it.next()); // prints `Some(&1)` +printfln!("%?", it.next()); // prints `Some(&2)` +printfln!("%?", it.next_back()); // prints `Some(&6)` // prints `5`, `4` and `3` for it.invert().advance |&x| { - println(fmt!("%?", x)) + printfln!("%?", x) } ~~~ The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted version of the standard immutable and mutable vector iterators. + +The `chain_`, `transform`, `filter`, `filter_map` and `peek` adaptors are +`DoubleEndedIterator` implementations if the underlying iterators are. + +~~~ +let xs = [1, 2, 3, 4]; +let ys = [5, 6, 7, 8]; +let mut it = xs.iter().chain_(ys.iter()).transform(|&x| x * 2); + +printfln!("%?", it.next()); // prints `Some(2)` + +// prints `16`, `14`, `12`, `10`, `8`, `6`, `4` +for it.invert().advance |x| { + printfln!("%?", x); +} +~~~ + +## Random-access iterators + +The `RandomAccessIterator` trait represents an iterator offering random access +to the whole range. The `indexable` method retrieves the number of elements +accessible with the `idx` method. + +The `chain_` adaptor is an implementation of `RandomAccessIterator` if the +underlying iterators are. + +~~~ +let xs = [1, 2, 3, 4, 5]; +let ys = ~[7, 9, 11]; +let mut it = xs.iter().chain_(ys.iter()); +printfln!("%?", it.idx(0)); // prints `Some(&1)` +printfln!("%?", it.idx(5)); // prints `Some(&7)` +printfln!("%?", it.idx(7)); // prints `Some(&11)` +printfln!("%?", it.idx(8)); // prints `None` + +// yield two elements from the beginning, and one from the end +it.next(); +it.next(); +it.next_back(); + +printfln!("%?", it.idx(0)); // prints `Some(&3)` +printfln!("%?", it.idx(4)); // prints `Some(&9)` +printfln!("%?", it.idx(6)); // prints `None` +~~~ diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index a2f36c104a0a2..7cd73c8253081 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -292,7 +292,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) { } } if i != num_check_lines { - fatal_ProcRes(fmt!("line not found in debugger output: %s" + fatal_ProcRes(fmt!("line not found in debugger output: %s", check_lines[i]), &ProcRes); } } diff --git a/src/libextra/base64.rs b/src/libextra/base64.rs index 3c549d4291710..37d95d622c083 100644 --- a/src/libextra/base64.rs +++ b/src/libextra/base64.rs @@ -75,7 +75,7 @@ impl<'self> ToBase64 for &'self [u8] { * * fn main () { * let str = [52,32].to_base64(standard); - * println(fmt!("%s", str)); + * printfln!("%s", str); * } * ~~~ */ @@ -164,7 +164,7 @@ impl<'self> ToBase64 for &'self str { * * fn main () { * let str = "Hello, World".to_base64(standard); - * println(fmt!("%s",str)); + * printfln!("%s", str); * } * ~~~ * @@ -194,9 +194,9 @@ impl<'self> FromBase64 for &'self [u8] { * * fn main () { * let str = [52,32].to_base64(standard); - * println(fmt!("%s", str)); + * printfln!("%s", str); * let bytes = str.from_base64(); - * println(fmt!("%?",bytes)); + * printfln!("%?", bytes); * } * ~~~ */ @@ -271,11 +271,11 @@ impl<'self> FromBase64 for &'self str { * * fn main () { * let hello_str = "Hello, World".to_base64(standard); - * println(fmt!("%s",hello_str)); + * printfln!("%s", hello_str); * let bytes = hello_str.from_base64(); - * println(fmt!("%?",bytes)); + * printfln!("%?", bytes); * let result_str = str::from_bytes(bytes); - * println(fmt!("%s",result_str)); + * printfln!("%s", result_str); * } * ~~~ */ diff --git a/src/libextra/future.rs b/src/libextra/future.rs index d8f21b460138e..5e37efa647ad6 100644 --- a/src/libextra/future.rs +++ b/src/libextra/future.rs @@ -19,7 +19,7 @@ * # fn make_a_sandwich() {}; * let mut delayed_fib = extra::future::spawn (|| fib(5000) ); * make_a_sandwich(); - * println(fmt!("fib(5000) = %?", delayed_fib.get())) + * printfln!("fib(5000) = %?", delayed_fib.get()) * ~~~ */ diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index 07a1c6744040e..ad452125239de 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -44,7 +44,7 @@ * } * * fn print_usage(program: &str, _opts: &[Opt]) { - * println(fmt!("Usage: %s [options]", program)); + * printfln!("Usage: %s [options]", program); * println("-o\t\tOutput"); * println("-h --help\tUsage"); * } diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 8d6b146e14264..04d6b8ebca5fe 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -23,11 +23,17 @@ cycle cannot be created with `Rc` because there is no way to modify it after use std::cast; -use std::libc::{c_void, size_t, malloc, free}; use std::ptr; -use std::sys; use std::unstable::intrinsics; +// Convert ~T into *mut T without dropping it +#[inline] +unsafe fn owned_to_raw(mut box: ~T) -> *mut T { + let ptr = ptr::to_mut_unsafe_ptr(box); + intrinsics::forget(box); + ptr +} + struct RcBox { value: T, count: uint @@ -42,21 +48,20 @@ pub struct Rc { impl Rc { unsafe fn new(value: T) -> Rc { - let ptr = malloc(sys::size_of::>() as size_t) as *mut RcBox; - assert!(!ptr::is_null(ptr)); - intrinsics::move_val_init(&mut *ptr, RcBox{value: value, count: 1}); - Rc{ptr: ptr} + Rc{ptr: owned_to_raw(~RcBox{value: value, count: 1})} } } -// FIXME: #6516: should be a static method -pub fn rc_from_owned(value: T) -> Rc { - unsafe { Rc::new(value) } +impl Rc { + pub fn from_owned(value: T) -> Rc { + unsafe { Rc::new(value) } + } } -// FIXME: #6516: should be a static method -pub fn rc_from_const(value: T) -> Rc { - unsafe { Rc::new(value) } +impl Rc { + pub fn from_const(value: T) -> Rc { + unsafe { Rc::new(value) } + } } impl Rc { @@ -73,8 +78,7 @@ impl Drop for Rc { if self.ptr.is_not_null() { (*self.ptr).count -= 1; if (*self.ptr).count == 0 { - ptr::read_ptr(self.ptr); - free(self.ptr as *c_void) + let _: ~T = cast::transmute(self.ptr); } } } @@ -107,7 +111,7 @@ mod test_rc { #[test] fn test_clone() { - let x = rc_from_owned(Cell::new(5)); + let x = Rc::from_owned(Cell::new(5)); let y = x.clone(); do x.borrow().with_mut_ref |inner| { *inner = 20; @@ -117,7 +121,7 @@ mod test_rc { #[test] fn test_deep_clone() { - let x = rc_from_owned(Cell::new(5)); + let x = Rc::from_owned(Cell::new(5)); let y = x.deep_clone(); do x.borrow().with_mut_ref |inner| { *inner = 20; @@ -127,13 +131,13 @@ mod test_rc { #[test] fn test_simple() { - let x = rc_from_const(5); + let x = Rc::from_const(5); assert_eq!(*x.borrow(), 5); } #[test] fn test_simple_clone() { - let x = rc_from_const(5); + let x = Rc::from_const(5); let y = x.clone(); assert_eq!(*x.borrow(), 5); assert_eq!(*y.borrow(), 5); @@ -141,17 +145,11 @@ mod test_rc { #[test] fn test_destructor() { - let x = rc_from_owned(~5); + let x = Rc::from_owned(~5); assert_eq!(**x.borrow(), 5); } } -#[abi = "rust-intrinsic"] -extern "rust-intrinsic" { - fn init() -> T; - fn uninit() -> T; -} - #[deriving(Eq)] enum Borrow { Mutable, @@ -175,21 +173,20 @@ pub struct RcMut { impl RcMut { unsafe fn new(value: T) -> RcMut { - let ptr = malloc(sys::size_of::>() as size_t) as *mut RcMutBox; - assert!(!ptr::is_null(ptr)); - intrinsics::move_val_init(&mut *ptr, RcMutBox{value: value, count: 1, borrow: Nothing}); - RcMut{ptr: ptr} + RcMut{ptr: owned_to_raw(~RcMutBox{value: value, count: 1, borrow: Nothing})} } } -// FIXME: #6516: should be a static method -pub fn rc_mut_from_owned(value: T) -> RcMut { - unsafe { RcMut::new(value) } +impl RcMut { + pub fn from_owned(value: T) -> RcMut { + unsafe { RcMut::new(value) } + } } -// FIXME: #6516: should be a static method -pub fn rc_mut_from_const(value: T) -> RcMut { - unsafe { RcMut::new(value) } +impl RcMut { + pub fn from_const(value: T) -> RcMut { + unsafe { RcMut::new(value) } + } } impl RcMut { @@ -226,8 +223,7 @@ impl Drop for RcMut { if self.ptr.is_not_null() { (*self.ptr).count -= 1; if (*self.ptr).count == 0 { - ptr::replace_ptr(self.ptr, uninit()); - free(self.ptr as *c_void) + let _: ~T = cast::transmute(self.ptr); } } } @@ -262,7 +258,7 @@ mod test_rc_mut { #[test] fn test_clone() { - let x = rc_mut_from_owned(5); + let x = RcMut::from_owned(5); let y = x.clone(); do x.with_mut_borrow |value| { *value = 20; @@ -274,7 +270,7 @@ mod test_rc_mut { #[test] fn test_deep_clone() { - let x = rc_mut_from_const(5); + let x = RcMut::from_const(5); let y = x.deep_clone(); do x.with_mut_borrow |value| { *value = 20; @@ -286,7 +282,7 @@ mod test_rc_mut { #[test] fn borrow_many() { - let x = rc_mut_from_owned(5); + let x = RcMut::from_owned(5); let y = x.clone(); do x.with_borrow |a| { @@ -302,7 +298,7 @@ mod test_rc_mut { #[test] fn modify() { - let x = rc_mut_from_const(5); + let x = RcMut::from_const(5); let y = x.clone(); do y.with_mut_borrow |a| { @@ -317,14 +313,14 @@ mod test_rc_mut { #[test] fn release_immutable() { - let x = rc_mut_from_owned(5); + let x = RcMut::from_owned(5); do x.with_borrow |_| {} do x.with_mut_borrow |_| {} } #[test] fn release_mutable() { - let x = rc_mut_from_const(5); + let x = RcMut::from_const(5); do x.with_mut_borrow |_| {} do x.with_borrow |_| {} } @@ -332,7 +328,7 @@ mod test_rc_mut { #[test] #[should_fail] fn frozen() { - let x = rc_mut_from_owned(5); + let x = RcMut::from_owned(5); let y = x.clone(); do x.with_borrow |_| { @@ -344,7 +340,7 @@ mod test_rc_mut { #[test] #[should_fail] fn mutable_dupe() { - let x = rc_mut_from_const(5); + let x = RcMut::from_const(5); let y = x.clone(); do x.with_mut_borrow |_| { @@ -356,7 +352,7 @@ mod test_rc_mut { #[test] #[should_fail] fn mutable_freeze() { - let x = rc_mut_from_owned(5); + let x = RcMut::from_owned(5); let y = x.clone(); do x.with_mut_borrow |_| { @@ -368,7 +364,7 @@ mod test_rc_mut { #[test] #[should_fail] fn restore_freeze() { - let x = rc_mut_from_const(5); + let x = RcMut::from_const(5); let y = x.clone(); do x.with_borrow |_| { diff --git a/src/libextra/task_pool.rs b/src/libextra/task_pool.rs index 49d5dd9386953..edd16fe88f425 100644 --- a/src/libextra/task_pool.rs +++ b/src/libextra/task_pool.rs @@ -103,6 +103,6 @@ fn test_task_pool() { }; let mut pool = TaskPool::new(4, Some(SingleThreaded), f); for 8.times { - pool.execute(|i| println(fmt!("Hello from thread %u!", *i))); + pool.execute(|i| printfln!("Hello from thread %u!", *i)); } } diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index 4ad1f56a9ae54..303ae6a6d1de1 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -1263,7 +1263,7 @@ mod test_set { let mut n = 0; for m.iter().advance |x| { - println(fmt!("%?", x)); + printfln!(x); assert_eq!(*x, n); n += 1 } diff --git a/src/librust/rust.rs b/src/librust/rust.rs index bc97ef0e8ca4d..c47c573d16fbe 100644 --- a/src/librust/rust.rs +++ b/src/librust/rust.rs @@ -132,13 +132,13 @@ fn cmd_help(args: &[~str]) -> ValidUsage { match find_cmd(command_string) { Some(command) => { match command.action { - CallMain(prog, _) => io::println(fmt!( + CallMain(prog, _) => printfln!( "The %s command is an alias for the %s program.", - command.cmd, prog)), + command.cmd, prog), _ => () } match command.usage_full { - UsgStr(msg) => io::println(fmt!("%s\n", msg)), + UsgStr(msg) => printfln!("%s\n", msg), UsgCall(f) => f(), } Valid(0) @@ -211,8 +211,7 @@ fn usage() { for COMMANDS.iter().advance |command| { let padding = " ".repeat(INDENT - command.cmd.len()); - io::println(fmt!(" %s%s%s", - command.cmd, padding, command.usage_line)); + printfln!(" %s%s%s", command.cmd, padding, command.usage_line); } io::print( diff --git a/src/librustc/back/passes.rs b/src/librustc/back/passes.rs index f9dc88074d3b1..48a685058bbd5 100644 --- a/src/librustc/back/passes.rs +++ b/src/librustc/back/passes.rs @@ -191,15 +191,15 @@ pub fn list_passes() { io::println("\nAnalysis Passes:"); for analysis_passes.iter().advance |&(name, desc)| { - io::println(fmt!(" %-30s -- %s", name, desc)); + printfln!(" %-30s -- %s", name, desc); } io::println("\nTransformation Passes:"); for transform_passes.iter().advance |&(name, desc)| { - io::println(fmt!(" %-30s -- %s", name, desc)); + printfln!(" %-30s -- %s", name, desc); } io::println("\nUtility Passes:"); for utility_passes.iter().advance |&(name, desc)| { - io::println(fmt!(" %-30s -- %s", name, desc)); + printfln!(" %-30s -- %s", name, desc); } } @@ -344,7 +344,7 @@ fn passes_exist() { if failed.len() > 0 { io::println("Some passes don't exist:"); for failed.iter().advance |&n| { - io::println(fmt!(" %s", n)); + printfln!(" %s", n); } fail!(); } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 3c02609def11e..78e1a579d741b 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1624,16 +1624,16 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] { } io::println("metadata stats:"); - io::println(fmt!(" inline bytes: %u", ecx.stats.inline_bytes)); - io::println(fmt!(" attribute bytes: %u", ecx.stats.attr_bytes)); - io::println(fmt!(" dep bytes: %u", ecx.stats.dep_bytes)); - io::println(fmt!(" lang item bytes: %u", ecx.stats.lang_item_bytes)); - io::println(fmt!(" link args bytes: %u", ecx.stats.link_args_bytes)); - io::println(fmt!(" misc bytes: %u", ecx.stats.misc_bytes)); - io::println(fmt!(" item bytes: %u", ecx.stats.item_bytes)); - io::println(fmt!(" index bytes: %u", ecx.stats.index_bytes)); - io::println(fmt!(" zero bytes: %u", ecx.stats.zero_bytes)); - io::println(fmt!(" total bytes: %u", ecx.stats.total_bytes)); + printfln!(" inline bytes: %u", ecx.stats.inline_bytes); + printfln!(" attribute bytes: %u", ecx.stats.attr_bytes); + printfln!(" dep bytes: %u", ecx.stats.dep_bytes); + printfln!(" lang item bytes: %u", ecx.stats.lang_item_bytes); + printfln!(" link args bytes: %u", ecx.stats.link_args_bytes); + printfln!(" misc bytes: %u", ecx.stats.misc_bytes); + printfln!(" item bytes: %u", ecx.stats.item_bytes); + printfln!(" index bytes: %u", ecx.stats.index_bytes); + printfln!(" zero bytes: %u", ecx.stats.zero_bytes); + printfln!(" total bytes: %u", ecx.stats.total_bytes); } // Pad this, since something (LLVM, presumably) is cutting off the diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 31fb1765e43bc..fc34e873ef95e 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -232,7 +232,7 @@ impl<'self> CheckLoanCtxt<'self> { self.bccx.span_err( new_loan.span, fmt!("cannot borrow `%s` as %s because \ - it is also borrowed as %s" + it is also borrowed as %s", self.bccx.loan_path_to_str(new_loan.loan_path), self.bccx.mut_to_str(new_loan.mutbl), self.bccx.mut_to_str(old_loan.mutbl))); @@ -320,7 +320,7 @@ impl<'self> CheckLoanCtxt<'self> { // Otherwise, just a plain error. self.bccx.span_err( expr.span, - fmt!("cannot assign to %s %s" + fmt!("cannot assign to %s %s", cmt.mutbl.to_user_str(), self.bccx.cmt_to_str(cmt))); return; diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index b307280729ed4..bf9b4fcaedfa6 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -93,16 +93,16 @@ pub fn check_crate( if tcx.sess.borrowck_stats() { io::println("--- borrowck stats ---"); - io::println(fmt!("paths requiring guarantees: %u", - bccx.stats.guaranteed_paths)); - io::println(fmt!("paths requiring loans : %s", - make_stat(bccx, bccx.stats.loaned_paths_same))); - io::println(fmt!("paths requiring imm loans : %s", - make_stat(bccx, bccx.stats.loaned_paths_imm))); - io::println(fmt!("stable paths : %s", - make_stat(bccx, bccx.stats.stable_paths))); - io::println(fmt!("paths requiring purity : %s", - make_stat(bccx, bccx.stats.req_pure_paths))); + printfln!("paths requiring guarantees: %u", + bccx.stats.guaranteed_paths); + printfln!("paths requiring loans : %s", + make_stat(bccx, bccx.stats.loaned_paths_same)); + printfln!("paths requiring imm loans : %s", + make_stat(bccx, bccx.stats.loaned_paths_imm)); + printfln!("stable paths : %s", + make_stat(bccx, bccx.stats.stable_paths)); + printfln!("paths requiring purity : %s", + make_stat(bccx, bccx.stats.req_pure_paths)); } return (bccx.root_map, bccx.write_guard_map); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index bf5c5ac334de9..fba67d57994e4 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -3011,17 +3011,15 @@ pub fn trans_crate(sess: session::Session, write_metadata(ccx, crate); if ccx.sess.trans_stats() { io::println("--- trans stats ---"); - io::println(fmt!("n_static_tydescs: %u", - ccx.stats.n_static_tydescs)); - io::println(fmt!("n_glues_created: %u", - ccx.stats.n_glues_created)); - io::println(fmt!("n_null_glues: %u", ccx.stats.n_null_glues)); - io::println(fmt!("n_real_glues: %u", ccx.stats.n_real_glues)); - - io::println(fmt!("n_fns: %u", ccx.stats.n_fns)); - io::println(fmt!("n_monos: %u", ccx.stats.n_monos)); - io::println(fmt!("n_inlines: %u", ccx.stats.n_inlines)); - io::println(fmt!("n_closures: %u", ccx.stats.n_closures)); + printfln!("n_static_tydescs: %u", ccx.stats.n_static_tydescs); + printfln!("n_glues_created: %u", ccx.stats.n_glues_created); + printfln!("n_null_glues: %u", ccx.stats.n_null_glues); + printfln!("n_real_glues: %u", ccx.stats.n_real_glues); + + printfln!("n_fns: %u", ccx.stats.n_fns); + printfln!("n_monos: %u", ccx.stats.n_monos); + printfln!("n_inlines: %u", ccx.stats.n_inlines); + printfln!("n_closures: %u", ccx.stats.n_closures); io::println("fn stats:"); do sort::quick_sort(ccx.stats.fn_stats) |&(_, _, insns_a), &(_, _, insns_b)| { insns_a > insns_b @@ -3029,14 +3027,14 @@ pub fn trans_crate(sess: session::Session, for ccx.stats.fn_stats.iter().advance |tuple| { match *tuple { (ref name, ms, insns) => { - io::println(fmt!("%u insns, %u ms, %s", insns, ms, *name)); + printfln!("%u insns, %u ms, %s", insns, ms, *name); } } } } if ccx.sess.count_llvm_insns() { for ccx.stats.llvm_insns.iter().advance |(k, v)| { - io::println(fmt!("%-7u %s", *v, *k)); + printfln!("%-7u %s", *v, *k); } } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 5f76981c79467..d64615e5dc7b3 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -654,9 +654,9 @@ pub fn trans_call_inner(in_cx: @mut Block, // Uncomment this to debug calls. /* - io::println(fmt!("calling: %s", bcx.val_to_str(llfn))); + printfln!("calling: %s", bcx.val_to_str(llfn)); for llargs.iter().advance |llarg| { - io::println(fmt!("arg: %s", bcx.val_to_str(*llarg))); + printfln!("arg: %s", bcx.val_to_str(*llarg)); } io::println("---"); */ diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index f8131c6337844..372d24e664cf8 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -805,6 +805,9 @@ pub fn trans_intrinsic(ccx: @mut CrateContext, _ => Ret(bcx, BitCast(bcx, llsrcval, llouttype)) } } + } else if ty::type_is_immediate(ccx.tcx, out_type) { + let llsrcptr = PointerCast(bcx, llsrcval, llouttype.ptr_to()); + Ret(bcx, Load(bcx, llsrcptr)); } else { // NB: Do not use a Load and Store here. This causes massive // code bloat when `transmute` is used on large structural diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index d554526a6d237..024ab7af0814d 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -37,7 +37,6 @@ use util::ppaux::ty_to_short_str; use middle::trans::type_::Type; -use std::io; use std::libc::c_uint; use std::str; use syntax::ast; @@ -649,8 +648,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info { let llty = type_of(ccx, t); if ccx.sess.count_type_sizes() { - io::println(fmt!("%u\t%s", llsize_of_real(ccx, llty), - ppaux::ty_to_str(ccx.tcx, t))); + printfln!("%u\t%s", llsize_of_real(ccx, llty), + ppaux::ty_to_str(ccx.tcx, t)); } let llsize = llsize_of(ccx, llty); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index cd9d744c24034..7eea20175f9fc 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2712,7 +2712,7 @@ pub fn node_id_to_trait_ref(cx: ctxt, id: ast::node_id) -> @ty::TraitRef { } pub fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t { - //io::println(fmt!("%?/%?", id, cx.node_types.len())); + //printfln!("%?/%?", id, cx.node_types.len()); match cx.node_types.find(&(id as uint)) { Some(&t) => t, None => cx.sess.bug( diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 4a32e8bf952c1..8d546366846b4 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -194,7 +194,6 @@ impl<'self> LookupContext<'self> { self.push_inherent_candidates(self_ty); self.push_extension_candidates(); - let mut enum_dids = ~[]; let mut self_ty = self_ty; let mut autoderefs = 0; loop { @@ -236,7 +235,7 @@ impl<'self> LookupContext<'self> { } // Otherwise, perform autoderef. - match self.deref(self_ty, &mut enum_dids) { + match self.deref(self_ty) { None => { break; } Some(ty) => { self_ty = ty; @@ -248,20 +247,8 @@ impl<'self> LookupContext<'self> { self.search_for_autosliced_method(self_ty, autoderefs) } - pub fn deref(&self, ty: ty::t, enum_dids: &mut ~[ast::def_id]) + pub fn deref(&self, ty: ty::t) -> Option { - match ty::get(ty).sty { - ty_enum(did, _) => { - // Watch out for newtype'd enums like "enum t = @T". - // See discussion in typeck::check::do_autoderef(). - if enum_dids.iter().any(|x| x == &did) { - return None; - } - enum_dids.push(did); - } - _ => {} - } - match ty::deref(self.tcx(), ty, false) { None => None, Some(t) => { @@ -285,7 +272,6 @@ impl<'self> LookupContext<'self> { * we'll want to find the inherent impls for `C`. */ - let mut enum_dids = ~[]; let mut self_ty = self_ty; loop { match get(self_ty).sty { @@ -314,7 +300,7 @@ impl<'self> LookupContext<'self> { // n.b.: Generally speaking, we only loop if we hit the // fallthrough case in the match above. The exception // would be newtype enums. - self_ty = match self.deref(self_ty, &mut enum_dids) { + self_ty = match self.deref(self_ty) { None => { return; } Some(ty) => { ty } } diff --git a/src/librustc/rustc.rs b/src/librustc/rustc.rs index e97f67ceb9cc4..39fbdb92a2fee 100644 --- a/src/librustc/rustc.rs +++ b/src/librustc/rustc.rs @@ -128,28 +128,28 @@ pub fn version(argv0: &str) { let mut vers = ~"unknown version"; let env_vers = env!("CFG_VERSION"); if env_vers.len() != 0 { vers = env_vers.to_owned(); } - io::println(fmt!("%s %s", argv0, vers)); - io::println(fmt!("host: %s", host_triple())); + printfln!("%s %s", argv0, vers); + printfln!("host: %s", host_triple()); } pub fn usage(argv0: &str) { let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0); - io::println(fmt!("%s\ + printfln!("%s\ Additional help: -W help Print 'lint' options and default settings -Z help Print internal options for debugging rustc\n", - groups::usage(message, optgroups()))); + groups::usage(message, optgroups())); } pub fn describe_warnings() { use extra::sort::Sort; - io::println(fmt!(" + printfln!(" Available lint options: -W Warn about -A Allow -D Deny -F Forbid (deny, and deny all overrides) -")); +"); let lint_dict = lint::get_lint_dict(); let mut lint_dict = lint_dict.consume() @@ -164,28 +164,28 @@ Available lint options: fn padded(max: uint, s: &str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } - io::println(fmt!("\nAvailable lint checks:\n")); - io::println(fmt!(" %s %7.7s %s", - padded(max_key, "name"), "default", "meaning")); - io::println(fmt!(" %s %7.7s %s\n", - padded(max_key, "----"), "-------", "-------")); + printfln!("\nAvailable lint checks:\n"); + printfln!(" %s %7.7s %s", + padded(max_key, "name"), "default", "meaning"); + printfln!(" %s %7.7s %s\n", + padded(max_key, "----"), "-------", "-------"); for lint_dict.consume_iter().advance |(spec, name)| { let name = name.replace("_", "-"); - io::println(fmt!(" %s %7.7s %s", - padded(max_key, name), - lint::level_to_str(spec.default), - spec.desc)); + printfln!(" %s %7.7s %s", + padded(max_key, name), + lint::level_to_str(spec.default), + spec.desc); } io::println(""); } pub fn describe_debug_flags() { - io::println(fmt!("\nAvailable debug options:\n")); + printfln!("\nAvailable debug options:\n"); let r = session::debugging_opts_map(); for r.iter().advance |tuple| { match *tuple { (ref name, ref desc, _) => { - io::println(fmt!(" -Z %-20s -- %s", *name, *desc)); + printfln!(" -Z %-20s -- %s", *name, *desc); } } } diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 733e8093a9d70..6d5498898555d 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -14,7 +14,6 @@ use syntax::codemap::{span}; use syntax::visit; use std::hashmap::HashSet; -use std::io; use extra; pub fn time(do_it: bool, what: ~str, thunk: &fn() -> T) -> T { @@ -22,7 +21,7 @@ pub fn time(do_it: bool, what: ~str, thunk: &fn() -> T) -> T { let start = extra::time::precise_time_s(); let rv = thunk(); let end = extra::time::precise_time_s(); - io::println(fmt!("time: %3.3f s\t%s", end - start, what)); + printfln!("time: %3.3f s\t%s", end - start, what); rv } diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 675ff7a8b9512..de4815ab7a6ed 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -74,7 +74,7 @@ pub fn usage() { println("Options:\n"); let r = opts(); for r.iter().advance |opt| { - println(fmt!(" %s", opt.second())); + printfln!(" %s", opt.second()); } println(""); } diff --git a/src/librustdoc/rustdoc.rs b/src/librustdoc/rustdoc.rs index cd2ffd7d60219..b738f4a958681 100644 --- a/src/librustdoc/rustdoc.rs +++ b/src/librustdoc/rustdoc.rs @@ -23,7 +23,6 @@ extern mod extra; extern mod rustc; extern mod syntax; -use std::io; use std::os; use config::Config; @@ -69,7 +68,7 @@ pub fn main() { let config = match config::parse_config(args) { Ok(config) => config, Err(err) => { - io::println(fmt!("error: %s", err)); + printfln!("error: %s", err); return; } }; diff --git a/src/librusti/rusti.rs b/src/librusti/rusti.rs index 63cf4001594f9..38c70f8be0595 100644 --- a/src/librusti/rusti.rs +++ b/src/librusti/rusti.rs @@ -334,7 +334,7 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option { None => { }, } if (should_compile) { - println(fmt!("compiling %s...", src_filename)); + printfln!("compiling %s...", src_filename); driver::compile_upto(sess, cfg, &input, driver::cu_everything, Some(outputs)); true @@ -413,8 +413,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer, if loaded_crates.is_empty() { println("no crates loaded"); } else { - println(fmt!("crates loaded: %s", - loaded_crates.connect(", "))); + printfln!("crates loaded: %s", loaded_crates.connect(", ")); } } ~"{" => { diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs index ed5b1118a9c7c..700dbea8182d2 100644 --- a/src/librustpkg/path_util.rs +++ b/src/librustpkg/path_util.rs @@ -400,7 +400,7 @@ pub fn mk_output_path(what: OutputType, where: Target, Test => "test", Bench => "bench", _ => "" - } + }, os::EXE_SUFFIX)) }; if !output_path.is_absolute() { diff --git a/src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs b/src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs index ebd6f9bf9d8cd..37eb3aa5911ed 100644 --- a/src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs +++ b/src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs @@ -34,7 +34,7 @@ pub fn main() { } if args[2] != ~"install" { - io::println(fmt!("Warning: I don't know how to %s", args[2])); + printfln!("Warning: I don't know how to %s", args[2]); return; } diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index 198e63f83c60c..0c2a7bb7b400c 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -53,6 +53,16 @@ pub trait DoubleEndedIterator: Iterator { fn next_back(&mut self) -> Option; } +/// An object implementing random access indexing by `uint` +pub trait RandomAccessIterator { + /// Return the number of indexable elements. At most `std::uint::max_value` + /// elements are indexable, even if the iterator represents a longer range. + fn indexable(&self) -> uint; + + /// Return an element at an index + fn idx(&self, index: uint) -> Option; +} + /// Iterator adaptors provided for every `DoubleEndedIterator` implementation. /// /// In the future these will be default methods instead of a utility trait. @@ -316,7 +326,7 @@ pub trait IteratorUtil { /// use std::iterator::Counter; /// /// for Counter::new(0, 10).advance |i| { - /// io::println(fmt!("%d", i)); + /// printfln!("%d", i); /// } /// ~~~ fn advance(&mut self, f: &fn(A) -> bool) -> bool; @@ -836,6 +846,30 @@ for ChainIterator { } } +impl, U: RandomAccessIterator> RandomAccessIterator +for ChainIterator { + #[inline] + fn indexable(&self) -> uint { + let (a, b) = (self.a.indexable(), self.b.indexable()); + let total = a + b; + if total < a || total < b { + uint::max_value + } else { + total + } + } + + #[inline] + fn idx(&self, index: uint) -> Option { + let len = self.a.indexable(); + if index < len { + self.a.idx(index) + } else { + self.b.idx(index - len) + } + } +} + /// An iterator which iterates two other iterators simultaneously // FIXME #6967: Dummy A & B parameters to get around type inference bug #[deriving(Clone)] @@ -1718,4 +1752,23 @@ mod tests { assert_eq!(it.next_back().unwrap(), &7) assert_eq!(it.next_back(), None) } + + #[test] + fn test_random_access_chain() { + let xs = [1, 2, 3, 4, 5]; + let ys = ~[7, 9, 11]; + let mut it = xs.iter().chain_(ys.iter()); + assert_eq!(it.idx(0).unwrap(), &1); + assert_eq!(it.idx(5).unwrap(), &7); + assert_eq!(it.idx(7).unwrap(), &11); + assert!(it.idx(8).is_none()); + + it.next(); + it.next(); + it.next_back(); + + assert_eq!(it.idx(0).unwrap(), &3); + assert_eq!(it.idx(4).unwrap(), &9); + assert!(it.idx(6).is_none()); + } } diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 54c1327fa9303..acf7ea683fb54 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -103,7 +103,7 @@ fn range_step_core(start: $T, stop: $T, step: $T_SIGNED, r: Range, it: &fn($T) - /// let nums = [1,2,3,4,5,6,7]; /// /// for uint::range_step(0, nums.len() - 1, 2) |i| { -/// println(fmt!("%d & %d", nums[i], nums[i+1])); +/// printfln!("%d & %d", nums[i], nums[i+1]); /// } /// ~~~ /// diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 06c743edd2bed..6d0613b2e674f 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -28,7 +28,7 @@ use std::rand::RngUtil; fn main() { let mut rng = rand::rng(); if rng.gen() { // bool - println(fmt!("int: %d, uint: %u", rng.gen(), rng.gen())) + printfln!("int: %d, uint: %u", rng.gen(), rng.gen()) } } ~~~ @@ -38,7 +38,7 @@ use std::rand; fn main () { let tuple_ptr = rand::random::<~(f64, char)>(); - println(fmt!("%?", tuple_ptr)) + printfln!(tuple_ptr) } ~~~ */ @@ -301,7 +301,7 @@ pub trait RngUtil { * * fn main() { * let mut rng = rand::rng(); - * println(fmt!("%b",rng.gen_weighted_bool(3))); + * printfln!("%b", rng.gen_weighted_bool(3)); * } * ~~~ */ @@ -335,7 +335,7 @@ pub trait RngUtil { * * fn main() { * let mut rng = rand::rng(); - * println(fmt!("%?",rng.gen_bytes(8))); + * printfln!(rng.gen_bytes(8)); * } * ~~~ */ @@ -352,7 +352,7 @@ pub trait RngUtil { * * fn main() { * let mut rng = rand::rng(); - * println(fmt!("%d",rng.choose([1,2,4,8,16,32]))); + * printfln!("%d", rng.choose([1,2,4,8,16,32])); * } * ~~~ */ @@ -375,7 +375,7 @@ pub trait RngUtil { * let x = [rand::Weighted {weight: 4, item: 'a'}, * rand::Weighted {weight: 2, item: 'b'}, * rand::Weighted {weight: 2, item: 'c'}]; - * println(fmt!("%c",rng.choose_weighted(x))); + * printfln!("%c", rng.choose_weighted(x)); * } * ~~~ */ @@ -396,7 +396,7 @@ pub trait RngUtil { * let x = [rand::Weighted {weight: 4, item: 'a'}, * rand::Weighted {weight: 2, item: 'b'}, * rand::Weighted {weight: 2, item: 'c'}]; - * println(fmt!("%?",rng.choose_weighted_option(x))); + * printfln!(rng.choose_weighted_option(x)); * } * ~~~ */ @@ -418,7 +418,7 @@ pub trait RngUtil { * let x = [rand::Weighted {weight: 4, item: 'a'}, * rand::Weighted {weight: 2, item: 'b'}, * rand::Weighted {weight: 2, item: 'c'}]; - * println(fmt!("%?",rng.weighted_vec(x))); + * printfln!(rng.weighted_vec(x)); * } * ~~~ */ @@ -435,7 +435,7 @@ pub trait RngUtil { * * fn main() { * let mut rng = rand::rng(); - * println(fmt!("%?",rng.shuffle([1,2,3]))); + * printfln!(rng.shuffle([1,2,3])); * } * ~~~ */ @@ -454,9 +454,9 @@ pub trait RngUtil { * let mut rng = rand::rng(); * let mut y = [1,2,3]; * rng.shuffle_mut(y); - * println(fmt!("%?",y)); + * printfln!(y); * rng.shuffle_mut(y); - * println(fmt!("%?",y)); + * printfln!(y); * } * ~~~ */ diff --git a/src/libstd/rand/distributions.rs b/src/libstd/rand/distributions.rs index 4d983b9495446..56eae0428751e 100644 --- a/src/libstd/rand/distributions.rs +++ b/src/libstd/rand/distributions.rs @@ -70,7 +70,7 @@ fn ziggurat(rng: &mut R, /// /// fn main() { /// let normal = 2.0 + (*rand::random::()) * 3.0; -/// println(fmt!("%f is from a N(2, 9) distribution", normal)) +/// printfln!("%f is from a N(2, 9) distribution", normal) /// } /// ~~~ pub struct StandardNormal(f64); @@ -124,7 +124,7 @@ impl Rand for StandardNormal { /// /// fn main() { /// let exp2 = (*rand::random::()) * 0.5; -/// println(fmt!("%f is from a Exp(2) distribution", exp2)); +/// printfln!("%f is from a Exp(2) distribution", exp2); /// } /// ~~~ pub struct Exp1(f64); diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index 75ee4f381f6ef..85cdb9fc94137 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -14,112 +14,167 @@ //! the processes `argc` and `argv` arguments to be stored //! in a globally-accessible location for use by the `os` module. //! +//! Only valid to call on linux. Mac and Windows use syscalls to +//! discover the command line arguments. +//! //! XXX: Would be nice for this to not exist. //! XXX: This has a lot of C glue for lack of globals. -use libc; -use option::{Option, Some, None}; -use str; -use uint; -use unstable::finally::Finally; -use util; +use option::Option; /// One-time global initialization. pub unsafe fn init(argc: int, argv: **u8) { - let args = load_argc_and_argv(argc, argv); - put(args); + imp::init(argc, argv) } /// One-time global cleanup. pub fn cleanup() { - rtassert!(take().is_some()); + imp::cleanup() } /// Take the global arguments from global storage. pub fn take() -> Option<~[~str]> { - with_lock(|| unsafe { - let ptr = get_global_ptr(); - let val = util::replace(&mut *ptr, None); - val.map(|s: &~~[~str]| (**s).clone()) - }) + imp::take() } /// Give the global arguments to global storage. /// /// It is an error if the arguments already exist. pub fn put(args: ~[~str]) { - with_lock(|| unsafe { - let ptr = get_global_ptr(); - rtassert!((*ptr).is_none()); - (*ptr) = Some(~args.clone()); - }) + imp::put(args) } /// Make a clone of the global arguments. pub fn clone() -> Option<~[~str]> { - with_lock(|| unsafe { - let ptr = get_global_ptr(); - (*ptr).map(|s: &~~[~str]| (**s).clone()) - }) + imp::clone() } -fn with_lock(f: &fn() -> T) -> T { - do (|| { - unsafe { - rust_take_global_args_lock(); - f() +#[cfg(target_os = "linux")] +#[cfg(target_os = "android")] +#[cfg(target_os = "freebsd")] +mod imp { + + use libc; + use option::{Option, Some, None}; + use str; + use uint; + use unstable::finally::Finally; + use util; + + pub unsafe fn init(argc: int, argv: **u8) { + let args = load_argc_and_argv(argc, argv); + put(args); + } + + pub fn cleanup() { + rtassert!(take().is_some()); + } + + pub fn take() -> Option<~[~str]> { + with_lock(|| unsafe { + let ptr = get_global_ptr(); + let val = util::replace(&mut *ptr, None); + val.map(|s: &~~[~str]| (**s).clone()) + }) + } + + pub fn put(args: ~[~str]) { + with_lock(|| unsafe { + let ptr = get_global_ptr(); + rtassert!((*ptr).is_none()); + (*ptr) = Some(~args.clone()); + }) + } + + pub fn clone() -> Option<~[~str]> { + with_lock(|| unsafe { + let ptr = get_global_ptr(); + (*ptr).map(|s: &~~[~str]| (**s).clone()) + }) + } + + fn with_lock(f: &fn() -> T) -> T { + do (|| { + unsafe { + rust_take_global_args_lock(); + f() + } + }).finally { + unsafe { + rust_drop_global_args_lock(); + } } - }).finally { - unsafe { - rust_drop_global_args_lock(); + } + + fn get_global_ptr() -> *mut Option<~~[~str]> { + unsafe { rust_get_global_args_ptr() } + } + + // Copied from `os`. + unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] { + let mut args = ~[]; + for uint::range(0, argc as uint) |i| { + args.push(str::raw::from_c_str(*(argv as **libc::c_char).offset(i))); } + return args; } -} -fn get_global_ptr() -> *mut Option<~~[~str]> { - unsafe { rust_get_global_args_ptr() } -} + extern { + fn rust_take_global_args_lock(); + fn rust_drop_global_args_lock(); + fn rust_get_global_args_ptr() -> *mut Option<~~[~str]>; + } -// Copied from `os`. -unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] { - let mut args = ~[]; - for uint::range(0, argc as uint) |i| { - args.push(str::raw::from_c_str(*(argv as **libc::c_char).offset(i))); + #[cfg(test)] + mod tests { + use option::{Some, None}; + use super::*; + use unstable::finally::Finally; + + #[test] + fn smoke_test() { + // Preserve the actual global state. + let saved_value = take(); + + let expected = ~[~"happy", ~"today?"]; + + put(expected.clone()); + assert!(clone() == Some(expected.clone())); + assert!(take() == Some(expected.clone())); + assert!(take() == None); + + do (|| { + }).finally { + // Restore the actual global state. + match saved_value { + Some(ref args) => put(args.clone()), + None => () + } + } + } } - return args; } -extern { - fn rust_take_global_args_lock(); - fn rust_drop_global_args_lock(); - fn rust_get_global_args_ptr() -> *mut Option<~~[~str]>; -} +#[cfg(target_os = "macos")] +#[cfg(target_os = "win32")] +mod imp { + use option::Option; -#[cfg(test)] -mod tests { - use option::{Some, None}; - use super::*; - use unstable::finally::Finally; + pub unsafe fn init(_argc: int, _argv: **u8) { + } - #[test] - fn smoke_test() { - // Preserve the actual global state. - let saved_value = take(); + pub fn cleanup() { + } - let expected = ~[~"happy", ~"today?"]; + pub fn take() -> Option<~[~str]> { + fail!() + } - put(expected.clone()); - assert!(clone() == Some(expected.clone())); - assert!(take() == Some(expected.clone())); - assert!(take() == None); + pub fn put(_args: ~[~str]) { + fail!() + } - do (|| { - }).finally { - // Restore the actual global state. - match saved_value { - Some(ref args) => put(args.clone()), - None => () - } - } + pub fn clone() -> Option<~[~str]> { + fail!() } } diff --git a/src/libstd/str.rs b/src/libstd/str.rs index c49a00502665b..5b83112fe6bc0 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -1727,7 +1727,7 @@ impl<'self> StrSlice<'self> for &'self str { * let i = 0u; * while i < s.len() { * let CharRange {ch, next} = s.char_range_at(i); - * std::io::println(fmt!("%u: %c",i,ch)); + * printfln!("%u: %c", i, ch); * i = next; * } * ~~~ diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index 227712e31e675..50cbd36ced9f9 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -50,7 +50,7 @@ impl ToStr for (A,) { } } -impl ToStr for HashMap { +impl ToStr for HashMap { #[inline] fn to_str(&self) -> ~str { let mut acc = ~"{"; @@ -182,6 +182,8 @@ mod tests { use hashmap::HashMap; use hashmap::HashSet; use container::{MutableSet, MutableMap}; + use super::*; + #[test] fn test_simple_types() { assert_eq!(1i.to_str(), ~"1"); @@ -212,17 +214,27 @@ mod tests { ~"[[], [1], [1, 1]]"); } + struct StructWithToStrWithoutEqOrHash { + value: int + } + + impl ToStr for StructWithToStrWithoutEqOrHash { + fn to_str(&self) -> ~str { + fmt!("s%d", self.value) + } + } + #[test] fn test_hashmap() { - let mut table: HashMap = HashMap::new(); - let empty: HashMap = HashMap::new(); + let mut table: HashMap = HashMap::new(); + let empty: HashMap = HashMap::new(); - table.insert(3, 4); - table.insert(1, 2); + table.insert(3, StructWithToStrWithoutEqOrHash { value: 4 }); + table.insert(1, StructWithToStrWithoutEqOrHash { value: 2 }); let table_str = table.to_str(); - assert!(table_str == ~"{1: 2, 3: 4}" || table_str == ~"{3: 4, 1: 2}"); + assert!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}"); assert_eq!(empty.to_str(), ~"{}"); } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index baeb87e51b910..8432f28a96986 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -833,7 +833,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { * ~~~ {.rust} * let v = &[1,2,3,4]; * for v.window_iter().advance |win| { - * io::println(fmt!("%?", win)); + * printfln!(win); * } * ~~~ * @@ -862,7 +862,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { * ~~~ {.rust} * let v = &[1,2,3,4,5]; * for v.chunk_iter().advance |win| { - * io::println(fmt!("%?", win)); + * printfln!(win); * } * ~~~ * @@ -2116,8 +2116,7 @@ macro_rules! iterator { #[inline] fn size_hint(&self) -> (uint, Option) { - let diff = (self.end as uint) - (self.ptr as uint); - let exact = diff / sys::nonzero_size_of::<$elem>(); + let exact = self.indexable(); (exact, Some(exact)) } } @@ -2145,6 +2144,28 @@ macro_rules! double_ended_iterator { } } +macro_rules! random_access_iterator { + (impl $name:ident -> $elem:ty) => { + impl<'self, T> RandomAccessIterator<$elem> for $name<'self, T> { + #[inline] + fn indexable(&self) -> uint { + let diff = (self.end as uint) - (self.ptr as uint); + diff / sys::nonzero_size_of::() + } + + fn idx(&self, index: uint) -> Option<$elem> { + unsafe { + if index < self.indexable() { + cast::transmute(self.ptr.offset(index)) + } else { + None + } + } + } + } + } +} + //iterator!{struct VecIterator -> *T, &'self T} /// An iterator for iterating over a vector. pub struct VecIterator<'self, T> { @@ -2154,6 +2175,7 @@ pub struct VecIterator<'self, T> { } iterator!{impl VecIterator -> &'self T} double_ended_iterator!{impl VecIterator -> &'self T} +random_access_iterator!{impl VecIterator -> &'self T} pub type VecRevIterator<'self, T> = InvertIterator<&'self T, VecIterator<'self, T>>; impl<'self, T> Clone for VecIterator<'self, T> { @@ -2169,6 +2191,7 @@ pub struct VecMutIterator<'self, T> { } iterator!{impl VecMutIterator -> &'self mut T} double_ended_iterator!{impl VecMutIterator -> &'self mut T} +random_access_iterator!{impl VecMutIterator -> &'self mut T} pub type VecMutRevIterator<'self, T> = InvertIterator<&'self mut T, VecMutIterator<'self, T>>; /// An iterator that moves out of a vector. @@ -3108,6 +3131,45 @@ mod tests { assert!(it.next().is_none()); } + #[test] + fn test_random_access_iterator() { + use iterator::*; + let xs = [1, 2, 5, 10, 11]; + let mut it = xs.iter(); + + assert_eq!(it.indexable(), 5); + assert_eq!(it.idx(0).unwrap(), &1); + assert_eq!(it.idx(2).unwrap(), &5); + assert_eq!(it.idx(4).unwrap(), &11); + assert!(it.idx(5).is_none()); + + assert_eq!(it.next().unwrap(), &1); + assert_eq!(it.indexable(), 4); + assert_eq!(it.idx(0).unwrap(), &2); + assert_eq!(it.idx(3).unwrap(), &11); + assert!(it.idx(4).is_none()); + + assert_eq!(it.next().unwrap(), &2); + assert_eq!(it.indexable(), 3); + assert_eq!(it.idx(1).unwrap(), &10); + assert!(it.idx(3).is_none()); + + assert_eq!(it.next().unwrap(), &5); + assert_eq!(it.indexable(), 2); + assert_eq!(it.idx(1).unwrap(), &11); + + assert_eq!(it.next().unwrap(), &10); + assert_eq!(it.indexable(), 1); + assert_eq!(it.idx(0).unwrap(), &11); + assert!(it.idx(1).is_none()); + + assert_eq!(it.next().unwrap(), &11); + assert_eq!(it.indexable(), 0); + assert!(it.idx(0).is_none()); + + assert!(it.next().is_none()); + } + #[test] fn test_iter_size_hints() { use iterator::*; diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index e831e32f23d49..a5c8f2a235ed9 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -357,15 +357,16 @@ pub fn get_single_str_from_tts(cx: @ExtCtxt, } } -pub fn get_exprs_from_tts(cx: @ExtCtxt, tts: &[ast::token_tree]) - -> ~[@ast::expr] { +pub fn get_exprs_from_tts(cx: @ExtCtxt, + sp: span, + tts: &[ast::token_tree]) -> ~[@ast::expr] { let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_owned()); let mut es = ~[]; while *p.token != token::EOF { - if es.len() != 0 { - p.eat(&token::COMMA); + if es.len() != 0 && !p.eat(&token::COMMA) { + cx.span_fatal(sp, "expected token: `,`"); } es.push(p.parse_expr()); } diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 3f64654dd8025..2092c45074eb6 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -18,7 +18,7 @@ use ext::build::AstBuilder; pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { // Gather all argument expressions - let exprs = get_exprs_from_tts(cx, tts); + let exprs = get_exprs_from_tts(cx, sp, tts); let mut bytes = ~[]; for exprs.iter().advance |expr| { diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 333570b6c9d7e..737127fcae73d 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -26,7 +26,7 @@ use parse::token::{str_to_ident}; pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { - let args = get_exprs_from_tts(cx, tts); + let args = get_exprs_from_tts(cx, sp, tts); if args.len() == 0 { cx.span_fatal(sp, "fmt! takes at least 1 argument."); } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index c20e35c299afd..4b3c8498380cc 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -23,8 +23,6 @@ use parse::token::{get_ident_interner, special_idents, gensym_ident, ident_to_st use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt}; use print; -use std::io; - pub fn add_new_extension(cx: @ExtCtxt, sp: span, name: ident, @@ -82,11 +80,11 @@ pub fn add_new_extension(cx: @ExtCtxt, -> MacResult { if cx.trace_macros() { - io::println(fmt!("%s! { %s }", - cx.str_of(name), - print::pprust::tt_to_str( - &ast::tt_delim(@mut arg.to_owned()), - get_ident_interner()))); + printfln!("%s! { %s }", + cx.str_of(name), + print::pprust::tt_to_str( + &ast::tt_delim(@mut arg.to_owned()), + get_ident_interner())); } // Which arm's failure should we report? (the one furthest along) diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 2d15d0ab7e82b..52b6d4459bf48 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -686,7 +686,7 @@ mod test { use std::io; #[test] fn t1() { let a = fresh_name("ghi"); - io::println(fmt!("interned name: %u,\ntextual name: %s\n", - a,interner_get(a))); + printfln!("interned name: %u,\ntextual name: %s\n", + a, interner_get(a)); } } diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 730b175a49944..3bd0157c48a56 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -24,7 +24,7 @@ fn timed(label: &str, f: &fn()) { let start = time::precise_time_s(); f(); let end = time::precise_time_s(); - io::println(fmt!(" %s: %f", label, end - start)); + printfln!(" %s: %f", label, end - start); } fn ascending>(map: &mut M, n_keys: uint) { @@ -116,7 +116,7 @@ fn main() { } } - io::println(fmt!("%? keys", n_keys)); + printfln!("%? keys", n_keys); io::println("\nTreeMap:"); diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index ea5aa309dc6c9..0d93bdb6f9446 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -58,7 +58,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: &fn()) { test(); let stop = precise_time_s(); - io::println(fmt!("%s:\t\t%f ms", name, (stop - start) * 1000f)); + printfln!("%s:\t\t%f ms", name, (stop - start) * 1000f); } fn shift_push() { diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index 86784c0b7d3bc..0fa641e395eee 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -119,8 +119,7 @@ fn main() { let elapsed = (stop - start); let rate = (num_msgs as float) / elapsed; - io::println(fmt!("Sent %? messages in %? seconds", - num_msgs, elapsed)); - io::println(fmt!(" %? messages / second", rate)); - io::println(fmt!(" %? μs / message", 1000000. / rate)); + printfln!("Sent %? messages in %? seconds", num_msgs, elapsed); + printfln!(" %? messages / second", rate); + printfln!(" %? μs / message", 1000000. / rate); } diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index b79f171147aa0..9eb415e889233 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -105,8 +105,7 @@ fn main() { let elapsed = (stop - start); let rate = (num_msgs as float) / elapsed; - io::println(fmt!("Sent %? messages in %? seconds", - num_msgs, elapsed)); - io::println(fmt!(" %? messages / second", rate)); - io::println(fmt!(" %? μs / message", 1000000. / rate)); + printfln!("Sent %? messages in %? seconds", num_msgs, elapsed); + printfln!(" %? messages / second", rate); + printfln!(" %? μs / message", 1000000. / rate); } diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index b4037d866a010..09d1c632d0e48 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -115,8 +115,7 @@ fn main() { let elapsed = (stop - start); let rate = (num_msgs as float) / elapsed; - io::println(fmt!("Sent %? messages in %? seconds", - num_msgs, elapsed)); - io::println(fmt!(" %? messages / second", rate)); - io::println(fmt!(" %? μs / message", 1000000. / rate)); + printfln!("Sent %? messages in %? seconds", num_msgs, elapsed); + printfln!(" %? messages / second", rate); + printfln!(" %? μs / message", 1000000. / rate); } diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index 2eb274378900a..b11daeef12f51 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -198,13 +198,13 @@ fn main() { let bounded = do timeit { bounded(count) }; let unbounded = do timeit { unbounded(count) }; - io::println(fmt!("count: %?\n", count)); - io::println(fmt!("bounded: %? s\t(%? μs/message)", - bounded, bounded * 1000000. / (count as float))); - io::println(fmt!("unbounded: %? s\t(%? μs/message)", - unbounded, unbounded * 1000000. / (count as float))); - - io::println(fmt!("\n\ - bounded is %?%% faster", - (unbounded - bounded) / bounded * 100.)); + printfln!("count: %?\n", count); + printfln!("bounded: %? s\t(%? μs/message)", + bounded, bounded * 1000000. / (count as float)); + printfln!("unbounded: %? s\t(%? μs/message)", + unbounded, unbounded * 1000000. / (count as float)); + + printfln!("\n\ + bounded is %?%% faster", + (unbounded - bounded) / bounded * 100.); } diff --git a/src/test/bench/shootout-ackermann.rs b/src/test/bench/shootout-ackermann.rs index ff806c8b5d44d..e06ff02a0b38f 100644 --- a/src/test/bench/shootout-ackermann.rs +++ b/src/test/bench/shootout-ackermann.rs @@ -36,5 +36,5 @@ fn main() { args }; let n = int::from_str(args[1]).get(); - io::println(fmt!("Ack(3,%d): %d\n", n, ack(3, n))); + printfln!("Ack(3,%d): %d\n", n, ack(3, n)); } diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index d88843e118045..596a5b5422a5d 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -61,9 +61,9 @@ fn main() { let stretch_depth = max_depth + 1; let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth); - println(fmt!("stretch tree of depth %d\t check: %d", - stretch_depth, - item_check(stretch_tree))); + printfln!("stretch tree of depth %d\t check: %d", + stretch_depth, + item_check(stretch_tree)); let long_lived_arena = arena::Arena(); let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth); @@ -79,12 +79,11 @@ fn main() { chk += item_check(temp_tree); i += 1; } - println(fmt!("%d\t trees of depth %d\t check: %d", - iterations * 2, depth, - chk)); + printfln!("%d\t trees of depth %d\t check: %d", + iterations * 2, depth, chk); depth += 2; } - println(fmt!("long lived tree of depth %d\t check: %d", - max_depth, - item_check(long_lived_tree))); + printfln!("long lived tree of depth %d\t check: %d", + max_depth, + item_check(long_lived_tree)); } diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 1d2095df9dfd5..97c2cba3b9e31 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -93,5 +93,5 @@ fn fannkuch_redux(n: i32) -> i32 { #[fixed_stack_segment] fn main() { let n: i32 = FromStr::from_str(os::args()[1]).get(); - println(fmt!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int)); + printfln!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int); } diff --git a/src/test/bench/shootout-fibo.rs b/src/test/bench/shootout-fibo.rs index de36a59dd6507..7b8bc31bf1c83 100644 --- a/src/test/bench/shootout-fibo.rs +++ b/src/test/bench/shootout-fibo.rs @@ -32,5 +32,5 @@ fn main() { args }; let n = int::from_str(args[1]).get(); - io::println(fmt!("%d\n", fib(n))); + printfln!("%d\n", fib(n)); } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 405aa68c483ba..a7b784e1a96e8 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -82,7 +82,7 @@ struct PrintCallback(&'static str); impl TableCallback for PrintCallback { fn f(&self, entry: &mut Entry) { - println(fmt!("%d\t%s", entry.count as int, **self)); + printfln!("%d\t%s", entry.count as int, **self); } } @@ -279,9 +279,9 @@ fn print_frequencies(frequencies: &Table, frame: i32) { } for vector.each |&(key, count)| { - println(fmt!("%s %.3f", - key.unpack(frame), - (count as float * 100.0) / (total_count as float))); + printfln!("%s %.3f", + key.unpack(frame), + (count as float * 100.0) / (total_count as float)); } } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index b79ecd03c0c68..594593e2ea343 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -15,7 +15,7 @@ fn main() { let mut byte_acc: i8 = 0; let mut bit_num: i32 = 0; - println(fmt!("P4\n%d %d", w as int, h as int)); + printfln!("P4\n%d %d", w as int, h as int); let mode = "w"; let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0])); diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 1fab646fb37a7..6d04292588d45 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -142,9 +142,9 @@ fn main() { let mut bodies = BODIES; offset_momentum(&mut bodies); - println(fmt!("%.9f", energy(&bodies) as float)); + printfln!("%.9f", energy(&bodies) as float); advance(&mut bodies, 0.01, n); - println(fmt!("%.9f", energy(&bodies) as float)); + printfln!("%.9f", energy(&bodies) as float); } diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index 3e3df53eaad97..388613482c2cf 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -61,5 +61,5 @@ fn main() { mult_AtAv(v, u, tmp); } - println(fmt!("%.9f", (dot(u,v) / dot(v,v)).sqrt() as float)); + printfln!("%.9f", (dot(u,v) / dot(v,v)).sqrt() as float); } diff --git a/src/test/bench/shootout-threadring.rs b/src/test/bench/shootout-threadring.rs index 7e75ac8584855..203b9c297fa6b 100644 --- a/src/test/bench/shootout-threadring.rs +++ b/src/test/bench/shootout-threadring.rs @@ -40,7 +40,7 @@ fn roundtrip(id: int, n_tasks: int, p: &Port, ch: &Chan) { while (true) { match p.recv() { 1 => { - println(fmt!("%d\n", id)); + printfln!("%d\n", id); return; } token => { diff --git a/src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs b/src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs index e2fbce6e195f5..9a82dd3f512ca 100644 --- a/src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs +++ b/src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs @@ -18,7 +18,7 @@ struct Foo { impl Foo { pub fn printme(&mut self) { - io::println(fmt!("%d", self.x)); + printfln!("%d", self.x); } } diff --git a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs index c02a0b4cfafd5..e3e12a4a4168b 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs @@ -9,5 +9,5 @@ fn a() -> &int { fn main() { let fifth = a(); - println(fmt!("%d", *fifth)); + printfln!("%d", *fifth); } diff --git a/src/test/compile-fail/issue-3820.rs b/src/test/compile-fail/issue-3820.rs index 8fafd04d1e2a5..04c3a0624264d 100644 --- a/src/test/compile-fail/issue-3820.rs +++ b/src/test/compile-fail/issue-3820.rs @@ -22,5 +22,5 @@ fn main() { let u = Thing {x: 2}; let _v = u.mul(&3); // This is ok let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing` - println(fmt!("%i", w.x)); + printfln!("%i", w.x); } diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs index ffa11e592608d..9ec1f5cd441b0 100644 --- a/src/test/compile-fail/issue-4335.rs +++ b/src/test/compile-fail/issue-4335.rs @@ -14,5 +14,5 @@ fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cann fn main() { let v = &5; - println(fmt!("%d", f(v)())); + printfln!("%d", f(v)()); } diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index f05c30c3355e0..19a3ce4f8384b 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -28,7 +28,7 @@ fn innocent_looking_victim() { match x { Some(ref msg) => { (f.c)(f, true); - println(fmt!("%?", msg)); + printfln!(msg); }, None => fail!("oops"), } diff --git a/src/test/compile-fail/rcmut-not-const-and-not-owned.rs b/src/test/compile-fail/rcmut-not-const-and-not-owned.rs index 45cb137b08459..c27debdbc7fb9 100644 --- a/src/test/compile-fail/rcmut-not-const-and-not-owned.rs +++ b/src/test/compile-fail/rcmut-not-const-and-not-owned.rs @@ -14,7 +14,7 @@ fn o(_: &T) {} fn c(_: &T) {} fn main() { - let x = extra::rc::rc_mut_from_owned(0); + let x = extra::rc::RcMut::from_owned(0); o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut`, which does not fulfill `Send` c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut`, which does not fulfill `Freeze` } diff --git a/src/test/compile-fail/tuple-struct-nonexhaustive.rs b/src/test/compile-fail/tuple-struct-nonexhaustive.rs index 785eeb24784fa..4640957a9a894 100644 --- a/src/test/compile-fail/tuple-struct-nonexhaustive.rs +++ b/src/test/compile-fail/tuple-struct-nonexhaustive.rs @@ -13,7 +13,7 @@ struct Foo(int, int); fn main() { let x = Foo(1, 2); match x { //~ ERROR non-exhaustive - Foo(1, b) => println(fmt!("%d", b)), - Foo(2, b) => println(fmt!("%d", b)) + Foo(1, b) => printfln!("%d", b), + Foo(2, b) => printfln!("%d", b) } } diff --git a/src/test/run-fail/borrowck-wg-one-mut-one-imm-slice-method.rs b/src/test/run-fail/borrowck-wg-one-mut-one-imm-slice-method.rs index 91df90f8b3ac9..8ed3297e7d142 100644 --- a/src/test/run-fail/borrowck-wg-one-mut-one-imm-slice-method.rs +++ b/src/test/run-fail/borrowck-wg-one-mut-one-imm-slice-method.rs @@ -33,5 +33,5 @@ pub fn main() let z = @mut [1,2,3]; let z2 = z; add(z.my_mut_slice(), z2.my_slice()); - print(fmt!("%d\n", z[0])); + printfln!("%d", z[0]); } diff --git a/src/test/run-fail/borrowck-wg-one-mut-one-imm-slices.rs b/src/test/run-fail/borrowck-wg-one-mut-one-imm-slices.rs index bae693ce4eae2..d2971ad40ab44 100644 --- a/src/test/run-fail/borrowck-wg-one-mut-one-imm-slices.rs +++ b/src/test/run-fail/borrowck-wg-one-mut-one-imm-slices.rs @@ -12,5 +12,5 @@ pub fn main() let z = @mut [1,2,3]; let z2 = z; add(z, z2); - print(fmt!("%d\n", z[0])); + printfln!("%d", z[0]); } diff --git a/src/test/run-fail/borrowck-wg-one-mut-one-imm.rs b/src/test/run-fail/borrowck-wg-one-mut-one-imm.rs index 9e2a02b32dfed..df096e8292f82 100644 --- a/src/test/run-fail/borrowck-wg-one-mut-one-imm.rs +++ b/src/test/run-fail/borrowck-wg-one-mut-one-imm.rs @@ -13,5 +13,5 @@ pub fn main() let z = @mut [1,2,3]; let z2 = z; add(&mut z[0], &z2[0]); - print(fmt!("%d\n", z[0])); + printfln!("%d", z[0]); } diff --git a/src/test/run-fail/borrowck-wg-two-array-indices.rs b/src/test/run-fail/borrowck-wg-two-array-indices.rs index ad68448876028..98bb72c93408b 100644 --- a/src/test/run-fail/borrowck-wg-two-array-indices.rs +++ b/src/test/run-fail/borrowck-wg-two-array-indices.rs @@ -13,5 +13,5 @@ pub fn main() let z = @mut [1,2,3]; let z2 = z; add(&mut z[0], &mut z2[0]); - print(fmt!("%d\n", z[0])); + printfln!("%d", z[0]); } diff --git a/src/test/run-pass/auto-ref.rs b/src/test/run-pass/auto-ref.rs index 7171b0ee86c4b..cc14af45c85cb 100644 --- a/src/test/run-pass/auto-ref.rs +++ b/src/test/run-pass/auto-ref.rs @@ -18,7 +18,7 @@ trait Stuff { impl Stuff for Foo { fn printme(&self) { - println(fmt!("%d", self.x)); + printfln!("%d", self.x); } } diff --git a/src/test/run-pass/borrowck-wg-two-imm-borrows.rs b/src/test/run-pass/borrowck-wg-two-imm-borrows.rs index 20f824e969a48..306141354ca76 100644 --- a/src/test/run-pass/borrowck-wg-two-imm-borrows.rs +++ b/src/test/run-pass/borrowck-wg-two-imm-borrows.rs @@ -10,5 +10,5 @@ pub fn main() let z = @mut [1,2,3]; let z2 = z; add(&z[0], &z2[0]); - print(fmt!("%d\n", z[0])); + printfln!("%d", z[0]); } diff --git a/src/test/run-pass/cci_impl_exe.rs b/src/test/run-pass/cci_impl_exe.rs index 097184540fdfc..30adaf2dae4a3 100644 --- a/src/test/run-pass/cci_impl_exe.rs +++ b/src/test/run-pass/cci_impl_exe.rs @@ -19,7 +19,7 @@ pub fn main() { //info!("%?", bt0); do 3u.to(10u) |i| { - print(fmt!("%u\n", i)); + printfln!("%u", i); //let bt1 = sys::frame_address(); //info!("%?", bt1); diff --git a/src/test/run-pass/cci_iter_exe.rs b/src/test/run-pass/cci_iter_exe.rs index a8c0583701380..4db0b1871d078 100644 --- a/src/test/run-pass/cci_iter_exe.rs +++ b/src/test/run-pass/cci_iter_exe.rs @@ -17,7 +17,7 @@ pub fn main() { //let bt0 = sys::rusti::frame_address(1u32); //info!("%?", bt0); do cci_iter_lib::iter(~[1, 2, 3]) |i| { - print(fmt!("%d", *i)); + printf!("%d", *i); //assert!(bt0 == sys::rusti::frame_address(2u32)); } } diff --git a/src/test/run-pass/cci_no_inline_exe.rs b/src/test/run-pass/cci_no_inline_exe.rs index 83a77ad987736..6459239e46959 100644 --- a/src/test/run-pass/cci_no_inline_exe.rs +++ b/src/test/run-pass/cci_no_inline_exe.rs @@ -23,7 +23,7 @@ pub fn main() { //let bt0 = sys::frame_address(); //info!("%?", bt0); do iter(~[1u, 2u, 3u]) |i| { - print(fmt!("%u\n", i)); + printfln!("%u", i); //let bt1 = sys::frame_address(); //info!("%?", bt1); diff --git a/src/test/run-pass/const-fields-and-indexing.rs b/src/test/run-pass/const-fields-and-indexing.rs index 990e5e6721915..6dca5d60f1111 100644 --- a/src/test/run-pass/const-fields-and-indexing.rs +++ b/src/test/run-pass/const-fields-and-indexing.rs @@ -27,9 +27,9 @@ static k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}}; static m : int = k.c.e; pub fn main() { - io::println(fmt!("%?", p)); - io::println(fmt!("%?", q)); - io::println(fmt!("%?", t)); + printfln!(p); + printfln!(q); + printfln!(t); assert_eq!(p, 3); assert_eq!(q, 3); assert_eq!(t, 20); diff --git a/src/test/run-pass/const-rec-and-tup.rs b/src/test/run-pass/const-rec-and-tup.rs index 31b806bf41a1b..5b80988dcdfb0 100644 --- a/src/test/run-pass/const-rec-and-tup.rs +++ b/src/test/run-pass/const-rec-and-tup.rs @@ -21,5 +21,5 @@ static y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0, pub fn main() { let (p, _) = y.x; assert_eq!(p, - 1085102592571150096); - println(fmt!("0x%x", p as uint)); + printfln!("0x%x", p as uint); } diff --git a/src/test/run-pass/const-region-ptrs.rs b/src/test/run-pass/const-region-ptrs.rs index cdc71292ae069..c2103a40bfea7 100644 --- a/src/test/run-pass/const-region-ptrs.rs +++ b/src/test/run-pass/const-region-ptrs.rs @@ -17,8 +17,8 @@ static x: &'static int = &10; static y: &'static Pair<'static> = &Pair {a: 15, b: x}; pub fn main() { - io::println(fmt!("x = %?", *x)); - io::println(fmt!("y = {a: %?, b: %?}", y.a, *(y.b))); + printfln!("x = %?", *x); + printfln!("y = {a: %?, b: %?}", y.a, *(y.b)); assert_eq!(*x, 10); assert_eq!(*(y.b), 10); } diff --git a/src/test/run-pass/const-struct.rs b/src/test/run-pass/const-struct.rs index 8a93a3e4c1ccb..c62fcd8980fad 100644 --- a/src/test/run-pass/const-struct.rs +++ b/src/test/run-pass/const-struct.rs @@ -30,6 +30,6 @@ pub fn main() { assert_eq!(x.b, 2); assert_eq!(x, y); assert_eq!(z.b, 22); - io::println(fmt!("0x%x", x.b as uint)); - io::println(fmt!("0x%x", z.c as uint)); + printfln!("0x%x", x.b as uint); + printfln!("0x%x", z.c as uint); } diff --git a/src/test/run-pass/const-vecs-and-slices.rs b/src/test/run-pass/const-vecs-and-slices.rs index 0aee53a4ed2d2..01ef3284e32f9 100644 --- a/src/test/run-pass/const-vecs-and-slices.rs +++ b/src/test/run-pass/const-vecs-and-slices.rs @@ -14,8 +14,8 @@ static x : [int, ..4] = [1,2,3,4]; static y : &'static [int] = &[1,2,3,4]; pub fn main() { - io::println(fmt!("%?", x[1])); - io::println(fmt!("%?", y[1])); + printfln!(x[1]); + printfln!(y[1]); assert_eq!(x[1], 2); assert_eq!(x[3], 4); assert_eq!(x[3], y[3]); diff --git a/src/test/run-pass/functional-struct-update.rs b/src/test/run-pass/functional-struct-update.rs index 6d95f6b23ab35..0cd9b2adf7ce6 100644 --- a/src/test/run-pass/functional-struct-update.rs +++ b/src/test/run-pass/functional-struct-update.rs @@ -16,5 +16,5 @@ struct Foo { pub fn main() { let a = Foo { x: 1, y: 2 }; let c = Foo { x: 4, .. a}; - println(fmt!("%?", c)); + printfln!(c); } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 5b320ddc06bb6..c84386c722da7 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -80,5 +80,5 @@ pub fn main() { a); let sum = foldl(filt, 0u, |accum, &&n: uint| accum + n ); - io::println(fmt!("%u", sum)); + printfln!("%u", sum); } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index 5b3333fb998cc..d4cbfa91fb6a4 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -42,7 +42,7 @@ pub fn main() { let bools2 = to_bools(Storage{storage: ~[0b01100100]}); for uint::range(0, 8) |i| { - io::println(fmt!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint)); + printfln!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint); } assert_eq!(bools, bools2); diff --git a/src/test/run-pass/issue-3211.rs b/src/test/run-pass/issue-3211.rs index c7b0823296c67..3e3e6d6f99215 100644 --- a/src/test/run-pass/issue-3211.rs +++ b/src/test/run-pass/issue-3211.rs @@ -4,5 +4,5 @@ pub fn main() { x += 1; } assert_eq!(x, 4096); - println(fmt!("x = %u", x)); + printfln!("x = %u", x); } diff --git a/src/test/run-pass/issue-3743.rs b/src/test/run-pass/issue-3743.rs index e9c2ab87c2b3d..e42b70b5a5e0d 100644 --- a/src/test/run-pass/issue-3743.rs +++ b/src/test/run-pass/issue-3743.rs @@ -42,11 +42,11 @@ pub fn main() { // the following compiles and works properly let v1: Vec2 = a * 3f; - io::println(fmt!("%f %f", v1.x, v1.y)); + printfln!("%f %f", v1.x, v1.y); // the following compiles but v2 will not be Vec2 yet and // using it later will cause an error that the type of v2 // must be known let v2 = a * 3f; - io::println(fmt!("%f %f", v2.x, v2.y)); // error regarding v2's type + printfln!("%f %f", v2.x, v2.y); // error regarding v2's type } diff --git a/src/test/run-pass/issue-3753.rs b/src/test/run-pass/issue-3753.rs index a94abe04fded2..12ec501788de8 100644 --- a/src/test/run-pass/issue-3753.rs +++ b/src/test/run-pass/issue-3753.rs @@ -35,5 +35,5 @@ impl Shape { pub fn main(){ let s = Circle(Point { x: 1f, y: 2f }, 3f); - println(fmt!("%f", s.area(s))); + printfln!("%f", s.area(s)); } diff --git a/src/test/run-pass/issue-3794.rs b/src/test/run-pass/issue-3794.rs index 1c1eb75c220c1..5ec8383dd20b2 100644 --- a/src/test/run-pass/issue-3794.rs +++ b/src/test/run-pass/issue-3794.rs @@ -19,7 +19,7 @@ struct S { impl T for S { fn print(&self) { - io::println(fmt!("%?", self)); + printfln!(self); } } diff --git a/src/test/run-pass/issue-3904.rs b/src/test/run-pass/issue-3904.rs index 6b0796a1260d5..98b7741461ec4 100644 --- a/src/test/run-pass/issue-3904.rs +++ b/src/test/run-pass/issue-3904.rs @@ -12,7 +12,7 @@ type ErrPrinter = &fn(&str, &str); fn example_err(prog: &str, arg: &str) { - io::println(fmt!("%s: %s", prog, arg)) + printfln!("%s: %s", prog, arg) } fn exit(+print: ErrPrinter, prog: &str, arg: &str) { diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index 1f5da69018ab5..857ecb3f9cbcf 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -114,7 +114,7 @@ fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result { //io::println(cmd); sb.write_str(cmd); let res = parse_response(@sb as @io::Reader); - //io::println(fmt!("%?", res)); + //printfln!(res); res } @@ -122,7 +122,7 @@ fn query2(cmd: ~[~str]) -> Result { let _cmd = cmd_to_str(cmd); do io::with_str_reader(~"$3\r\nXXX\r\n") |sb| { let res = parse_response(@sb as @io::Reader); - io::println(fmt!("%?", res)); + printfln!(res); res } } diff --git a/src/test/run-pass/issue-4401.rs b/src/test/run-pass/issue-4401.rs index d0d211c109c85..e993d827abb7d 100644 --- a/src/test/run-pass/issue-4401.rs +++ b/src/test/run-pass/issue-4401.rs @@ -4,5 +4,5 @@ pub fn main() { count += 1; } assert_eq!(count, 999_999); - println(fmt!("%u", count)); + printfln!("%u", count); } diff --git a/src/test/run-pass/max-min-classes.rs b/src/test/run-pass/max-min-classes.rs index c34067c329d27..685a11c79ee32 100644 --- a/src/test/run-pass/max-min-classes.rs +++ b/src/test/run-pass/max-min-classes.rs @@ -35,5 +35,5 @@ fn Foo(x: int, y: int) -> Foo { pub fn main() { let foo = Foo(3, 20); - println(fmt!("%d %d", foo.sum(), foo.product())); + printfln!("%d %d", foo.sum(), foo.product()); } diff --git a/src/test/run-pass/new-style-constants.rs b/src/test/run-pass/new-style-constants.rs index 2da532422c0cb..a00bfceab0f4d 100644 --- a/src/test/run-pass/new-style-constants.rs +++ b/src/test/run-pass/new-style-constants.rs @@ -13,5 +13,5 @@ use std::io::println; static FOO: int = 3; pub fn main() { - println(fmt!("%d", FOO)); + printfln!("%d", FOO); } diff --git a/src/test/run-pass/new-style-fixed-length-vec.rs b/src/test/run-pass/new-style-fixed-length-vec.rs index 41704c252c8db..488bd65f5484a 100644 --- a/src/test/run-pass/new-style-fixed-length-vec.rs +++ b/src/test/run-pass/new-style-fixed-length-vec.rs @@ -13,5 +13,5 @@ use std::io::println; static FOO: [int, ..3] = [1, 2, 3]; pub fn main() { - println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2])); + printfln!("%d %d %d", FOO[0], FOO[1], FOO[2]); } diff --git a/src/test/run-pass/newtype.rs b/src/test/run-pass/newtype.rs index d26210e9a4c1c..3e2308bfcaf66 100644 --- a/src/test/run-pass/newtype.rs +++ b/src/test/run-pass/newtype.rs @@ -16,6 +16,6 @@ fn compute(i: mytype) -> int { return i.val + 20; } pub fn main() { let myval = mytype(Mytype{compute: compute, val: 30}); - println(fmt!("%d", compute(myval))); + printfln!("%d", compute(myval)); assert_eq!((myval.compute)(myval), 50); } diff --git a/src/test/run-pass/num-range-rev.rs b/src/test/run-pass/num-range-rev.rs index 7262339e431d9..e40a183243e01 100644 --- a/src/test/run-pass/num-range-rev.rs +++ b/src/test/run-pass/num-range-rev.rs @@ -56,13 +56,13 @@ pub fn main() { let primes = [2,3,5,7,11]; let mut prod = 1i; for uint_range_rev(5, 0) |i| { - println(fmt!("uint 4 downto 0: %u", i)); + printfln!("uint 4 downto 0: %u", i); prod *= int::pow(primes[i], i); } assert_eq!(prod, 11*11*11*11*7*7*7*5*5*3*1); let mut prod = 1i; for int_range_rev(5, 0) |i| { - println(fmt!("int 4 downto 0: %d", i)); + printfln!("int 4 downto 0: %d", i); prod *= int::pow(primes[i], i as uint); } assert_eq!(prod, 11*11*11*11*7*7*7*5*5*3*1); diff --git a/src/test/run-pass/num-range.rs b/src/test/run-pass/num-range.rs index 7c1f905a049b6..d01b22404467a 100644 --- a/src/test/run-pass/num-range.rs +++ b/src/test/run-pass/num-range.rs @@ -28,7 +28,7 @@ fn uint_range_step(a: uint, b: uint, s: int, it: &fn(uint) -> bool) -> bool { } pub fn main() { - println(fmt!("num-range start")); + println("num-range start"); // int and uint have same result for // Sum{2 <= i < 100} == (Sum{1 <= i <= 99} - 1) == n*(n+1)/2 - 1 for n=99 let mut sum = 0u; @@ -105,7 +105,7 @@ pub fn main() { let mut saw21 = false; for uint::range_step_inclusive(0, 21, 3) |x| { assert!(x <= 21); - println(fmt!("saw: %u", x)); + printfln!("saw: %u", x); if x == 21 { saw21 = true; } } assert!(saw21); diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs index 839f40fe67f57..9500f83b76b09 100644 --- a/src/test/run-pass/placement-new-arena.rs +++ b/src/test/run-pass/placement-new-arena.rs @@ -17,6 +17,6 @@ pub fn main() { let mut arena = arena::Arena(); let p = &mut arena; let x = p.alloc(|| 4u); - print(fmt!("%u", *x)); + printf!("%u", *x); assert_eq!(*x, 4u); } diff --git a/src/test/run-pass/recursion.rs b/src/test/run-pass/recursion.rs index 092cd3d8ed5bb..07a5c10ab1fd1 100644 --- a/src/test/run-pass/recursion.rs +++ b/src/test/run-pass/recursion.rs @@ -30,5 +30,5 @@ fn test (n:int, i:int, first:T, second:T) ->int { } pub fn main() { let n = test(1, 0, Nil, Nil); - io::println(fmt!("%d", n)); + printfln!("%d", n); } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 88fac13c33e8f..21d13c722e752 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -667,7 +667,7 @@ pub fn main() { let r = u.vals.clone(); for r.iter().advance |s| { - println(fmt!("val: %s", *s)); + printfln!("val: %s", *s); } error!("%?", u.vals.clone()); assert_eq!(u.vals.clone(), diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index b3c5acd7dd5c4..dc639bad75efa 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -171,7 +171,7 @@ pub fn main() { visit_ty::<~[int]>(vv); for v.types.iter().advance |s| { - println(fmt!("type: %s", (*s).clone())); + printfln!("type: %s", (*s).clone()); } assert_eq!((*v.types).clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]); } diff --git a/src/test/run-pass/struct-pattern-matching.rs b/src/test/run-pass/struct-pattern-matching.rs index 68fa137397525..3d8c2b7f56a0d 100644 --- a/src/test/run-pass/struct-pattern-matching.rs +++ b/src/test/run-pass/struct-pattern-matching.rs @@ -16,6 +16,6 @@ struct Foo { pub fn main() { let a = Foo { x: 1, y: 2 }; match a { - Foo { x: x, y: y } => println(fmt!("yes, %d, %d", x, y)) + Foo { x: x, y: y } => printfln!("yes, %d, %d", x, y) } } diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs index bc1583a08780a..4003a83e80bb0 100644 --- a/src/test/run-pass/trait-inheritance-num2.rs +++ b/src/test/run-pass/trait-inheritance-num2.rs @@ -99,7 +99,7 @@ impl FloatExt for f64 {} impl FloatExt for float {} -fn test_float_ext(n: T) { println(fmt!("%?", n < n)) } +fn test_float_ext(n: T) { printfln!(n < n) } pub fn main() { test_float_ext(1f32); diff --git a/src/test/run-pass/trait-inheritance-num3.rs b/src/test/run-pass/trait-inheritance-num3.rs index e0285a7b59831..2d6b5e1132536 100644 --- a/src/test/run-pass/trait-inheritance-num3.rs +++ b/src/test/run-pass/trait-inheritance-num3.rs @@ -16,7 +16,7 @@ pub trait NumExt: Eq + Ord + Num + NumCast {} impl NumExt for f32 {} fn num_eq_one(n: T) { - println(fmt!("%?", n == NumCast::from(1))) + printfln!(n == NumCast::from(1)) } pub fn main() { diff --git a/src/test/run-pass/transmute-non-immediate-to-immediate.rs b/src/test/run-pass/transmute-non-immediate-to-immediate.rs new file mode 100644 index 0000000000000..2f097bc90a942 --- /dev/null +++ b/src/test/run-pass/transmute-non-immediate-to-immediate.rs @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #7988 +// Transmuting non-immediate type to immediate type + +fn main() { + unsafe { + ::std::cast::transmute::<[int,..1],int>([1]) + }; +} diff --git a/src/test/run-pass/tuple-struct-construct.rs b/src/test/run-pass/tuple-struct-construct.rs index 20be5df3242e7..9f1b930f16835 100644 --- a/src/test/run-pass/tuple-struct-construct.rs +++ b/src/test/run-pass/tuple-struct-construct.rs @@ -12,5 +12,5 @@ struct Foo(int, int); pub fn main() { let x = Foo(1, 2); - println(fmt!("%?", x)); + printfln!(x); } diff --git a/src/test/run-pass/tuple-struct-destructuring.rs b/src/test/run-pass/tuple-struct-destructuring.rs index 4a1258264f8d1..a1b1f36dc4131 100644 --- a/src/test/run-pass/tuple-struct-destructuring.rs +++ b/src/test/run-pass/tuple-struct-destructuring.rs @@ -13,7 +13,7 @@ struct Foo(int, int); pub fn main() { let x = Foo(1, 2); let Foo(y, z) = x; - println(fmt!("%d %d", y, z)); + printfln!("%d %d", y, z); assert_eq!(y, 1); assert_eq!(z, 2); } diff --git a/src/test/run-pass/tuple-struct-matching.rs b/src/test/run-pass/tuple-struct-matching.rs index 261b913b1d2c8..36467189bbd9b 100644 --- a/src/test/run-pass/tuple-struct-matching.rs +++ b/src/test/run-pass/tuple-struct-matching.rs @@ -16,7 +16,7 @@ pub fn main() { Foo(a, b) => { assert_eq!(a, 1); assert_eq!(b, 2); - println(fmt!("%d %d", a, b)); + printfln!("%d %d", a, b); } } } diff --git a/src/test/run-pass/vec-fixed-length.rs b/src/test/run-pass/vec-fixed-length.rs index 56adc6d259881..e4c6bcf6791e2 100644 --- a/src/test/run-pass/vec-fixed-length.rs +++ b/src/test/run-pass/vec-fixed-length.rs @@ -10,5 +10,5 @@ pub fn main() { let x: [int, ..4] = [1, 2, 3, 4]; - println(fmt!("%d", x[0])); + printfln!("%d", x[0]); } diff --git a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs index aae287deb8a1e..08b62cce71562 100644 --- a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs +++ b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs @@ -5,6 +5,6 @@ pub fn main() { [1, ..ref tail] => &tail[0], _ => ::std::util::unreachable() }; - println(fmt!("%d", *el)); + printfln!("%d", *el); } }