Merge pull request #433 from ebfe/fix-build-master

fail! -> panic!
This commit is contained in:
Heather 2014-10-31 08:19:31 +04:00
commit 9c578ad9ca
27 changed files with 64 additions and 64 deletions

View file

@ -35,7 +35,7 @@ fn main() {
let mut out = File::open_mode(&Path::new(outfile), Truncate, ReadWrite);
match out.write(main.as_bytes()) {
Err(e) => fail!("{}", e),
Err(e) => panic!("{}", e),
_ => (),
}
}

View file

@ -52,7 +52,7 @@ fn main() {
let main = input.read_to_string().unwrap().replace("@CRATES@", crates.as_slice()).replace("@UTIL_MAP@", util_map.as_slice());
match out.write(main.as_bytes()) {
Err(e) => fail!("{}", e),
Err(e) => panic!("{}", e),
_ => (),
}
}

View file

@ -48,7 +48,7 @@ pub fn uumain(args: Vec<String>) -> int {
Ok(m) => m,
Err(e) => {
error!("error: {}", e);
fail!()
panic!()
}
};
@ -69,7 +69,7 @@ pub fn uumain(args: Vec<String>) -> int {
Some(s) => s,
None => {
error!("error: {:s}", "Argument to option 'wrap' improperly formatted.");
fail!()
panic!()
}
},
None => 76
@ -98,7 +98,7 @@ pub fn uumain(args: Vec<String>) -> int {
fn decode(input: &mut Reader, ignore_garbage: bool) {
let mut to_decode = match input.read_to_string() {
Ok(m) => m,
Err(f) => fail!(f)
Err(f) => panic!(f)
};
let slice =
@ -134,7 +134,7 @@ fn decode(input: &mut Reader, ignore_garbage: bool) {
}
Err(s) => {
error!("error: {}", s);
fail!()
panic!()
}
}
}

View file

