diff --git a/src/euph/api/types.rs b/src/euph/api/types.rs index 1f77811..e518083 100644 --- a/src/euph/api/types.rs +++ b/src/euph/api/types.rs @@ -304,10 +304,10 @@ impl Serialize for Snowflake { struct SnowflakeVisitor; -impl<'de> de::Visitor<'de> for SnowflakeVisitor { +impl de::Visitor<'_> for SnowflakeVisitor { type Value = Snowflake; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "a base36 string of length 13") } diff --git a/src/logger.rs b/src/logger.rs index 9a52477..7a80295 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -105,11 +105,11 @@ impl MsgStore for Logger { } impl Log for Logger { - fn enabled(&self, _metadata: &log::Metadata) -> bool { + fn enabled(&self, _metadata: &log::Metadata<'_>) -> bool { true } - fn log(&self, record: &log::Record) { + fn log(&self, record: &log::Record<'_>) { if !self.enabled(record.metadata()) { return; } diff --git a/src/main.rs b/src/main.rs index 42e0437..fef3cef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,20 @@ +#![deny(unsafe_code)] +// Rustc lint groups +#![warn(future_incompatible)] +#![warn(rust_2018_idioms)] +// Rustc lints +#![warn(noop_method_call)] +#![warn(single_use_lifetimes)] +#![warn(trivial_numeric_casts)] +#![warn(unused_crate_dependencies)] +#![warn(unused_extern_crates)] +#![warn(unused_import_braces)] +#![warn(unused_lifetimes)] +#![warn(unused_qualifications)] +// Clippy lints #![warn(clippy::use_self)] +// TODO Enable warn(unreachable_pub)? // TODO Clean up use and manipulation of toss Pos and Size mod euph; diff --git a/src/ui.rs b/src/ui.rs index 622821f..e1ee007 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -58,7 +58,7 @@ impl Ui { terminal: &mut Terminal, vault: Vault, logger: Logger, - logger_rx: mpsc::UnboundedReceiver<()>, + logger_rx: UnboundedReceiver<()>, ) -> anyhow::Result<()> { let (event_tx, event_rx) = mpsc::unbounded_channel(); let crossterm_lock = Arc::new(FairMutex::new(())); @@ -107,8 +107,8 @@ impl Ui { } async fn update_on_log_event( - mut logger_rx: mpsc::UnboundedReceiver<()>, - event_tx: &mpsc::UnboundedSender, + mut logger_rx: UnboundedReceiver<()>, + event_tx: &UnboundedSender, ) { while let Some(()) = logger_rx.recv().await { if event_tx.send(UiEvent::Redraw).is_err() { diff --git a/src/ui/chat/blocks.rs b/src/ui/chat/blocks.rs index 86075b2..1389d43 100644 --- a/src/ui/chat/blocks.rs +++ b/src/ui/chat/blocks.rs @@ -66,7 +66,7 @@ impl Blocks { } } - pub fn iter(&self) -> vec_deque::Iter> { + pub fn iter(&self) -> vec_deque::Iter<'_, Block> { self.blocks.iter() } diff --git a/src/ui/widgets/float.rs b/src/ui/widgets/float.rs index a70c854..96f398c 100644 --- a/src/ui/widgets/float.rs +++ b/src/ui/widgets/float.rs @@ -48,14 +48,14 @@ impl Widget for Float { let available = (size.width - inner_size.width) as f32; // Biased towards the left if horizontal lands exactly on the // boundary between two cells - inner_pos.x = (horizontal * available as f32).floor().min(available) as i32; + inner_pos.x = (horizontal * available).floor().min(available) as i32; } if let Some(vertical) = self.vertical { let available = (size.height - inner_size.height) as f32; // Biased towards the top if vertical lands exactly on the boundary // between two cells - inner_pos.y = (vertical * available as f32).floor().min(available) as i32; + inner_pos.y = (vertical * available).floor().min(available) as i32; } frame.push(inner_pos, inner_size); diff --git a/src/vault/euph.rs b/src/vault/euph.rs index 0f37d81..863f77a 100644 --- a/src/vault/euph.rs +++ b/src/vault/euph.rs @@ -406,7 +406,7 @@ impl EuphRequest { Ok(()) } - fn insert_msgs(tx: &Transaction, room: &str, msgs: Vec) -> rusqlite::Result<()> { + fn insert_msgs(tx: &Transaction<'_>, room: &str, msgs: Vec) -> rusqlite::Result<()> { let mut insert_msg = tx.prepare( " INSERT OR REPLACE INTO euph_msgs ( @@ -475,7 +475,7 @@ impl EuphRequest { } fn add_span( - tx: &Transaction, + tx: &Transaction<'_>, room: &str, start: Option, end: Option, diff --git a/src/vault/migrate.rs b/src/vault/migrate.rs index ce52af8..4a0904f 100644 --- a/src/vault/migrate.rs +++ b/src/vault/migrate.rs @@ -16,9 +16,9 @@ pub fn migrate(conn: &mut Connection) -> rusqlite::Result<()> { tx.commit() } -const MIGRATIONS: [fn(&mut Transaction) -> rusqlite::Result<()>; 2] = [m1, m2]; +const MIGRATIONS: [fn(&mut Transaction<'_>) -> rusqlite::Result<()>; 2] = [m1, m2]; -fn m1(tx: &mut Transaction) -> rusqlite::Result<()> { +fn m1(tx: &mut Transaction<'_>) -> rusqlite::Result<()> { tx.execute_batch( " CREATE TABLE euph_rooms ( @@ -76,7 +76,7 @@ fn m1(tx: &mut Transaction) -> rusqlite::Result<()> { ) } -fn m2(tx: &mut Transaction) -> rusqlite::Result<()> { +fn m2(tx: &mut Transaction<'_>) -> rusqlite::Result<()> { tx.execute_batch( " CREATE TABLE euph_cookies (