From 5dc477bcd59d22ee8636d51cda8893dd6a1cf429 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 27 Jan 2020 17:32:12 +0200 Subject: [PATCH] Fix some unused etc warnings --- melib/src/async_workers.rs | 4 - melib/src/backends.rs | 2 +- melib/src/backends/imap/connection.rs | 2 +- melib/src/thread.rs | 86 ++----------------- ui/src/components/mail/listing.rs | 2 +- ui/src/components/mail/listing/compact.rs | 18 ++-- .../components/mail/listing/conversations.rs | 17 ++-- ui/src/components/mail/listing/plain.rs | 8 +- ui/src/components/mail/status.rs | 3 +- ui/src/components/utilities.rs | 1 + ui/src/plugins/backend.rs | 3 - 11 files changed, 29 insertions(+), 117 deletions(-) diff --git a/melib/src/async_workers.rs b/melib/src/async_workers.rs index 25497d4f2..37654cab7 100644 --- a/melib/src/async_workers.rs +++ b/melib/src/async_workers.rs @@ -50,8 +50,6 @@ pub struct Work { priority: u64, pub is_static: bool, pub closure: Box () + Send + Sync>, - name: String, - status: String, } impl Ord for Work { @@ -169,8 +167,6 @@ where priority: self.priority, is_static: self.is_static, closure: work, - name: String::new(), - status: String::new(), }), tx: self.tx, rx: self.rx, diff --git a/melib/src/backends.rs b/melib/src/backends.rs index 41c471ae1..c68e2dfb6 100644 --- a/melib/src/backends.rs +++ b/melib/src/backends.rs @@ -264,7 +264,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { fn operation(&self, hash: EnvelopeHash) -> Box; fn save(&self, bytes: &[u8], folder: &str, flags: Option) -> Result<()>; - fn create_folder(&mut self, path: String) -> Result { + fn create_folder(&mut self, _path: String) -> Result { unimplemented!() } fn tags(&self) -> Option>>> { diff --git a/melib/src/backends/imap/connection.rs b/melib/src/backends/imap/connection.rs index f683ebd71..edcde3797 100644 --- a/melib/src/backends/imap/connection.rs +++ b/melib/src/backends/imap/connection.rs @@ -339,7 +339,7 @@ impl ImapConnection { } pub fn read_response(&mut self, ret: &mut String) -> Result<()> { - let res = self.try_send(|s| s.read_response(ret)); + self.try_send(|s| s.read_response(ret))?; let r: Result<()> = ImapResponse::from(&ret).into(); r } diff --git a/melib/src/thread.rs b/melib/src/thread.rs index b9ff98d1e..5d9509ede 100644 --- a/melib/src/thread.rs +++ b/melib/src/thread.rs @@ -301,13 +301,6 @@ impl ThreadGroup { None } } - fn root_mut(&mut self) -> Option<&mut Thread> { - if let ThreadGroup::Root(ref mut root) = self { - Some(root) - } else { - None - } - } } macro_rules! property { @@ -410,71 +403,6 @@ impl ThreadNode { pub fn children(&self) -> &[ThreadNodeHash] { &self.children } - - fn insert_child_pos( - vec: &[ThreadNodeHash], - child: ThreadNodeHash, - sort: (SortField, SortOrder), - buf: &mut FnvHashMap, - dates: &FnvHashMap, - envelopes: &Envelopes, - ) -> std::result::Result { - let envelopes = envelopes.read().unwrap(); - match sort { - (SortField::Date, SortOrder::Asc) => { - vec.binary_search_by(|probe| dates[probe].cmp(&dates[&child])) - } - (SortField::Date, SortOrder::Desc) => { - vec.binary_search_by(|probe| dates[probe].cmp(&dates[&child]).reverse()) - } - (SortField::Subject, SortOrder::Asc) => vec.binary_search_by(|probe| { - match ( - buf.get(&probe).map(|n| n.message.as_ref()).unwrap_or(None), - buf.get(&child).map(|n| n.message.as_ref()).unwrap_or(None), - ) { - (Some(p), Some(c)) => { - #[cfg(feature = "unicode_algorithms")] - { - envelopes[p] - .subject() - .split_graphemes() - .cmp(&envelopes[c].subject().split_graphemes()) - } - #[cfg(not(feature = "unicode_algorithms"))] - { - envelopes[p].subject().cmp(&envelopes[c].subject()) - } - } - (Some(_), None) => Ordering::Greater, - (None, Some(_)) => Ordering::Less, - (None, None) => Ordering::Equal, - } - }), - (SortField::Subject, SortOrder::Desc) => vec.binary_search_by(|probe| { - match ( - buf.get(&probe).map(|n| n.message.as_ref()).unwrap_or(None), - buf.get(&child).map(|n| n.message.as_ref()).unwrap_or(None), - ) { - (Some(p), Some(c)) => { - #[cfg(feature = "unicode_algorithms")] - { - envelopes[c] - .subject() - .split_graphemes() - .cmp(&envelopes[p].subject().split_graphemes()) - } - #[cfg(not(feature = "unicode_algorithms"))] - { - envelopes[c].subject().cmp(&envelopes[p].subject()) - } - } - (Some(_), None) => Ordering::Less, - (None, Some(_)) => Ordering::Greater, - (None, None) => Ordering::Equal, - } - }), - } - } } #[derive(Clone, Debug, Default, Deserialize, Serialize)] @@ -622,14 +550,12 @@ impl Threads { let was_unseen = self.thread_nodes[&thread_hash].unseen; let is_unseen = !envelopes.read().unwrap()[&new_hash].is_seen(); if was_unseen != is_unseen { - if let Thread { ref mut unseen, .. } = - self.thread_ref_mut(self.thread_nodes[&thread_hash].group) - { - if was_unseen { - *unseen -= 1; - } else { - *unseen += 1; - } + let Thread { ref mut unseen, .. } = + self.thread_ref_mut(self.thread_nodes[&thread_hash].group); + if was_unseen { + *unseen -= 1; + } else { + *unseen += 1; } } self.thread_nodes.get_mut(&thread_hash).unwrap().unseen = is_unseen; diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index 24446e5de..50bd3370c 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -195,7 +195,7 @@ pub trait MailListingTrait: ListingTrait { fn row_updates(&mut self) -> &mut SmallVec<[ThreadHash; 8]>; fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]>; - fn redraw_list(&mut self, context: &Context, items: Box>) { + fn redraw_list(&mut self, _context: &Context, _items: Box>) { unimplemented!() } } diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index 9fa5df4db..2dea9198d 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -82,9 +82,9 @@ impl MailListingTrait for CompactListing { &mut self.row_updates } - fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadHash; 8]> { + fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> { let is_selection_empty = self.selection.values().cloned().any(std::convert::identity); - let i = [self.get_thread_under_cursor(self.cursor_pos.2, context)]; + let i = [self.get_thread_under_cursor(self.cursor_pos.2)]; let cursor_iter; let sel_iter = if is_selection_empty { cursor_iter = None; @@ -120,7 +120,7 @@ impl ListingTrait for CompactListing { if self.length == 0 { return; } - let thread_hash = self.get_thread_under_cursor(idx, context); + let thread_hash = self.get_thread_under_cursor(idx); let account = &context.accounts[self.cursor_pos.0]; let threads = &account.collection.threads[&self.folder_hash]; @@ -344,7 +344,7 @@ impl ListingTrait for CompactListing { for r in 0..cmp::min(self.length - top_idx, rows) { let (fg_color, bg_color) = { - let thread_hash = self.get_thread_under_cursor(r + top_idx, context); + let thread_hash = self.get_thread_under_cursor(r + top_idx); let c = &self.data_columns.columns[0][(0, r + top_idx)]; if self.selection[&thread_hash] { @@ -682,7 +682,7 @@ impl CompactListing { if old_cursor_pos == self.new_cursor_pos { self.view.update(context); } else if self.unfocused { - let thread = self.get_thread_under_cursor(self.cursor_pos.2, context); + let thread = self.get_thread_under_cursor(self.cursor_pos.2); self.view = ThreadView::new(self.new_cursor_pos, thread, None, context); } @@ -946,7 +946,7 @@ impl CompactListing { } } - fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash { + fn get_thread_under_cursor(&self, cursor: usize) -> ThreadHash { if self.filter_term.is_empty() { *self .order @@ -1183,7 +1183,7 @@ impl Component for CompactListing { k == shortcuts[CompactListing::DESCRIPTION]["open_thread"] ) => { - let thread = self.get_thread_under_cursor(self.cursor_pos.2, context); + let thread = self.get_thread_under_cursor(self.cursor_pos.2); self.view = ThreadView::new(self.cursor_pos, thread, None, context); self.unfocused = true; self.dirty = true; @@ -1209,7 +1209,7 @@ impl Component for CompactListing { key == shortcuts[CompactListing::DESCRIPTION]["select_entry"] ) => { - let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context); + let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2); self.selection.entry(thread_hash).and_modify(|e| *e = !*e); } UIEvent::Action(ref action) => { @@ -1232,7 +1232,7 @@ impl Component for CompactListing { return true; } Action::ToggleThreadSnooze if !self.unfocused => { - let thread = self.get_thread_under_cursor(self.cursor_pos.2, context); + let thread = self.get_thread_under_cursor(self.cursor_pos.2); let account = &mut context.accounts[self.cursor_pos.0]; account .collection diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs index 6bca1d111..328e44b77 100644 --- a/ui/src/components/mail/listing/conversations.rs +++ b/ui/src/components/mail/listing/conversations.rs @@ -61,9 +61,9 @@ impl MailListingTrait for ConversationsListing { &mut self.row_updates } - fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadHash; 8]> { + fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> { let is_selection_empty = self.selection.values().cloned().any(std::convert::identity); - let i = [self.get_thread_under_cursor(self.cursor_pos.2, context)]; + let i = [self.get_thread_under_cursor(self.cursor_pos.2)]; let cursor_iter; let sel_iter = if is_selection_empty { cursor_iter = None; @@ -99,7 +99,7 @@ impl ListingTrait for ConversationsListing { if self.length == 0 { return; } - let thread_hash = self.get_thread_under_cursor(idx, context); + let thread_hash = self.get_thread_under_cursor(idx); let account = &context.accounts[self.cursor_pos.0]; let threads = &account.collection.threads[&self.folder_hash]; @@ -610,7 +610,7 @@ impl ConversationsListing { if old_cursor_pos == self.new_cursor_pos { self.view.update(context); } else if self.unfocused { - let thread_group = self.get_thread_under_cursor(self.cursor_pos.2, context); + let thread_group = self.get_thread_under_cursor(self.cursor_pos.2); self.view = ThreadView::new(self.new_cursor_pos, thread_group, None, context); } @@ -855,7 +855,7 @@ impl ConversationsListing { } } - fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash { + fn get_thread_under_cursor(&self, cursor: usize) -> ThreadHash { if self.filter_term.is_empty() { *self .order @@ -866,7 +866,6 @@ impl ConversationsListing { panic!(); }) .0 - //threads.root_set(cursor) } else { self.filtered_selection[cursor] } @@ -1120,7 +1119,7 @@ impl Component for ConversationsListing { k == shortcuts[ConversationsListing::DESCRIPTION]["open_thread"] ) => { - let thread = self.get_thread_under_cursor(self.cursor_pos.2, context); + let thread = self.get_thread_under_cursor(self.cursor_pos.2); self.view = ThreadView::new(self.cursor_pos, thread, None, context); self.unfocused = true; self.dirty = true; @@ -1146,7 +1145,7 @@ impl Component for ConversationsListing { key == shortcuts[ConversationsListing::DESCRIPTION]["select_entry"] ) => { - let thread = self.get_thread_under_cursor(self.cursor_pos.2, context); + let thread = self.get_thread_under_cursor(self.cursor_pos.2); self.selection.entry(thread).and_modify(|e| *e = !*e); return true; } @@ -1205,7 +1204,7 @@ impl Component for ConversationsListing { return true; } Action::ToggleThreadSnooze if !self.unfocused => { - let thread = self.get_thread_under_cursor(self.cursor_pos.2, context); + let thread = self.get_thread_under_cursor(self.cursor_pos.2); let account = &mut context.accounts[self.cursor_pos.0]; account .collection diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs index d1572cb27..8c75bc09f 100644 --- a/ui/src/components/mail/listing/plain.rs +++ b/ui/src/components/mail/listing/plain.rs @@ -83,7 +83,7 @@ impl MailListingTrait for PlainListing { &mut self._row_updates } - fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadHash; 8]> { + fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> { return SmallVec::new(); /* let is_selection_empty = self.selection.values().cloned().any(std::convert::identity); @@ -890,12 +890,6 @@ impl PlainListing { } } - fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadNodeHash { - let account = &context.accounts[self.cursor_pos.0]; - let env_hash = self.get_env_under_cursor(cursor, context); - account.collection.get_env(env_hash).thread() - } - fn format_date(envelope: &Envelope) -> String { let d = std::time::UNIX_EPOCH + std::time::Duration::from_secs(envelope.date()); let now: std::time::Duration = std::time::SystemTime::now() diff --git a/ui/src/components/mail/status.rs b/ui/src/components/mail/status.rs index 0917957f9..aca38b978 100644 --- a/ui/src/components/mail/status.rs +++ b/ui/src/components/mail/status.rs @@ -457,11 +457,10 @@ impl Component for AccountStatus { ((1, line), (width - 1, height - 1)), None, ); - for (i, f) in a + for f in a .ref_folders .values() .filter(|f| f.special_usage() != SpecialUsageMailbox::Normal) - .enumerate() { line += 1; write_string_to_grid( diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index 46bde9e5d..a450278cb 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -834,6 +834,7 @@ impl StatusBar { change_colors(grid, area, Color::Byte(123), Color::Byte(26)); context.dirty_areas.push_back(area); } + fn draw_execute_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { clear_area(grid, area); let (x, y) = write_string_to_grid( diff --git a/ui/src/plugins/backend.rs b/ui/src/plugins/backend.rs index 4731a1ee0..b4db63821 100644 --- a/ui/src/plugins/backend.rs +++ b/ui/src/plugins/backend.rs @@ -302,9 +302,6 @@ impl BackendOp for PluginOp { debug!(channel.expect_ack())?; let bytes: Result> = channel.from_read(); self.bytes = Some(bytes.map(Into::into).and_then(std::convert::identity)?); - if let Some(ref bytes) = self.bytes { - debug!(Envelope::from_bytes(bytes.as_bytes(), None)); - } Ok(self.bytes.as_ref().map(String::as_bytes).unwrap()) } else { Err(MeliError::new("busy"))