@ -38,7 +38,7 @@ pub fn uumain(args: Vec<String>) -> int {
];
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
Err(f) => fail!("Invalid options\n{}", f)
Err(f) => panic!("Invalid options\n{}", f)
};
if matches.opt_present("help") {
println!("cat 1.0.0");
@ -328,7 +328,7 @@ impl<'a, W: Writer> UnsafeWriter<'a, W> {
#[inline(never)]
fn fail() -> ! {
fail!("assertion failed");
panic!("assertion failed");
}
impl<'a, W: Writer> Writer for UnsafeWriter<'a, W> {

View file

@ -82,7 +82,7 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
if matches.opt_present("help") {

View file

@ -105,7 +105,7 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
if matches.opt_present("version") {

View file

@ -94,7 +94,7 @@ macro_rules! pipe_print(
if f.kind == ::std::io::BrokenPipe {
false
} else {
fail!("{}", f)
panic!("{}", f)
}
}
}
@ -110,7 +110,7 @@ macro_rules! pipe_println(
if f.kind == ::std::io::BrokenPipe {
false
} else {
fail!("{}", f)
panic!("{}", f)
}
}
}
@ -126,7 +126,7 @@ macro_rules! pipe_write(
if f.kind == ::std::io::BrokenPipe {
false
} else {
fail!("{}", f)
panic!("{}", f)
}
}
}
@ -142,7 +142,7 @@ macro_rules! pipe_writeln(
if f.kind == ::std::io::BrokenPipe {
false
} else {
fail!("{}", f)
panic!("{}", f)
}
}
}
@ -154,7 +154,7 @@ macro_rules! safe_write(
($fd:expr, $($args:expr),+) => (
match write!($fd, $($args),+) {
Ok(_) => {}
Err(f) => fail!(f.to_string())
Err(f) => panic!(f.to_string())
}
)
)
@ -164,7 +164,7 @@ macro_rules! safe_writeln(
($fd:expr, $($args:expr),+) => (
match writeln!($fd, $($args),+) {
Ok(_) => {}
Err(f) => fail!(f.to_string())
Err(f) => panic!(f.to_string())
}
)
)

View file

@ -40,7 +40,7 @@ pub fn uumain(args: Vec<String>) -> int {
Ok(m) => m,
Err(e) => {
error!("error: {}", e);
fail!()
panic!()
},
};
@ -79,7 +79,7 @@ fn help(progname: &str, usage: &str) {
fn copy(matches: getopts::Matches) {
let sources : Vec<Path> = if matches.free.len() < 1 {
error!("error: Missing SOURCE argument. Try --help.");
fail!()
panic!()
} else {
// All but the last argument:
matches.free.slice(0, matches.free.len() - 1).iter()
@ -87,7 +87,7 @@ fn copy(matches: getopts::Matches) {
};
let dest = if matches.free.len() < 2 {
error!("error: Missing DEST argument. Try --help.");
fail!()
panic!()
} else {
// Only the last argument:
Path::new(matches.free[matches.free.len() - 1].as_slice())
@ -103,7 +103,7 @@ fn copy(matches: getopts::Matches) {
false
} else {
error!("error: {:s}", e.to_string());
fail!()
panic!()
}
};
@ -111,7 +111,7 @@ fn copy(matches: getopts::Matches) {
error!("error: \"{:s}\" and \"{:s}\" are the same file",
source.display().to_string(),
dest.display().to_string());
fail!();
panic!();
}
let io_result = fs::copy(source, &dest);
@ -119,12 +119,12 @@ fn copy(matches: getopts::Matches) {
if io_result.is_err() {
let err = io_result.unwrap_err();
error!("error: {:s}", err.to_string());
fail!();
panic!();
}
} else {
if fs::stat(&dest).unwrap().kind != io::TypeDirectory {
error!("error: TARGET must be a directory");
fail!();
panic!();
}
for source in sources.iter() {
@ -144,7 +144,7 @@ fn copy(matches: getopts::Matches) {
if io_result.is_err() {
let err = io_result.unwrap_err();
error!("error: {:s}", err.to_string());
fail!()
panic!()
}
}
}

View file

@ -68,7 +68,7 @@ impl<R: Reader> BufReader<R> {
match self.maybe_fill_buf() {
Ok(0) | Err(IoError { kind: std::io::EndOfFile, .. })
if self.start == self.end => return bytes_consumed,
Err(err) => fail!("read error: {}", err.desc),
Err(err) => panic!("read error: {}", err.desc),
_ => ()
}
@ -94,7 +94,7 @@ impl<R: Reader> Bytes::Select for BufReader<R> {
fn select<'a>(&'a mut self, bytes: uint) -> Bytes::Selected<'a> {
match self.maybe_fill_buf() {
Err(IoError { kind: std::io::EndOfFile, .. }) => (),
Err(err) => fail!("read error: {}", err.desc),
Err(err) => panic!("read error: {}", err.desc),
_ => ()
}

View file

@ -142,7 +142,7 @@ fn cut_characters<R: Reader>(reader: R,
let line = match buf_in.read_line() {
Ok(line) => line,
Err(std::io::IoError { kind: std::io::EndOfFile, .. }) => break,
_ => fail!(),
_ => panic!(),
};
let mut char_pos = 0;
@ -248,7 +248,7 @@ fn cut_fields_delimiter<R: Reader>(reader: R,
let line = match buf_in.read_until(b'\n') {
Ok(line) => line,
Err(std::io::IoError { kind: std::io::EndOfFile, .. }) => break,
_ => fail!(),
_ => panic!(),
};
let mut fields_pos = 1;
@ -330,7 +330,7 @@ fn cut_fields<R: Reader>(reader: R,
let line = match buf_in.read_until(b'\n') {
Ok(line) => line,
Err(std::io::IoError { kind: std::io::EndOfFile, .. }) => break,
_ => fail!(),
_ => panic!(),
};
let mut fields_pos = 1;

View file

@ -25,7 +25,7 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
Err(f) => fail!("Invalid options\n{}", f)
Err(f) => panic!("Invalid options\n{}", f)
};
if matches.opt_present("help") {

View file

@ -55,7 +55,7 @@ fn convert_str(string: &[u8], index: uint, base: uint) -> (char, uint) {
let (max_digits, is_legal_digit) = match base {
8u => (3, isodigit),
16u => (2, isxdigit),
_ => fail!(),
_ => panic!(),
};
let mut bytes = vec!();

View file

@ -41,7 +41,7 @@ impl Line {
fn get_formatline(self) -> FileLine {
match self {
FormatLine(fl) => fl,
NoFormatLine(..) => fail!("Found NoFormatLine when expecting FormatLine")
NoFormatLine(..) => panic!("Found NoFormatLine when expecting FormatLine")
}
}
@ -49,7 +49,7 @@ impl Line {
fn get_noformatline(self) -> (String, bool) {
match self {
NoFormatLine(s, b) => (s, b),
FormatLine(..) => fail!("Found FormatLine when expecting NoFormatLine")
FormatLine(..) => panic!("Found FormatLine when expecting NoFormatLine")
}
}
}

View file

@ -139,7 +139,7 @@ fn xgethostname() -> String {
};
if err != 0 {
fail!("Cannot determine hostname");
panic!("Cannot determine hostname");
}
let last_char = name.iter().position(|byte| *byte == 0).unwrap_or(namelen);

View file

@ -29,7 +29,7 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
if matches.opt_present("version") {

View file

@ -32,7 +32,7 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
if matches.opt_present("version") {

View file

@ -196,7 +196,7 @@ fn tail<T: Reader>(reader: &mut BufferedReader<T>, line_count: uint, byte_count:
for io_line in reader.lines() {
match io_line {
Ok(line) => print!("{}", line),
Err(err) => fail!(err)
Err(err) => panic!(err)
}
}
}
@ -225,7 +225,7 @@ fn tail_lines<T: Reader>(reader: &mut BufferedReader<T>, mut line_count: uint, b
}
ringbuf.push(line);
}
Err(err) => fail!(err)
Err(err) => panic!(err)
}
}
for line in ringbuf.iter() {
@ -253,7 +253,7 @@ fn tail_bytes<T: Reader>(reader: &mut BufferedReader<T>, mut byte_count: uint, b
}
ringbuf.push(byte);
}
Err(err) => fail!(err)
Err(err) => panic!(err)
}
}
for byte in ringbuf.iter() {

View file

@ -41,7 +41,7 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
Err(e) => fail!("Invalid options\n{}", e)
Err(e) => panic!("Invalid options\n{}", e)
};
if matches.opt_present("version") {
@ -65,7 +65,7 @@ pub fn uumain(args: Vec<String>) -> int {
if matches.opt_present("date") && matches.opts_present(["reference".to_string(), "t".to_string()]) ||
matches.opt_present("reference") && matches.opts_present(["date".to_string(), "t".to_string()]) ||
matches.opt_present("t") && matches.opts_present(["date".to_string(), "reference".to_string()]) {
fail!("Invalid options: cannot specify reference time from more than one source");
panic!("Invalid options: cannot specify reference time from more than one source");
}
let (mut atime, mut mtime) =
@ -97,7 +97,7 @@ pub fn uumain(args: Vec<String>) -> int {
match File::create(&path) {
Ok(fd) => fd,
Err(e) => fail!("Unable to create file: {}\n{}", filename, e.desc)
Err(e) => panic!("Unable to create file: {}\n{}", filename, e.desc)
};
// Minor optimization: if no reference time was specified, we're done.
@ -128,7 +128,7 @@ pub fn uumain(args: Vec<String>) -> int {
match std::io::fs::change_file_times(&path, atime, mtime) {
Ok(t) => t,
Err(e) => fail!("Unable to modify times\n{}", e.desc)
Err(e) => panic!("Unable to modify times\n{}", e.desc)
}
}
@ -139,12 +139,12 @@ fn stat(path: &Path, follow: bool) -> std::io::FileStat {
if follow {
match std::io::fs::stat(path) {
Ok(stat) => stat,
Err(e) => fail!("Unable to open file\n{}", e.desc)
Err(e) => panic!("Unable to open file\n{}", e.desc)
}
} else {
match std::io::fs::lstat(path) {
Ok(stat) => stat,
Err(e) => fail!("Unable to open file\n{}", e.desc)
Err(e) => panic!("Unable to open file\n{}", e.desc)
}
}
}
@ -156,7 +156,7 @@ fn parse_date(str: &str) -> u64 {
// http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=lib/parse-datetime.y
match time::strptime(str, "%c") {
Ok(tm) => (tm.to_timespec().sec * 1000) as u64,
Err(e) => fail!("Unable to parse date\n{}", e)
Err(e) => panic!("Unable to parse date\n{}", e)
}
}
@ -168,12 +168,12 @@ fn parse_timestamp(str: &str) -> u64 {
10 => "%y%m%d%H%M",
11 => "%m%d%H%M.%S",
8 => "%m%d%H%M",
_ => fail!("Unknown timestamp format")
_ => panic!("Unknown timestamp format")
};
match time::strptime(str, format) {
Ok(tm) => (tm.to_timespec().sec * 1000) as u64,
Err(e) => fail!("Unable to parse timestamp\n{}", e)
Err(e) => panic!("Unable to parse timestamp\n{}", e)
}
}

View file

@ -103,7 +103,7 @@ fn delete(set: Vec<char>, complement: bool) {
match c {
Ok(c) if is_allowed(c) => out.write_char(c).unwrap(),
Ok(_) => (),
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
}
}
@ -130,7 +130,7 @@ fn tr(set1: &[char], set2: &[char]) {
out.write_char(trc).unwrap();
}
Err(err) => {
fail!("{}", err);
panic!("{}", err);
}
}
}

View file

@ -61,7 +61,7 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
Err(f) => fail!("{}", f),
Err(f) => panic!("{}", f),
};
if matches.opt_present("help") {

View file

@ -12,7 +12,7 @@ fn test_output_multi_files_print_all_chars() {
.arg("-n").output() {
Ok(p) => p,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
let out = str::from_utf8(po.output.as_slice()).unwrap();

View file

@ -32,7 +32,7 @@ fn test_mkdir_dup_dir() {
let exit_success = prog.unwrap().success();
if !exit_success {
cleanup(TEST_DIR2);
fail!();
panic!();
}
let prog2 = Command::new(EXE).arg(TEST_DIR2).status();
let exit_success2 = prog2.unwrap().success();

View file

@ -14,7 +14,7 @@ static EXE: &'static str = "./mv";
macro_rules! assert_empty_stderr(
($cond:expr) => (
if $cond.stderr.len() > 0 {
fail!(format!("stderr: {}", $cond.stderr))
panic!(format!("stderr: {}", $cond.stderr))
}
);
)

View file

@ -34,13 +34,13 @@ fn numeric_helper(test_num: int) {
cmd.arg("-n");
let po = match cmd.clone().arg(format!("{}{}{}", "numeric", test_num, ".txt")).output() {
Ok(p) => p,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
let answer = match File::open(&Path::new(format!("{}{}{}", "numeric", test_num, ".ans")))
.read_to_end() {
Ok(answer) => answer,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
assert_eq!(String::from_utf8(po.output), String::from_utf8(answer));
}
}

View file

@ -9,7 +9,7 @@ fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
let po = match process.wait_with_output() {
Ok(p) => p,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
po.output
}

View file

@ -8,7 +8,7 @@ static TFILE2: &'static str = "truncate_test_2";
fn make_file(name: &str) -> io::File {
match io::File::create(&Path::new(name)) {
Ok(f) => f,
Err(_) => fail!()
Err(_) => panic!()
}
}
@ -16,11 +16,11 @@ fn make_file(name: &str) -> io::File {
fn test_increase_file_size() {
let mut file = make_file(TFILE1);
if !Command::new(PROGNAME).args(["-s", "+5K", TFILE1]).status().unwrap().success() {
fail!();
panic!();
}
file.seek(0, io::SeekEnd).unwrap();
if file.tell().unwrap() != 5 * 1024 {
fail!();
panic!();
}
io::fs::unlink(&Path::new(TFILE1)).unwrap();
}
@ -30,12 +30,12 @@ fn test_decrease_file_size() {
let mut file = make_file(TFILE2);
file.write(b"1234567890").unwrap();
if !Command::new(PROGNAME).args(["--size=-4", TFILE2]).status().unwrap().success() {
fail!();
panic!();
}
file.seek(0, io::SeekEnd).unwrap();
if file.tell().unwrap() != 6 {
println!("{}", file.tell());
fail!();
panic!();
}
io::fs::unlink(&Path::new(TFILE2)).unwrap();
}

View file

@ -9,7 +9,7 @@ fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
let po = match process.wait_with_output() {
Ok(p) => p,
Err(err) => fail!("{}", err),
Err(err) => panic!("{}", err),
};
po.output
}