From a636040907caf9b5022dea583936c3a4c7953d79 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Apr 2016 22:31:42 +0200 Subject: [PATCH 1/2] Use unused results by calling write!() with .ok() --- libimagutil/src/trace.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libimagutil/src/trace.rs b/libimagutil/src/trace.rs index 6e1a5a76..f075f037 100644 --- a/libimagutil/src/trace.rs +++ b/libimagutil/src/trace.rs @@ -21,7 +21,7 @@ use std::io::stderr; /// ``` pub fn trace_error(e: &Error) { print_trace_maxdepth(count_error_causes(e), e, ::std::u64::MAX); - write!(stderr(), "\n"); + write!(stderr(), "\n").ok(); } /// Print an Error type and its cause recursively, but only `max` levels @@ -29,9 +29,10 @@ pub fn trace_error(e: &Error) { /// Output is the same as for `trace_error()`, though there are only `max` levels printed. pub fn trace_error_maxdepth(e: &Error, max: u64) { let n = count_error_causes(e); - write!(stderr(), "{}/{} Levels of errors will be printed\n", (if max > n { n } else { max }), n); + write!(stderr(), + "{}/{} Levels of errors will be printed\n", (if max > n { n } else { max }), n).ok(); print_trace_maxdepth(n, e, max); - write!(stderr(), ""); + write!(stderr(), "").ok(); } /// Print an Error type and its cause recursively with the debug!() macro @@ -48,13 +49,13 @@ pub fn trace_error_dbg(e: &Error) { fn print_trace_maxdepth(idx: u64, e: &Error, max: u64) -> Option<&Error> { if e.cause().is_some() && idx > 0 { match print_trace_maxdepth(idx - 1, e.cause().unwrap(), max) { - None => write!(stderr(), "\n"), - Some(_) => write!(stderr(), " -- caused:\n"), + None => write!(stderr(), "\n").ok(), + Some(_) => write!(stderr(), " -- caused:\n").ok(), }; } else { - write!(stderr(), "\n"); + write!(stderr(), "\n").ok(); } - write!(stderr(), "Error {:>4} : {}", idx, e.description()); + write!(stderr(), "Error {:>4} : {}", idx, e.description()).ok(); e.cause() } From 7bcff482869db21c00d1d48dae65d130b9b01833 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Apr 2016 22:31:51 +0200 Subject: [PATCH 2/2] Enable lints --- libimagutil/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libimagutil/src/lib.rs b/libimagutil/src/lib.rs index 4140f429..e9894c0a 100644 --- a/libimagutil/src/lib.rs +++ b/libimagutil/src/lib.rs @@ -1,3 +1,18 @@ +#![deny( + non_camel_case_types, + non_snake_case, + path_statements, + trivial_numeric_casts, + unstable_features, + unused_allocation, + unused_import_braces, + unused_imports, + unused_must_use, + unused_mut, + unused_qualifications, + while_true, +)] + #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate regex;