Skip to content

Remove io::io_error #10449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
@@ -261,7 +261,7 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
debug!("making tests from {}",
config.src_base.display());
let mut tests = ~[];
let dirs = fs::readdir(&config.src_base);
let dirs = fs::readdir(&config.src_base).unwrap();
for file in dirs.iter() {
let file = file.clone();
debug!("inspecting file {}", file.display());
2 changes: 1 addition & 1 deletion src/compiletest/errors.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
let mut line_num = 1u;
loop {
let ln = match rdr.read_line() {
Some(ln) => ln, None => break,
Ok(ln) => ln, Err(*) => break,
};
error_patterns.push_all_move(parse_expected(line_num, ln));
line_num += 1u;
2 changes: 1 addition & 1 deletion src/compiletest/header.rs
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
loop {
let ln = match rdr.read_line() {
Some(ln) => ln, None => break
Ok(ln) => ln, Err(*) => break
};

// Assume that any directives will be found before the first
8 changes: 4 additions & 4 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
@@ -152,7 +152,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
let rounds =
match props.pp_exact { Some(_) => 1, None => 2 };

let src = File::open(testfile).read_to_end();
let src = File::open(testfile).read_to_end().unwrap();
let src = str::from_utf8_owned(src);
let mut srcs = ~[src];

@@ -174,7 +174,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
let mut expected = match props.pp_exact {
Some(ref file) => {
let filepath = testfile.dir_path().join(file);
let s = File::open(&filepath).read_to_end();
let s = File::open(&filepath).read_to_end().unwrap();
str::from_utf8_owned(s)
}
None => { srcs[srcs.len() - 2u].clone() }
@@ -995,7 +995,7 @@ fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
let tdir = aux_output_dir_name(config, testfile);

let dirs = fs::readdir(&tdir);
let dirs = fs::readdir(&tdir).unwrap();
for file in dirs.iter() {
if file.extension_str() == Some("so") {
// FIXME (#9639): This needs to handle non-utf8 paths
@@ -1090,7 +1090,7 @@ fn disassemble_extract(config: &config, _props: &TestProps,


fn count_extracted_lines(p: &Path) -> uint {
let x = File::open(&p.with_extension("ll")).read_to_end();
let x = File::open(&p.with_extension("ll")).read_to_end().unwrap();
let x = str::from_utf8_owned(x);
x.lines().len()
}
4 changes: 2 additions & 2 deletions src/libextra/ebml.rs
Original file line number Diff line number Diff line change
@@ -658,14 +658,14 @@ pub mod writer {
write_vuint(self.writer, tag_id);

// Write a placeholder four-byte size.
self.size_positions.push(self.writer.tell() as uint);
self.size_positions.push(self.writer.tell().unwrap() as uint);
let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8];
self.writer.write(zeroes);
}

pub fn end_tag(&mut self) {
let last_size_pos = self.size_positions.pop();
let cur_pos = self.writer.tell();
let cur_pos = self.writer.tell().unwrap();
self.writer.seek(last_size_pos as i64, io::SeekSet);
let size = (cur_pos as uint - last_size_pos - 4);
write_sized_vuint(self.writer, size as uint, 4u);
3 changes: 1 addition & 2 deletions src/libextra/glob.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@
*/

use std::{os, path};
use std::io;
use std::io::fs;
use std::path::is_sep;

@@ -148,7 +147,7 @@ impl Iterator<Path> for GlobIterator {
}

fn list_dir_sorted(path: &Path) -> ~[Path] {
match io::result(|| fs::readdir(path)) {
match fs::readdir(path) {
Ok(children) => {
let mut children = children;
sort::quick_sort(children, |p1, p2| p2.filename() <= p1.filename());
21 changes: 13 additions & 8 deletions src/libextra/json.rs
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ pub fn Encoder(wr: @mut io::Writer) -> Encoder {
}

impl serialize::Encoder for Encoder {
fn emit_nil(&mut self) { write!(self.wr, "null") }
fn emit_nil(&mut self) { write!(self.wr, "null"); }

fn emit_uint(&mut self, v: uint) { self.emit_f64(v as f64); }
fn emit_u64(&mut self, v: u64) { self.emit_f64(v as f64); }
@@ -118,13 +118,13 @@ impl serialize::Encoder for Encoder {
}

fn emit_f64(&mut self, v: f64) {
write!(self.wr, "{}", f64::to_str_digits(v, 6u))
write!(self.wr, "{}", f64::to_str_digits(v, 6u));
}
fn emit_f32(&mut self, v: f32) { self.emit_f64(v as f64); }

fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) }
fn emit_str(&mut self, v: &str) {
write!(self.wr, "{}", escape_str(v))
write!(self.wr, "{}", escape_str(v));
}

fn emit_enum(&mut self, _name: &str, f: |&mut Encoder|) { f(self) }
@@ -180,7 +180,7 @@ impl serialize::Encoder for Encoder {
name: &str,
idx: uint,
f: |&mut Encoder|) {
if idx != 0 { write!(self.wr, ",") }
if idx != 0 { write!(self.wr, ","); }
write!(self.wr, "{}:", escape_str(name));
f(self);
}
@@ -226,7 +226,7 @@ impl serialize::Encoder for Encoder {
}

fn emit_map_elt_key(&mut self, idx: uint, f: |&mut Encoder|) {
if idx != 0 { write!(self.wr, ",") }
if idx != 0 { write!(self.wr, ","); }
f(self)
}

@@ -252,7 +252,7 @@ pub fn PrettyEncoder(wr: @mut io::Writer) -> PrettyEncoder {
}

impl serialize::Encoder for PrettyEncoder {
fn emit_nil(&mut self) { write!(self.wr, "null") }
fn emit_nil(&mut self) { write!(self.wr, "null"); }

fn emit_uint(&mut self, v: uint) { self.emit_f64(v as f64); }
fn emit_u64(&mut self, v: u64) { self.emit_f64(v as f64); }
@@ -275,7 +275,7 @@ impl serialize::Encoder for PrettyEncoder {
}

fn emit_f64(&mut self, v: f64) {
write!(self.wr, "{}", f64::to_str_digits(v, 6u))
write!(self.wr, "{}", f64::to_str_digits(v, 6u));
}
fn emit_f32(&mut self, v: f32) { self.emit_f64(v as f64); }

@@ -841,7 +841,12 @@ impl<T : Iterator<char>> Parser<T> {

/// Decodes a json value from an `&mut io::Reader`
pub fn from_reader(rdr: &mut io::Reader) -> Result<Json, Error> {
let s = str::from_utf8(rdr.read_to_end());
let s = match rdr.read_to_end() {
Ok(b) => str::from_utf8_owned(b),
Err(e) => return Err(Error {
line: 0, col: 0, msg: @format!("{}", e)
})
};
let mut parser = Parser(~s.chars());
parser.parse()
}
2 changes: 1 addition & 1 deletion src/libextra/task_pool.rs
Original file line number Diff line number Diff line change
@@ -103,6 +103,6 @@ fn test_task_pool() {
};
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
8.times(|| {
pool.execute(proc(i) println!("Hello from thread {}!", *i));
pool.execute(proc(i) { println!("Hello from thread {}!", *i); });
})
}
2 changes: 1 addition & 1 deletion src/libextra/tempfile.rs
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ impl TempDir {
let mut r = rand::rng();
for _ in range(0u, 1000) {
let p = tmpdir.join(r.gen_ascii_str(16) + suffix);
match io::result(|| fs::mkdir(&p, io::UserRWX)) {
match fs::mkdir(&p, io::UserRWX) {
Err(*) => {}
Ok(()) => return Some(TempDir { path: Some(p) })
}
24 changes: 14 additions & 10 deletions src/libextra/terminfo/parser/compiled.rs
Original file line number Diff line number Diff line change
@@ -177,17 +177,17 @@ pub fn parse(file: &mut io::Reader,
}

// Check magic number
let magic = file.read_le_u16();
let magic = file.read_le_u16().unwrap();
if (magic != 0x011A) {
return Err(format!("invalid magic number: expected {:x} but found {:x}",
0x011A, magic as uint));
}

let names_bytes = file.read_le_i16() as int;
let bools_bytes = file.read_le_i16() as int;
let numbers_count = file.read_le_i16() as int;
let string_offsets_count = file.read_le_i16() as int;
let string_table_bytes = file.read_le_i16() as int;
let names_bytes = file.read_le_i16().unwrap() as int;
let bools_bytes = file.read_le_i16().unwrap() as int;
let numbers_count = file.read_le_i16().unwrap() as int;
let string_offsets_count = file.read_le_i16().unwrap() as int;
let string_table_bytes = file.read_le_i16().unwrap() as int;

assert!(names_bytes > 0);

@@ -215,7 +215,11 @@ pub fn parse(file: &mut io::Reader,
return Err(~"incompatible file: more string offsets than expected");
}

let names_str = str::from_utf8(file.read_bytes(names_bytes as uint - 1)); // don't read NUL
let b = match file.read_bytes(names_bytes as uint - 1) { // don't read NUL
Ok(bytes) => bytes,
Err((_, e)) => return Err(format!("{}", e)),
};
let names_str = str::from_utf8(b);
let term_names: ~[~str] = names_str.split('|').map(|s| s.to_owned()).collect();

file.read_byte(); // consume NUL
@@ -246,7 +250,7 @@ pub fn parse(file: &mut io::Reader,
let mut numbers_map = HashMap::new();
if numbers_count != 0 {
for i in range(0, numbers_count) {
let n = file.read_le_u16();
let n = file.read_le_u16().unwrap();
if n != 0xFFFF {
debug!("{}\\#{}", nnames[i], n);
numbers_map.insert(nnames[i].to_owned(), n);
@@ -261,12 +265,12 @@ pub fn parse(file: &mut io::Reader,
if string_offsets_count != 0 {
let mut string_offsets = vec::with_capacity(10);
for _ in range(0, string_offsets_count) {
string_offsets.push(file.read_le_u16());
string_offsets.push(file.read_le_u16().unwrap());
}

debug!("offsets: {:?}", string_offsets);

let string_table = file.read_bytes(string_table_bytes as uint);
let string_table = file.read_bytes(string_table_bytes as uint).unwrap();

if string_table.len() != string_table_bytes as uint {
error!("EOF reading string table after {} bytes, wanted {}", string_table.len(),
7 changes: 4 additions & 3 deletions src/libextra/test.rs
Original file line number Diff line number Diff line change
@@ -428,7 +428,7 @@ impl<T: Writer> ConsoleTestState<T> {
term.reset();
}
}
Right(ref mut stdout) => stdout.write(word.as_bytes())
Right(ref mut stdout) => { stdout.write(word.as_bytes()); }
}
}

@@ -550,9 +550,10 @@ impl<T: Writer> ConsoleTestState<T> {
self.write_plain(format!("\nusing metrics ratcher: {}\n", pth.display()));
match ratchet_pct {
None => (),
Some(pct) =>
Some(pct) => {
self.write_plain(format!("with noise-tolerance forced to: {}%\n",
pct))
pct));
}
}
let (diff, ok) = self.metrics.ratchet(pth, ratchet_pct);
self.write_metric_diff(&diff);
35 changes: 13 additions & 22 deletions src/libextra/time.rs
Original file line number Diff line number Diff line change
@@ -679,26 +679,22 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
let ch = range.ch;
let next = range.next;

let mut buf = [0];
let c = match rdr.read(buf) {
Some(*) => buf[0] as u8 as char,
None => break
};
match c {
'%' => {
let ch = match rdr.read(buf) {
Some(*) => buf[0] as u8 as char,
None => break
match rdr.read_byte() {
Ok(c) if c == '%' as u8 => {
let ch = match rdr.read_byte() {
Ok(b) => b as char,
Err(*) => break
};
match parse_type(s, pos, ch, &mut tm) {
Ok(next) => pos = next,
Err(e) => { result = Err(e); break; }
}
},
c => {
if c != ch { break }
Ok(c) => {
if c as char != ch { break }
pos = next;
}
Err(*) => break
}
}

@@ -930,18 +926,13 @@ pub fn strftime(format: &str, tm: &Tm) -> ~str {

let mut rdr = BufReader::new(format.as_bytes());
loop {
let mut b = [0];
let ch = match rdr.read(b) {
Some(*) => b[0],
None => break,
};
match ch as char {
'%' => {
rdr.read(b);
let s = parse_type(b[0] as char, tm);
match rdr.read_byte() {
Ok(c) if c == '%' as u8 => {
let s = parse_type(rdr.read_byte().unwrap() as char, tm);
buf.push_all(s.as_bytes());
}
ch => buf.push(ch as u8)
Ok(ch) => buf.push(ch as u8),
Err(*) => break,
}
}

Loading