From ff281e4334c0d33506aaf78372c7e94d0620a3e6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:03:44 +0100 Subject: [PATCH 01/60] Turn warnings into errors for unused {imports,variables,must_use,mut} --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 52ac03d7..d0a4d92d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,8 @@ +#![deny(unused_imports)] +#![deny(unused_variables)] +#![deny(unused_must_use)] +#![deny(unused_mut)] + #[macro_use] extern crate clap; #[macro_use] extern crate log; #[macro_use] extern crate serde; From c380e0f64fe03a3e68d243519add5972bd2552d3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:05:59 +0100 Subject: [PATCH 02/60] Use return value: fail if content could not be read --- src/ui/external/editor.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui/external/editor.rs b/src/ui/external/editor.rs index fb43895c..ea2980aa 100644 --- a/src/ui/external/editor.rs +++ b/src/ui/external/editor.rs @@ -101,7 +101,11 @@ pub fn edit_content(rt: &Runtime, old_content: String) -> (String, bool) { let mut contents = String::new(); File::open(filepath).map(|mut file| { - file.read_to_string(&mut contents); + file.read_to_string(&mut contents).map_err(|e| { + error!("Error reading content: {}", e); + debug!("Error reading content: {:?}", e); + exit(1); + }).is_ok(); (contents, true) }).unwrap_or((old_content, false)) } From 67dd4d3be100ca6f17c9db19e441496a6aec05e6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:07:29 +0100 Subject: [PATCH 03/60] Use return value: fail if content could not be written --- src/ui/external/editor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui/external/editor.rs b/src/ui/external/editor.rs index ea2980aa..41a83ccf 100644 --- a/src/ui/external/editor.rs +++ b/src/ui/external/editor.rs @@ -73,7 +73,12 @@ pub fn edit_content(rt: &Runtime, old_content: String) -> (String, bool) { } }; - file.write(old_content.as_ref()); + file.write(old_content.as_ref()) + .map_err(|e| { + error!("Error writing content: {}", e); + debug!("Error writing content: {:?}", e); + exit(1); + }).is_ok(); } debug!("Ready with putting old content into the file"); From 0d4c390b9f82eb21b7a0c67aeec2ca25cd6e49c5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:10:09 +0100 Subject: [PATCH 04/60] Remove unused import --- src/ui/external/editor.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui/external/editor.rs b/src/ui/external/editor.rs index 41a83ccf..3091be89 100644 --- a/src/ui/external/editor.rs +++ b/src/ui/external/editor.rs @@ -7,7 +7,6 @@ use runtime::Runtime; pub fn let_user_provide_content(rt: &Runtime) -> Option { use std::io::Read; use std::fs::File; - use std::process::Command; let filepath = "/tmp/imag-tmp.md"; let file_created = File::create(filepath) From 6ee54dfb78baef8dcbe8aa7f155e8304749ac9ef Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:09:46 +0100 Subject: [PATCH 05/60] Use return value: fail if content could not be read --- src/ui/external/editor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui/external/editor.rs b/src/ui/external/editor.rs index 3091be89..1f00bedb 100644 --- a/src/ui/external/editor.rs +++ b/src/ui/external/editor.rs @@ -7,6 +7,7 @@ use runtime::Runtime; pub fn let_user_provide_content(rt: &Runtime) -> Option { use std::io::Read; use std::fs::File; + use std::process::exit; let filepath = "/tmp/imag-tmp.md"; let file_created = File::create(filepath) @@ -44,7 +45,13 @@ pub fn let_user_provide_content(rt: &Runtime) -> Option { let mut contents = String::new(); File::open(filepath).map(|mut file| { - file.read_to_string(&mut contents); + file.read_to_string(&mut contents) + .map_err(|e| { + error!("Error reading content: {}", e); + debug!("Error reading content: {:?}", e); + exit(1); + }) + .is_ok(); Some(contents) }).unwrap_or(None) } From 3284e78d736386332abbba9ec57ec50b2a921e22 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:11:59 +0100 Subject: [PATCH 06/60] Use return value: Check whether read succeeded --- src/storage/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index e47a7a73..98cedf5d 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -217,7 +217,8 @@ impl Store { FSFile::open(&path).map(|mut file| { file.read_to_string(&mut string) - .map_err(|e| error!("Failed reading file: '{}'", path)); + .map_err(|e| error!("Failed reading file: '{}'", path)) + .is_ok(); }); parser.read(string).map(|(header, data)| { From b0a8fd642c8aaad7bb418bc921523c678b0cf1b2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:14:10 +0100 Subject: [PATCH 07/60] Use unused variable: writeerr --- src/storage/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 98cedf5d..9b16d770 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -179,6 +179,7 @@ impl Store { fsfile.write_all(&text.unwrap().clone().into_bytes()[..]) }).map_err(|writeerr| { debug!("Could not create file at '{}'", path); + debug!(" error: {:?}", writeerr); }).and(Ok(true)).unwrap() // TODO: Is this unwrap() save? From 6c6851cc2b72ada6ca3719891d126d1d3c9749f5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:14:15 +0100 Subject: [PATCH 08/60] Use unused variable: e --- src/storage/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 9b16d770..446ebec7 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -218,7 +218,10 @@ impl Store { FSFile::open(&path).map(|mut file| { file.read_to_string(&mut string) - .map_err(|e| error!("Failed reading file: '{}'", path)) + .map_err(|e| { + error!("Failed reading file: '{}'", path); + debug!(" error {}", e); + }) .is_ok(); }); From 8053599f94ade63ba0c2a7b0b879259f7e2109e9 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:15:22 +0100 Subject: [PATCH 09/60] Mark variables as not used --- src/storage/json/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index c49855f4..e0523daa 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -138,7 +138,7 @@ impl Serialize for FileHeaderData { hm.serialize(ser) }, - &FileHeaderData::Key{name: ref n, value: ref v} => unreachable!(), + &FileHeaderData::Key{name: _, value: _} => unreachable!(), } } From 5e1b720cb7d48c5dca2a1cf10b8020acd9737a8e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:16:03 +0100 Subject: [PATCH 10/60] Remove unneeded Keyword "mut" --- src/storage/parser.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/storage/parser.rs b/src/storage/parser.rs index 70cd3acb..f6ebb281 100644 --- a/src/storage/parser.rs +++ b/src/storage/parser.rs @@ -125,9 +125,8 @@ impl Parser { if divided.is_err() { debug!("Error reading into internal datastructure"); - let mut p = ParserError::new("Dividing text failed", - s, 0, - "Dividing text with divide_text() failed"); + let p = ParserError::new("Dividing text failed", s, 0, + "Dividing text with divide_text() failed"); return Err(p.with_cause(Box::new(divided.err().unwrap()))); } From cc2d0ad0d4a7fdedfc1bb8f2eb33dc6d91d67923 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:16:38 +0100 Subject: [PATCH 11/60] Remove unused import --- src/storage/file/id_type.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/file/id_type.rs b/src/storage/file/id_type.rs index 06c6a1c7..fe7a2661 100644 --- a/src/storage/file/id_type.rs +++ b/src/storage/file/id_type.rs @@ -1,4 +1,4 @@ -use std::fmt::{Debug, Display, Formatter}; +use std::fmt::{Display, Formatter}; use std::fmt; use std::convert::{From, Into}; use std::str::FromStr; From e233073305f85516412111f0b458541240c820c5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:17:05 +0100 Subject: [PATCH 12/60] Remove unneeded Keyword "mut" --- src/storage/file/id.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/storage/file/id.rs b/src/storage/file/id.rs index 0096fad3..f89eb551 100644 --- a/src/storage/file/id.rs +++ b/src/storage/file/id.rs @@ -68,9 +68,9 @@ impl FileID { } debug!("Matches: {}", capts.len()); - let modname = capts.at(1).unwrap(); - let hashname = capts.at(2).unwrap(); - let mut hash = capts.at(3).unwrap(); + let modname = capts.at(1).unwrap(); + let hashname = capts.at(2).unwrap(); + let hash = capts.at(3).unwrap(); debug!("Destructure FilePath to ID:"); debug!(" FilePath: {:?}", s); From 2ddca14ef5478c95fe92c9b60ca67adaeeb890ce Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:17:54 +0100 Subject: [PATCH 13/60] Use return value: try!() around write!() --- src/storage/file/hash.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/file/hash.rs b/src/storage/file/hash.rs index 9b55ed60..ff42bee1 100644 --- a/src/storage/file/hash.rs +++ b/src/storage/file/hash.rs @@ -60,7 +60,7 @@ impl Into for FileHash { impl Display for FileHash { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "{}", self.hash); + try!(write!(fmt, "{}", self.hash)); Ok(()) } From f8d90af6d02ad4fb4cd15902576526090a601547 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:18:13 +0100 Subject: [PATCH 14/60] Remove unused import --- src/ui/external/editor.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui/external/editor.rs b/src/ui/external/editor.rs index 1f00bedb..e93b8f32 100644 --- a/src/ui/external/editor.rs +++ b/src/ui/external/editor.rs @@ -65,7 +65,6 @@ pub fn edit_content(rt: &Runtime, old_content: String) -> (String, bool) { use std::io::Read; use std::io::Write; use std::fs::File; - use std::process::Command; use std::process::exit; let filepath = "/tmp/imag-tmp.md"; From b772b34837380cb8ca2ead41860d13e059569165 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:20:55 +0100 Subject: [PATCH 15/60] Use return value from serialize() and print debug output on failure --- src/storage/json/parser.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index e0523daa..11893f5e 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -70,7 +70,9 @@ impl FileHeaderParser for JsonHeaderParser { let mut s = Vec::::new(); { let mut ser = Serializer::pretty(&mut s); - data.serialize(&mut ser); + data.serialize(&mut ser).map_err(|e| { + debug!("Serializer error: {:?}", e); + }).ok(); } String::from_utf8(s).or( From 22be304a3ad0cf9bf4743a9c08b16de5dcba9bcd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:21:49 +0100 Subject: [PATCH 16/60] Use return value: ImagLogger::init() -> fail if init failed --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index d0a4d92d..1642dcdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,13 +37,17 @@ pub use module::bm::BM; pub use module::notes::Notes; fn main() { + use std::process::exit; use ansi_term::Colour::Yellow; let yaml = load_yaml!("../etc/cli.yml"); let app = App::from_yaml(yaml); let config = CliConfig::new(app); - ImagLogger::init(&config); + ImagLogger::init(&config).map_err(|e| { + error!("Could not initialize logger"); + exit(1); + }).ok(); let configuration = Configuration::new(&config); From 7361f8835363e86ed81330d4a1cdb67b070bf3b5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:23:04 +0100 Subject: [PATCH 17/60] Remove unused import --- src/module/bm/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index ba08f7d8..8682e805 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -1,7 +1,6 @@ use std::fmt::{Debug, Formatter}; use std::fmt; use std::ops::Deref; -use std::process::exit; use clap::ArgMatches; From c8175df5c8a82888de4e767f8a4bfd659c9bee4e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:23:08 +0100 Subject: [PATCH 18/60] Remove unused import --- src/module/bm/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 8682e805..09450acc 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -13,7 +13,6 @@ use storage::json::parser::JsonHeaderParser; use module::helpers::cli::create_tag_filter; use module::helpers::cli::create_hash_filter; use module::helpers::cli::create_text_header_field_grep_filter; -use module::helpers::cli::create_content_grep_filter; use module::helpers::cli::CliFileFilter; mod header; From ec74bc436274239904b5425ceab9437379100913 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:23:13 +0100 Subject: [PATCH 19/60] Remove unused import --- src/module/bm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 09450acc..52a4233a 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -155,7 +155,7 @@ impl<'a> BM<'a> { * Subcommand: open */ fn command_open(&self, matches: &ArgMatches) -> bool { - use ansi_term::Colour::{Green, Yellow, Red}; + use ansi_term::Colour::{Green, Red}; use open; let parser = Parser::new(JsonHeaderParser::new(None)); From 67fe96ef9e9d1cdb02428ac0a1ab41666913eb62 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:23:18 +0100 Subject: [PATCH 20/60] Remove unused import --- src/module/bm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 52a4233a..ed86b22c 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -203,7 +203,7 @@ impl<'a> BM<'a> { * Subcommand: remove */ fn command_remove(&self, matches: &ArgMatches) -> bool { - use ansi_term::Colour::{Green, Yellow, Red}; + use ansi_term::Colour::{Green, Red}; let parser = Parser::new(JsonHeaderParser::new(None)); From 4e01a1c1eb62445725a5735a8085b345e3980282 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:23:23 +0100 Subject: [PATCH 21/60] Remove unused import --- src/module/bm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index ed86b22c..90735644 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -293,7 +293,7 @@ impl<'a> BM<'a> { impl<'a> Module<'a> for BM<'a> { fn exec(&self, matches: &ArgMatches) -> bool { - use ansi_term::Colour::{Green, Yellow, Red}; + use ansi_term::Colour::{Yellow, Red}; match matches.subcommand_name() { Some("add") => { From 9918260f324f09334c1570f1da3836ee7f6191a8 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:25:40 +0100 Subject: [PATCH 22/60] Remove unused variable --- src/module/bm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 90735644..801fc4dd 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -280,7 +280,7 @@ impl<'a> BM<'a> { use self::header::rebuild_header_with_tags; let parser = Parser::new(JsonHeaderParser::new(None)); - alter_tags_in_files(self, matches, &parser, |old_tags, cli_tags| { + alter_tags_in_files(self, matches, &parser, |_, cli_tags| { cli_tags.clone() }, rebuild_header_with_tags) } From 0c2b406cfc7b5250faa26b0a9c9a7573731f26b0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:25:51 +0100 Subject: [PATCH 23/60] Remove unused variable --- src/module/notes/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 004c47e8..d22ff87e 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -435,7 +435,7 @@ impl<'a> Notes<'a> { use self::header::rebuild_header_with_tags; let parser = Parser::new(JsonHeaderParser::new(None)); - alter_tags_in_files(self, matches, &parser, |old_tags, cli_tags| { + alter_tags_in_files(self, matches, &parser, |_, cli_tags| { cli_tags.clone() }, rebuild_header_with_tags) } From 192c9fd7a568b63de5e0454c5eab7387460d46cf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:26:02 +0100 Subject: [PATCH 24/60] Remove unused variable --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index d22ff87e..b8d20670 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -276,7 +276,6 @@ impl<'a> Notes<'a> { debug!("list internal links = {}", list_intern); debug!("list external links = {}", list_extern); - let printer = TablePrinter::new(self.rt.is_verbose(), self.rt.is_debugging()); let titles = row!["#", "Text", "Link", "Direction"]; let mut table = Table::new(); table.set_titles(titles); From 25f6711904bf974e536fe13171c1ca0d65b64b73 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:26:07 +0100 Subject: [PATCH 25/60] Remove unused variable --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index b8d20670..4e4bfb5d 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -311,7 +311,6 @@ impl<'a> Notes<'a> { }) .flatten() .filter(|link| { - let title = &link.title; let url = &link.url; let is_extern = is_url(&url); debug!("Is external URL {} -> {}", url, is_extern); From 9f9721f2278243eb592aee8435f1b7aa000b306f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:26:15 +0100 Subject: [PATCH 26/60] Remove unused variable --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 4e4bfb5d..79389787 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -1,7 +1,6 @@ use std::fmt::{Debug, Formatter}; use std::fmt::Result as FMTResult; use std::rc::Rc; -use std::cell::RefCell; use std::ops::Deref; use clap::ArgMatches; From 15a64d6237a33e8483128f0630e9ddd85210fe96 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:26:20 +0100 Subject: [PATCH 27/60] Remove unused variable --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 79389787..65c1e88b 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -4,7 +4,6 @@ use std::rc::Rc; use std::ops::Deref; use clap::ArgMatches; -use regex::Regex; mod header; From feb146870ec0872cd500a901f09b24a3e4bc278e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:26:23 +0100 Subject: [PATCH 28/60] Remove unused variable --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 65c1e88b..0026bb88 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -9,7 +9,6 @@ mod header; use module::Module; use runtime::Runtime; -use storage::file::File; use storage::parser::Parser; use storage::json::parser::JsonHeaderParser; use module::helpers::cli::create_tag_filter; From ee0d3e90d28f5aaf463cdefd14b3c6ae163971a2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:26:27 +0100 Subject: [PATCH 29/60] Remove unused variable --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 0026bb88..18989aac 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -30,7 +30,6 @@ impl<'a> Notes<'a> { } fn command_add(&self, matches: &ArgMatches) -> bool { - use std::process::exit; use ansi_term::Colour::Yellow; use self::header::build_header; use ui::external::editor::let_user_provide_content; From 0b250224918abeae6f185132be515caeeb662aaf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:26:30 +0100 Subject: [PATCH 30/60] Remove unused variable --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 18989aac..53992036 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -216,7 +216,6 @@ impl<'a> Notes<'a> { } fn command_list(&self, matches: &ArgMatches) -> bool { - use ansi_term::Colour::{Red, Green}; use ui::file::{FilePrinter, TablePrinter}; use self::header::get_name_from_header; use self::header::get_tags_from_header; From 7fbd98016d287acf16db68ee8a276c858ccf76e0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:26:34 +0100 Subject: [PATCH 31/60] Remove unused variable --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 53992036..917d7d0a 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -219,7 +219,6 @@ impl<'a> Notes<'a> { use ui::file::{FilePrinter, TablePrinter}; use self::header::get_name_from_header; use self::header::get_tags_from_header; - use std::process::exit; use module::helpers::cli::CliFileFilter; let parser = Parser::new(JsonHeaderParser::new(None)); From 92d84482c6597091c46bbb884b7a4b53c6903fec Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:28:07 +0100 Subject: [PATCH 32/60] Remove unused variable --- src/module/helpers/header/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/helpers/header/mod.rs b/src/module/helpers/header/mod.rs index 367f845c..b5bf8793 100644 --- a/src/module/helpers/header/mod.rs +++ b/src/module/helpers/header/mod.rs @@ -47,7 +47,7 @@ pub mod data { let mut keys : Vec = ks.clone(); keys.iter().find(|k| { match k.deref() { - &FHD::Key{name: ref n, value: ref v} => n == name, + &FHD::Key{name: ref n, value: _} => n == name, _ => false } }).and_then(|urlkey| { From a7603b1594d9ac8ab22af1c44491074c90da6285 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:28:18 +0100 Subject: [PATCH 33/60] Remove unneeded Keyword "mut" --- src/module/helpers/header/tags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/helpers/header/tags.rs b/src/module/helpers/header/tags.rs index 7e754b5b..a6d55dd0 100644 --- a/src/module/helpers/header/tags.rs +++ b/src/module/helpers/header/tags.rs @@ -61,7 +61,7 @@ pub mod data { * Does no spec verification. */ pub fn get_tags_from_header(header: &FHD) -> Vec { - let mut tags : Vec = vec![]; + let tags : Vec = vec![]; fn match_array(a: &Box) -> Vec { let mut tags : Vec = vec![]; From 4036e31b3570f0e98f5e2ab6f92f7a0712eb9f62 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:29:40 +0100 Subject: [PATCH 34/60] Remove unused imports --- src/module/helpers/cli.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/module/helpers/cli.rs b/src/module/helpers/cli.rs index a06cc14b..bd644d91 100644 --- a/src/module/helpers/cli.rs +++ b/src/module/helpers/cli.rs @@ -8,9 +8,6 @@ use regex::Regex; use storage::file::File; use storage::file::hash::FileHash; -use storage::json::parser::JsonHeaderParser; -use storage::parser::FileHeaderParser; -use storage::parser::Parser; pub trait CliFileFilter { From cfd16730c026b4b64a16013487a20cf1e9680d91 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:29:47 +0100 Subject: [PATCH 35/60] Remove unused variables --- src/module/helpers/content.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/module/helpers/content.rs b/src/module/helpers/content.rs index 08711368..befe850e 100644 --- a/src/module/helpers/content.rs +++ b/src/module/helpers/content.rs @@ -32,8 +32,8 @@ pub mod markdown { impl Render for LinkExtractRenderer { fn link(&mut self, - output: &mut Buffer, - content: &Buffer, + _: &mut Buffer, + _: &Buffer, link: &Buffer, title: &Buffer) -> bool { From d14cb47bf9de2952598e377f749b407d540f32de Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:30:52 +0100 Subject: [PATCH 36/60] Remove unneeded Keyword "mut" and unneeded variable --- src/module/helpers/header/mod.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/module/helpers/header/mod.rs b/src/module/helpers/header/mod.rs index b5bf8793..a496b9e6 100644 --- a/src/module/helpers/header/mod.rs +++ b/src/module/helpers/header/mod.rs @@ -44,12 +44,13 @@ pub mod data { pub fn get_named_text_from_header(name: &'static str, header: &FHD) -> Option { match header { &FHD::Map{keys: ref ks} => { - let mut keys : Vec = ks.clone(); - keys.iter().find(|k| { - match k.deref() { - &FHD::Key{name: ref n, value: _} => n == name, - _ => false - } + ks.clone() + .iter() + .find(|k| { + match k.deref() { + &FHD::Key{name: ref n, value: _} => n == name, + _ => false + } }).and_then(|urlkey| { match urlkey.deref().clone() { FHD::Key{name: ref n, value: ref v} => { From 97008e5f9b00803f207944a7f8d9194e32e3b3b1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:31:20 +0100 Subject: [PATCH 37/60] Use unused variable, print debug output --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index 1642dcdc..edd6ad24 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,6 +46,7 @@ fn main() { ImagLogger::init(&config).map_err(|e| { error!("Could not initialize logger"); + debug!("Could not initialize logger: {:?}", e); exit(1); }).ok(); From 7f99ac8aac43a8069b8b36c62a11fdfc5a217823 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:31:47 +0100 Subject: [PATCH 38/60] Remove unused import --- src/module/bm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 801fc4dd..8fdc1a0c 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -293,7 +293,7 @@ impl<'a> BM<'a> { impl<'a> Module<'a> for BM<'a> { fn exec(&self, matches: &ArgMatches) -> bool { - use ansi_term::Colour::{Yellow, Red}; + use ansi_term::Colour::Red; match matches.subcommand_name() { Some("add") => { From 668811dafa8012711f6ebcdf0b478161afa4fd26 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:32:32 +0100 Subject: [PATCH 39/60] Remove unused import --- src/module/helpers/header/tags.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/helpers/header/tags.rs b/src/module/helpers/header/tags.rs index a6d55dd0..0ad6bfc3 100644 --- a/src/module/helpers/header/tags.rs +++ b/src/module/helpers/header/tags.rs @@ -118,7 +118,6 @@ pub mod data { use module::helpers::cli::create_tag_filter; use module::helpers::cli::create_hash_filter; use module::helpers::cli::create_text_header_field_grep_filter; - use module::helpers::cli::create_content_grep_filter; use module::helpers::cli::CliFileFilter; let cli_tags = matches.value_of("tags") From 0a63bc8f4d20dad383b429c2da07eb30ad39b652 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:32:45 +0100 Subject: [PATCH 40/60] Remove unused variable --- src/module/helpers/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/helpers/utils.rs b/src/module/helpers/utils.rs index 10566f44..c4cf281f 100644 --- a/src/module/helpers/utils.rs +++ b/src/module/helpers/utils.rs @@ -10,7 +10,7 @@ pub mod cli { * Get a commandline option "tags" and split the argument by "," to be able to provide a * Vec with the argument as array. */ - pub fn get_tags<'a>(rt: &Runtime, sub: &ArgMatches<'a, 'a>) -> Vec { + pub fn get_tags<'a>(sub: &ArgMatches<'a, 'a>) -> Vec { fn reject_if_with_spaces(e: &String) -> bool { if e.contains(" ") { From b00befbcaf37c1cf746860721a740f81da7a5ec6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:33:13 +0100 Subject: [PATCH 41/60] Use unused return value by wrapping in try!() --- src/module/notes/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 917d7d0a..cefee621 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -496,7 +496,7 @@ impl<'a> Module<'a> for Notes<'a> { impl<'a> Debug for Notes<'a> { fn fmt(&self, fmt: &mut Formatter) -> FMTResult { - write!(fmt, "[Module][Notes]"); + try!(write!(fmt, "[Module][Notes]")); Ok(()) } From e46fb41dd2d8ef50420a6eaf7db6e9122bb43c42 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:33:32 +0100 Subject: [PATCH 42/60] Remove unused import --- src/module/notes/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index cefee621..e20e79a5 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -256,7 +256,7 @@ impl<'a> Notes<'a> { fn command_links(&self, matches: &ArgMatches) -> bool { use ansi_term::Colour::{Red, Green}; use module::helpers::content::markdown::MarkdownParser; - use ui::file::{FilePrinter, TablePrinter}; + use ui::file::FilePrinter; use util::is_url; use prettytable::Table; use prettytable::row::Row; From 1ddbaae9e0d233150b19f8699b5290431e623f0f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:35:14 +0100 Subject: [PATCH 43/60] Use unused return values from write_all() --- src/module/notes/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index e20e79a5..09a2a2f8 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -211,7 +211,12 @@ impl<'a> Notes<'a> { } }; - tempfile.write_all(MarkdownParser::new(&s).to_html_page().as_ref()); + tempfile.write_all(MarkdownParser::new(&s).to_html_page().as_ref()) + .map_err(|e| { + error!("Could not write HTML to file: {}", temppath); + debug!("Could not write HTML to file: {:?}", e); + }) + .ok(); open::that(&temppath[..]).is_ok() } From 4f8886f3c7aa2df6bdcfdeb3ef198e3dc764a906 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:36:04 +0100 Subject: [PATCH 44/60] Remove unused import --- src/module/helpers/utils.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/module/helpers/utils.rs b/src/module/helpers/utils.rs index c4cf281f..3e39813a 100644 --- a/src/module/helpers/utils.rs +++ b/src/module/helpers/utils.rs @@ -4,8 +4,6 @@ pub mod cli { use clap::ArgMatches; - use runtime::Runtime; - /** * Get a commandline option "tags" and split the argument by "," to be able to provide a * Vec with the argument as array. From 128fa427f81deb6df0a3c6a178820ab39a9768ab Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:36:06 +0100 Subject: [PATCH 45/60] Remove unused import --- src/module/notes/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 09a2a2f8..5bb455bb 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -1,6 +1,5 @@ use std::fmt::{Debug, Formatter}; use std::fmt::Result as FMTResult; -use std::rc::Rc; use std::ops::Deref; use clap::ArgMatches; From fb15a57a88af61ea8771ffab883952313f228153 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:37:34 +0100 Subject: [PATCH 46/60] Use unused return value: On error, print error --- src/storage/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 446ebec7..1d333520 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -223,7 +223,11 @@ impl Store { debug!(" error {}", e); }) .is_ok(); - }); + }) + .map_err(|e| { + error!("Error opening file: {}", path); + debug!("Error opening file: {:?}", e); + }).ok(); parser.read(string).map(|(header, data)| { self.new_file_from_parser_result(m, id.clone(), header, data); From 20dfd661d47c26af3ac884273505b3080a47fd4d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:38:55 +0100 Subject: [PATCH 47/60] Use unused return value: On glob() error, print error msg --- src/storage/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 1d333520..900d5fdc 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -327,7 +327,12 @@ impl Store { }); } } - }); + }) + .map_err(|e| { + error!("Could not glob: '{}'", globstr); + debug!("Could not glob(): {:?}", e); + }) + .ok(); res } From 64eee78db0b43ca5db55d77079ecede76ade71e1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:40:03 +0100 Subject: [PATCH 48/60] deny(non_shorthand_field_patterns) --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index edd6ad24..436435bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ #![deny(unused_variables)] #![deny(unused_must_use)] #![deny(unused_mut)] +#![deny(non_shorthand_field_patterns)] #[macro_use] extern crate clap; #[macro_use] extern crate log; From 35487ec9a65cb98c9c27c03854ae7d898060c268 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:40:17 +0100 Subject: [PATCH 49/60] Remove unneeded shorthand field pattern --- src/module/helpers/header/tags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/helpers/header/tags.rs b/src/module/helpers/header/tags.rs index 0ad6bfc3..52e9ebaa 100644 --- a/src/module/helpers/header/tags.rs +++ b/src/module/helpers/header/tags.rs @@ -87,7 +87,7 @@ pub mod data { let keys : Vec = ks.clone(); for key in keys { match key { - FHD::Key{name: ref name, value: ref v} => { + FHD::Key{ref name, value: ref v} => { if name == "TAGS" { return match_array(v) } From 270466ab3ac2cef5c0fe9683904a08da2bfe8f1e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:46:13 +0100 Subject: [PATCH 50/60] Add missing imports after rebase --- src/module/notes/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index 5bb455bb..004f2ad5 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -1,6 +1,8 @@ use std::fmt::{Debug, Formatter}; use std::fmt::Result as FMTResult; use std::ops::Deref; +use std::rc::Rc; +use std::cell::RefCell; use clap::ArgMatches; @@ -8,6 +10,7 @@ mod header; use module::Module; use runtime::Runtime; +use storage::file::File; use storage::parser::Parser; use storage::json::parser::JsonHeaderParser; use module::helpers::cli::create_tag_filter; From afd80b39c61ffec8105dd0207638664c5d0aeffb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:57:21 +0100 Subject: [PATCH 51/60] Remove unused import --- src/storage/file/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/file/mod.rs b/src/storage/file/mod.rs index 19866a81..4ce19a47 100644 --- a/src/storage/file/mod.rs +++ b/src/storage/file/mod.rs @@ -128,7 +128,7 @@ mod test { // we use the JSON parser here, so we can generate FileHeaderData use storage::json::parser::JsonHeaderParser; use storage::file::header::match_header_spec; - use storage::parser::{FileHeaderParser, ParserError}; + use storage::parser::FileHeaderParser; use storage::file::header::data::FileHeaderData as FHD; use storage::file::header::spec::FileHeaderSpec as FHS; From 29ba1464ffab97fbb1f1629f5d4f8477057a5f9a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:57:32 +0100 Subject: [PATCH 52/60] Remove unused import --- src/storage/file/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/storage/file/mod.rs b/src/storage/file/mod.rs index 4ce19a47..cd1f47c5 100644 --- a/src/storage/file/mod.rs +++ b/src/storage/file/mod.rs @@ -129,7 +129,6 @@ mod test { use storage::json::parser::JsonHeaderParser; use storage::file::header::match_header_spec; use storage::parser::FileHeaderParser; - use storage::file::header::data::FileHeaderData as FHD; use storage::file::header::spec::FileHeaderSpec as FHS; #[test] From b2f7200b382e4777e4f032284ae9e721b64932ff Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:57:49 +0100 Subject: [PATCH 53/60] Remove unused import --- src/storage/json/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index 11893f5e..b1d81342 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -153,7 +153,7 @@ mod test { use std::ops::Deref; use super::JsonHeaderParser; - use storage::parser::{FileHeaderParser, ParserError}; + use storage::parser::FileHeaderParser; use storage::file::header::data::FileHeaderData as FHD; use storage::file::header::spec::FileHeaderSpec as FHS; From 7b04d02a4aa85c5aa85d4c4ad8c7a92db3673147 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:58:54 +0100 Subject: [PATCH 54/60] Remove unneeded shorthand field pattern --- src/storage/json/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index b1d81342..8f5ba400 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -178,7 +178,7 @@ mod test { assert!(parsed.is_ok(), "Parsed is not ok: {:?}", parsed); match parsed.ok() { - Some(FHD::Map{keys: keys}) => { + Some(FHD::Map{keys}) => { for k in keys { match k { FHD::Key{name: name, value: value} => { From 92d84d39e4d09031f953f00c8b246537f8ec017e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:59:11 +0100 Subject: [PATCH 55/60] Remove unneeded shorthand field pattern --- src/storage/json/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index 8f5ba400..82646745 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -181,7 +181,7 @@ mod test { Some(FHD::Map{keys}) => { for k in keys { match k { - FHD::Key{name: name, value: value} => { + FHD::Key{name, value} => { assert!(name == "a" || name == "b", "Key unknown"); match value.deref() { &FHD::UInteger(u) => assert_eq!(u, 1), From 4b489b2088a6747cbc23ef1d55f8e6eb6fcf108a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:59:32 +0100 Subject: [PATCH 56/60] Remove unneeded shorthand field pattern --- src/storage/json/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index 82646745..bd4670ff 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -207,7 +207,7 @@ mod test { assert!(parsed.is_ok(), "Parsed is not ok: {:?}", parsed); match parsed.ok() { - Some(FHD::Map{keys: keys}) => { + Some(FHD::Map{keys}) => { for k in keys { match_key(&k); } From ed72b8b25034fbc48db9a488ebdd1441f9b350c0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 16:59:38 +0100 Subject: [PATCH 57/60] Remove unneeded shorthand field pattern --- src/storage/json/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index bd4670ff..6a448c08 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -221,7 +221,7 @@ mod test { use std::ops::Deref; match k { - &FHD::Key{name: ref name, value: ref value} => { + &FHD::Key{ref name, ref value} => { assert!(name == "a" || name == "b", "Key unknown"); match value.deref() { &FHD::Array{values: ref vs} => { From 8b7ab8fae1e0ff0996b7260f3e6bfccef2e00afe Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 17:00:04 +0100 Subject: [PATCH 58/60] Remove unneeded shorthand field pattern --- src/storage/json/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index 6a448c08..1b67be1a 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -236,7 +236,7 @@ mod test { &FHD::Map{keys: ref ks} => { for key in ks.iter() { match key { - &FHD::Key{name: ref name, value: ref value} => { + &FHD::Key{ref name, ref value} => { match value.deref() { &FHD::Integer(i) => { assert_eq!(i, -2); From b43a68d10ab672349511f5b62e7ece2d428ff54e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 17:00:30 +0100 Subject: [PATCH 59/60] Rename some variables, so we can remove unneeded shorthand field patterns --- src/storage/json/parser.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index 1b67be1a..dbcadd70 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -224,8 +224,8 @@ mod test { &FHD::Key{ref name, ref value} => { assert!(name == "a" || name == "b", "Key unknown"); match value.deref() { - &FHD::Array{values: ref vs} => { - for value in vs.iter() { + &FHD::Array{ref values} => { + for value in values.iter() { match value { &FHD::UInteger(u) => assert_eq!(u, 1), _ => assert!(false, "UInt is not an UInt"), @@ -233,8 +233,8 @@ mod test { } } - &FHD::Map{keys: ref ks} => { - for key in ks.iter() { + &FHD::Map{ref keys} => { + for key in keys.iter() { match key { &FHD::Key{ref name, ref value} => { match value.deref() { From 0bdd548eabd2d4b097b523c16a92cc4276dfbcd5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 17:31:05 +0100 Subject: [PATCH 60/60] Use unused result in test: set_logger() --- src/storage/file/id.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/storage/file/id.rs b/src/storage/file/id.rs index f89eb551..4fcdeb45 100644 --- a/src/storage/file/id.rs +++ b/src/storage/file/id.rs @@ -169,7 +169,12 @@ mod test { let lvl = LogLevelFilter::Debug; max_log_lvl.set(lvl); Box::new(ImagLogger::new(lvl.to_log_level().unwrap())) - }); + }) + .map_err(|e| { + println!("Error setting logger: {:?}", e); + assert!(false); + }) + .ok(); debug!("Init logger for test"); }