diff --git a/src/libextra/arena.rs b/src/libextra/arena.rs index ae4356eb4bacc..ff2a91db6319c 100644 --- a/src/libextra/arena.rs +++ b/src/libextra/arena.rs @@ -38,7 +38,7 @@ use list::{MutList, MutCons, MutNil}; use std::at_vec; -use std::cast::{transmute, transmute_mut, transmute_mut_region}; +use std::cast::{transmute, transmute_mut_region}; use std::cast; use std::num; use std::ptr; @@ -263,14 +263,12 @@ impl Arena { // The external interface #[inline] - pub fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T { + pub fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T { unsafe { - // XXX: Borrow check - let this = transmute_mut(self); if intrinsics::needs_drop::() { - this.alloc_nonpod(op) + self.alloc_nonpod(op) } else { - this.alloc_pod(op) + self.alloc_pod(op) } } } @@ -279,7 +277,7 @@ impl Arena { #[test] fn test_arena_destructors() { let arena = Arena::new(); - for i in range(0u, 10) { + for i in range(0, 10) { // Arena allocate something with drop glue to make sure it // doesn't leak. do arena.alloc { @i }; diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs index e268e83bf3fb0..680e421181580 100644 --- a/src/libextra/fileinput.rs +++ b/src/libextra/fileinput.rs @@ -27,7 +27,7 @@ reset once it has been finished, so attempting to iterate on `[None, None]` will only take input once unless `io::stdin().seek(0, SeekSet)` is called between. -The `pathify` function handles converting a list of file paths as +The `make_path_option_vec` function handles converting a list of file paths as strings to the appropriate format, including the (optional) conversion of `"-"` to `stdin`. @@ -42,7 +42,7 @@ to handle any `FileInput` structs. E.g. a simple `cat` program or a program that numbers lines after concatenating two files - for input_vec_state(pathify([~"a.txt", ~"b.txt"])) |line, state| { + for input_vec_state(make_path_option_vec([~"a.txt", ~"b.txt"])) |line, state| { io::println(fmt!("%u: %s", state.line_num, line)); } @@ -145,8 +145,14 @@ struct FileInput_ { previous_was_newline: bool } -// XXX: remove this when Reader has &mut self. Should be removable via -// "self.fi." -> "self." and renaming FileInput_. Documentation above + +// FIXME #5723: remove this when Reader has &mut self. +// Removing it would mean giving read_byte in the Reader impl for +// FileInput &mut self, which in turn means giving most of the +// io::Reader trait methods &mut self. That can't be done right now +// because of io::with_bytes_reader and #5723. +// Should be removable via +// "self.fi" -> "self." and renaming FileInput_. Documentation above // will likely have to be updated to use `let mut in = ...`. pub struct FileInput { fi: @mut FileInput_ @@ -194,7 +200,7 @@ impl FileInput { */ pub fn from_args() -> FileInput { let args = os::args(); - let pathed = pathify(args.tail(), true); + let pathed = make_path_option_vec(args.tail(), true); FileInput::from_vec(pathed) } @@ -351,8 +357,7 @@ Convert a list of strings to an appropriate form for a `FileInput` instance. `stdin_hyphen` controls whether `-` represents `stdin` or a literal `-`. */ -// XXX: stupid, unclear name -pub fn pathify(vec: &[~str], stdin_hyphen : bool) -> ~[Option] { +pub fn make_path_option_vec(vec: &[~str], stdin_hyphen : bool) -> ~[Option] { vec.iter().map(|str| { if stdin_hyphen && "-" == *str { None @@ -410,7 +415,7 @@ pub fn input_vec_state(files: ~[Option], #[cfg(test)] mod test { - use super::{FileInput, pathify, input_vec, input_vec_state}; + use super::{FileInput, make_path_option_vec, input_vec, input_vec_state}; use std::io; use std::uint; @@ -426,22 +431,22 @@ mod test { } #[test] - fn test_pathify() { + fn test_make_path_option_vec() { let strs = [~"some/path", ~"some/other/path"]; let paths = ~[Some(Path("some/path")), Some(Path("some/other/path"))]; - assert_eq!(pathify(strs, true), paths.clone()); - assert_eq!(pathify(strs, false), paths); + assert_eq!(make_path_option_vec(strs, true), paths.clone()); + assert_eq!(make_path_option_vec(strs, false), paths); - assert_eq!(pathify([~"-"], true), ~[None]); - assert_eq!(pathify([~"-"], false), ~[Some(Path("-"))]); + assert_eq!(make_path_option_vec([~"-"], true), ~[None]); + assert_eq!(make_path_option_vec([~"-"], false), ~[Some(Path("-"))]); } #[test] fn test_fileinput_read_byte() { - let filenames = pathify(vec::from_fn( + let filenames = make_path_option_vec(vec::from_fn( 3, |i| fmt!("tmp/lib-fileinput-test-fileinput-read-byte-%u.tmp", i)), true); @@ -471,7 +476,7 @@ mod test { #[test] fn test_fileinput_read() { - let filenames = pathify(vec::from_fn( + let filenames = make_path_option_vec(vec::from_fn( 3, |i| fmt!("tmp/lib-fileinput-test-fileinput-read-%u.tmp", i)), true); @@ -492,7 +497,7 @@ mod test { #[test] fn test_input_vec() { let mut all_lines = ~[]; - let filenames = pathify(vec::from_fn( + let filenames = make_path_option_vec(vec::from_fn( 3, |i| fmt!("tmp/lib-fileinput-test-input-vec-%u.tmp", i)), true); @@ -514,7 +519,7 @@ mod test { #[test] fn test_input_vec_state() { - let filenames = pathify(vec::from_fn( + let filenames = make_path_option_vec(vec::from_fn( 3, |i| fmt!("tmp/lib-fileinput-test-input-vec-state-%u.tmp", i)),true); @@ -536,7 +541,7 @@ mod test { #[test] fn test_empty_files() { - let filenames = pathify(vec::from_fn( + let filenames = make_path_option_vec(vec::from_fn( 3, |i| fmt!("tmp/lib-fileinput-test-empty-files-%u.tmp", i)),true); @@ -583,7 +588,7 @@ mod test { #[test] fn test_next_file() { - let filenames = pathify(vec::from_fn( + let filenames = make_path_option_vec(vec::from_fn( 3, |i| fmt!("tmp/lib-fileinput-test-next-file-%u.tmp", i)),true); @@ -614,7 +619,7 @@ mod test { #[test] #[should_fail] fn test_input_vec_missing_file() { - do input_vec(pathify([~"this/file/doesnt/exist"], true)) |line| { + do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| { println(line); true }; diff --git a/src/libextra/flatpipes.rs b/src/libextra/flatpipes.rs index 74653828121e9..639e0292ded46 100644 --- a/src/libextra/flatpipes.rs +++ b/src/libextra/flatpipes.rs @@ -564,8 +564,10 @@ pub mod bytepipes { } } - // XXX: Remove `@mut` when this module is ported to the new I/O traits, - // which use `&mut self` properly. + // FIXME #6850: Remove `@mut` when this module is ported to the new I/O traits, + // which use `&mut self` properly. (For example, util::comm::GenericPort's try_recv + // method doesn't use `&mut self`, so the `try_recv` method in the impl of `BytePort` + // for `PipeBytePort` can't have `&mut self` either.) pub struct PipeBytePort { port: comm::Port<~[u8]>, buf: @mut ~[u8] diff --git a/src/libextra/io_util.rs b/src/libextra/io_util.rs index afefca8ae65bd..b75295ffd22ea 100644 --- a/src/libextra/io_util.rs +++ b/src/libextra/io_util.rs @@ -30,7 +30,7 @@ impl BufReader { } fn as_bytes_reader(&self, f: &fn(&BytesReader) -> A) -> A { - // XXX FIXME(#5723) + // FIXME(#5723) let bytes = ::std::util::id::<&[u8]>(self.buf); let bytes: &'static [u8] = unsafe { cast::transmute(bytes) }; // Recreating the BytesReader state every call since diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 8a2ae3e899520..59f394fba28ae 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -59,7 +59,7 @@ fn main() { let stretch_arena = Arena::new(); let stretch_depth = max_depth + 1; - let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth); + let stretch_tree = bottom_up_tree(&mut stretch_arena, 0, stretch_depth); printfln!("stretch tree of depth %d\t check: %d", stretch_depth,