From 05709c37d62b7ed7a46c71f9fb007b7f44f0dacb Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 3 Feb 2015 21:14:42 +0100 Subject: [PATCH 1/5] Update dependencies --- deps/regex | 2 +- deps/rust-crypto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/regex b/deps/regex index 6c0f8aa82..e12e57ed1 160000 --- a/deps/regex +++ b/deps/regex @@ -1 +1 @@ -Subproject commit 6c0f8aa82582441e9cb3813048ef9b098c026db0 +Subproject commit e12e57ed188dd4ed655bb7f3690e666317a7d198 diff --git a/deps/rust-crypto b/deps/rust-crypto index bdc3371e7..093f3918c 160000 --- a/deps/rust-crypto +++ b/deps/rust-crypto @@ -1 +1 @@ -Subproject commit bdc3371e7c70f8df17b9546bf1ae29dd4a3e3743 +Subproject commit 093f3918c8d77281050bba35a261fd8c56d2a866 From d89d9ca73b2a16b430952a8d606050a8e037b420 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 3 Feb 2015 22:19:13 +0100 Subject: [PATCH 2/5] Various functions in std::str return Result instead of Option now --- src/base64/base64.rs | 6 +++--- src/common/time.rs | 4 ++-- src/cut/ranges.rs | 35 +++++++++++++++++++++++------------ src/du/du.rs | 2 +- src/expand/expand.rs | 2 +- src/factor/factor.rs | 4 ++-- src/fmt/fmt.rs | 12 ++++++------ src/fold/fold.rs | 4 ++-- src/head/head.rs | 14 +++++++------- src/kill/kill.rs | 8 ++++---- src/mkdir/mkdir.rs | 2 +- src/mkfifo/mkfifo.rs | 6 +++--- src/nice/nice.rs | 6 +++--- src/nl/helper.rs | 8 ++++---- src/nproc/nproc.rs | 10 +++++----- src/seq/seq.rs | 4 ++-- src/shuf/shuf.rs | 14 +++++++------- src/split/split.rs | 16 ++++++++-------- src/stdbuf/libstdbuf.rs | 4 ++-- src/stdbuf/stdbuf.rs | 2 +- src/tail/tail.rs | 8 ++++---- src/test/test.rs | 4 ++-- src/truncate/truncate.rs | 6 +++--- src/unexpand/unexpand.rs | 2 +- src/uniq/uniq.rs | 2 +- src/uptime/uptime.rs | 4 ++-- 26 files changed, 100 insertions(+), 89 deletions(-) diff --git a/src/base64/base64.rs b/src/base64/base64.rs index 54ac93278..fbefc79fe 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -66,9 +66,9 @@ pub fn uumain(args: Vec) -> isize { let ignore_garbage = matches.opt_present("ignore-garbage"); let line_wrap = match matches.opt_str("wrap") { Some(s) => match s.parse() { - Some(s) => s, - None => { - crash!(1, "error: {}", "Argument to option 'wrap' improperly formatted."); + Ok(s) => s, + Err(e)=> { + crash!(1, "error: Argument to option 'wrap' improperly formatted: {}", e); } }, None => 76 diff --git a/src/common/time.rs b/src/common/time.rs index 7b8f9a505..6a30c6e05 100644 --- a/src/common/time.rs +++ b/src/common/time.rs @@ -29,7 +29,7 @@ pub fn from_str(string: &str) -> Result { } }; match numstr.parse::() { - Some(m) => Ok(m * times as f64), - None => Err(format!("invalid time interval '{}'", string)) + Ok(m) => Ok(m * times as f64), + Err(e) => Err(format!("invalid time interval '{}': {}", string, e)) } } diff --git a/src/cut/ranges.rs b/src/cut/ranges.rs index 1c834f89e..c97885761 100644 --- a/src/cut/ranges.rs +++ b/src/cut/ranges.rs @@ -16,30 +16,41 @@ pub struct Range { } impl std::str::FromStr for Range { - fn from_str(s: &str) -> Option { + type Err = &'static str; + + fn from_str(s: &str) -> Result { use std::usize::MAX; let mut parts = s.splitn(1, '-'); match (parts.next(), parts.next()) { (Some(nm), None) => { - nm.parse::().and_then(|nm| if nm > 0 { Some(nm) } else { None }) - .map(|nm| Range { low: nm, high: nm }) + if let Ok(nm) = nm.parse::() { + if nm > 0 { Ok(Range{ low: nm, high: nm}) } else { Err("invalid range") } + } else { + Err("invalid range") + } } (Some(n), Some(m)) if m.len() == 0 => { - n.parse::().and_then(|low| if low > 0 { Some(low) } else { None }) - .map(|low| Range { low: low, high: MAX }) + if let Ok(low) = n.parse::() { + if low > 0 { Ok(Range{ low: low, high: MAX}) } else { Err("invalid range") } + } else { + Err("invalid range") + } } (Some(n), Some(m)) if n.len() == 0 => { - m.parse::().and_then(|high| if high >= 1 { Some(high) } else { None }) - .map(|high| Range { low: 1, high: high }) + if let Ok(high) = m.parse::() { + if high > 0 { Ok(Range{ low: 1, high: high}) } else { Err("invalid range") } + } else { + Err("invalid range") + } } (Some(n), Some(m)) => { match (n.parse::(), m.parse::()) { - (Some(low), Some(high)) if low > 0 && low <= high => { - Some(Range { low: low, high: high }) + (Ok(low), Ok(high)) if low > 0 && low <= high => { + Ok(Range { low: low, high: high }) } - _ => None + _ => Err("invalid range") } } _ => unreachable!() @@ -55,8 +66,8 @@ impl Range { for item in list.split(',') { match std::str::FromStr::from_str(item) { - Some(range_item) => ranges.push(range_item), - None => return Err(format!("range '{}' was invalid", item)) + Ok(range_item) => ranges.push(range_item), + Err(e)=> return Err(format!("range '{}' was invalid: {}", item, e)) } } diff --git a/src/du/du.rs b/src/du/du.rs index bb37fcd39..76f549123 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -194,7 +194,7 @@ ers of 1000).", let summarize = matches.opt_present("summarize"); let max_depth_str = matches.opt_str("max-depth"); - let max_depth = max_depth_str.as_ref().and_then(|s| s.parse::()); + let max_depth = max_depth_str.as_ref().and_then(|s| s.parse::().ok()); match (max_depth_str, max_depth) { (Some(ref s), _) if summarize => { show_error!("summarizing conflicts with --max-depth={}", *s); diff --git a/src/expand/expand.rs b/src/expand/expand.rs index 70fc5c34d..e89b62b98 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -33,7 +33,7 @@ fn tabstops_parse(s: String) -> Vec { let nums = words.into_iter() .map(|sn| sn.parse::() .unwrap_or_else( - || crash!(1, "{}\n", "tab size contains invalid character(s)")) + |_| crash!(1, "{}\n", "tab size contains invalid character(s)")) ) .collect::>(); diff --git a/src/factor/factor.rs b/src/factor/factor.rs index 80e1960a3..112cd99f0 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -58,8 +58,8 @@ fn print_factors(num: u64) { fn print_factors_str(num_str: &str) { let num = match num_str.parse::() { - Some(x) => x, - None => { crash!(1, "{} not a number", num_str); } + Ok(x) => x, + Err(e)=> { crash!(1, "{} not a number: {}", num_str, e); } }; print_factors(num); } diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index 466012afa..ec0c10ba9 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -146,8 +146,8 @@ pub fn uumain(args: Vec) -> isize { Some(s) => { fmt_opts.width = match s.parse::() { - Some(t) => t, - None => { crash!(1, "Invalid WIDTH specification: `{}'", s); } + Ok(t) => t, + Err(e) => { crash!(1, "Invalid WIDTH specification: `{}': {}", s, e); } }; fmt_opts.goal = cmp::min(fmt_opts.width * 94 / 100, fmt_opts.width - 3); } @@ -158,8 +158,8 @@ pub fn uumain(args: Vec) -> isize { Some(s) => { fmt_opts.goal = match s.parse::() { - Some(t) => t, - None => { crash!(1, "Invalid GOAL specification: `{}'", s); } + Ok(t) => t, + Err(e) => { crash!(1, "Invalid GOAL specification: `{}': {}", s, e); } }; if !matches.opt_present("w") { fmt_opts.width = cmp::max(fmt_opts.goal * 100 / 94, fmt_opts.goal + 3); @@ -174,8 +174,8 @@ pub fn uumain(args: Vec) -> isize { Some(s) => { fmt_opts.tabwidth = match s.parse::() { - Some(t) => t, - None => { crash!(1, "Invalid TABWIDTH specification: `{}'", s); } + Ok(t) => t, + Err(e) => { crash!(1, "Invalid TABWIDTH specification: `{}': {}", s, e); } }; } None => () diff --git a/src/fold/fold.rs b/src/fold/fold.rs index e20e9dcf3..8ccd0b13c 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -64,8 +64,8 @@ pub fn uumain(args: Vec) -> isize { }; let width = match poss_width { Some(inp_width) => match inp_width.parse::() { - Some(width) => width, - None => crash!(1, "illegal width value (\"{}\")", inp_width) + Ok(width) => width, + Err(e) => crash!(1, "illegal width value (\"{}\"): {}", inp_width, e) }, None => 80 }; diff --git a/src/head/head.rs b/src/head/head.rs index 33b56202a..b7611130a 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -71,18 +71,18 @@ pub fn uumain(args: Vec) -> isize { return 1; } match n.parse::() { - Some(m) => { line_count = m } - None => { - show_error!("invalid line count '{}'", n); + Ok(m) => { line_count = m } + Err(e) => { + show_error!("invalid line count '{}': {}", n, e); return 1; } } } None => match given_options.opt_str("c") { Some(count) => match count.parse::() { - Some(m) => byte_count = m, - None => { - show_error!("invalid byte count '{}'", count); + Ok(m) => byte_count = m, + Err(e)=> { + show_error!("invalid byte count '{}': {}", count, e); return 1; } }, @@ -151,7 +151,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_utf8(¤t[1..len]).unwrap().parse::(); + let number: Option = from_utf8(¤t[1..len]).unwrap().parse::().ok(); return (options, Some(number.unwrap())); } } diff --git a/src/kill/kill.rs b/src/kill/kill.rs index d1b979544..83f0afea4 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -109,13 +109,13 @@ fn handle_obsolete(mut args: Vec) -> (Vec, Option) { if slice.char_at(0) == '-' && slice.len() > 1 && slice.char_at(1).is_digit(10) { let val = &slice[1..]; match val.parse() { - Some(num) => { + Ok(num) => { if signals::is_signal(num) { args.remove(i); return (args, Some(val.to_string())); } } - None => break /* getopts will error out for us */ + Err(_)=> break /* getopts will error out for us */ } } i += 1; @@ -194,7 +194,7 @@ fn kill(signalname: &str, pids: std::vec::Vec) -> isize { }; for pid in pids.iter() { match pid.as_slice().parse() { - Some(x) => { + Ok(x) => { let result = Process::kill(x, signal_value as isize); match result { Ok(_) => (), @@ -204,7 +204,7 @@ fn kill(signalname: &str, pids: std::vec::Vec) -> isize { } }; }, - None => crash!(EXIT_ERR, "failed to parse argument {}", pid) + Err(e) => crash!(EXIT_ERR, "failed to parse argument {}: {}", pid, e) }; } status diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index 67946aaf3..c0f16e79a 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -64,7 +64,7 @@ pub fn uumain(args: Vec) -> isize { let mode_match = matches.opts_str(&["mode".to_string()]); let mode: FilePermission = if mode_match.is_some() { let m = mode_match.unwrap(); - let res: Option = from_str_radix(m.as_slice(), 8); + let res: Option = from_str_radix(m.as_slice(), 8).ok(); if res.is_some() { unsafe { std::mem::transmute(res.unwrap()) } } else { diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index c990d4cee..e76b44b15 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -57,9 +57,9 @@ pub fn uumain(args: Vec) -> isize { let mode = match matches.opt_str("m") { Some(m) => match FromStrRadix::from_str_radix(m.as_slice(), 8) { - Some(m) => m, - None => { - show_error!("invalid mode"); + Ok(m) => m, + Err(e )=> { + show_error!("invalid mode: {}", e); return 1; } }, diff --git a/src/nice/nice.rs b/src/nice/nice.rs index 3ccdd82cb..8131454fa 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -80,9 +80,9 @@ pub fn uumain(args: Vec) -> isize { return 125; } match nstr.as_slice().parse() { - Some(num) => num, - None => { - show_error!("\"{}\" is not a valid number", nstr); + Ok(num) => num, + Err(e)=> { + show_error!("\"{}\" is not a valid number: {}", nstr, e); return 125; } } diff --git a/src/nl/helper.rs b/src/nl/helper.rs index 7b8cc66d9..c1d0fc584 100644 --- a/src/nl/helper.rs +++ b/src/nl/helper.rs @@ -72,7 +72,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("i") { None => {} Some(val) => { - let conv: Option = val.as_slice().parse(); + let conv: Option = val.as_slice().parse().ok(); match conv { None => { errs.push(String::from_str("Illegal value for -i")); @@ -84,7 +84,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("w") { None => {} Some(val) => { - let conv: Option = val.as_slice().parse(); + let conv: Option = val.as_slice().parse().ok(); match conv { None => { errs.push(String::from_str("Illegal value for -w")); @@ -96,7 +96,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("v") { None => {} Some(val) => { - let conv: Option = val.as_slice().parse(); + let conv: Option = val.as_slice().parse().ok(); match conv { None => { errs.push(String::from_str("Illegal value for -v")); @@ -108,7 +108,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("l") { None => {} Some(val) => { - let conv: Option = val.as_slice().parse(); + let conv: Option = val.as_slice().parse().ok(); match conv { None => { errs.push(String::from_str("Illegal value for -l")); diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index bf050c2fb..ac8cd3f11 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -54,9 +54,9 @@ pub fn uumain(args: Vec) -> isize { let mut ignore = match matches.opt_str("ignore") { Some(numstr) => match numstr.parse() { - Some(num) => num, - None => { - show_error!("\"{}\" is not a valid number", numstr); + Ok(num) => num, + Err(e) => { + show_error!("\"{}\" is not a valid number: {}", numstr, e); return 1; } }, @@ -66,8 +66,8 @@ pub fn uumain(args: Vec) -> isize { if !matches.opt_present("all") { ignore += match os::getenv("OMP_NUM_THREADS") { Some(threadstr) => match threadstr.parse() { - Some(num) => num, - None => 0 + Ok(num) => num, + Err(e)=> 0 }, None => 0 }; diff --git a/src/seq/seq.rs b/src/seq/seq.rs index 3fcc93cca..2a651199b 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -27,8 +27,8 @@ fn parse_float(mut s: &str) -> Result { s = &s[1..]; } match s.parse() { - Some(n) => Ok(n), - None => Err(format!("seq: invalid floating point argument: {}", s)) + Ok(n) => Ok(n), + Err(e) => Err(format!("seq: invalid floating point argument `{}`: {}", s, e)) } } diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index faf39e96f..3e86fac30 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -97,9 +97,9 @@ With no FILE, or when FILE is -, read standard input.", let zero = matches.opt_present("zero-terminated"); let count = match matches.opt_str("head-count") { Some(cnt) => match cnt.parse::() { - Some(val) => val, - None => { - show_error!("'{}' is not a valid count", cnt); + Ok(val) => val, + Err(e) => { + show_error!("'{}' is not a valid count: {}", cnt, e); return 1; } }, @@ -192,12 +192,12 @@ fn parse_range(input_range: String) -> Result, (String, is Err(("invalid range format".to_string(), 1)) } else { let begin = match split[0].parse::() { - Some(m) => m, - None => return Err((format!("{} is not a valid number", split[0]), 1)) + Ok(m) => m, + Err(e)=> return Err((format!("{} is not a valid number: {}", split[0], e), 1)) }; let end = match split[1].parse::() { - Some(m) => m, - None => return Err((format!("{} is not a valid number", split[1]), 1)) + Ok(m) => m, + Err(e)=> return Err((format!("{} is not a valid number: {}", split[1], e), 1)) }; Ok(range_inclusive(begin, end)) } diff --git a/src/split/split.rs b/src/split/split.rs index e9ca79659..443310921 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -72,8 +72,8 @@ pub fn uumain(args: Vec) -> isize { settings.suffix_length = match matches.opt_str("a") { Some(n) => match n.as_slice().parse() { - Some(m) => m, - None => crash!(1, "cannot parse num") + Ok(m) => m, + Err(e) => crash!(1, "cannot parse num: {}", e) }, None => 2 }; @@ -136,8 +136,8 @@ struct LineSplitter { impl LineSplitter { fn new(settings: &Settings) -> Box { let n = match settings.strategy_param.as_slice().parse() { - Some(a) => a, - _ => crash!(1, "invalid number of lines") + Ok(a) => a, + Err(e) => crash!(1, "invalid number of lines: {}", e) }; Box::new(LineSplitter { saved_lines_to_write: n, @@ -178,13 +178,13 @@ impl ByteSplitter { }; let n = if suffix.is_alphabetic() { match strategy_param.as_slice().iter().map(|c| *c).collect::().as_slice().parse::() { - Some(a) => a, - _ => crash!(1, "invalid number of bytes") + Ok(a) => a, + Err(e) => crash!(1, "invalid number of bytes: {}", e) } } else { match settings.strategy_param.as_slice().parse::() { - Some(a) => a, - _ => crash!(1, "invalid number of bytes") + Ok(a) => a, + Err(e) => crash!(1, "invalid number of bytes: {}", e) } }; Box::new(ByteSplitter { diff --git a/src/stdbuf/libstdbuf.rs b/src/stdbuf/libstdbuf.rs index 4c14fab0f..755f6fbe9 100644 --- a/src/stdbuf/libstdbuf.rs +++ b/src/stdbuf/libstdbuf.rs @@ -25,8 +25,8 @@ fn set_buffer(stream: *mut FILE, value: &str) { "L" => (_IOLBF, 0 as size_t), input => { let buff_size: usize = match input.parse() { - Some(num) => num, - None => crash!(1, "incorrect size of buffer!") + Ok(num) => num, + Err(e) => crash!(1, "incorrect size of buffer!: {}", e) }; (_IOFBF, buff_size as size_t) } diff --git a/src/stdbuf/stdbuf.rs b/src/stdbuf/stdbuf.rs index 51b411d85..5ffc703bb 100644 --- a/src/stdbuf/stdbuf.rs +++ b/src/stdbuf/stdbuf.rs @@ -97,7 +97,7 @@ fn parse_size(size: &str) -> Option { if recovered.as_slice() != size { return None; } - let buf_size: u64 = match num.parse() { + let buf_size: u64 = match num.parse().ok() { Some(m) => m, None => return None, }; diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 3f994ee1e..350f6567f 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -73,7 +73,7 @@ pub fn uumain(args: Vec) -> isize { if follow { match given_options.opt_str("s") { Some(n) => { - let parsed: Option = n.parse(); + let parsed: Option = n.parse().ok(); match parsed { Some(m) => { sleep_msec = m * 1000 } None => {} @@ -196,8 +196,8 @@ fn parse_size(mut size_slice: &str) -> Option { } else { let value = size_slice.parse(); match value { - Some(v) => Some(multiplier * v), - None => None + Ok(v) => Some(multiplier * v), + _ => None } } } @@ -224,7 +224,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_utf8(¤t[1..len]).unwrap().parse(); + let number: Option = from_utf8(¤t[1..len]).unwrap().parse().ok(); return (options, Some(number.unwrap())); } } diff --git a/src/test/test.rs b/src/test/test.rs index 91caba31f..a3434e77a 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -127,7 +127,7 @@ fn integers(a: &[u8], b: &[u8], cond: IntegerCondition) -> bool { _ => return false, }; let (a, b): (i64, i64) = match (a.parse(), b.parse()) { - (Some(a), Some(b)) => (a, b), + (Ok(a), Ok(b)) => (a, b), _ => return false, }; match cond { @@ -142,7 +142,7 @@ fn integers(a: &[u8], b: &[u8], cond: IntegerCondition) -> bool { fn isatty(fd: &[u8]) -> bool { use libc::{isatty}; - from_utf8(fd).ok().and_then(|s| s.parse()) + from_utf8(fd).ok().and_then(|s| s.parse().ok()) .map(|i| unsafe { isatty(i) == 1 }).unwrap_or(false) } diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index b02666f68..85f35e69c 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -186,9 +186,9 @@ fn parse_size(size: &str) -> (u64, TruncateMode) { slice }.to_string(); let mut number: u64 = match bytes.as_slice().parse() { - Some(num) => num, - None => { - crash!(1, "'{}' is not a valid number.", size) + Ok(num) => num, + Err(e) => { + crash!(1, "'{}' is not a valid number: {}", size, e) } }; if size.char_at(size.len() - 1).is_alphabetic() { diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index bcf743f00..40e4ffdd4 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -30,7 +30,7 @@ fn tabstops_parse(s: String) -> Vec { let nums = words.into_iter() .map(|sn| sn.parse() .unwrap_or_else( - || crash!(1, "{}\n", "tab size contains invalid character(s)")) + |_| crash!(1, "{}\n", "tab size contains invalid character(s)")) ) .collect::>(); diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index f0e31fce2..d1fd13484 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -113,7 +113,7 @@ impl Uniq { fn opt_parsed(opt_name: &str, matches: &getopts::Matches) -> Option { matches.opt_str(opt_name).map(|arg_str| { - let opt_val: Option = arg_str.parse(); + let opt_val: Option = arg_str.parse().ok(); opt_val.unwrap_or_else(|| crash!(1, "Invalid argument for {}: {}", opt_name, arg_str)) }) diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index ca0cb645e..d872292fe 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -181,8 +181,8 @@ fn get_uptime(boot_time: Option) -> i64 { match uptime_text.as_slice().words().next() { Some(s) => match s.replace(".", "").as_slice().parse() { - Some(n) => n, - None => -1 + Ok(n) => n, + Err(_) => -1 }, None => -1 } From db8506532e4d6960ee3a663e0ffc9c2516021016 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 3 Feb 2015 22:34:45 +0100 Subject: [PATCH 3/5] derive(Show) -> derive(Debug) --- src/cut/ranges.rs | 2 +- src/fmt/parasplit.rs | 6 +++--- src/od/od.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cut/ranges.rs b/src/cut/ranges.rs index c97885761..10b1bcf80 100644 --- a/src/cut/ranges.rs +++ b/src/cut/ranges.rs @@ -9,7 +9,7 @@ use std; -#[derive(PartialEq,Eq,PartialOrd,Ord,Show)] +#[derive(PartialEq,Eq,PartialOrd,Ord,Debug)] pub struct Range { pub low: usize, pub high: usize, diff --git a/src/fmt/parasplit.rs b/src/fmt/parasplit.rs index 901ec2f8f..4efc623f5 100644 --- a/src/fmt/parasplit.rs +++ b/src/fmt/parasplit.rs @@ -31,7 +31,7 @@ fn char_width(c: char) -> usize { // lines with PSKIP, lacking PREFIX, or which are entirely blank are // NoFormatLines; otherwise, they are FormatLines -#[derive(Show)] +#[derive(Debug)] pub enum Line { FormatLine(FileLine), NoFormatLine(String, bool) @@ -57,7 +57,7 @@ impl Line { // each line's prefix has to be considered to know whether to merge it with // the next line or not -#[derive(Show)] +#[derive(Debug)] struct FileLine { line : String, indent_end : usize, // the end of the indent, always the start of the text @@ -198,7 +198,7 @@ impl<'a> Iterator for FileLines<'a> { // plus info about the paragraph's indentation // (but we only retain the String from the FileLine; the other info // is only there to help us in deciding how to merge lines into Paragraphs -#[derive(Show)] +#[derive(Debug)] pub struct Paragraph { lines : Vec, // the lines of the file pub init_str : String, // string representing the init, that is, the first line's indent diff --git a/src/od/od.rs b/src/od/od.rs index 779bd60e5..93f11dd56 100644 --- a/src/od/od.rs +++ b/src/od/od.rs @@ -16,7 +16,7 @@ extern crate collections; use collections::string::String; use std::old_io::File; -#[derive(Show)] +#[derive(Debug)] enum Radix { Decimal, Hexadecimal, Octal, Binary } pub fn uumain(args: Vec) -> isize { From 3eb5a814a3000043066f5874eedf6691aaaeeb22 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 3 Feb 2015 23:49:03 +0100 Subject: [PATCH 4/5] Fix most unstable feature warnings --- mkmain.rs | 5 ++--- mkuutils.rs | 2 +- src/base64/base64.rs | 2 +- src/basename/basename.rs | 2 +- src/cat/cat.rs | 2 +- src/chmod/chmod.rs | 2 +- src/chroot/chroot.rs | 2 +- src/cksum/cksum.rs | 2 +- src/comm/comm.rs | 2 +- src/cp/cp.rs | 2 +- src/cut/cut.rs | 2 +- src/dirname/dirname.rs | 2 +- src/du/du.rs | 2 +- src/echo/echo.rs | 2 +- src/env/env.rs | 2 +- src/expand/expand.rs | 2 +- src/factor/factor.rs | 2 +- src/false/false.rs | 1 - src/fold/fold.rs | 2 +- src/groups/groups.rs | 2 +- src/hashsum/hashsum.rs | 2 +- src/head/head.rs | 2 +- src/hostid/hostid.rs | 2 +- src/hostname/hostname.rs | 2 +- src/id/id.rs | 2 +- src/kill/kill.rs | 2 +- src/link/link.rs | 2 +- src/logname/logname.rs | 2 +- src/mkdir/mkdir.rs | 2 +- src/mkfifo/mkfifo.rs | 2 +- src/mv/mv.rs | 2 +- src/nice/nice.rs | 2 +- src/nl/nl.rs | 2 +- src/nohup/nohup.rs | 2 +- src/nproc/nproc.rs | 2 +- src/od/od.rs | 2 +- src/paste/paste.rs | 2 +- src/printenv/printenv.rs | 2 +- src/pwd/pwd.rs | 2 +- src/readlink/readlink.rs | 2 +- src/realpath/realpath.rs | 2 +- src/relpath/relpath.rs | 2 +- src/rm/rm.rs | 2 +- src/rmdir/rmdir.rs | 2 +- src/seq/seq.rs | 2 +- src/shuf/shuf.rs | 2 +- src/sleep/sleep.rs | 2 +- src/sort/sort.rs | 2 +- src/split/split.rs | 2 +- src/stdbuf/libstdbuf.rs | 2 +- src/stdbuf/stdbuf.rs | 2 +- src/sum/sum.rs | 2 +- src/sync/sync.rs | 2 +- src/tac/tac.rs | 2 +- src/tail/tail.rs | 2 +- src/tee/tee.rs | 2 +- src/test/test.rs | 2 +- src/timeout/timeout.rs | 2 +- src/touch/touch.rs | 2 +- src/tr/tr.rs | 2 +- src/true/true.rs | 1 - src/truncate/truncate.rs | 2 +- src/tsort/tsort.rs | 2 +- src/tty/tty.rs | 2 +- src/uname/uname.rs | 2 +- src/unexpand/unexpand.rs | 2 +- src/uniq/uniq.rs | 2 +- src/unlink/unlink.rs | 2 +- src/uptime/uptime.rs | 2 +- src/users/users.rs | 2 +- src/uutils/uutils.rs | 2 +- src/wc/wc.rs | 2 +- src/whoami/whoami.rs | 2 +- src/yes/yes.rs | 2 +- 74 files changed, 73 insertions(+), 76 deletions(-) diff --git a/mkmain.rs b/mkmain.rs index 262ca42ac..9203f4950 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -1,11 +1,10 @@ -#![allow(unstable)] - +#![feature(core, io, os, path)] use std::old_io::{File, Truncate, ReadWrite}; use std::os; use std::path::Path; static TEMPLATE: &'static str = "\ -#![allow(unstable)] +#![feature(os)] extern crate \"@UTIL_CRATE@\" as uu@UTIL_CRATE@; use std::os; diff --git a/mkuutils.rs b/mkuutils.rs index 56869bb89..abeb53f60 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -1,4 +1,4 @@ -#![allow(unstable)] +#![feature(core, io, os, path)] use std::old_io::{File, Truncate, Write}; use std::os; diff --git a/src/base64/base64.rs b/src/base64/base64.rs index fbefc79fe..3af288b10 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -1,5 +1,5 @@ #![crate_name = "base64"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/basename/basename.rs b/src/basename/basename.rs index 21b37ea5b..e2d77c955 100644 --- a/src/basename/basename.rs +++ b/src/basename/basename.rs @@ -1,5 +1,5 @@ #![crate_name = "basename"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 999c19092..0f24ef944 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -1,5 +1,5 @@ #![crate_name = "cat"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] #![feature(box_syntax, unsafe_destructor)] diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index 735f4e77d..d8cf2734c 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -1,5 +1,5 @@ #![crate_name = "chmod"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index 5f5cb88d9..346f82153 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -1,5 +1,5 @@ #![crate_name = "chroot"] -#![allow(unstable)] +#![feature(collections, core, io, libc, os, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index 7d9a7a875..bfb1c56d1 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -1,5 +1,5 @@ #![crate_name = "cksum"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/comm/comm.rs b/src/comm/comm.rs index 154548333..33d4e9269 100644 --- a/src/comm/comm.rs +++ b/src/comm/comm.rs @@ -1,5 +1,5 @@ #![crate_name = "comm"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/cp/cp.rs b/src/cp/cp.rs index 7c9188158..680d7c488 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -1,5 +1,5 @@ #![crate_name = "cp"] -#![allow(unstable)] +#![feature(collections, core, io, os, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/cut/cut.rs b/src/cut/cut.rs index aabf2acdc..0921ed95b 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -1,5 +1,5 @@ #![crate_name = "cut"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/dirname/dirname.rs b/src/dirname/dirname.rs index 26f898a2e..a08adc523 100644 --- a/src/dirname/dirname.rs +++ b/src/dirname/dirname.rs @@ -1,5 +1,5 @@ #![crate_name = "dirname"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/du/du.rs b/src/du/du.rs index 76f549123..343cb6580 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -1,5 +1,5 @@ #![crate_name = "du"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private, std_misc, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 25975f828..a53c984e7 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -1,5 +1,5 @@ #![crate_name = "echo"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/env/env.rs b/src/env/env.rs index cb9559a50..845f740d3 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -1,5 +1,5 @@ #![crate_name = "env"] -#![allow(unstable)] +#![feature(core, io, os)] /* * This file is part of the uutils coreutils package. diff --git a/src/expand/expand.rs b/src/expand/expand.rs index e89b62b98..056991a8f 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -1,5 +1,5 @@ #![crate_name = "expand"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/factor/factor.rs b/src/factor/factor.rs index 112cd99f0..846c73290 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -1,5 +1,5 @@ #![crate_name = "factor"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/false/false.rs b/src/false/false.rs index 48f937079..471c523a7 100644 --- a/src/false/false.rs +++ b/src/false/false.rs @@ -1,5 +1,4 @@ #![crate_name = "false"] -#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/fold/fold.rs b/src/fold/fold.rs index 8ccd0b13c..7a91be41d 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -1,5 +1,5 @@ #![crate_name = "fold"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/groups/groups.rs b/src/groups/groups.rs index f22773f60..3526b1e69 100644 --- a/src/groups/groups.rs +++ b/src/groups/groups.rs @@ -1,5 +1,5 @@ #![crate_name = "groups"] -#![allow(unstable)] +#![feature(collections, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index 83e847e5b..ee3c4923f 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -1,5 +1,5 @@ #![crate_name = "hashsum"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/head/head.rs b/src/head/head.rs index b7611130a..789bd760a 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -1,5 +1,5 @@ #![crate_name = "head"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/hostid/hostid.rs b/src/hostid/hostid.rs index 7fc737330..5800b6823 100644 --- a/src/hostid/hostid.rs +++ b/src/hostid/hostid.rs @@ -1,5 +1,5 @@ #![crate_name = "hostid"] -#![allow(unstable)] +#![feature(collections, core, libc, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index e7a2bbf3d..ed216b2a3 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -1,5 +1,5 @@ #![crate_name = "hostname"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/id/id.rs b/src/id/id.rs index 1de0a46c0..f9cc8eafb 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -1,5 +1,5 @@ #![crate_name = "id"] -#![allow(unstable)] +#![feature(collections, core, libc, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/kill/kill.rs b/src/kill/kill.rs index 83f0afea4..febce87a6 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -1,5 +1,5 @@ #![crate_name = "kill"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/link/link.rs b/src/link/link.rs index a58e47921..5bc2bb103 100644 --- a/src/link/link.rs +++ b/src/link/link.rs @@ -1,5 +1,5 @@ #![crate_name = "link"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/logname/logname.rs b/src/logname/logname.rs index b09859334..e10647c26 100644 --- a/src/logname/logname.rs +++ b/src/logname/logname.rs @@ -1,5 +1,5 @@ #![crate_name = "logname"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index c0f16e79a..7e5c69391 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -1,5 +1,5 @@ #![crate_name = "mkdir"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index e76b44b15..79694f950 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -1,5 +1,5 @@ #![crate_name = "mkfifo"] -#![allow(unstable)] +#![feature(collections, core, libc, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/mv/mv.rs b/src/mv/mv.rs index 8fad6d672..7c8695f54 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -1,5 +1,5 @@ #![crate_name = "mv"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/nice/nice.rs b/src/nice/nice.rs index 8131454fa..b8f4c0931 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -1,5 +1,5 @@ #![crate_name = "nice"] -#![allow(unstable)] +#![feature(collections, core, libc, os, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 6fc6aea61..cd8407c5b 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -1,5 +1,5 @@ #![crate_name = "nl"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index ceb5f1819..7a1d0ff73 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -1,5 +1,5 @@ #![crate_name = "nohup"] -#![allow(unstable)] +#![feature(collections, core, io, libc, os, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index ac8cd3f11..aec64328d 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -1,5 +1,5 @@ #![crate_name = "nproc"] -#![allow(unstable)] +#![feature(collections, os, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/od/od.rs b/src/od/od.rs index 93f11dd56..0a841c181 100644 --- a/src/od/od.rs +++ b/src/od/od.rs @@ -1,5 +1,5 @@ #![crate_name = "od"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/paste/paste.rs b/src/paste/paste.rs index a28538e75..f075aad4d 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -1,5 +1,5 @@ #![crate_name = "paste"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/printenv/printenv.rs b/src/printenv/printenv.rs index 99a57fec8..03688ede7 100644 --- a/src/printenv/printenv.rs +++ b/src/printenv/printenv.rs @@ -1,5 +1,5 @@ #![crate_name = "printenv"] -#![allow(unstable)] +#![feature(collections, core, io, libc, os, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/pwd/pwd.rs b/src/pwd/pwd.rs index 0e2bffff3..bc40b6433 100644 --- a/src/pwd/pwd.rs +++ b/src/pwd/pwd.rs @@ -1,5 +1,5 @@ #![crate_name = "pwd"] -#![allow(unstable)] +#![feature(collections, core, io, libc, os, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/readlink/readlink.rs b/src/readlink/readlink.rs index 596c81930..9134bd648 100644 --- a/src/readlink/readlink.rs +++ b/src/readlink/readlink.rs @@ -1,5 +1,5 @@ #![crate_name = "readlink"] -#![allow(unstable)] +#![feature(collections, core, io, os, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 8715e132d..3bbef8e05 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -1,5 +1,5 @@ #![crate_name= "realpath"] -#![allow(unstable)] +#![feature(collections, core, io, libc, os, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index f16b38c9f..2aa2251ca 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -1,5 +1,5 @@ #![crate_name = "relpath"] -#![allow(unstable)] +#![feature(collections, core, libc, os, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/rm/rm.rs b/src/rm/rm.rs index c5f7a86c2..29dacc081 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -1,5 +1,5 @@ #![crate_name = "rm"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index 852e8be27..c2bcdc75a 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -1,5 +1,5 @@ #![crate_name = "rmdir"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/seq/seq.rs b/src/seq/seq.rs index 2a651199b..7db5ec766 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -1,5 +1,5 @@ #![crate_name = "seq"] -#![allow(unstable)] +#![feature(collections, core, libc, rustc_private)] // TODO: Make -w flag work with decimals // TODO: Support -f flag diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 3e86fac30..1eb5c71a4 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -1,5 +1,5 @@ #![crate_name = "shuf"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rand, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/sleep/sleep.rs b/src/sleep/sleep.rs index 51964a6a1..e0622068c 100644 --- a/src/sleep/sleep.rs +++ b/src/sleep/sleep.rs @@ -1,5 +1,5 @@ #![crate_name = "sleep"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 46f495eb3..14091e9b9 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -1,5 +1,5 @@ #![crate_name = "sort"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/split/split.rs b/src/split/split.rs index 443310921..a4f0f9403 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -1,5 +1,5 @@ #![crate_name = "split"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/stdbuf/libstdbuf.rs b/src/stdbuf/libstdbuf.rs index 755f6fbe9..d530b09ce 100644 --- a/src/stdbuf/libstdbuf.rs +++ b/src/stdbuf/libstdbuf.rs @@ -1,6 +1,6 @@ #![crate_name = "libstdbuf"] #![crate_type = "staticlib"] -#![allow(unstable)] +#![feature(core, libc, os)] extern crate libc; use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf}; diff --git a/src/stdbuf/stdbuf.rs b/src/stdbuf/stdbuf.rs index 5ffc703bb..08262ce2e 100644 --- a/src/stdbuf/stdbuf.rs +++ b/src/stdbuf/stdbuf.rs @@ -1,5 +1,5 @@ #![crate_name = "stdbuf"] -#![allow(unstable)] +#![feature(core, io, libc, os, path, rustc_private, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/sum/sum.rs b/src/sum/sum.rs index 0c4539927..263fe216f 100644 --- a/src/sum/sum.rs +++ b/src/sum/sum.rs @@ -1,5 +1,5 @@ #![crate_name = "sum"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/sync/sync.rs b/src/sync/sync.rs index 21efeb3ba..e4c3b08ca 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -1,5 +1,5 @@ #![crate_name = "sync"] -#![allow(unstable)] +#![feature(collections, libc, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/tac/tac.rs b/src/tac/tac.rs index 61d58b352..9d10f6ce0 100644 --- a/src/tac/tac.rs +++ b/src/tac/tac.rs @@ -1,5 +1,5 @@ #![crate_name = "tac"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 350f6567f..8a2682c24 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -1,5 +1,5 @@ #![crate_name = "tail"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/tee/tee.rs b/src/tee/tee.rs index 28cb1a8cc..204f27536 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -1,5 +1,5 @@ #![crate_name = "tee"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/test/test.rs b/src/test/test.rs index a3434e77a..57b33dd23 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -1,5 +1,5 @@ #![crate_name = "test"] -#![allow(unstable)] +#![feature(core, libc, os, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index a2314cc2c..c96b4d44a 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -1,5 +1,5 @@ #![crate_name = "timeout"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/touch/touch.rs b/src/touch/touch.rs index d99faee7b..ea2aa8cfa 100644 --- a/src/touch/touch.rs +++ b/src/touch/touch.rs @@ -1,5 +1,5 @@ #![crate_name = "touch"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/tr/tr.rs b/src/tr/tr.rs index bd538690c..bf3b2ff92 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -1,5 +1,5 @@ #![crate_name = "tr"] -#![allow(unstable)] +#![feature(collections, core, io, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/true/true.rs b/src/true/true.rs index 7818801fc..9909466d6 100644 --- a/src/true/true.rs +++ b/src/true/true.rs @@ -1,5 +1,4 @@ #![crate_name= "true"] -#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 85f35e69c..9cfff2461 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -1,5 +1,5 @@ #![crate_name = "truncate"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index 1f5a54009..90753896b 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -1,5 +1,5 @@ #![crate_name = "tsort"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/tty/tty.rs b/src/tty/tty.rs index 6bee5b45c..861e99baf 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -1,5 +1,5 @@ #![crate_name = "tty"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/uname/uname.rs b/src/uname/uname.rs index 0c5b97a9d..1e755ac3e 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -1,5 +1,5 @@ #![crate_name = "uname"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index 40e4ffdd4..90512f1fc 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -1,5 +1,5 @@ #![crate_name = "unexpand"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index d1fd13484..1125943d2 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -1,5 +1,5 @@ #![crate_name = "uniq"] -#![allow(unstable)] +#![feature(collections, core, io, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index e01dc08c2..5be5c2810 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -1,5 +1,5 @@ #![crate_name = "unlink"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index d872292fe..0bb9ee247 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -1,5 +1,5 @@ #![crate_name = "uptime"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/users/users.rs b/src/users/users.rs index 3287a6877..5a6989116 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -1,5 +1,5 @@ #![crate_name = "users"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index 4b9e5a470..0e2dd4560 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -1,5 +1,5 @@ #![crate_name = "uutils"] -#![allow(unstable)] +#![feature(core, os, path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/wc/wc.rs b/src/wc/wc.rs index a88fcc52a..55c53f7ce 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -1,5 +1,5 @@ #![crate_name = "wc"] -#![allow(unstable)] +#![feature(collections, core, io, libc, path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index 927547697..eef3f5394 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -1,5 +1,5 @@ #![crate_name = "whoami"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/yes/yes.rs b/src/yes/yes.rs index ae41cdc7d..44d9606c6 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -1,5 +1,5 @@ #![crate_name = "yes"] -#![allow(unstable)] +#![feature(collections, core, io, libc, rustc_private)] /* * This file is part of the uutils coreutils package. From 25232c36974d9890afcd433ca34e49fd9becaee5 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 3 Feb 2015 23:59:48 +0100 Subject: [PATCH 5/5] Fix warnings --- src/nproc/nproc.rs | 2 +- src/sort/sort.rs | 2 +- src/tail/tail.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index aec64328d..94807d114 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -67,7 +67,7 @@ pub fn uumain(args: Vec) -> isize { ignore += match os::getenv("OMP_NUM_THREADS") { Some(threadstr) => match threadstr.parse() { Ok(num) => num, - Err(e)=> 0 + Err(_)=> 0 }, None => 0 }; diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 14091e9b9..318342cb5 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -146,7 +146,7 @@ fn frac_compare(a: &String, b: &String) -> Ordering { } #[inline(always)] -fn print_sorted>(mut iter: T) where S: std::fmt::Display { +fn print_sorted>(iter: T) where S: std::fmt::Display { for line in iter { print!("{}", line); } diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 8a2682c24..ccaac02fe 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -242,7 +242,7 @@ macro_rules! tail_impl ( // count lines/chars. When reaching the end of file, output the data in the // ringbuf. let mut ringbuf: RingBuf<$kind> = RingBuf::new(); - let mut data = $reader.$kindfn().skip( + let data = $reader.$kindfn().skip( if $beginning { let temp = $count; $count = ::std::usize::MAX;