From 617d5786587a1fa5b5b02770b1eb95ad9f8357a0 Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Thu, 4 Apr 2024 14:45:43 -0400 Subject: [PATCH 1/2] Move Lint Definitions to Cargo.toml This feature was stabilized in cargo 1.74.0. --- Cargo.toml | 14 ++++++++++++++ clippy.toml | 2 +- src/lib.rs | 9 --------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 19e371a..f8bbb55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,3 +25,17 @@ anyhow = "1" bytes = "1" colored = "2" mockall = { version = "0.12", features = ["nightly"] } + +[lints.rust] +warnings = "deny" + +[lints.clippy] +pedantic = { level = "deny", priority = -1 } +nursery = { level = "deny", priority = -1 } +undocumented_unsafe_blocks = "deny" +arithmetic_side_effects = "deny" + +[lints.rustdoc] +all = "warn" +missing_doc_code_examples = "warn" + diff --git a/clippy.toml b/clippy.toml index a450b34..a319ba8 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -doc-valid-idents = ["VersaTest"] \ No newline at end of file +doc-valid-idents = ["VersaTest"] diff --git a/src/lib.rs b/src/lib.rs index fbc6d17..0c06a6e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,5 @@ #![feature(lint_reasons, rustdoc_missing_doc_code_examples)] -#![deny( - clippy::undocumented_unsafe_blocks, - clippy::pedantic, - clippy::nursery, - clippy::arithmetic_side_effects -)] #![feature(assert_matches)] -//#![warn(missing_docs, rustdoc::all)] -//#![allow(rustdoc::missing_doc_code_examples)] #![doc(html_logo_url = "../../../ki-comms_doc_icon.png")] //! The TSP Instrument crate defines the necessary components to enable communication @@ -25,7 +17,6 @@ pub mod model; #[cfg(test)] pub(crate) mod test_util; -//pub use connect::{AsyncToSync, Connect, ConnectAsync, ConnectionAddr, Disconnect}; pub use error::InstrumentError; pub use instrument::firmware::Flash; pub use interface::{connection_addr::ConnectionAddr, usbtmc, Interface}; From 01e7f166be520c1a9f9dd2c829b56c67cbf9b0a5 Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Thu, 2 May 2024 08:49:47 -0400 Subject: [PATCH 2/2] Clean up Clippy Lints --- src/interface/async_stream.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/interface/async_stream.rs b/src/interface/async_stream.rs index 27cdbfb..407db82 100644 --- a/src/interface/async_stream.rs +++ b/src/interface/async_stream.rs @@ -57,19 +57,19 @@ impl AsyncStream { } fn drop_write_channel(&mut self) -> Result<()> { - match self.write_to.take() { - Some(send) => { - match send.send(AsyncMessage::End) { - Ok(()) => {} - Err(_) => { - return Err(InstrumentError::IoError { source: (std::io::Error::new( + if let Some(send) = self.write_to.take() { + match send.send(AsyncMessage::End) { + Ok(()) => {} + Err(_) => { + return Err(InstrumentError::IoError { + source: (std::io::Error::new( ErrorKind::NotConnected, - "attempted to write asynchronously to socket, but it was not connected".to_string(), - ))}); - } + "attempted to write asynchronously to socket, but it was not connected" + .to_string(), + )), + }); } } - None => {} } Ok(()) }